• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "window_node.h"
17 #include "window_helper.h"
18 #include "window_manager_hilog.h"
19 
20 namespace OHOS {
21 namespace Rosen {
22 namespace {
23     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "WindowNode"};
24 }
25 
SetDisplayId(DisplayId displayId)26 void WindowNode::SetDisplayId(DisplayId displayId)
27 {
28     property_->SetDisplayId(displayId);
29 }
30 
SetLayoutRect(const Rect & rect)31 void WindowNode::SetLayoutRect(const Rect& rect)
32 {
33     layoutRect_ = rect;
34 }
35 
SetHotZoneRect(const Rect & rect)36 void WindowNode::SetHotZoneRect(const Rect& rect)
37 {
38     hotZoneRect_ = rect;
39 }
40 
SetWindowRect(const Rect & rect)41 void WindowNode::SetWindowRect(const Rect& rect)
42 {
43     property_->SetWindowRect(rect);
44 }
45 
SetWindowProperty(const sptr<WindowProperty> & property)46 void WindowNode::SetWindowProperty(const sptr<WindowProperty>& property)
47 {
48     property_ = property;
49 }
50 
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)51 void WindowNode::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
52 {
53     property_->SetSystemBarProperty(type, property);
54 }
55 
SetWindowMode(WindowMode mode)56 void WindowNode::SetWindowMode(WindowMode mode)
57 {
58     property_->SetWindowMode(mode);
59 }
60 
SetWindowBackgroundBlur(WindowBlurLevel level)61 void WindowNode::SetWindowBackgroundBlur(WindowBlurLevel level)
62 {
63     float blurRadiusX;
64     float blurRadiusY;
65     const float OFF_BLUR_RADIUS = 0.0f;
66     const float LOW_BLUR_RADIUS = 3.0f;
67     const float MEDIUM_BLUR_RADIUS = 11.0f;
68     const float HIGH_BLUR_RADIUS = 19.0f;
69 
70     switch (level) {
71         case WindowBlurLevel::WINDOW_BLUR_LOW:
72             blurRadiusX = LOW_BLUR_RADIUS;
73             blurRadiusY = LOW_BLUR_RADIUS;
74             break;
75         case WindowBlurLevel::WINDOW_BLUR_MEDIUM:
76             blurRadiusX = MEDIUM_BLUR_RADIUS;
77             blurRadiusY = MEDIUM_BLUR_RADIUS;
78             break;
79         case WindowBlurLevel::WINDOW_BLUR_HIGH:
80             blurRadiusX = HIGH_BLUR_RADIUS;
81             blurRadiusY = HIGH_BLUR_RADIUS;
82             break;
83         default:
84             blurRadiusX = OFF_BLUR_RADIUS;
85             blurRadiusY = OFF_BLUR_RADIUS;
86             break;
87     }
88     property_->SetWindowBackgroundBlur(level);
89     WLOGFI("WindowEffect WindowNode Setblur X:%{public}f  Y:%{public}f!", blurRadiusX, blurRadiusY);
90     surfaceNode_->SetBackgroundFilter(RSFilter::CreateBlurFilter(blurRadiusX, blurRadiusY));
91 }
92 
SetAlpha(float alpha)93 void WindowNode::SetAlpha(float alpha)
94 {
95     property_->SetAlpha(alpha);
96     WLOGFI("WindowEffect WinodwNode SetAlpha alpha:%{public}f", alpha);
97     surfaceNode_->SetAlpha(alpha);
98 }
99 
SetBrightness(float brightness)100 void WindowNode::SetBrightness(float brightness)
101 {
102     property_->SetBrightness(brightness);
103 }
104 
SetFocusable(bool focusable)105 void WindowNode::SetFocusable(bool focusable)
106 {
107     property_->SetFocusable(focusable);
108 }
109 
SetTouchable(bool touchable)110 void WindowNode::SetTouchable(bool touchable)
111 {
112     property_->SetTouchable(touchable);
113 }
114 
SetTurnScreenOn(bool turnScreenOn)115 void WindowNode::SetTurnScreenOn(bool turnScreenOn)
116 {
117     property_->SetTurnScreenOn(turnScreenOn);
118 }
119 
SetKeepScreenOn(bool keepScreenOn)120 void WindowNode::SetKeepScreenOn(bool keepScreenOn)
121 {
122     property_->SetKeepScreenOn(keepScreenOn);
123 }
124 
SetCallingWindow(uint32_t windowId)125 void WindowNode::SetCallingWindow(uint32_t windowId)
126 {
127     property_->SetCallingWindow(windowId);
128 }
129 
GetCallingWindow() const130 uint32_t WindowNode::GetCallingWindow() const
131 {
132     return property_->GetCallingWindow();
133 }
134 
SetWindowSizeChangeReason(WindowSizeChangeReason reason)135 void WindowNode::SetWindowSizeChangeReason(WindowSizeChangeReason reason)
136 {
137     windowSizeChangeReason_ = reason;
138 }
139 
SetRequestedOrientation(Orientation orientation)140 void WindowNode::SetRequestedOrientation(Orientation orientation)
141 {
142     property_->SetRequestedOrientation(orientation);
143 }
144 
ResetWindowSizeChangeReason()145 void WindowNode::ResetWindowSizeChangeReason()
146 {
147     windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
148 }
149 
GetWindowToken() const150 const sptr<IWindow>& WindowNode::GetWindowToken() const
151 {
152     return windowToken_;
153 }
154 
GetDisplayId() const155 DisplayId WindowNode::GetDisplayId() const
156 {
157     return property_->GetDisplayId();
158 }
159 
GetWindowName() const160 const std::string& WindowNode::GetWindowName() const
161 {
162     return property_->GetWindowName();
163 }
164 
GetWindowId() const165 uint32_t WindowNode::GetWindowId() const
166 {
167     return property_->GetWindowId();
168 }
169 
GetParentId() const170 uint32_t WindowNode::GetParentId() const
171 {
172     return property_->GetParentId();
173 }
174 
GetLayoutRect() const175 const Rect& WindowNode::GetLayoutRect() const
176 {
177     return layoutRect_;
178 }
179 
GetHotZoneRect() const180 Rect WindowNode::GetHotZoneRect() const
181 {
182     return hotZoneRect_;
183 }
184 
GetWindowRect() const185 Rect WindowNode::GetWindowRect() const
186 {
187     return property_->GetWindowRect();
188 }
189 
GetWindowType() const190 WindowType WindowNode::GetWindowType() const
191 {
192     return property_->GetWindowType();
193 }
194 
GetWindowMode() const195 WindowMode WindowNode::GetWindowMode() const
196 {
197     return property_->GetWindowMode();
198 }
199 
GetWindowBackgroundBlur() const200 WindowBlurLevel WindowNode::GetWindowBackgroundBlur() const
201 {
202     return property_->GetWindowBackgroundBlur();
203 }
204 
GetAlpha() const205 float WindowNode::GetAlpha() const
206 {
207     return property_->GetAlpha();
208 }
209 
GetBrightness() const210 float WindowNode::GetBrightness() const
211 {
212     return property_->GetBrightness();
213 }
214 
IsTurnScreenOn() const215 bool WindowNode::IsTurnScreenOn() const
216 {
217     return property_->IsTurnScreenOn();
218 }
219 
IsKeepScreenOn() const220 bool WindowNode::IsKeepScreenOn() const
221 {
222     return property_->IsKeepScreenOn();
223 }
224 
GetWindowFlags() const225 uint32_t WindowNode::GetWindowFlags() const
226 {
227     return property_->GetWindowFlags();
228 }
229 
GetWindowProperty() const230 const sptr<WindowProperty>& WindowNode::GetWindowProperty() const
231 {
232     return property_;
233 }
234 
GetCallingPid() const235 int32_t WindowNode::GetCallingPid() const
236 {
237     return callingPid_;
238 }
239 
GetCallingUid() const240 int32_t WindowNode::GetCallingUid() const
241 {
242     return callingUid_;
243 }
244 
GetSystemBarProperty() const245 const std::unordered_map<WindowType, SystemBarProperty>& WindowNode::GetSystemBarProperty() const
246 {
247     return property_->GetSystemBarProperty();
248 }
249 
IsSplitMode() const250 bool WindowNode::IsSplitMode() const
251 {
252     return (property_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ||
253         property_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
254 }
255 
GetWindowSizeChangeReason() const256 WindowSizeChangeReason WindowNode::GetWindowSizeChangeReason() const
257 {
258     return windowSizeChangeReason_;
259 }
260 
GetRequestedOrientation() const261 Orientation WindowNode::GetRequestedOrientation() const
262 {
263     return property_->GetRequestedOrientation();
264 }
265 } // namespace Rosen
266 } // namespace OHOS
267