1 /* 2 * Copyright (c) 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_UI_RS_FRAME_RATE_LINKER_H 17 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_FRAME_RATE_LINKER_H 18 19 #include <atomic> 20 #include <memory> 21 #include <unistd.h> 22 23 #include "common/rs_common_def.h" 24 #include "animation/rs_frame_rate_range.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 29 class RSC_EXPORT RSFrameRateLinker { 30 public: 31 RSFrameRateLinker(); 32 ~RSFrameRateLinker(); 33 34 FrameRateLinkerId GetId() const; 35 bool IsUniRenderEnabled() const; 36 void UpdateFrameRateRange(const FrameRateRange& range, int32_t animatorExpectedFrameRate = -1); 37 void UpdateFrameRateRangeImme(const FrameRateRange& range, int32_t animatorExpectedFrameRate = -1); 38 void SetEnable(bool enabled); 39 bool IsEnable(); 40 static std::shared_ptr<RSFrameRateLinker> Create(); 41 private: 42 void InitUniRenderEnabled(); 43 static FrameRateLinkerId GenerateId(); 44 const FrameRateLinkerId id_; 45 FrameRateRange currentRange_; 46 int32_t currAnimatorExpectedFrameRate_ = -1; 47 std::atomic<bool> isEnabled_ = true; 48 }; 49 } // namespace Rosen 50 } // namespace OHOS 51 52 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_FRAME_RATE_LINKER_H 53