• 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->SetDuration(GetDuration());
41     transition->SetStartDelay(GetStartDelay());
42     transition->SetRepeatCount(GetRepeatCount());
43     transition->SetAutoReverse(GetAutoReverse());
44     transition->SetSpeed(GetSpeed());
45     transition->SetDirection(GetDirection());
46     transition->SetFillMode(GetFillMode());
47     transition->SetInterpolator(interpolator);
48     std::unique_ptr<RSCommand> command =
49         std::make_unique<RSAnimationCreateTransition>(target->GetId(), transition);
50     auto transactionProxy = RSTransactionProxy::GetInstance();
51     if (transactionProxy != nullptr) {
52         transactionProxy->AddCommand(command, target->IsRenderServiceNode());
53         if (target->NeedForcedSendToRemote()) {
54             std::unique_ptr<RSCommand> commandForRemote =
55                 std::make_unique<RSAnimationCreateTransition>(target->GetId(), transition);
56             transactionProxy->AddCommand(commandForRemote, true);
57         }
58     }
59 }
60 } // namespace Rosen
61 } // namespace OHOS
62