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()19RsCommonHook& RsCommonHook::Instance() 20 { 21 static RsCommonHook rch; 22 return rch; 23 } 24 RegisterStartNewAnimationListener(std::function<void ()> listener)25void RsCommonHook::RegisterStartNewAnimationListener(std::function<void()> listener) 26 { 27 startNewAniamtionFunc_ = listener; 28 } 29 OnStartNewAnimation()30void RsCommonHook::OnStartNewAnimation() 31 { 32 if (startNewAniamtionFunc_) { 33 startNewAniamtionFunc_(); 34 } 35 } 36 SetVideoSurfaceFlag(bool videoSurfaceFlag)37void RsCommonHook::SetVideoSurfaceFlag(bool videoSurfaceFlag) 38 { 39 videoSurfaceFlag_ = videoSurfaceFlag; 40 } 41 GetVideoSurfaceFlag() const42bool RsCommonHook::GetVideoSurfaceFlag() const 43 { 44 return videoSurfaceFlag_; 45 } 46 47 // skip hwcnode hardware state updating SetHardwareEnabledByHwcnodeBelowSelfInAppFlag(bool hardwareEnabledByHwcnodeSkippedFlag)48void RsCommonHook::SetHardwareEnabledByHwcnodeBelowSelfInAppFlag(bool hardwareEnabledByHwcnodeSkippedFlag) 49 { 50 hardwareEnabledByHwcnodeSkippedFlag_ = hardwareEnabledByHwcnodeSkippedFlag; 51 } 52 SetHardwareEnabledByBackgroundAlphaFlag(bool hardwareEnabledByBackgroundAlphaSkippedFlag)53void RsCommonHook::SetHardwareEnabledByBackgroundAlphaFlag(bool hardwareEnabledByBackgroundAlphaSkippedFlag) 54 { 55 hardwareEnabledByBackgroundAlphaSkippedFlag_ = hardwareEnabledByBackgroundAlphaSkippedFlag; 56 } 57 GetHardwareEnabledByHwcnodeBelowSelfInAppFlag() const58bool RsCommonHook::GetHardwareEnabledByHwcnodeBelowSelfInAppFlag() const 59 { 60 return hardwareEnabledByHwcnodeSkippedFlag_; 61 } 62 GetHardwareEnabledByBackgroundAlphaFlag() const63bool RsCommonHook::GetHardwareEnabledByBackgroundAlphaFlag() const 64 { 65 return hardwareEnabledByBackgroundAlphaSkippedFlag_; 66 } 67 GetIsWhiteListForSolidColorLayerFlag() const68bool RsCommonHook::GetIsWhiteListForSolidColorLayerFlag() const 69 { 70 return isWhiteListForSolidColorLayerFlag_; 71 } 72 SetIsWhiteListForSolidColorLayerFlag(bool isWhiteListForSolidColorLayerFlag)73void RsCommonHook::SetIsWhiteListForSolidColorLayerFlag(bool isWhiteListForSolidColorLayerFlag) 74 { 75 isWhiteListForSolidColorLayerFlag_ = isWhiteListForSolidColorLayerFlag; 76 } 77 78 } // namespace OHOS::Rosen