1 /* 2 * Copyright (c) 2023-2024 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 enum class HgmModifierType { 24 TRANSLATE, 25 SCALE, 26 ROTATION 27 }; 28 29 struct HgmModifierProfile { 30 float xSpeed; 31 float ySpeed; 32 HgmModifierType hgmModifierType; 33 }; 34 35 class FrameRateRange { 36 public: FrameRateRange()37 FrameRateRange() : min_(0), max_(0), preferred_(0) {} 38 FrameRateRange(int min,int max,int preferred)39 FrameRateRange(int min, int max, int preferred) : min_(min), max_(max), preferred_(preferred) {} 40 IsZero()41 bool IsZero() const 42 { 43 return this->min_ == 0 && this->max_ == 0 && this->preferred_ == 0; 44 } 45 IsValid()46 bool IsValid() const 47 { 48 return !this->IsZero() && this->min_ <= this->preferred_ && this->preferred_ <= this->max_ && 49 this->min_ >= 0 && this->max_ <= RANGE_MAX_REFRESHRATE; 50 } 51 IsDynamic()52 bool IsDynamic() const 53 { 54 return IsValid() && this->min_ != this->max_; 55 } 56 Reset()57 void Reset() 58 { 59 this->min_ = 0; 60 this->max_ = 0; 61 this->preferred_ = 0; 62 } 63 Set(int min,int max,int preferred)64 void Set(int min, int max, int preferred) 65 { 66 this->min_ = min; 67 this->max_ = max; 68 this->preferred_ = preferred; 69 } 70 Merge(FrameRateRange other)71 void Merge(FrameRateRange other) 72 { 73 if (this->preferred_ < other.preferred_) { 74 this->Set(other.min_, other.max_, other.preferred_); 75 } 76 } 77 78 bool operator==(const FrameRateRange& other) 79 { 80 return this->min_ == other.min_ && this->max_ == other.max_ && 81 this->preferred_ == other.preferred_; 82 } 83 84 bool operator!=(const FrameRateRange& other) 85 { 86 return this->min_ != other.min_ || this->max_ != other.max_ || 87 this->preferred_ != other.preferred_; 88 } 89 90 int min_ = 0; 91 int max_ = 0; 92 int preferred_ = 0; 93 }; 94 } // namespace Rosen 95 } // namespace OHOS 96 #endif // ROSEN_RENDER_SERVICE_BASE_ANIMATION_RS_FRAME_RATE_RANGE_H