1 /*
2  * Copyright (c) 2021-2023 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 #ifndef RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_TRANSITION_H
17 #define RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_TRANSITION_H
18 
19 #include <cinttypes>
20 #include "animation/rs_animation.h"
21 #include "animation/rs_animation_timing_curve.h"
22 #include "animation/rs_interpolator.h"
23 #include "animation/rs_transition_effect.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 class RSC_EXPORT RSTransition : public RSAnimation {
28 public:
29     RSTransition(const std::shared_ptr<const RSTransitionEffect>& effect, bool isTransitionIn);
30     virtual ~RSTransition() = default;
31 
SetTransitionEffect(const std::shared_ptr<const RSTransitionEffect> & effect)32     void SetTransitionEffect(const std::shared_ptr<const RSTransitionEffect>& effect)
33     {
34         effect_ = effect;
35     }
36 
SetTimingCurve(const RSAnimationTimingCurve & timingCurve)37     void SetTimingCurve(const RSAnimationTimingCurve& timingCurve)
38     {
39         if (timingCurve.type_ != RSAnimationTimingCurve::CurveType::INTERPOLATING) {
40             return;
41         }
42         timingCurve_ = timingCurve;
43     }
44 
SetIsCustom(bool isCustom)45     void SetIsCustom(bool isCustom)
46     {
47         isCustom_ = isCustom;
48     }
49 
50 protected:
51     void OnStart() override;
52     void OnUpdateStagingValue(bool isFirstStart) override;
53     void StartCustomTransition();
54     void StartRenderTransition();
55 
56 private:
57     bool isCustom_ { false };
58     bool isTransitionIn_ { false };
59     std::shared_ptr<const RSTransitionEffect> effect_;
60     RSAnimationTimingCurve timingCurve_ { RSAnimationTimingCurve::DEFAULT };
61 };
62 } // namespace Rosen
63 } // namespace OHOS
64 
65 #endif
66