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_ANIMATION_TIMING_PROTOCOL_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_PROTOCOL_H 18 19 #include "common/rs_common_def.h" 20 #include "rs_frame_rate_range.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 enum class FillMode { 25 NONE, 26 FORWARDS, 27 BACKWARDS, 28 BOTH, 29 }; 30 31 class RSB_EXPORT RSAnimationTimingProtocol { 32 public: 33 RSAnimationTimingProtocol() = default; RSAnimationTimingProtocol(int duration)34 RSAnimationTimingProtocol(int duration) : duration_(duration) {} 35 virtual ~RSAnimationTimingProtocol() = default; 36 SetDuration(int duration)37 void SetDuration(int duration) 38 { 39 duration_ = duration; 40 } 41 SetStartDelay(int startDelay)42 void SetStartDelay(int startDelay) 43 { 44 startDelay_ = startDelay; 45 } 46 SetSpeed(float speed)47 void SetSpeed(float speed) 48 { 49 speed_ = speed; 50 } 51 SetRepeatCount(int repeatCount)52 void SetRepeatCount(int repeatCount) 53 { 54 repeatCount_ = repeatCount; 55 } 56 SetAutoReverse(bool autoReverse)57 void SetAutoReverse(bool autoReverse) 58 { 59 autoReverse_ = autoReverse; 60 } 61 SetFillMode(const FillMode & fillMode)62 void SetFillMode(const FillMode& fillMode) 63 { 64 fillMode_ = fillMode; 65 } 66 SetDirection(bool isForward)67 void SetDirection(bool isForward) 68 { 69 isForward_ = isForward; 70 } 71 SetFrameRateRange(FrameRateRange range)72 void SetFrameRateRange(FrameRateRange range) 73 { 74 range_ = range; 75 } 76 GetDuration()77 int GetDuration() const 78 { 79 return duration_; 80 } 81 GetStartDelay()82 int GetStartDelay() const 83 { 84 return startDelay_; 85 } 86 GetSpeed()87 float GetSpeed() const 88 { 89 return speed_; 90 } 91 GetRepeatCount()92 int GetRepeatCount() const 93 { 94 return repeatCount_; 95 } 96 GetAutoReverse()97 bool GetAutoReverse() const 98 { 99 return autoReverse_; 100 } 101 GetFillMode()102 const FillMode& GetFillMode() const 103 { 104 return fillMode_; 105 } 106 GetDirection()107 bool GetDirection() const 108 { 109 return isForward_; 110 } 111 GetFrameRateRange()112 FrameRateRange GetFrameRateRange() const 113 { 114 return range_; 115 } 116 117 static const RSAnimationTimingProtocol DEFAULT; 118 static const RSAnimationTimingProtocol IMMEDIATE; 119 120 protected: 121 int duration_ { 300 }; 122 int startDelay_ { 0 }; 123 float speed_ { 1.0f }; 124 int repeatCount_ { 1 }; 125 bool autoReverse_ { false }; 126 FillMode fillMode_ { FillMode::FORWARDS }; 127 bool isForward_ { true }; 128 FrameRateRange range_ = {0, 0, 0}; 129 }; 130 } // namespace Rosen 131 } // namespace OHOS 132 133 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_PROTOCOL_H 134