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