• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "animation/rs_transition.h"
17 
18 #include "animation/rs_render_transition.h"
19 #include "command/rs_animation_command.h"
20 #include "transaction/rs_transaction_proxy.h"
21 #include "ui/rs_node.h"
22 
23 namespace OHOS {
24 namespace Rosen {
RSTransition(const std::shared_ptr<const RSTransitionEffect> & effect,bool isTransitionIn)25 RSTransition::RSTransition(const std::shared_ptr<const RSTransitionEffect>& effect, bool isTransitionIn)
26     : isTransitionIn_(isTransitionIn), effect_(effect)
27 {}
28 
OnStart()29 void RSTransition::OnStart()
30 {
31     auto target = GetTarget().lock();
32     if (target == nullptr) {
33         return;
34     }
35     auto transition = std::make_shared<RSRenderTransition>(GetId(), effect_, isTransitionIn_);
36     if (transition == nullptr) {
37         return;
38     }
39     auto interpolator = timingCurve_.GetInterpolator(GetDuration());
40     transition->SetInterpolator(interpolator);
41     UpdateParamToRenderAnimation(transition);
42     std::unique_ptr<RSCommand> command =
43         std::make_unique<RSAnimationCreateTransition>(target->GetId(), transition);
44     auto transactionProxy = RSTransactionProxy::GetInstance();
45     if (transactionProxy != nullptr) {
46         transactionProxy->AddCommand(command, target->IsRenderServiceNode(), target->GetFollowType(), target->GetId());
47         if (target->NeedForcedSendToRemote()) {
48             std::unique_ptr<RSCommand> commandForRemote =
49                 std::make_unique<RSAnimationCreateTransition>(target->GetId(), transition);
50             transactionProxy->AddCommand(commandForRemote, true, target->GetFollowType(), target->GetId());
51         }
52         if (target->NeedSendExtraCommand()) {
53             std::unique_ptr<RSCommand> extraCommand =
54                 std::make_unique<RSAnimationCreateTransition>(target->GetId(), transition);
55             transactionProxy->AddCommand(extraCommand, !target->IsRenderServiceNode(), target->GetFollowType(),
56                 target->GetId());
57         }
58     }
59 }
60 } // namespace Rosen
61 } // namespace OHOS
62