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 namespace OHOS::Rosen { 25 class RsCommonHook { 26 public: 27 static RsCommonHook& Instance(); 28 void RegisterStartNewAnimationListener(std::function<void()> listener); 29 void OnStartNewAnimation(); 30 // source crop tuning 31 void SetVideoSurfaceFlag(bool videoSurfaceFlag); 32 bool GetVideoSurfaceFlag() const; 33 34 // use in updating hwcnode hardware state with background alpha 35 void SetHardwareEnabledByHwcnodeBelowSelfInAppFlag(bool hardwareEnabledByHwcNodeSkippedFlag); 36 void SetHardwareEnabledByBackgroundAlphaFlag(bool hardwareEnabledByBackgroundAlphaSkippedFlag); 37 bool GetHardwareEnabledByHwcnodeBelowSelfInAppFlag() const; 38 bool GetHardwareEnabledByBackgroundAlphaFlag() const; 39 40 private: 41 std::function<void()> startNewAniamtionFunc_ = nullptr; 42 // source crop tuning 43 std::atomic<bool> videoSurfaceFlag_{false}; 44 45 // use in updating hwcnode hardware state with background alpha 46 std::atomic<bool> hardwareEnabledByHwcnodeSkippedFlag_{false}; 47 std::atomic<bool> hardwareEnabledByBackgroundAlphaSkippedFlag_{false}; 48 }; 49 } // namespace OHOS::Rosen 50 #endif