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 16 #include "pipeline/rs_render_frame_rate_linker.h" 17 18 #include "platform/common/rs_log.h" 19 #include "sandbox_utils.h" 20 21 namespace OHOS { 22 namespace Rosen { GenerateId()23FrameRateLinkerId RSRenderFrameRateLinker::GenerateId() 24 { 25 static pid_t pid_ = GetRealPid(); 26 static std::atomic<uint32_t> currentId_ = 0; 27 28 auto currentId = currentId_.fetch_add(1, std::memory_order_relaxed); 29 if (currentId == UINT32_MAX) { 30 ROSEN_LOGE("RSRenderFrameRateLinker Id overflow"); 31 } 32 33 // concat two 32-bit numbers to one 64-bit number 34 return ((FrameRateLinkerId)pid_ << 32) | (currentId); 35 } 36 RSRenderFrameRateLinker(FrameRateLinkerId id)37RSRenderFrameRateLinker::RSRenderFrameRateLinker(FrameRateLinkerId id) : id_(id) {} RSRenderFrameRateLinker()38RSRenderFrameRateLinker::RSRenderFrameRateLinker() : id_(GenerateId()) {} 39 SetExpectedRange(const FrameRateRange & range)40void RSRenderFrameRateLinker::SetExpectedRange(const FrameRateRange& range) 41 { 42 expectedRange_ = range; 43 } 44 GetExpectedRange() const45const FrameRateRange& RSRenderFrameRateLinker::GetExpectedRange() const 46 { 47 return expectedRange_; 48 } 49 SetFrameRate(uint32_t rate)50void RSRenderFrameRateLinker::SetFrameRate(uint32_t rate) 51 { 52 frameRate_ = rate; 53 } 54 GetFrameRate() const55uint32_t RSRenderFrameRateLinker::GetFrameRate() const 56 { 57 return frameRate_; 58 } 59 SetAnimatorExpectedFrameRate(int32_t animatorExpectedFrameRate)60void RSRenderFrameRateLinker::SetAnimatorExpectedFrameRate(int32_t animatorExpectedFrameRate) 61 { 62 animatorExpectedFrameRate_ = animatorExpectedFrameRate; 63 } 64 65 } // namespace Rosen 66 } // namespace OHOS 67