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 "animation/rs_animation.h" 20 #include "animation/rs_animation_timing_curve.h" 21 #include "animation/rs_interpolator.h" 22 #include "animation/rs_transition_effect.h" 23 #include "platform/common/rs_log.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 ROSEN_LOGE("RSTransition::SetTimingCurve: invalid timing curve type"); 41 return; 42 } 43 timingCurve_ = timingCurve; 44 } 45 SetIsCustom(bool isCustom)46 void SetIsCustom(bool isCustom) 47 { 48 isCustom_ = isCustom; 49 } 50 51 protected: 52 void OnStart() override; 53 void OnUpdateStagingValue(bool isFirstStart) override; 54 void StartCustomTransition(); 55 void StartRenderTransition(); 56 57 private: 58 bool isCustom_ { false }; 59 bool isTransitionIn_; 60 std::shared_ptr<const RSTransitionEffect> effect_; 61 RSAnimationTimingCurve timingCurve_ { RSAnimationTimingCurve::DEFAULT }; 62 }; 63 } // namespace Rosen 64 } // namespace OHOS 65 66 #endif 67