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 #ifndef RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_RENDER_TRANSITION_H 17 #define RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_RENDER_TRANSITION_H 18 19 #include "animation/rs_interpolator.h" 20 #include "animation/rs_render_animation.h" 21 #include "animation/rs_render_transition_effect.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class RSTransitionEffect; 26 27 class RSRenderTransition : public RSRenderAnimation { 28 public: 29 RSRenderTransition(AnimationId id, const std::shared_ptr<const RSTransitionEffect>& effect, bool isTransitionIn); SetInterpolator(const std::shared_ptr<RSInterpolator> & interpolator)30 void SetInterpolator(const std::shared_ptr<RSInterpolator>& interpolator) 31 { 32 interpolator_ = interpolator; 33 } 34 #ifdef ROSEN_OHOS 35 bool Marshalling(Parcel& parcel) const override; 36 static RSRenderTransition* Unmarshalling(Parcel& parcel); 37 #endif 38 39 protected: 40 #ifdef ROSEN_OHOS 41 bool ParseParam(Parcel& parcel) override; 42 #endif 43 void OnAnimate(float fraction) override; 44 void OnAttach() override; 45 void OnDetach() override; 46 47 float currentFraction_ { 0.0f }; 48 49 std::vector<std::shared_ptr<RSRenderTransitionEffect>> effects_; 50 std::shared_ptr<RSInterpolator> interpolator_ { RSInterpolator::DEFAULT }; 51 52 private: 53 RSRenderTransition() = default; 54 bool isTransitionIn_; 55 }; 56 } // namespace Rosen 57 } // namespace OHOS 58 59 #endif 60