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_RENDER_PROPERTY_ANIMATION_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PROPERTY_ANIMATION_H 18 19 #include "animation/rs_render_animation.h" 20 #include "common/rs_common_def.h" 21 #include "common/rs_macros.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class RSRenderPropertyBase; 26 class RSAnimationLog; 27 28 class RSB_EXPORT RSRenderPropertyAnimation : public RSRenderAnimation { 29 public: 30 virtual ~RSRenderPropertyAnimation() = default; 31 32 void DumpAnimationType(std::string& out) const override; 33 34 PropertyId GetPropertyId() const override; 35 36 void SetAdditive(bool isAdditive); 37 38 bool GetAdditive(); 39 40 void AttachRenderProperty(const std::shared_ptr<RSRenderPropertyBase>& property) override; 41 bool Marshalling(Parcel& parcel) const override; 42 protected: 43 RSRenderPropertyAnimation(AnimationId id, const PropertyId& propertyId, 44 const std::shared_ptr<RSRenderPropertyBase>& originValue); RSRenderPropertyAnimation(AnimationId id,const PropertyId & propertyId)45 RSRenderPropertyAnimation(AnimationId id, const PropertyId& propertyId) : RSRenderAnimation(id) 46 { 47 propertyId_ = propertyId; 48 } 49 RSRenderPropertyAnimation() =default; 50 bool ParseParam(Parcel& parcel) override; 51 void SetPropertyValue(const std::shared_ptr<RSRenderPropertyBase>& value); 52 53 const std::shared_ptr<RSRenderPropertyBase> GetPropertyValue() const; 54 55 const std::shared_ptr<RSRenderPropertyBase>& GetOriginValue() const; 56 57 const std::shared_ptr<RSRenderPropertyBase>& GetLastValue() const; 58 59 void SetAnimationValue(const std::shared_ptr<RSRenderPropertyBase>& value); 60 61 const std::shared_ptr<RSRenderPropertyBase> GetAnimationValue(const std::shared_ptr<RSRenderPropertyBase>& value); 62 63 void OnRemoveOnCompletion() override; 64 65 void RecordLastAnimateValue() override; 66 67 void UpdateAnimateVelocity(float frameInterval) override; 68 69 void ProcessAnimateVelocityUnderAngleRotation(float frameInterval) override; 70 InitValueEstimator()71 virtual void InitValueEstimator() {} 72 73 void DumpFraction(float fraction, int64_t time) override; 74 75 protected: 76 PropertyId propertyId_; 77 std::shared_ptr<RSRenderPropertyBase> originValue_; 78 std::shared_ptr<RSRenderPropertyBase> lastValue_; 79 std::shared_ptr<RSRenderPropertyBase> property_; 80 std::shared_ptr<RSRenderPropertyBase> lastAnimateValue_; 81 std::shared_ptr<RSValueEstimator> valueEstimator_; 82 83 private: 84 bool isAdditive_ { true }; 85 }; 86 } // namespace Rosen 87 } // namespace OHOS 88 89 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PROPERTY_ANIMATION_H 90