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 #ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_FRAME_RATE_LINKER_H 16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_FRAME_RATE_LINKER_H 17 18 #include <refbase.h> 19 20 #include "animation/rs_frame_rate_range.h" 21 #include "common/rs_common_def.h" 22 #include "common/rs_macros.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class RSB_EXPORT RSRenderFrameRateLinker : public std::enable_shared_from_this<RSRenderFrameRateLinker> { 27 public: 28 explicit RSRenderFrameRateLinker(FrameRateLinkerId id); 29 explicit RSRenderFrameRateLinker(); 30 31 RSRenderFrameRateLinker(const RSRenderFrameRateLinker&) = delete; 32 RSRenderFrameRateLinker(const RSRenderFrameRateLinker&&) = delete; 33 RSRenderFrameRateLinker& operator=(const RSRenderFrameRateLinker&) = delete; 34 RSRenderFrameRateLinker& operator=(const RSRenderFrameRateLinker&&) = delete; 35 ~RSRenderFrameRateLinker() = default; 36 GetId()37 inline FrameRateLinkerId GetId() const 38 { 39 return id_; 40 } 41 GetAceAnimatorExpectedFrameRate()42 inline int32_t GetAceAnimatorExpectedFrameRate() { 43 return animatorExpectedFrameRate_; 44 } 45 46 void SetAnimatorExpectedFrameRate(int32_t animatorExpectedFrameRate); 47 48 void SetExpectedRange(const FrameRateRange& range); 49 const FrameRateRange& GetExpectedRange() const; 50 void SetFrameRate(uint32_t rate); 51 uint32_t GetFrameRate() const; 52 void SyncFrameRateRange(FrameRateLinkerId id, const FrameRateRange& range, int32_t animatorExpectedFrameRate); 53 private: 54 static FrameRateLinkerId GenerateId(); 55 FrameRateLinkerId id_ = 0; 56 FrameRateRange expectedRange_; 57 uint32_t frameRate_ = 0; 58 int32_t animatorExpectedFrameRate_ = -1; 59 }; 60 } // namespace Rosen 61 } // namespace OHOS 62 63 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_FRAME_RATE_LINKER_H 64