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 #include "command/rs_frame_rate_linker_command.h"
17 #include "platform/common/rs_log.h"
18
19 namespace OHOS {
20 namespace Rosen {
Destroy(RSContext & context,FrameRateLinkerId id)21 void RSFrameRateLinkerCommandHelper::Destroy(RSContext& context, FrameRateLinkerId id)
22 {
23 auto& linkerMap = context.GetMutableFrameRateLinkerMap();
24 auto linker = linkerMap.GetFrameRateLinker(id);
25 if (linker == nullptr) {
26 return;
27 }
28 linkerMap.UnregisterFrameRateLinker(id);
29 }
30
UpdateRange(RSContext & context,FrameRateLinkerId id,FrameRateRange range,int32_t animatorExpectedFrameRate)31 void RSFrameRateLinkerCommandHelper::UpdateRange(RSContext& context, FrameRateLinkerId id,
32 FrameRateRange range, int32_t animatorExpectedFrameRate)
33 {
34 ROSEN_LOGD("RSFrameRateLinkerCommandHelper::UpdateRange %{public}" PRIu64 ", {%{public}d, %{public}d, %{public}d}",
35 id, range.min_, range.max_, range.preferred_);
36 auto linker = context.GetMutableFrameRateLinkerMap().GetFrameRateLinker(id);
37 if (linker != nullptr) {
38 linker->SetExpectedRange(range);
39 linker->SetAnimatorExpectedFrameRate(animatorExpectedFrameRate);
40 }
41 }
42 } // namespace Rosen
43 } // namespace OHOS
44