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     bool GetIsWhiteListForSolidColorLayerFlag() const;
40     void SetIsWhiteListForSolidColorLayerFlag(bool isWhiteListForSolidColorLayerFlag);
41 
42 private:
43     std::function<void()> startNewAniamtionFunc_ = nullptr;
44     // source crop tuning
45     std::atomic<bool> videoSurfaceFlag_{false};
46 
47     // use in updating hwcnode hardware state with background alpha
48     std::atomic<bool> hardwareEnabledByHwcnodeSkippedFlag_{false};
49     std::atomic<bool> hardwareEnabledByBackgroundAlphaSkippedFlag_{false};
50     std::atomic<bool> isWhiteListForSolidColorLayerFlag_{false};
51 };
52 } // namespace OHOS::Rosen
53 #endif