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 enum class FinishCallbackType { 32 TIME_SENSITIVE, 33 TIME_INSENSITIVE, 34 LOGICALLY, 35 }; 36 37 class RSB_EXPORT RSAnimationTimingProtocol { 38 public: 39 RSAnimationTimingProtocol() = default; RSAnimationTimingProtocol(int duration)40 RSAnimationTimingProtocol(int duration) : duration_(duration) {} 41 virtual ~RSAnimationTimingProtocol() = default; 42 SetDuration(int duration)43 void SetDuration(int duration) 44 { 45 duration_ = duration; 46 } 47 SetStartDelay(int startDelay)48 void SetStartDelay(int startDelay) 49 { 50 startDelay_ = startDelay; 51 } 52 SetSpeed(float speed)53 void SetSpeed(float speed) 54 { 55 speed_ = speed; 56 } 57 SetRepeatCount(int repeatCount)58 void SetRepeatCount(int repeatCount) 59 { 60 repeatCount_ = repeatCount; 61 } 62 SetAutoReverse(bool autoReverse)63 void SetAutoReverse(bool autoReverse) 64 { 65 autoReverse_ = autoReverse; 66 } 67 SetFillMode(const FillMode & fillMode)68 void SetFillMode(const FillMode& fillMode) 69 { 70 fillMode_ = fillMode; 71 } 72 SetDirection(bool isForward)73 void SetDirection(bool isForward) 74 { 75 isForward_ = isForward; 76 } 77 SetFrameRateRange(FrameRateRange range)78 void SetFrameRateRange(FrameRateRange range) 79 { 80 range_ = range; 81 } 82 SetFinishCallbackType(FinishCallbackType finishCallbackType)83 void SetFinishCallbackType(FinishCallbackType finishCallbackType) 84 { 85 finishCallbackType_ = finishCallbackType; 86 } 87 SetInterfaceName(const std::string & interfaceName)88 void SetInterfaceName(const std::string& interfaceName) 89 { 90 interfaceName_ = interfaceName; 91 } 92 GetDuration()93 int GetDuration() const 94 { 95 return duration_; 96 } 97 GetStartDelay()98 int GetStartDelay() const 99 { 100 return startDelay_; 101 } 102 GetSpeed()103 float GetSpeed() const 104 { 105 return speed_; 106 } 107 GetRepeatCount()108 int GetRepeatCount() const 109 { 110 return repeatCount_; 111 } 112 GetAutoReverse()113 bool GetAutoReverse() const 114 { 115 return autoReverse_; 116 } 117 GetFillMode()118 const FillMode& GetFillMode() const 119 { 120 return fillMode_; 121 } 122 GetDirection()123 bool GetDirection() const 124 { 125 return isForward_; 126 } 127 GetFrameRateRange()128 FrameRateRange GetFrameRateRange() const 129 { 130 return range_; 131 } 132 GetFinishCallbackType()133 FinishCallbackType GetFinishCallbackType() const 134 { 135 return finishCallbackType_; 136 } 137 GetInterfaceName()138 const std::string& GetInterfaceName() const 139 { 140 return interfaceName_; 141 } 142 143 static const RSAnimationTimingProtocol DEFAULT; 144 static const RSAnimationTimingProtocol IMMEDIATE; 145 146 protected: 147 int duration_ { 300 }; 148 int startDelay_ { 0 }; 149 float speed_ { 1.0f }; 150 int repeatCount_ { 1 }; 151 bool autoReverse_ { false }; 152 FillMode fillMode_ { FillMode::FORWARDS }; 153 bool isForward_ { true }; 154 FrameRateRange range_ = {0, 0, 0}; 155 FinishCallbackType finishCallbackType_ { FinishCallbackType::TIME_SENSITIVE }; 156 std::string interfaceName_; 157 }; 158 } // namespace Rosen 159 } // namespace OHOS 160 161 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_PROTOCOL_H 162