1 /*
2 * Copyright (c) 2021-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 #include "command/rs_surface_node_command.h"
17
18 #include "command/rs_command_verify_helper.h"
19 #include "common/rs_vector4.h"
20 #include "pipeline/rs_surface_render_node.h"
21 #include "pipeline/rs_display_render_node.h"
22 #include "pipeline/rs_render_node_gc.h"
23 #include "platform/common/rs_log.h"
24 #ifndef ROSEN_CROSS_PLATFORM
25 #include "surface_type.h"
26 #endif
27
28 namespace OHOS {
29 namespace Rosen {
30
Create(RSContext & context,NodeId id,RSSurfaceNodeType type,bool isTextureExportNode)31 void SurfaceNodeCommandHelper::Create(RSContext& context, NodeId id, RSSurfaceNodeType type, bool isTextureExportNode)
32 {
33 if (!context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
34 if (!RsCommandVerifyHelper::GetInstance().IsSurfaceNodeCreateCommandVaild(ExtractPid(id))) {
35 ROSEN_LOGI("SurfaceNodeCommandHelper::Create command is not vaild because there "
36 "have been too many surfaceNodes, nodeId:%{public}" PRIu64 "", id);
37 return;
38 }
39 auto node = std::shared_ptr<RSSurfaceRenderNode>(new RSSurfaceRenderNode(id,
40 context.weak_from_this(), isTextureExportNode), RSRenderNodeGC::NodeDestructor);
41 node->SetSurfaceNodeType(type);
42 auto& nodeMap = context.GetMutableNodeMap();
43 nodeMap.RegisterRenderNode(node);
44 }
45 }
46
CreateWithConfig(RSContext & context,NodeId nodeId,std::string name,uint8_t type,enum SurfaceWindowType windowType)47 void SurfaceNodeCommandHelper::CreateWithConfig(
48 RSContext& context, NodeId nodeId, std::string name, uint8_t type, enum SurfaceWindowType windowType)
49 {
50 RSSurfaceRenderNodeConfig config = {
51 .id = nodeId, .name = name,
52 .nodeType = static_cast<RSSurfaceNodeType>(type), .surfaceWindowType = windowType
53 };
54 if (!RsCommandVerifyHelper::GetInstance().IsSurfaceNodeCreateCommandVaild(ExtractPid(nodeId))) {
55 ROSEN_LOGI("SurfaceNodeCommandHelper::CreateWithConfig command is not vaild because there "
56 "have been too many surfaceNodes, nodeId:%{public}" PRIu64 "", nodeId);
57 return;
58 }
59 auto node = std::shared_ptr<RSSurfaceRenderNode>(new RSSurfaceRenderNode(config,
60 context.weak_from_this()), RSRenderNodeGC::NodeDestructor);
61 context.GetMutableNodeMap().RegisterRenderNode(node);
62 }
63
CreateWithConfigInRS(const RSSurfaceRenderNodeConfig & config,RSContext & context,bool unobscured)64 std::shared_ptr<RSSurfaceRenderNode> SurfaceNodeCommandHelper::CreateWithConfigInRS(
65 const RSSurfaceRenderNodeConfig& config, RSContext& context, bool unobscured)
66 {
67 if (!RsCommandVerifyHelper::GetInstance().IsSurfaceNodeCreateCommandVaild(ExtractPid(config.id))) {
68 ROSEN_LOGI("SurfaceNodeCommandHelper::CreateWithConfigInRS command is not vaild because there have "
69 "been too many surfaceNodes, nodeId:%{public}" PRIu64 "", config.id);
70 return nullptr;
71 }
72 auto node = std::shared_ptr<RSSurfaceRenderNode>(new RSSurfaceRenderNode(config,
73 context.weak_from_this()), RSRenderNodeGC::NodeDestructor);
74 node->SetUIExtensionUnobscured(unobscured);
75 return node;
76 }
77
SetContextMatrix(RSContext & context,NodeId id,const std::optional<Drawing::Matrix> & matrix)78 void SurfaceNodeCommandHelper::SetContextMatrix(
79 RSContext& context, NodeId id, const std::optional<Drawing::Matrix>& matrix)
80 {
81 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
82 node->SetContextMatrix(matrix, false);
83 }
84 }
85
SetContextAlpha(RSContext & context,NodeId id,float alpha)86 void SurfaceNodeCommandHelper::SetContextAlpha(RSContext& context, NodeId id, float alpha)
87 {
88 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
89 node->SetContextAlpha(alpha, false);
90 }
91 }
92
SetContextClipRegion(RSContext & context,NodeId id,const std::optional<Drawing::Rect> & clipRect)93 void SurfaceNodeCommandHelper::SetContextClipRegion(
94 RSContext& context, NodeId id, const std::optional<Drawing::Rect>& clipRect)
95 {
96 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
97 node->SetContextClipRegion(clipRect, false);
98 }
99 }
100
SetSecurityLayer(RSContext & context,NodeId id,bool isSecurityLayer)101 void SurfaceNodeCommandHelper::SetSecurityLayer(RSContext& context, NodeId id, bool isSecurityLayer)
102 {
103 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
104 node->SetSecurityLayer(isSecurityLayer);
105 }
106 }
107
SetLeashPersistentId(RSContext & context,NodeId id,LeashPersistentId leashPersistentId)108 void SurfaceNodeCommandHelper::SetLeashPersistentId(RSContext& context, NodeId id, LeashPersistentId leashPersistentId)
109 {
110 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
111 node->SetLeashPersistentId(leashPersistentId);
112 }
113 }
114
SetIsTextureExportNode(RSContext & context,NodeId id,bool isTextureExportNode)115 void SurfaceNodeCommandHelper::SetIsTextureExportNode(RSContext& context, NodeId id, bool isTextureExportNode)
116 {
117 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
118 node->SetIsTextureExportNode(isTextureExportNode);
119 }
120 }
121
SetSkipLayer(RSContext & context,NodeId id,bool isSkipLayer)122 void SurfaceNodeCommandHelper::SetSkipLayer(RSContext& context, NodeId id, bool isSkipLayer)
123 {
124 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
125 node->SetSkipLayer(isSkipLayer);
126 }
127 }
128
SetSnapshotSkipLayer(RSContext & context,NodeId id,bool isSnapshotSkipLayer)129 void SurfaceNodeCommandHelper::SetSnapshotSkipLayer(RSContext& context, NodeId id, bool isSnapshotSkipLayer)
130 {
131 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
132 node->SetSnapshotSkipLayer(isSnapshotSkipLayer);
133 }
134 }
135
SetFingerprint(RSContext & context,NodeId id,bool hasFingerprint)136 void SurfaceNodeCommandHelper::SetFingerprint(RSContext& context, NodeId id, bool hasFingerprint)
137 {
138 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
139 node->SetFingerprint(hasFingerprint);
140 }
141 }
142
SetColorSpace(RSContext & context,NodeId id,GraphicColorGamut colorSpace)143 void SurfaceNodeCommandHelper::SetColorSpace(RSContext& context, NodeId id, GraphicColorGamut colorSpace)
144 {
145 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
146 node->SetColorSpace(colorSpace);
147 }
148 }
149
UpdateSurfaceDefaultSize(RSContext & context,NodeId id,float width,float height)150 void SurfaceNodeCommandHelper::UpdateSurfaceDefaultSize(RSContext& context, NodeId id, float width, float height)
151 {
152 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
153 node->UpdateSurfaceDefaultSize(width, height);
154 }
155 }
156
ConnectToNodeInRenderService(RSContext & context,NodeId id)157 void SurfaceNodeCommandHelper::ConnectToNodeInRenderService(RSContext& context, NodeId id)
158 {
159 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
160 node->ConnectToNodeInRenderService();
161 }
162 }
163
SetCallbackForRenderThreadRefresh(RSContext & context,NodeId id,bool isRefresh)164 void SurfaceNodeCommandHelper::SetCallbackForRenderThreadRefresh(
165 RSContext& context, NodeId id, bool isRefresh)
166 {
167 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
168 if (node->NeedSetCallbackForRenderThreadRefresh()) {
169 node->SetCallbackForRenderThreadRefresh(isRefresh);
170 }
171 }
172 }
173
SetContextBounds(RSContext & context,NodeId id,Vector4f bounds)174 void SurfaceNodeCommandHelper::SetContextBounds(RSContext& context, NodeId id, Vector4f bounds)
175 {
176 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
177 node->GetMutableRenderProperties().SetBounds(bounds);
178 }
179 }
180
SetAbilityBGAlpha(RSContext & context,NodeId id,uint8_t alpha)181 void SurfaceNodeCommandHelper::SetAbilityBGAlpha(RSContext& context, NodeId id, uint8_t alpha)
182 {
183 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
184 node->SetAbilityBGAlpha(alpha);
185 }
186 }
187
SetIsNotifyUIBufferAvailable(RSContext & context,NodeId id,bool available)188 void SurfaceNodeCommandHelper::SetIsNotifyUIBufferAvailable(RSContext& context, NodeId id, bool available)
189 {
190 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
191 node->SetIsNotifyUIBufferAvailable(available);
192 }
193 }
194
MarkUIHidden(RSContext & context,NodeId id,bool isHidden)195 void SurfaceNodeCommandHelper::MarkUIHidden(RSContext& context, NodeId id, bool isHidden)
196 {
197 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
198 node->MarkUIHidden(isHidden);
199 }
200 }
201
SetSurfaceNodeType(RSContext & context,NodeId nodeId,uint8_t surfaceNodeType)202 void SurfaceNodeCommandHelper::SetSurfaceNodeType(RSContext& context, NodeId nodeId, uint8_t surfaceNodeType)
203 {
204 auto type = static_cast<RSSurfaceNodeType>(surfaceNodeType);
205 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
206 node->SetSurfaceNodeType(type);
207 }
208 }
209
SetContainerWindow(RSContext & context,NodeId nodeId,bool hasContainerWindow,RRect rrect)210 void SurfaceNodeCommandHelper::SetContainerWindow(
211 RSContext& context, NodeId nodeId, bool hasContainerWindow, RRect rrect)
212 {
213 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
214 node->SetContainerWindow(hasContainerWindow, rrect);
215 }
216 }
217
SetAnimationFinished(RSContext & context,NodeId nodeId)218 void SurfaceNodeCommandHelper::SetAnimationFinished(RSContext& context, NodeId nodeId)
219 {
220 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
221 node->SetStartAnimationFinished();
222 }
223 }
224
AttachToDisplay(RSContext & context,NodeId nodeId,uint64_t screenId)225 void SurfaceNodeCommandHelper::AttachToDisplay(RSContext& context, NodeId nodeId, uint64_t screenId)
226 {
227 const auto& nodeMap = context.GetNodeMap();
228 auto surfaceRenderNode = nodeMap.GetRenderNode<RSSurfaceRenderNode>(nodeId);
229 if (surfaceRenderNode == nullptr) {
230 return;
231 }
232 nodeMap.TraverseDisplayNodes(
233 [&surfaceRenderNode, &screenId](const std::shared_ptr<RSDisplayRenderNode>& displayRenderNode) {
234 if (displayRenderNode == nullptr || displayRenderNode->GetScreenId() != screenId ||
235 displayRenderNode->GetBootAnimation() != surfaceRenderNode->GetBootAnimation() ||
236 !displayRenderNode->IsOnTheTree()) {
237 return;
238 }
239 displayRenderNode->AddChild(surfaceRenderNode);
240 });
241 }
242
DetachToDisplay(RSContext & context,NodeId nodeId,uint64_t screenId)243 void SurfaceNodeCommandHelper::DetachToDisplay(RSContext& context, NodeId nodeId, uint64_t screenId)
244 {
245 const auto& nodeMap = context.GetNodeMap();
246 auto surfaceRenderNode = nodeMap.GetRenderNode<RSSurfaceRenderNode>(nodeId);
247 if (surfaceRenderNode == nullptr) {
248 return;
249 }
250 nodeMap.TraverseDisplayNodes(
251 [&surfaceRenderNode, &screenId](const std::shared_ptr<RSDisplayRenderNode>& displayRenderNode) {
252 if (displayRenderNode == nullptr || displayRenderNode->GetScreenId() != screenId ||
253 displayRenderNode->GetBootAnimation() != surfaceRenderNode->GetBootAnimation()) {
254 return;
255 }
256 displayRenderNode->RemoveChild(surfaceRenderNode);
257 });
258 }
259
SetBootAnimation(RSContext & context,NodeId nodeId,bool isBootAnimation)260 void SurfaceNodeCommandHelper::SetBootAnimation(RSContext& context, NodeId nodeId, bool isBootAnimation)
261 {
262 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
263 node->SetBootAnimation(isBootAnimation);
264 }
265 }
266
SetGlobalPositionEnabled(RSContext & context,NodeId nodeId,bool isEnabled)267 void SurfaceNodeCommandHelper::SetGlobalPositionEnabled(RSContext& context, NodeId nodeId, bool isEnabled)
268 {
269 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
270 node->SetGlobalPositionEnabled(isEnabled);
271 }
272 }
273
274 #ifdef USE_SURFACE_TEXTURE
CreateSurfaceExt(RSContext & context,NodeId id,const std::shared_ptr<RSSurfaceTexture> & surfaceExt)275 void SurfaceNodeCommandHelper::CreateSurfaceExt(RSContext& context, NodeId id,
276 const std::shared_ptr<RSSurfaceTexture>& surfaceExt)
277 {
278 auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id);
279 if (node != nullptr) {
280 node->SetSurfaceTexture(surfaceExt);
281 }
282 }
283 #endif
284
SetForceHardwareAndFixRotation(RSContext & context,NodeId nodeId,bool flag)285 void SurfaceNodeCommandHelper::SetForceHardwareAndFixRotation(RSContext& context, NodeId nodeId, bool flag)
286 {
287 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
288 node->SetForceHardwareAndFixRotation(flag);
289 }
290 }
291
SetForeground(RSContext & context,NodeId nodeId,bool isForeground)292 void SurfaceNodeCommandHelper::SetForeground(RSContext& context, NodeId nodeId, bool isForeground)
293 {
294 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
295 node->SetForeground(isForeground);
296 }
297 }
298
SetSurfaceId(RSContext & context,NodeId nodeId,SurfaceId surfaceId)299 void SurfaceNodeCommandHelper::SetSurfaceId(RSContext& context, NodeId nodeId, SurfaceId surfaceId)
300 {
301 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
302 node->SetSurfaceId(surfaceId);
303 }
304 }
305
SetClonedNodeId(RSContext & context,NodeId nodeId,NodeId cloneNodeId)306 void SurfaceNodeCommandHelper::SetClonedNodeId(RSContext& context, NodeId nodeId, NodeId cloneNodeId)
307 {
308 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
309 node->SetClonedNodeId(cloneNodeId);
310 }
311 }
312
SetForceUIFirst(RSContext & context,NodeId nodeId,bool forceUIFirst)313 void SurfaceNodeCommandHelper::SetForceUIFirst(RSContext& context, NodeId nodeId, bool forceUIFirst)
314 {
315 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
316 node->SetForceUIFirst(forceUIFirst);
317 }
318 }
319
SetAncoFlags(RSContext & context,NodeId nodeId,uint32_t flags)320 void SurfaceNodeCommandHelper::SetAncoFlags(RSContext& context, NodeId nodeId, uint32_t flags)
321 {
322 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
323 node->SetAncoFlags(flags);
324 }
325 }
326
SetHDRPresent(RSContext & context,NodeId nodeId,bool hdrPresent)327 void SurfaceNodeCommandHelper::SetHDRPresent(RSContext& context, NodeId nodeId, bool hdrPresent)
328 {
329 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
330 node->SetHDRPresent(hdrPresent);
331 }
332 }
333
SetSkipDraw(RSContext & context,NodeId nodeId,bool skip)334 void SurfaceNodeCommandHelper::SetSkipDraw(RSContext& context, NodeId nodeId, bool skip)
335 {
336 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
337 node->SetSkipDraw(skip);
338 }
339 }
340
SetWatermarkEnabled(RSContext & context,NodeId nodeId,const std::string & name,bool isEnabled)341 void SurfaceNodeCommandHelper::SetWatermarkEnabled(RSContext& context, NodeId nodeId,
342 const std::string& name, bool isEnabled)
343 {
344 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
345 node->SetWatermarkEnabled(name, isEnabled);
346 }
347 }
348
SetAbilityState(RSContext & context,NodeId nodeId,RSSurfaceNodeAbilityState abilityState)349 void SurfaceNodeCommandHelper::SetAbilityState(RSContext& context, NodeId nodeId,
350 RSSurfaceNodeAbilityState abilityState)
351 {
352 auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId);
353 if (!node) {
354 ROSEN_LOGE("SurfaceNodeCommandHelper::SetAbilityState node is null!");
355 return;
356 }
357 node->SetAbilityState(abilityState);
358 }
359
SetApiCompatibleVersion(RSContext & context,NodeId nodeId,uint32_t apiCompatibleVersion)360 void SurfaceNodeCommandHelper::SetApiCompatibleVersion(RSContext& context, NodeId nodeId, uint32_t apiCompatibleVersion)
361 {
362 auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId);
363 if (!node) {
364 RS_LOGE("SurfaceNodeCommandHelper::SetApiCompatibleVersion node is null!");
365 return;
366 }
367 node->SetApiCompatibleVersion(apiCompatibleVersion);
368 }
369
SetHardwareEnableHint(RSContext & context,NodeId nodeId,bool enable)370 void SurfaceNodeCommandHelper::SetHardwareEnableHint(RSContext& context, NodeId nodeId, bool enable)
371 {
372 if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
373 node->SetHardwareEnableHint(enable);
374 }
375 }
376
SetSourceVirtualDisplayId(RSContext & context,NodeId nodeId,ScreenId screenId)377 void SurfaceNodeCommandHelper::SetSourceVirtualDisplayId(RSContext& context, NodeId nodeId, ScreenId screenId)
378 {
379 if (auto surfaceRenderNode = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
380 const auto& nodeMap = context.GetNodeMap();
381 nodeMap.TraverseDisplayNodes(
382 [surfaceRenderNode, screenId](const std::shared_ptr<RSDisplayRenderNode>& displayRenderNode) {
383 if (displayRenderNode != nullptr && displayRenderNode->GetScreenId() == screenId) {
384 surfaceRenderNode->SetSourceDisplayRenderNodeId(displayRenderNode->GetId());
385 }
386 }
387 );
388 }
389 }
390
AttachToWindowContainer(RSContext & context,NodeId nodeId,ScreenId screenId)391 void SurfaceNodeCommandHelper::AttachToWindowContainer(RSContext& context, NodeId nodeId, ScreenId screenId)
392 {
393 const auto& nodeMap = context.GetNodeMap();
394 auto surfaceRenderNode = nodeMap.GetRenderNode<RSSurfaceRenderNode>(nodeId);
395 if (surfaceRenderNode == nullptr) {
396 RS_LOGE("SurfaceNodeCommandHelper::AttachToWindowContainer Invalid surfaceRenderNode");
397 return;
398 }
399 nodeMap.TraverseDisplayNodes(
400 [surfaceRenderNode, screenId](const std::shared_ptr<RSDisplayRenderNode>& displayRenderNode) {
401 if (displayRenderNode == nullptr || displayRenderNode->GetScreenId() != screenId ||
402 displayRenderNode->GetBootAnimation() != surfaceRenderNode->GetBootAnimation()) {
403 return;
404 }
405 auto windowContainer = displayRenderNode->GetWindowContainer();
406 if (windowContainer == nullptr) {
407 displayRenderNode->AddChild(surfaceRenderNode);
408 RS_LOGD("SurfaceNodeCommandHelper::AttachToWindowContainer %{public}" PRIu64 " attach to %{public}"
409 PRIu64, surfaceRenderNode->GetId(), displayRenderNode->GetId());
410 } else {
411 windowContainer->AddChild(surfaceRenderNode);
412 RS_LOGD("SurfaceNodeCommandHelper::AttachToWindowContainer %{public}" PRIu64 " attach to %{public}"
413 PRIu64, surfaceRenderNode->GetId(), windowContainer->GetId());
414 }
415 }
416 );
417 }
418
DetachFromWindowContainer(RSContext & context,NodeId nodeId,ScreenId screenId)419 void SurfaceNodeCommandHelper::DetachFromWindowContainer(RSContext& context, NodeId nodeId, ScreenId screenId)
420 {
421 const auto& nodeMap = context.GetNodeMap();
422 auto surfaceRenderNode = nodeMap.GetRenderNode<RSSurfaceRenderNode>(nodeId);
423 if (surfaceRenderNode == nullptr) {
424 RS_LOGE("SurfaceNodeCommandHelper::DetachFromWindowContainer Invalid surfaceRenderNode");
425 return;
426 }
427 nodeMap.TraverseDisplayNodes(
428 [surfaceRenderNode, screenId](const std::shared_ptr<RSDisplayRenderNode>& displayRenderNode) {
429 if (displayRenderNode == nullptr || displayRenderNode->GetScreenId() != screenId ||
430 displayRenderNode->GetBootAnimation() != surfaceRenderNode->GetBootAnimation()) {
431 return;
432 }
433 auto windowContainer = displayRenderNode->GetWindowContainer();
434 if (windowContainer == nullptr) {
435 displayRenderNode->RemoveChild(surfaceRenderNode);
436 RS_LOGD("SurfaceNodeCommandHelper::DetachFromWindowContainer %{public}" PRIu64 " detach from %{public}"
437 PRIu64, surfaceRenderNode->GetId(), displayRenderNode->GetId());
438 } else {
439 windowContainer->RemoveChild(surfaceRenderNode);
440 RS_LOGD("SurfaceNodeCommandHelper::DetachFromWindowContainer %{public}" PRIu64 " detach from %{public}"
441 PRIu64, surfaceRenderNode->GetId(), windowContainer->GetId());
442 }
443 }
444 );
445 }
446 } // namespace Rosen
447 } // namespace OHOS
448