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 #ifndef RS_COMMON_HOOK_H 17 #define RS_COMMON_HOOK_H 18 19 #include <atomic> 20 #include <functional> 21 #include <string> 22 #include <unordered_map> 23 24 #include "animation/rs_frame_rate_range.h" 25 26 namespace OHOS::Rosen { 27 class RsCommonHook { 28 public: 29 static RsCommonHook& Instance(); 30 void RegisterStartNewAnimationListener(std::function<void(const std::string&)> listener); 31 void OnStartNewAnimation(const std::string &componentName); 32 // source crop tuning 33 void SetVideoSurfaceFlag(bool videoSurfaceFlag); 34 bool GetVideoSurfaceFlag() const; 35 36 // use to implement product isolation for the adaptive P3 scheme 37 void SetAdaptiveColorGamutEnable(bool isAdaptiveColorGamutEnable); 38 bool IsAdaptiveColorGamutEnabled() const; 39 40 void SetTvPlayerBundleName(const std::string& bundleName); 41 const std::string& GetTvPlayerBundleName() const; 42 43 void SetFilterUnderHwcConfigByApp(const std::string& appName, const std::string& val); 44 std::string_view GetFilterUnderHwcConfigByApp(const std::string& appName); 45 46 // use in updating hwcnode hardware state with background alpha 47 void SetHardwareEnabledByHwcnodeBelowSelfInAppFlag(bool hardwareEnabledByHwcNodeSkippedFlag); 48 void SetHardwareEnabledByBackgroundAlphaFlag(bool hardwareEnabledByBackgroundAlphaSkippedFlag); 49 bool GetHardwareEnabledByHwcnodeBelowSelfInAppFlag() const; 50 bool GetHardwareEnabledByBackgroundAlphaFlag() const; 51 void SetComponentPowerFpsFunc(std::function<void(FrameRateRange& range)> func); 52 void GetComponentPowerFps(FrameRateRange& range); 53 bool GetIsWhiteListForSolidColorLayerFlag() const; 54 void SetIsWhiteListForSolidColorLayerFlag(bool isWhiteListForSolidColorLayerFlag); 55 56 // DISPLAY ENGINE 57 void SetCurrentPkgName(const std::string& pkgName); 58 std::string GetCurrentPkgName() const; 59 60 private: 61 std::function<void(const std::string&)> startNewAniamtionFunc_ = nullptr; 62 // source crop tuning 63 std::atomic<bool> videoSurfaceFlag_{false}; 64 65 // use to implement product isolation for the adaptive P3 scheme 66 std::atomic<bool> isAdaptiveColorGamutEnable_{false}; 67 68 std::string tvPlayerBundleName_; 69 70 std::unordered_map<std::string, std::string> filterUnderHwcConfig_; 71 72 // use in updating hwc node hardware state with background alpha 73 std::atomic<bool> hardwareEnabledByHwcnodeSkippedFlag_{false}; 74 std::atomic<bool> hardwareEnabledByBackgroundAlphaSkippedFlag_{false}; 75 std::atomic<bool> isWhiteListForSolidColorLayerFlag_{false}; 76 77 std::function<void(FrameRateRange& range)> componentPowerFpsFunc_ = nullptr; 78 79 // DISPLAY ENGINE 80 std::string pkgName_{}; 81 }; 82 } // namespace OHOS::Rosen 83 #endif