• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "common/rs_common_hook.h"
17 
18 namespace OHOS::Rosen {
Instance()19 RsCommonHook& RsCommonHook::Instance()
20 {
21     static RsCommonHook rch;
22     return rch;
23 }
24 
RegisterStartNewAnimationListener(std::function<void (const std::string &)> listener)25 void RsCommonHook::RegisterStartNewAnimationListener(std::function<void(const std::string &)> listener)
26 {
27     startNewAniamtionFunc_ = listener;
28 }
29 
OnStartNewAnimation(const std::string & componentName)30 void RsCommonHook::OnStartNewAnimation(const std::string &componentName)
31 {
32     if (startNewAniamtionFunc_) {
33         startNewAniamtionFunc_(componentName);
34     }
35 }
36 
SetVideoSurfaceFlag(bool videoSurfaceFlag)37 void RsCommonHook::SetVideoSurfaceFlag(bool videoSurfaceFlag)
38 {
39     videoSurfaceFlag_ = videoSurfaceFlag;
40 }
41 
GetVideoSurfaceFlag() const42 bool RsCommonHook::GetVideoSurfaceFlag() const
43 {
44     return videoSurfaceFlag_;
45 }
46 
47 // skip hwcnode hardware state updating
SetHardwareEnabledByHwcnodeBelowSelfInAppFlag(bool hardwareEnabledByHwcnodeSkippedFlag)48 void RsCommonHook::SetHardwareEnabledByHwcnodeBelowSelfInAppFlag(bool hardwareEnabledByHwcnodeSkippedFlag)
49 {
50     hardwareEnabledByHwcnodeSkippedFlag_ = hardwareEnabledByHwcnodeSkippedFlag;
51 }
52 
SetHardwareEnabledByBackgroundAlphaFlag(bool hardwareEnabledByBackgroundAlphaSkippedFlag)53 void RsCommonHook::SetHardwareEnabledByBackgroundAlphaFlag(bool hardwareEnabledByBackgroundAlphaSkippedFlag)
54 {
55     hardwareEnabledByBackgroundAlphaSkippedFlag_ = hardwareEnabledByBackgroundAlphaSkippedFlag;
56 }
57 
GetHardwareEnabledByHwcnodeBelowSelfInAppFlag() const58 bool RsCommonHook::GetHardwareEnabledByHwcnodeBelowSelfInAppFlag() const
59 {
60     return hardwareEnabledByHwcnodeSkippedFlag_;
61 }
62 
GetHardwareEnabledByBackgroundAlphaFlag() const63 bool RsCommonHook::GetHardwareEnabledByBackgroundAlphaFlag() const
64 {
65     return hardwareEnabledByBackgroundAlphaSkippedFlag_;
66 }
67 
GetIsWhiteListForSolidColorLayerFlag() const68 bool RsCommonHook::GetIsWhiteListForSolidColorLayerFlag() const
69 {
70     return isWhiteListForSolidColorLayerFlag_;
71 }
72 
SetIsWhiteListForSolidColorLayerFlag(bool isWhiteListForSolidColorLayerFlag)73 void RsCommonHook::SetIsWhiteListForSolidColorLayerFlag(bool isWhiteListForSolidColorLayerFlag)
74 {
75     isWhiteListForSolidColorLayerFlag_ = isWhiteListForSolidColorLayerFlag;
76 }
77 
SetComponentPowerFpsFunc(std::function<void (FrameRateRange & range)> func)78 void RsCommonHook::SetComponentPowerFpsFunc(std::function<void(FrameRateRange& range)> func)
79 {
80     componentPowerFpsFunc_ = func;
81 }
82 
GetComponentPowerFps(FrameRateRange & range)83 void RsCommonHook::GetComponentPowerFps(FrameRateRange& range)
84 {
85     if (componentPowerFpsFunc_) {
86         componentPowerFpsFunc_(range);
87     }
88 }
89 
90 } // namespace OHOS::Rosen