1 /* 2 * Copyright (c) 2021 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_EFFECT_H 17 #define RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_RENDER_TRANSITION_EFFECT_H 18 19 #ifdef ROSEN_OHOS 20 #include <parcel.h> 21 #include <refbase.h> 22 #endif 23 #include <memory> 24 25 #include "animation/rs_animation_common.h" 26 #include "common/rs_vector4.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 class RSCanvasRenderNode; 31 class RSPaintFilterCanvas; 32 class RSProperties; 33 class RSTransitionProperties; 34 35 #ifdef ROSEN_OHOS 36 class RSRenderTransitionEffect : public Parcelable { 37 #else 38 class RSRenderTransitionEffect { 39 #endif 40 public: 41 RSRenderTransitionEffect() = default; 42 virtual ~RSRenderTransitionEffect() = default; 43 virtual void OnTransition(const std::unique_ptr<RSTransitionProperties>& transitionProperties, float fraction) = 0; 44 45 #ifdef ROSEN_OHOS 46 virtual bool Marshalling(Parcel& parcel) const override = 0; 47 static RSRenderTransitionEffect* Unmarshalling(Parcel& parcel); 48 #endif 49 50 protected: 51 }; 52 53 class RSTransitionFade : public RSRenderTransitionEffect { 54 public: RSTransitionFade(float alpha)55 explicit RSTransitionFade(float alpha) : alpha_(alpha = 0.0f) {} 56 virtual ~RSTransitionFade() = default; 57 void OnTransition(const std::unique_ptr<RSTransitionProperties>& transitionProperties, float fraction) override; 58 59 #ifdef ROSEN_OHOS 60 bool Marshalling(Parcel& parcel) const override; 61 static RSRenderTransitionEffect* Unmarshalling(Parcel& parcel); 62 #endif 63 private: 64 float alpha_; 65 }; 66 67 class RSTransitionScale : public RSRenderTransitionEffect { 68 public: 69 RSTransitionScale() = default; 70 explicit RSTransitionScale(float scaleX = 0.0f, float scaleY = 0.0f, float scaleZ = 0.0f) scaleX_(scaleX)71 : scaleX_(scaleX), scaleY_(scaleY), scaleZ_(scaleZ) 72 {} 73 virtual ~RSTransitionScale() = default; 74 void OnTransition(const std::unique_ptr<RSTransitionProperties>& transitionProperties, float fraction) override; 75 76 #ifdef ROSEN_OHOS 77 bool Marshalling(Parcel& parcel) const override; 78 static RSRenderTransitionEffect* Unmarshalling(Parcel& parcel); 79 #endif 80 private: 81 float scaleX_; 82 float scaleY_; 83 float scaleZ_; 84 }; 85 86 class RSTransitionTranslate : public RSRenderTransitionEffect { 87 public: 88 RSTransitionTranslate() = default; RSTransitionTranslate(float translateX,float translateY,float translateZ)89 explicit RSTransitionTranslate(float translateX, float translateY, float translateZ) 90 : translateX_(translateX), translateY_(translateY), translateZ_(translateZ) 91 {} 92 virtual ~RSTransitionTranslate() = default; 93 void OnTransition(const std::unique_ptr<RSTransitionProperties>& transitionProperties, float fraction) override; 94 95 #ifdef ROSEN_OHOS 96 bool Marshalling(Parcel& parcel) const override; 97 static RSRenderTransitionEffect* Unmarshalling(Parcel& parcel); 98 #endif 99 private: 100 float translateX_; 101 float translateY_; 102 float translateZ_; 103 }; 104 105 class RSTransitionRotate : public RSRenderTransitionEffect { 106 public: 107 RSTransitionRotate() = default; RSTransitionRotate(float dx,float dy,float dz,float angle)108 explicit RSTransitionRotate(float dx, float dy, float dz, float angle) : dx_(dx), dy_(dy), dz_(dz), angle_(angle) {} 109 virtual ~RSTransitionRotate() = default; 110 void OnTransition(const std::unique_ptr<RSTransitionProperties>& transitionProperties, float fraction) override; 111 112 #ifdef ROSEN_OHOS 113 bool Marshalling(Parcel& parcel) const override; 114 static RSRenderTransitionEffect* Unmarshalling(Parcel& parcel); 115 #endif 116 private: 117 float dx_; 118 float dy_; 119 float dz_; 120 float angle_; 121 }; 122 } // namespace Rosen 123 } // namespace OHOS 124 125 #endif 126