• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OHOS_ROSEN_WINDOW_SYSTEM_EFFECT_H
17 #define OHOS_ROSEN_WINDOW_SYSTEM_EFFECT_H
18 
19 #include <refbase.h>
20 #include "wm_common.h"
21 #include "window_node.h"
22 #include "window_root.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 struct WindowShadowParameters {
27     float elevation_;
28     std::string color_;
29     float offsetX_;
30     float offsetY_;
31     float alpha_;
32     float radius_;
33 };
34 struct AppWindowEffectConfig {
35     float fullScreenCornerRadius_;
36     float splitCornerRadius_;
37     float floatCornerRadius_;
38 
39     WindowShadowParameters focusedShadow_;
40     WindowShadowParameters unfocusedShadow_;
41 
42     // defaultCornerRadiusL = 16.0vp
AppWindowEffectConfigAppWindowEffectConfig43     AppWindowEffectConfig() : fullScreenCornerRadius_(0.0), splitCornerRadius_(0.0), floatCornerRadius_(0.0)
44     {
45         focusedShadow_ = {0, "#000000", 0, 0, 0};
46         unfocusedShadow_ = {0, "#000000", 0, 0, 0};
47     }
48 };
49 class WindowSystemEffect : public RefBase {
50 public:
51     WindowSystemEffect() = delete;
52     ~WindowSystemEffect() = default;
53 
54     static void SetWindowSystemEffectConfig(AppWindowEffectConfig config);
55     static void SetWindowRoot(const sptr<WindowRoot>& windowRoot);
56 
57     static WMError SetWindowEffect(const sptr<WindowNode>& node, bool needCheckAnimation = true);
58     static WMError SetWindowShadow(const sptr<WindowNode>& node);
59     static WMError SetCornerRadius(const sptr<WindowNode>& node, bool needCheckAnimation = true);
60 private:
ConvertRadiusToSigma(float radius)61     static float ConvertRadiusToSigma(float radius)
62     {
63         constexpr float BlurSigmaScale = 0.57735f;
64         return radius > 0.0f ? BlurSigmaScale * radius + SK_ScalarHalf : 0.0f;
65     }
66     static bool IsAppMainOrSubOrFloatingWindow(const sptr<WindowNode>& node);
67     static AppWindowEffectConfig windowSystemEffectConfig_;
68     static wptr<WindowRoot> windowRoot_;
69 };
70 } // Rosen
71 } // OHOS
72 #endif // OHOS_ROSEN_WINDOW_SYSTEM_EFFECT_H
73