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 DumpAnimationInfo(std::string& out) const override; 33 void DumpProperty(std::string& out) const; 34 35 PropertyId GetPropertyId() const override; 36 37 void SetAdditive(bool isAdditive); 38 39 bool GetAdditive(); 40 41 void AttachRenderProperty(const std::shared_ptr<RSRenderPropertyBase>& property) override; 42 bool Marshalling(Parcel& parcel) const override; 43 protected: 44 RSRenderPropertyAnimation(AnimationId id, const PropertyId& propertyId, 45 const std::shared_ptr<RSRenderPropertyBase>& originValue); RSRenderPropertyAnimation(AnimationId id,const PropertyId & propertyId)46 RSRenderPropertyAnimation(AnimationId id, const PropertyId& propertyId) : RSRenderAnimation(id) 47 { 48 propertyId_ = propertyId; 49 } 50 RSRenderPropertyAnimation() =default; 51 bool ParseParam(Parcel& parcel) override; 52 void SetPropertyValue(const std::shared_ptr<RSRenderPropertyBase>& value); 53 54 const std::shared_ptr<RSRenderPropertyBase> GetPropertyValue() const; 55 56 const std::shared_ptr<RSRenderPropertyBase>& GetOriginValue() const; 57 58 const std::shared_ptr<RSRenderPropertyBase>& GetLastValue() const; 59 60 void SetAnimationValue(const std::shared_ptr<RSRenderPropertyBase>& value); 61 62 const std::shared_ptr<RSRenderPropertyBase> GetAnimationValue(const std::shared_ptr<RSRenderPropertyBase>& value); 63 64 void OnRemoveOnCompletion() override; 65 66 void RecordLastAnimateValue() override; 67 68 void UpdateAnimateVelocity(float frameInterval) override; 69 70 void ProcessAnimateVelocityUnderAngleRotation(float frameInterval) override; 71 InitValueEstimator()72 virtual void InitValueEstimator() {} 73 74 void DumpFraction(float fraction, int64_t time) override; 75 76 protected: 77 PropertyId propertyId_; 78 std::shared_ptr<RSRenderPropertyBase> originValue_; 79 std::shared_ptr<RSRenderPropertyBase> lastValue_; 80 std::shared_ptr<RSRenderPropertyBase> property_; 81 std::shared_ptr<RSRenderPropertyBase> lastAnimateValue_; 82 std::shared_ptr<RSValueEstimator> valueEstimator_; 83 84 private: 85 bool isAdditive_ { true }; 86 }; 87 } // namespace Rosen 88 } // namespace OHOS 89 90 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PROPERTY_ANIMATION_H 91