• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 ROSEN_RENDER_SERVICE_BASE_ANIMATION_RS_FRAME_RATE_RANGE_H
17 #define ROSEN_RENDER_SERVICE_BASE_ANIMATION_RS_FRAME_RATE_RANGE_H
18 
19 #define RANGE_MAX_REFRESHRATE 144
20 
21 namespace OHOS {
22 namespace Rosen {
23 class FrameRateRange {
24 public:
FrameRateRange()25     FrameRateRange() : min_(0), max_(0), preferred_(0) {}
26 
FrameRateRange(int min,int max,int preferred)27     FrameRateRange(int min, int max, int preferred) : min_(min), max_(max), preferred_(preferred) {}
28 
IsZero()29     bool IsZero() const
30     {
31         return this->preferred_ == 0;
32     }
33 
IsValid()34     bool IsValid() const
35     {
36         return !this->IsZero() && this->min_ <= this->preferred_ && this->preferred_ <= this->max_ &&
37             this->min_ >= 0 && this->max_ <= RANGE_MAX_REFRESHRATE;
38     }
39 
IsDynamic()40     bool IsDynamic() const
41     {
42         return IsValid() && this->min_ != this->max_;
43     }
44 
Reset()45     void Reset()
46     {
47         this->min_ = 0;
48         this->max_ = 0;
49         this->preferred_ = 0;
50     }
51 
Set(int min,int max,int preferred)52     void Set(int min, int max, int preferred)
53     {
54         this->min_ = min;
55         this->max_ = max;
56         this->preferred_ = preferred;
57     }
58 
Merge(const FrameRateRange & other)59     void Merge(const FrameRateRange& other)
60     {
61         if (this->preferred_ < other.preferred_) {
62             this->Set(other.min_, other.max_, other.preferred_);
63         }
64     }
65 
66     bool operator==(const FrameRateRange& other) const
67     {
68         return this->min_ == other.min_ && this->max_ == other.max_ &&
69             this->preferred_ == other.preferred_;
70     }
71 
72     bool operator!=(const FrameRateRange& other) const
73     {
74         return this->min_ != other.min_ || this->max_ != other.max_ ||
75             this->preferred_ != other.preferred_;
76     }
77 
78     int min_ = 0;
79     int max_ = 0;
80     int preferred_ = 0;
81 };
82 } // namespace Rosen
83 } // namespace OHOS
84 #endif // ROSEN_RENDER_SERVICE_BASE_ANIMATION_RS_FRAME_RATE_RANGE_H