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/LICENSE2.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_ANIMATION_RS_TRANSITION_EFFECT_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_TRANSITION_EFFECT_H 18 19 #if defined(_WIN32) 20 #define _USE_MATH_DEFINES 21 #endif 22 #include <cmath> 23 #include <memory> 24 #include <vector> 25 26 #include "common/rs_macros.h" 27 #include "common/rs_vector3.h" 28 #include "common/rs_vector4.h" 29 30 namespace OHOS { 31 namespace Rosen { 32 class RSRenderTransitionEffect; 33 class RSTransitionModifier; 34 class RSPropertyBase; 35 36 class RSC_EXPORT RSCustomTransitionEffect final { 37 public: RSCustomTransitionEffect(const std::shared_ptr<RSTransitionModifier> & modifier)38 RSCustomTransitionEffect(const std::shared_ptr<RSTransitionModifier>& modifier) : modifier_(modifier) 39 {} 40 41 private: 42 void Custom(const std::shared_ptr<RSPropertyBase>& property, 43 const std::shared_ptr<RSPropertyBase>& startValue, const std::shared_ptr<RSPropertyBase>& endValue); 44 45 void Active(); 46 void Identity(); 47 48 std::shared_ptr<RSTransitionModifier> modifier_; 49 std::vector<std::shared_ptr<RSRenderTransitionEffect>> customTransitionEffects_; 50 std::vector<std::pair<std::shared_ptr<RSPropertyBase>, std::shared_ptr<RSPropertyBase>>> properties_; 51 52 friend class RSNode; 53 friend class RSTransition; 54 friend class RSTransitionEffect; 55 friend class RSImplicitTransitionParam; 56 }; 57 58 class RSC_EXPORT RSTransitionEffect final : public std::enable_shared_from_this<RSTransitionEffect> { 59 public: 60 static const std::shared_ptr<const RSTransitionEffect> EMPTY; 61 static const std::shared_ptr<const RSTransitionEffect> OPACITY; 62 static const std::shared_ptr<const RSTransitionEffect> SCALE; 63 64 static std::shared_ptr<RSTransitionEffect> Create(); 65 66 static std::shared_ptr<RSTransitionEffect> Asymmetric(const std::shared_ptr<RSTransitionEffect>& transitionIn, 67 const std::shared_ptr<RSTransitionEffect>& transitionOut); 68 69 std::shared_ptr<RSTransitionEffect> Opacity(float opacity = 0.0f); 70 std::shared_ptr<RSTransitionEffect> Scale(const Vector3f& scale); 71 std::shared_ptr<RSTransitionEffect> Translate(const Vector3f& translate); 72 std::shared_ptr<RSTransitionEffect> Rotate(const Vector4f& axisAngle); 73 std::shared_ptr<RSTransitionEffect> Custom(const std::shared_ptr<RSTransitionModifier>& modifier); 74 75 private: 76 RSTransitionEffect() = default; 77 78 RSTransitionEffect(const std::shared_ptr<RSTransitionEffect>& transitionIn, 79 const std::shared_ptr<RSTransitionEffect>& transitionOut); 80 81 std::vector<std::shared_ptr<RSRenderTransitionEffect>> transitionInEffects_; 82 std::vector<std::shared_ptr<RSRenderTransitionEffect>> transitionOutEffects_; 83 84 std::vector<std::shared_ptr<RSCustomTransitionEffect>> customTransitionInEffects_; 85 std::vector<std::shared_ptr<RSCustomTransitionEffect>> customTransitionOutEffects_; 86 87 friend class RSNode; 88 friend class RSTransition; 89 friend class RSImplicitTransitionParam; 90 }; 91 } // namespace Rosen 92 } // namespace OHOS 93 94 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_TRANSITION_EFFECT_H 95