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_ANIMATION_RS_CURVE_ANIMATION_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_CURVE_ANIMATION_H 18 19 #include <iostream> 20 #include <memory> 21 22 #include "animation/rs_animation_timing_curve.h" 23 #include "animation/rs_property_animation.h" 24 #include "common/rs_color.h" 25 #include "common/rs_matrix3.h" 26 #include "common/rs_vector4.h" 27 #include "render/rs_filter.h" 28 29 namespace OHOS { 30 namespace Rosen { 31 template<typename T> 32 class RS_EXPORT RSCurveAnimation : public RSPropertyAnimation<T> { 33 public: RSCurveAnimation(const RSAnimatableProperty & property,const T & byValue)34 RSCurveAnimation(const RSAnimatableProperty& property, const T& byValue) : RSPropertyAnimation<T>(property) 35 { 36 RSPropertyAnimation<T>::isDelta_ = true; 37 RSPropertyAnimation<T>::byValue_ = byValue; 38 } 39 RSCurveAnimation(const RSAnimatableProperty & property,const T & startValue,const T & endValue)40 RSCurveAnimation(const RSAnimatableProperty& property, const T& startValue, const T& endValue) 41 : RSPropertyAnimation<T>(property) 42 { 43 RSPropertyAnimation<T>::isDelta_ = false; 44 RSPropertyAnimation<T>::startValue_ = startValue; 45 RSPropertyAnimation<T>::endValue_ = endValue; 46 } 47 48 virtual ~RSCurveAnimation() = default; 49 SetTimingCurve(const RSAnimationTimingCurve & timingCurve)50 void SetTimingCurve(const RSAnimationTimingCurve& timingCurve) 51 { 52 timingCurve_ = timingCurve; 53 } 54 GetTimingCurve()55 const RSAnimationTimingCurve& GetTimingCurve() const 56 { 57 return timingCurve_; 58 } 59 60 protected: 61 void OnStart() override; 62 63 private: 64 RSAnimationTimingCurve timingCurve_ { RSAnimationTimingCurve::DEFAULT }; 65 }; 66 67 template class RSCurveAnimation<int>; 68 template class RSCurveAnimation<float>; 69 template class RSCurveAnimation<Color>; 70 template class RSCurveAnimation<Matrix3f>; 71 template class RSCurveAnimation<Vector2f>; 72 template class RSCurveAnimation<Vector4f>; 73 template class RSCurveAnimation<Quaternion>; 74 template class RSCurveAnimation<std::shared_ptr<RSFilter>>; 75 76 } // namespace Rosen 77 } // namespace OHOS 78 79 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_CURVE_ANIMATION_H 80