1 /* 2 * Copyright (c) 2025 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 FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_ANIMATION_FRAME_RATE_RANGE_H 17 #define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_ANIMATION_FRAME_RATE_RANGE_H 18 19 #include "ui/base/ace_type.h" 20 21 namespace OHOS::Ace { 22 23 class FrameRateRange : public AceType { 24 DECLARE_ACE_TYPE(FrameRateRange, AceType); 25 public: FrameRateRange()26 FrameRateRange() : min_(0), max_(0), preferred_(0), componentScene_(0) {} 27 FrameRateRange(int min,int max,int preferred)28 FrameRateRange(int min, int max, int preferred) : min_(min), max_(max), preferred_(preferred) {} 29 FrameRateRange(int min,int max,int preferred,int componentScene)30 FrameRateRange(int min, int max, int preferred, int componentScene) 31 : min_(min), max_(max), preferred_(preferred), componentScene_(componentScene) {} 32 IsZero()33 bool IsZero() const 34 { 35 return this->preferred_ == 0; 36 } 37 IsValid()38 bool IsValid() const 39 { 40 return !this->IsZero() && this->min_ <= this->preferred_ && this->preferred_ <= this->max_ && 41 this->min_ >= 0 && this->max_ <= rangeMaxRefreshrate; 42 } 43 IsDynamic()44 bool IsDynamic() const 45 { 46 return IsValid() && this->min_ != this->max_; 47 } 48 Reset()49 void Reset() 50 { 51 this->min_ = 0; 52 this->max_ = 0; 53 this->preferred_ = 0; 54 this->componentScene_ = 0; 55 } 56 Set(int min,int max,int preferred)57 void Set(int min, int max, int preferred) 58 { 59 this->min_ = min; 60 this->max_ = max; 61 this->preferred_ = preferred; 62 } 63 Merge(const FrameRateRange & other)64 void Merge(const FrameRateRange& other) 65 { 66 if (this->preferred_ < other.preferred_) { 67 this->Set(other.min_, other.max_, other.preferred_); 68 } 69 } 70 71 bool operator==(const FrameRateRange& other) 72 { 73 return this->min_ == other.min_ && this->max_ == other.max_ && 74 this->preferred_ == other.preferred_; 75 } 76 77 bool operator!=(const FrameRateRange& other) 78 { 79 return this->min_ != other.min_ || this->max_ != other.max_ || 80 this->preferred_ != other.preferred_; 81 } 82 83 int min_ = 0; 84 int max_ = 0; 85 int preferred_ = 0; 86 int componentScene_ = 0; 87 const int32_t rangeMaxRefreshrate = 144; 88 }; 89 90 } // namespace OHOS::Ace 91 92 #endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_ANIMATION_FRAME_RATE_RANGE_H 93