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_ANIMATION_RS_PROPERTY_ANIMATION_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ANIMATION_H 18 19 #include <memory> 20 21 #include "animation/rs_animation.h" 22 #include "common/rs_macros.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class RSPropertyBase; 27 class RSRenderAnimation; 28 29 class RSC_EXPORT RSPropertyAnimation : public RSAnimation { 30 public: 31 RSPropertyAnimation() = delete; 32 virtual ~RSPropertyAnimation() = default; 33 34 void SetIsCustom(const bool isCustom); 35 36 protected: 37 RSPropertyAnimation(std::shared_ptr<RSPropertyBase> property); 38 39 void SetAdditive(bool isAdditive); 40 41 bool GetAdditive() const; 42 43 const std::shared_ptr<RSPropertyBase> GetOriginValue() const; 44 45 void SetPropertyValue(const std::shared_ptr<RSPropertyBase>& value); 46 47 const std::shared_ptr<RSPropertyBase> GetPropertyValue() const; 48 49 PropertyId GetPropertyId() const override; 50 51 void OnStart() override; 52 53 void SetOriginValue(const std::shared_ptr<RSPropertyBase>& originValue); 54 55 virtual void InitInterpolationValue(); 56 57 void OnUpdateStagingValue(bool isFirstStart) override; 58 59 void StartCustomPropertyAnimation(const std::shared_ptr<RSRenderAnimation>& animation); 60 61 void SetPropertyOnAllAnimationFinish() override; 62 63 std::shared_ptr<RSPropertyBase> property_; 64 std::shared_ptr<RSPropertyBase> byValue_ {}; 65 std::shared_ptr<RSPropertyBase> startValue_ {}; 66 std::shared_ptr<RSPropertyBase> endValue_ {}; 67 std::shared_ptr<RSPropertyBase> originValue_ {}; 68 bool isAdditive_ { true }; 69 bool isCustom_ { false }; 70 bool isDelta_ { false }; 71 bool hasOriginValue_ { false }; 72 73 private: 74 void InitAdditiveMode(); 75 }; 76 } // namespace Rosen 77 } // namespace OHOS 78 79 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ANIMATION_H 80