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 #ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_NODE_H
17 
18 #include <atomic>
19 #include <bitset>
20 #include <cstdint>
21 #include <functional>
22 #include <list>
23 #include <memory>
24 #include <mutex>
25 #include <unordered_map>
26 #include <unordered_set>
27 #include <variant>
28 #include <vector>
29 
30 #include "animation/rs_animation_manager.h"
31 #include "animation/rs_frame_rate_range.h"
32 #include "common/rs_common_def.h"
33 #include "common/rs_macros.h"
34 #include "common/rs_rect.h"
35 #include "draw/surface.h"
36 #include "drawable/rs_drawable.h"
37 #include "drawable/rs_property_drawable.h"
38 #include "image/gpu_context.h"
39 #include "modifier/rs_render_modifier.h"
40 #include "pipeline/rs_dirty_region_manager.h"
41 #include "pipeline/rs_render_display_sync.h"
42 #include "pipeline/rs_paint_filter_canvas.h"
43 #include "pipeline/rs_render_content.h"
44 #include "pipeline/rs_single_frame_composer.h"
45 #include "property/rs_properties.h"
46 #include "drawable/rs_render_node_drawable_adapter.h"
47 
48 namespace OHOS {
49 namespace Rosen {
50 namespace DrawableV2 {
51 class RSChildrenDrawable;
52 class RSRenderNodeDrawableAdapter;
53 class RSRenderNodeShadowDrawable;
54 }
55 class RSRenderParams;
56 class RSContext;
57 class RSNodeVisitor;
58 class RSCommand;
59 namespace NativeBufferUtils {
60 class VulkanCleanupHelper;
61 }
62 struct SharedTransitionParam;
63 class RSB_EXPORT RSRenderNode : public std::enable_shared_from_this<RSRenderNode>  {
64 public:
65 
66     using WeakPtr = std::weak_ptr<RSRenderNode>;
67     using SharedPtr = std::shared_ptr<RSRenderNode>;
68     static inline constexpr RSRenderNodeType Type = RSRenderNodeType::RS_NODE;
69     std::atomic<int32_t> cacheCnt_ = -1;
GetType()70     virtual RSRenderNodeType GetType() const
71     {
72         return Type;
73     }
74 
75     explicit RSRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {}, bool isTextureExportNode = false);
76     explicit RSRenderNode(NodeId id, bool isOnTheTree, const std::weak_ptr<RSContext>& context = {},
77         bool isTextureExportNode = false);
78     RSRenderNode(const RSRenderNode&) = delete;
79     RSRenderNode(const RSRenderNode&&) = delete;
80     RSRenderNode& operator=(const RSRenderNode&) = delete;
81     RSRenderNode& operator=(const RSRenderNode&&) = delete;
82     virtual ~RSRenderNode();
83 
84     void AddChild(SharedPtr child, int index = -1);
85     void SetContainBootAnimation(bool isContainBootAnimation);
86 
87     virtual void SetBootAnimation(bool isBootAnimation);
88     virtual bool GetBootAnimation() const;
89 
90     void MoveChild(SharedPtr child, int index);
91     void RemoveChild(SharedPtr child, bool skipTransition = false);
92     void ClearChildren();
93     void RemoveFromTree(bool skipTransition = false);
94 
95     // Add/RemoveCrossParentChild only used as: the child is under multiple parents(e.g. a window cross multi-screens)
96     void AddCrossParentChild(const SharedPtr& child, int32_t index = -1);
97     void RemoveCrossParentChild(const SharedPtr& child, const WeakPtr& newParent);
98 
99     virtual void CollectSurface(const std::shared_ptr<RSRenderNode>& node,
100                                 std::vector<RSRenderNode::SharedPtr>& vec,
101                                 bool isUniRender,
102                                 bool onlyFirstLevel);
103     virtual void CollectSurfaceForUIFirstSwitch(uint32_t& leashWindowCount, uint32_t minNodeNum);
104     virtual void QuickPrepare(const std::shared_ptr<RSNodeVisitor>& visitor);
105     void PrepareSelfNodeForApplyModifiers();
106     void PrepareChildrenForApplyModifiers();
107     // if subtree dirty or child filter need prepare
108     virtual bool IsSubTreeNeedPrepare(bool filterInGlobal, bool isOccluded = false);
109     virtual void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor);
110     virtual void Process(const std::shared_ptr<RSNodeVisitor>& visitor);
111     bool SetAccumulatedClipFlag(bool clipChange);
GetAccumulatedClipFlagChange()112     bool GetAccumulatedClipFlagChange() const
113     {
114         return isAccumulatedClipFlagChanged_;
115     }
116     bool IsDirty() const;
117     bool IsSubTreeDirty() const;
118     void SetSubTreeDirty(bool val);
119     void SetParentSubTreeDirty();
120     // attention: current all base node's dirty ops causing content dirty
121     // if there is any new dirty op, check it
122     bool IsContentDirty() const;
123     void SetContentDirty();
124     void ResetIsOnlyBasicGeoTransform();
125     bool IsOnlyBasicGeoTransform() const;
126     void ForceMergeSubTreeDirtyRegion(RSDirtyRegionManager& dirtyManager, const RectI& clipRect);
127     void SubTreeSkipPrepare(RSDirtyRegionManager& dirtymanager, bool isDirty, bool accumGeoDirty,
128         const RectI& clipRect);
LastFrameSubTreeSkipped()129     inline bool LastFrameSubTreeSkipped() const
130     {
131         return lastFrameSubTreeSkipped_;
132     }
133 
GetParent()134     inline WeakPtr GetParent() const
135     {
136         return parent_;
137     }
138 
GetId()139     inline NodeId GetId() const
140     {
141         return id_;
142     }
143 
GetSubSurfaceNodes()144     inline const std::map<NodeId, std::vector<WeakPtr>>& GetSubSurfaceNodes() const
145     {
146         return subSurfaceNodes_;
147     }
148 
149     bool IsFirstLevelNode();
150     void AddSubSurfaceNode(SharedPtr parent);
151     void RemoveSubSurfaceNode(SharedPtr parent);
152     void UpdateChildSubSurfaceNode();
153     bool GetAbsMatrixReverse(const RSRenderNode& rootNode, Drawing::Matrix& absMatrix);
154     inline static const bool isSubSurfaceEnabled_ =
155         RSSystemProperties::GetSubSurfaceEnabled() && RSSystemProperties::IsPhoneType();
156 
157     // flag: isOnTheTree; instanceRootNodeId: displaynode or leash/appnode attached to
158     // firstLevelNodeId: surfacenode for uiFirst to assign task; cacheNodeId: drawing cache rootnode attached to
159     virtual void SetIsOnTheTree(bool flag, NodeId instanceRootNodeId = INVALID_NODEID,
160         NodeId firstLevelNodeId = INVALID_NODEID, NodeId cacheNodeId = INVALID_NODEID,
161         NodeId uifirstRootNodeId = INVALID_NODEID, NodeId displayNodeId = INVALID_NODEID);
SetIsOntheTreeOnlyFlag(bool flag)162     void SetIsOntheTreeOnlyFlag(bool flag)
163     {
164         SetIsOnTheTree(flag, instanceRootNodeId_, firstLevelNodeId_, drawingCacheRootId_,
165             uifirstRootNodeId_, displayNodeId_);
166     }
IsOnTheTree()167     inline bool IsOnTheTree() const
168     {
169         return isOnTheTree_;
170     }
171 
IsNewOnTree()172     inline bool IsNewOnTree() const
173     {
174         return isNewOnTree_;
175     }
176 
GetIsTextureExportNode()177     inline bool GetIsTextureExportNode() const
178     {
179         return isTextureExportNode_;
180     }
181 
GetFilterRegion()182     inline RectI GetFilterRegion() const
183     {
184         return filterRegion_;
185     }
186 
187     using ChildrenListSharedPtr = std::shared_ptr<const std::vector<std::shared_ptr<RSRenderNode>>>;
188     // return children and disappeared children, not guaranteed to be sorted by z-index
189     ChildrenListSharedPtr GetChildren() const;
190     // return children and disappeared children, sorted by z-index
191     virtual ChildrenListSharedPtr GetSortedChildren() const;
192     uint32_t GetChildrenCount() const;
193     std::shared_ptr<RSRenderNode> GetFirstChild() const;
194 
195     void DumpTree(int32_t depth, std::string& ou) const;
196 
197     virtual bool HasDisappearingTransition(bool recursive = true) const;
198 
199     void SetTunnelHandleChange(bool change);
200     bool GetTunnelHandleChange() const;
201 
202     void SetChildHasSharedTransition(bool val);
203     bool ChildHasSharedTransition() const;
204 
205     // type-safe reinterpret_cast
206     template<typename T>
IsInstanceOf()207     bool IsInstanceOf() const
208     {
209         constexpr auto targetType = static_cast<uint32_t>(T::Type);
210         return (static_cast<uint32_t>(GetType()) & targetType) == targetType;
211     }
212     template<typename T>
ReinterpretCast(std::shared_ptr<RSRenderNode> node)213     static std::shared_ptr<T> ReinterpretCast(std::shared_ptr<RSRenderNode> node)
214     {
215         return node ? node->ReinterpretCastTo<T>() : nullptr;
216     }
217     template<typename T>
ReinterpretCastTo()218     std::shared_ptr<T> ReinterpretCastTo()
219     {
220         return (IsInstanceOf<T>()) ? std::static_pointer_cast<T>(shared_from_this()) : nullptr;
221     }
222     template<typename T>
ReinterpretCastTo()223     std::shared_ptr<const T> ReinterpretCastTo() const
224     {
225         return (IsInstanceOf<T>()) ? std::static_pointer_cast<const T>(shared_from_this()) : nullptr;
226     }
227 
228     bool HasChildrenOutOfRect() const;
229     void UpdateChildrenOutOfRectFlag(bool flag);
230 
231     void ResetHasRemovedChild();
232     bool HasRemovedChild() const;
ResetChildrenRect()233     inline void ResetChildrenRect()
234     {
235         childrenRect_.Clear();
236     }
237     RectI GetChildrenRect() const;
238 
239     bool ChildHasVisibleFilter() const;
240     void SetChildHasVisibleFilter(bool val);
241     bool ChildHasVisibleEffect() const;
242     void SetChildHasVisibleEffect(bool val);
243     const std::vector<NodeId>& GetVisibleFilterChild() const;
244     void UpdateVisibleFilterChild(RSRenderNode& childNode);
245     const std::unordered_set<NodeId>& GetVisibleEffectChild() const;
246     void UpdateVisibleEffectChild(RSRenderNode& childNode);
247 
GetInstanceRootNodeId()248     inline NodeId GetInstanceRootNodeId() const
249     {
250         return instanceRootNodeId_;
251     }
252     const std::shared_ptr<RSRenderNode> GetInstanceRootNode() const;
GetFirstLevelNodeId()253     inline NodeId GetFirstLevelNodeId() const
254     {
255         return firstLevelNodeId_;
256     }
257     const std::shared_ptr<RSRenderNode> GetFirstLevelNode() const;
258 
GetPreFirstLevelNodeIdSet()259     inline const std::set<NodeId>& GetPreFirstLevelNodeIdSet()
260     {
261         return preFirstLevelNodeIdSet_;
262     }
263 
GetMutablePreFirstLevelNodeIdSet()264     inline std::set<NodeId>& GetMutablePreFirstLevelNodeIdSet()
265     {
266         return preFirstLevelNodeIdSet_;
267     }
268 
AddPreFirstLevelNodeIdSet(const std::set<NodeId> & preSet)269     inline void AddPreFirstLevelNodeIdSet(const std::set<NodeId>& preSet)
270     {
271         preFirstLevelNodeIdSet_.insert(preSet.begin(), preSet.end());
272     }
273 
274     // only use for ARKTS_CARD
GetUifirstRootNodeId()275     inline NodeId GetUifirstRootNodeId() const
276     {
277         return uifirstRootNodeId_;
278     }
279     const std::shared_ptr<RSRenderNode> GetUifirstRootNode() const;
280     void UpdateTreeUifirstRootNodeId(NodeId id);
281 
282     // reset accumulated vals before traverses children
283     void ResetChildRelevantFlags();
284     // accumulate all valid children's area
285     void UpdateChildrenRect(const RectI& subRect);
286     void UpdateCurCornerRadius(Vector4f& curCornerRadius);
287     void SetDirty(bool forceAddToActiveList = false);
288 
AddDirtyType(RSModifierType type)289     virtual void AddDirtyType(RSModifierType type)
290     {
291         dirtyTypes_.set(static_cast<int>(type), true);
292     }
293 
294     std::tuple<bool, bool, bool> Animate(int64_t timestamp, int64_t period = 0, bool isDisplaySyncEnabled = false);
295 
296     bool IsClipBound() const;
297     // clipRect has value in UniRender when calling PrepareCanvasRenderNode, else it is nullopt
298     const RectF& GetSelfDrawRect() const;
299     const RectI& GetAbsDrawRect() const;
300     void UpdateAbsDrawRect();
301 
302     void ResetChangeState();
303     bool UpdateDrawRectAndDirtyRegion(RSDirtyRegionManager& dirtyManager, bool accumGeoDirty, const RectI& clipRect,
304         const Drawing::Matrix& parentSurfaceMatrix);
305     void UpdateDirtyRegionInfoForDFX(RSDirtyRegionManager& dirtyManager);
306     void UpdateSubTreeSkipDirtyForDFX(RSDirtyRegionManager& dirtyManager, const RectI& rect);
307     // update node's local draw region (based on node itself, including childrenRect)
308     bool UpdateLocalDrawRect();
309 
310     bool Update(RSDirtyRegionManager& dirtyManager, const std::shared_ptr<RSRenderNode>& parent, bool parentDirty,
311         std::optional<RectI> clipRect = std::nullopt);
GetContextClipRegion()312     virtual std::optional<Drawing::Rect> GetContextClipRegion() const { return std::nullopt; }
313 
314     RSProperties& GetMutableRenderProperties();
GetRenderProperties()315     inline const RSProperties& GetRenderProperties() const
316     {
317         return renderContent_->GetRenderProperties();
318     }
319     void UpdateRenderStatus(RectI& dirtyRegion, bool isPartialRenderEnabled);
320     bool IsRenderUpdateIgnored() const;
321 
322     // used for animation test
323     RSAnimationManager& GetAnimationManager();
324 
325     void ApplyBoundsGeometry(RSPaintFilterCanvas& canvas);
326     void ApplyAlpha(RSPaintFilterCanvas& canvas);
327     virtual void ProcessTransitionBeforeChildren(RSPaintFilterCanvas& canvas);
328     virtual void ProcessAnimatePropertyBeforeChildren(RSPaintFilterCanvas& canvas, bool includeProperty = true) {}
329     virtual void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas);
330 
ProcessRenderContents(RSPaintFilterCanvas & canvas)331     virtual void ProcessRenderContents(RSPaintFilterCanvas& canvas) {}
332 
333     virtual void ProcessTransitionAfterChildren(RSPaintFilterCanvas& canvas);
ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas & canvas)334     virtual void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) {}
335     virtual void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas);
336 
337     void RenderTraceDebug() const;
ShouldPaint()338     inline bool ShouldPaint() const
339     {
340         return shouldPaint_;
341     }
342 
343     // dirty rect of current frame after update dirty, last frame before update
344     RectI GetOldDirty() const;
345     // dirty rect in display of current frame after update dirty, last frame before update
346     RectI GetOldDirtyInSurface() const;
347     // clip rect of last frame before post prepare, current frame after post prepare
348     RectI GetOldClipRect() const;
349 
350     bool IsDirtyRegionUpdated() const;
351     void CleanDirtyRegionUpdated();
352 
353     void AddModifier(const std::shared_ptr<RSRenderModifier>& modifier, bool isSingleFrameComposer = false);
354     void RemoveModifier(const PropertyId& id);
355     void RemoveAllModifiers();
356     std::shared_ptr<RSRenderModifier> GetModifier(const PropertyId& id);
357 
358     bool IsShadowValidLastFrame() const;
SetShadowValidLastFrame(bool isShadowValidLastFrame)359     void SetShadowValidLastFrame(bool isShadowValidLastFrame)
360     {
361         isShadowValidLastFrame_ = isShadowValidLastFrame;
362     }
363 
364     // update parent's children rect including childRect and itself
365     void MapAndUpdateChildrenRect();
366     void UpdateSubTreeInfo(const RectI& clipRect);
367     void UpdateParentChildrenRect(std::shared_ptr<RSRenderNode> parentNode) const;
368 
369     void SetStaticCached(bool isStaticCached);
370     virtual bool IsStaticCached() const;
371     void SetNodeName(const std::string& nodeName);
372     const std::string& GetNodeName() const;
373     // store prev surface subtree's must-renewed info that need prepare
374     virtual void StoreMustRenewedInfo();
375     bool HasMustRenewedInfo() const;
376     bool HasSubSurface() const;
377 
378     bool NeedInitCacheSurface() const;
379     bool NeedInitCacheCompletedSurface() const;
380     bool IsPureContainer() const;
381     bool IsContentNode() const;
382 
GetDrawCmdModifiers()383     inline const RSRenderContent::DrawCmdContainer& GetDrawCmdModifiers() const
384     {
385         return renderContent_->drawCmdModifiers_;
386     }
387 
388     using ClearCacheSurfaceFunc =
389         std::function<void(std::shared_ptr<Drawing::Surface>&&,
390         std::shared_ptr<Drawing::Surface>&&, uint32_t, uint32_t)>;
391     void InitCacheSurface(Drawing::GPUContext* grContext, ClearCacheSurfaceFunc func = nullptr,
392         uint32_t threadIndex = UNI_MAIN_THREAD_INDEX);
393 
394     Vector2f GetOptionalBufferSize() const;
395 
GetCacheSurface()396     std::shared_ptr<Drawing::Surface> GetCacheSurface() const
397     {
398         std::scoped_lock<std::recursive_mutex> lock(surfaceMutex_);
399         return cacheSurface_;
400     }
401 
SetIsTextureExportNode(bool isTextureExportNode)402     void SetIsTextureExportNode(bool isTextureExportNode)
403     {
404         isTextureExportNode_ = isTextureExportNode;
405     }
406 
407 // use for uni render visitor
408     std::shared_ptr<Drawing::Surface> GetCacheSurface(uint32_t threadIndex, bool needCheckThread,
409         bool releaseAfterGet = false);
410 
411     void UpdateCompletedCacheSurface();
412     void SetTextureValidFlag(bool isValid);
413     std::shared_ptr<Drawing::Surface> GetCompletedCacheSurface(uint32_t threadIndex = UNI_MAIN_THREAD_INDEX,
414         bool needCheckThread = true, bool releaseAfterGet = false);
415     void ClearCacheSurfaceInThread();
416     void ClearCacheSurface(bool isClearCompletedCacheSurface = true);
417     bool IsCacheCompletedSurfaceValid() const;
418     bool IsCacheSurfaceValid() const;
419 
420 #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)
421     void UpdateBackendTexture();
422 #endif
423 
424     void DrawCacheSurface(RSPaintFilterCanvas& canvas, uint32_t threadIndex = UNI_MAIN_THREAD_INDEX,
425         bool isUIFirst = false);
426 
427     void SetCacheType(CacheType cacheType);
428     CacheType GetCacheType() const;
429 
SetCacheSurfaceNeedUpdated(bool isCacheSurfaceNeedUpdate)430     void SetCacheSurfaceNeedUpdated(bool isCacheSurfaceNeedUpdate)
431     {
432         isCacheSurfaceNeedUpdate_ = isCacheSurfaceNeedUpdate;
433     }
434 
GetCacheSurfaceNeedUpdated()435     bool GetCacheSurfaceNeedUpdated() const
436     {
437         return isCacheSurfaceNeedUpdate_;
438     }
439 
440     int GetShadowRectOffsetX() const;
441     int GetShadowRectOffsetY() const;
442 
443     void SetDrawingCacheType(RSDrawingCacheType cacheType);
444     RSDrawingCacheType GetDrawingCacheType() const;
445     void ResetFilterRectsInCache(const std::unordered_set<NodeId>& curRects);
446     void GetFilterRectsInCache(std::unordered_map<NodeId, std::unordered_set<NodeId>>& allRects) const;
447     bool IsFilterRectsInCache() const;
448     void SetDrawingCacheChanged(bool cacheChanged);
449     bool GetDrawingCacheChanged() const;
450     void ResetDrawingCacheNeedUpdate();
451     void SetVisitedCacheRootIds(const std::unordered_set<NodeId>& visitedNodes);
452     const std::unordered_set<NodeId>& GetVisitedCacheRootIds() const;
453     // manage cache root nodeid
454     void SetDrawingCacheRootId(NodeId id);
455     NodeId GetDrawingCacheRootId() const;
456     // record cache geodirty for preparation optimization
457     void SetGeoUpdateDelay(bool val);
458     void ResetGeoUpdateDelay();
459     bool GetGeoUpdateDelay() const;
460 
461     bool HasAnimation() const;
GetCurFrameHasAnimation()462     bool GetCurFrameHasAnimation() const
463     {
464         return curFrameHasAnimation_;
465     }
SetCurFrameHasAnimation(bool b)466     void SetCurFrameHasAnimation(bool b)
467     {
468         curFrameHasAnimation_ = b;
469     }
470 
471     bool HasFilter() const;
472     void SetHasFilter(bool hasFilter);
GetCommandExecuted()473     bool GetCommandExecuted() const
474     {
475         return commandExecuted_;
476     }
477 
SetCommandExecuted(bool commandExecuted)478     void SetCommandExecuted(bool commandExecuted)
479     {
480         commandExecuted_ = commandExecuted;
481     }
482 
483     std::recursive_mutex& GetSurfaceMutex() const;
484 
485     bool HasHardwareNode() const;
486     void SetHasHardwareNode(bool hasHardwareNode);
487 
488     bool HasAbilityComponent() const;
489     void SetHasAbilityComponent(bool hasAbilityComponent);
490 
491     uint32_t GetCacheSurfaceThreadIndex() const;
492 
493     uint32_t GetCompletedSurfaceThreadIndex() const;
494 
495     bool IsMainThreadNode() const;
496     void SetIsMainThreadNode(bool isMainThreadNode);
497 
498     bool IsScale() const;
499     void SetIsScale(bool isScale);
500 
501     bool IsScaleInPreFrame() const;
502     void SetIsScaleInPreFrame(bool isScale);
503 
504     void SetPriority(NodePriorityType priority);
505     NodePriorityType GetPriority();
506 
507     bool IsAncestorDirty() const;
508     void SetIsAncestorDirty(bool isAncestorDirty);
509 
510     bool IsParentLeashWindow() const;
511     void SetParentLeashWindow();
512 
513     bool IsParentScbScreen() const;
514     void SetParentScbScreen();
515 
516     bool HasCachedTexture() const;
517 
518     void SetDrawRegion(const std::shared_ptr<RectF>& rect);
519     const std::shared_ptr<RectF>& GetDrawRegion() const;
520     void SetOutOfParent(OutOfParentType outOfParent);
521     OutOfParentType GetOutOfParent() const;
522 
523     void UpdateEffectRegion(std::optional<Drawing::RectI>& region, bool isForced = false);
MarkFilterHasEffectChildren()524     virtual void MarkFilterHasEffectChildren() {};
OnFilterCacheStateChanged()525     virtual void OnFilterCacheStateChanged() {};
526 
527     // for blur filter cache
528     virtual void CheckBlurFilterCacheNeedForceClearOrSave(bool rotationChanged = false,
529         bool rotationStatusChanged = false);
530     void UpdateLastFilterCacheRegion();
531     void UpdateFilterRegionInSkippedSubTree(RSDirtyRegionManager& dirtyManager,
532         const RSRenderNode& subTreeRoot, RectI& filterRect, const RectI& clipRect);
533     void MarkFilterStatusChanged(bool isForeground, bool isFilterRegionChanged);
534     void UpdateFilterCacheWithBackgroundDirty();
535     virtual void UpdateFilterCacheWithBelowDirty(RSDirtyRegionManager& dirtyManager, bool isForeground = false);
536     virtual void UpdateFilterCacheWithSelfDirty();
537     bool IsBackgroundInAppOrNodeSelfDirty() const;
538     void PostPrepareForBlurFilterNode(RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync);
539     void CheckFilterCacheAndUpdateDirtySlots(
540         std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable, RSDrawableSlot slot);
541     bool IsFilterCacheValid() const;
542     bool IsAIBarFilterCacheValid() const;
543     void MarkForceClearFilterCacheWithInvisible();
544 
545     void CheckGroupableAnimation(const PropertyId& id, bool isAnimAdd);
546     bool IsForcedDrawInGroup() const;
547     bool IsSuggestedDrawInGroup() const;
548     void CheckDrawingCacheType();
HasCacheableAnim()549     bool HasCacheableAnim() const { return hasCacheableAnim_; }
550     enum NodeGroupType : uint8_t {
551         NONE = 0,
552         GROUPED_BY_ANIM = 1,
553         GROUPED_BY_UI = GROUPED_BY_ANIM << 1,
554         GROUPED_BY_USER = GROUPED_BY_UI << 1,
555         GROUPED_BY_FOREGROUND_FILTER = GROUPED_BY_USER << 1,
556         GROUP_TYPE_BUTT = GROUPED_BY_FOREGROUND_FILTER,
557     };
558     void MarkNodeGroup(NodeGroupType type, bool isNodeGroup, bool includeProperty);
559     void MarkForegroundFilterCache();
560     NodeGroupType GetNodeGroupType();
561     bool IsNodeGroupIncludeProperty() const;
562 
563     void MarkNodeSingleFrameComposer(bool isNodeSingleFrameComposer, pid_t pid = 0);
564     virtual bool GetNodeIsSingleFrameComposer() const;
565 
566     // mark stable node
567     void OpincSetInAppStateStart(bool& unchangeMarkInApp);
568     void OpincSetInAppStateEnd(bool& unchangeMarkInApp);
569     void OpincQuickMarkStableNode(bool& unchangeMarkInApp, bool& unchangeMarkEnable, bool isAccessibilityChanged);
570     bool IsOpincUnchangeState();
571     std::string QuickGetNodeDebugInfo();
572 
573     // mark support node
574     void OpincUpdateNodeSupportFlag(bool supportFlag);
OpincGetNodeSupportFlag()575     virtual bool OpincGetNodeSupportFlag()
576     {
577         return isOpincNodeSupportFlag_;
578     }
579     bool IsMarkedRenderGroup();
580     bool OpincForcePrepareSubTree();
581 
582     // sync to drawable
583     void OpincUpdateRootFlag(bool& unchangeMarkEnable);
584     bool OpincGetRootFlag() const;
585 
586     // arkui mark
587     void MarkSuggestOpincNode(bool isOpincNode, bool isNeedCalculate);
588     bool GetSuggestOpincNode() const;
589 
590     /////////////////////////////////////////////
591 
592     void SetSharedTransitionParam(const std::shared_ptr<SharedTransitionParam>& sharedTransitionParam);
593     const std::shared_ptr<SharedTransitionParam>& GetSharedTransitionParam() const;
594 
595     void SetGlobalAlpha(float alpha);
596     float GetGlobalAlpha() const;
OnAlphaChanged()597     virtual void OnAlphaChanged() {}
598 
GetGlobalCornerRadius()599     inline const Vector4f& GetGlobalCornerRadius() noexcept
600     {
601         return globalCornerRadius_;
602     }
603 
SetGlobalCornerRadius(const Vector4f & globalCornerRadius)604     inline void SetGlobalCornerRadius(const Vector4f& globalCornerRadius) noexcept
605     {
606         globalCornerRadius_ = globalCornerRadius;
607     }
608 
609     void ActivateDisplaySync();
InActivateDisplaySync()610     inline void InActivateDisplaySync()
611     {
612         displaySync_ = nullptr;
613     }
614     void UpdateDisplaySyncRange();
615 
616     void MarkNonGeometryChanged();
617 
618     void ApplyModifier(RSModifierContext& context, std::shared_ptr<RSRenderModifier> modifier);
619     void ApplyModifiers();
620     void ApplyPositionZModifier();
621     virtual void UpdateRenderParams();
622     void UpdateDrawingCacheInfoBeforeChildren(bool isScreenRotation);
623     void UpdateDrawingCacheInfoAfterChildren();
624 
625     virtual RectI GetFilterRect() const;
626     void CalVisibleFilterRect(const std::optional<RectI>& clipRect);
627     void SetIsUsedBySubThread(bool isUsedBySubThread);
628     bool GetIsUsedBySubThread() const;
629 
630     void SetLastIsNeedAssignToSubThread(bool lastIsNeedAssignToSubThread);
631     bool GetLastIsNeedAssignToSubThread() const;
632 
GetRenderContent()633     inline const std::shared_ptr<RSRenderContent> GetRenderContent() const
634     {
635         return renderContent_;
636     }
637 
638 #ifdef RS_ENABLE_STACK_CULLING
639     void SetFullSurfaceOpaqueMarks(const std::shared_ptr<RSRenderNode> curSurfaceNodeParam);
640     void SetSubNodesCovered();
641     void ResetSubNodesCovered();
642     bool isFullSurfaceOpaquCanvasNode_ = false;
643     bool hasChildFullSurfaceOpaquCanvasNode_ = false;
644     bool isCoveredByOtherNode_ = false;
645     static const int32_t MAX_COLD_DOWN_NUM = 20;
646     int32_t coldDownCounter_ = 0;
647 #endif
648 
649     void MarkParentNeedRegenerateChildren() const;
650 
ResetChildUifirstSupportFlag()651     void ResetChildUifirstSupportFlag()
652     {
653         isChildSupportUifirst_ = true;
654     }
655 
UpdateChildUifirstSupportFlag(bool b)656     void UpdateChildUifirstSupportFlag(bool b)
657     {
658         isChildSupportUifirst_ = isChildSupportUifirst_ && b;
659     }
660 
661     virtual bool GetUifirstSupportFlag();
662 
MergeOldDirtyRect()663     virtual void MergeOldDirtyRect()
664     {
665         return;
666     }
667 
668     std::unique_ptr<RSRenderParams>& GetStagingRenderParams();
669 
670     // Deprecated! Do not use this interface.
671     // This interface has crash risks and will be deleted in later versions.
672     const std::unique_ptr<RSRenderParams>& GetRenderParams() const;
673 
674     void UpdatePointLightDirtySlot();
675     void AccmulateDirtyInOcclusion(bool isOccluded);
676     void RecordCurDirtyStatus();
677     void AccmulateDirtyStatus();
678     void ResetAccmulateDirtyStatus();
679     void RecordCurDirtyTypes();
680     void AccmulateDirtyTypes();
681     void ResetAccmulateDirtyTypes();
682     void SetUifirstSyncFlag(bool needSync);
SetUifirstSkipPartialSync(bool skip)683     void SetUifirstSkipPartialSync(bool skip)
684     {
685         uifirstSkipPartialSync_ = skip;
686     }
687 
SetForceUpdateByUifirst(bool b)688     void SetForceUpdateByUifirst(bool b)
689     {
690         forceUpdateByUifirst_ = b;
691     }
692 
GetForceUpdateByUifirst()693     bool GetForceUpdateByUifirst() const
694     {
695         return forceUpdateByUifirst_;
696     }
697 
GetLastFrameUifirstFlag()698     MultiThreadCacheType GetLastFrameUifirstFlag()
699     {
700         return lastFrameUifirstFlag_;
701     }
702 
SetLastFrameUifirstFlag(MultiThreadCacheType b)703     void SetLastFrameUifirstFlag(MultiThreadCacheType b)
704     {
705         lastFrameUifirstFlag_ = b;
706     }
707 
SkipSync()708     void SkipSync()
709     {
710         lastFrameSynced_ = false;
711         // clear flag: after skips sync, node not in RSMainThread::Instance()->GetContext.pendingSyncNodes_
712         addedToPendingSyncList_ = false;
713     }
Sync()714     void Sync()
715     {
716         OnSync();
717     }
718     void AddToPendingSyncList();
GetContext()719     const std::weak_ptr<RSContext> GetContext() const
720     {
721         return context_;
722     }
723 
724     // will be abandoned
725     void MarkUifirstNode(bool isUifirstNode);
726     // Mark uifirst leash node
727     void MarkUifirstNode(bool isForceFlag, bool isUifirstEnable);
728     bool GetUifirstNodeForceFlag() const;
729 
730     void SetOccludedStatus(bool occluded);
731     const RectI GetFilterCachedRegion() const;
EffectNodeShouldPaint()732     virtual bool EffectNodeShouldPaint() const { return true; };
FirstFrameHasEffectChildren()733     virtual bool FirstFrameHasEffectChildren() const { return false; }
MarkClearFilterCacheIfEffectChildrenChanged()734     virtual void MarkClearFilterCacheIfEffectChildrenChanged() {}
735     bool HasBlurFilter() const;
SkipFrame(uint32_t refreshRate,uint32_t skipFrameInterval)736     virtual bool SkipFrame(uint32_t refreshRate, uint32_t skipFrameInterval) { return false; }
737     void SetChildrenHasSharedTransition(bool hasSharedTransition);
738     void RemoveChildFromFulllist(NodeId nodeId);
739     void SetStartingWindowFlag(bool startingFlag);
GetStartingWindowFlag()740     bool GetStartingWindowFlag() const
741     {
742         return startingWindowFlag_;
743     }
744     void SetChildrenHasUIExtension(bool SetChildrenHasUIExtension);
ChildrenHasUIExtension()745     bool ChildrenHasUIExtension() const
746     {
747         return childrenHasUIExtension_;
748     }
749 
750     void SetHdrNum(bool flag, NodeId instanceRootNodeId);
751 
GetDisplayNodeId()752     NodeId GetDisplayNodeId() const
753     {
754         return displayNodeId_;
755     }
756 
757     // temporary used for dfx/surfaceHandler/canvas drawing render node
GetRenderDrawable()758     DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr GetRenderDrawable() const
759     {
760         return renderDrawable_;
761     }
762     void MarkBlurIntersectWithDRM(bool intersectWithDRM, bool isDark);
GetAbilityState()763     virtual RSSurfaceNodeAbilityState GetAbilityState() const { return RSSurfaceNodeAbilityState::FOREGROUND; }
GetIsFullChildrenListValid()764     bool GetIsFullChildrenListValid() const
765     {
766         return isFullChildrenListValid_;
767     }
768 
769     // recursive update subSurfaceCnt
770     void UpdateSubSurfaceCnt(int updateCnt);
771 
772     void ProcessBehindWindowOnTreeStateChanged();
773     void ProcessBehindWindowAfterApplyModifiers();
NeedDrawBehindWindow()774     virtual bool NeedDrawBehindWindow() const { return false; }
AddChildBlurBehindWindow(NodeId id)775     virtual void AddChildBlurBehindWindow(NodeId id) {}
RemoveChildBlurBehindWindow(NodeId id)776     virtual void RemoveChildBlurBehindWindow(NodeId id) {}
777 
SetAbsRotation(float degree)778     void SetAbsRotation(float degree)
779     {
780         absRotation_ = degree;
781     }
782 
GetAbsRotation()783     float GetAbsRotation() const
784     {
785         return absRotation_;
786     }
787 
788 protected:
OnApplyModifiers()789     virtual void OnApplyModifiers() {}
790     void SetOldDirtyInSurface(RectI oldDirtyInSurface);
791 
792     enum class NodeDirty {
793         CLEAN = 0,
794         DIRTY,
795     };
SetClean()796     inline void SetClean()
797     {
798         isNewOnTree_ = false;
799         isContentDirty_ = false;
800         dirtyStatus_ = NodeDirty::CLEAN;
801     }
802 
803     static void DumpNodeType(RSRenderNodeType nodeType, std::string& out);
804 
805     void DumpSubClassNode(std::string& out) const;
806     void DumpDrawCmdModifiers(std::string& out) const;
807     void DumpModifiers(std::string& out) const;
808 
809     virtual void OnTreeStateChanged();
810     void AddSubSurfaceUpdateInfo(SharedPtr curParent, SharedPtr preParent);
811 
812     static void SendCommandFromRT(std::unique_ptr<RSCommand>& command, NodeId nodeId);
813     void AddGeometryModifier(const std::shared_ptr<RSRenderModifier>& modifier);
814 
815     virtual void InitRenderParams();
816     virtual void OnSync();
ClearResource()817     virtual void ClearResource() {};
818 
819     std::unique_ptr<RSRenderParams> stagingRenderParams_;
820     mutable std::shared_ptr<DrawableV2::RSRenderNodeDrawableAdapter> renderDrawable_;
821 
822     RSPaintFilterCanvas::SaveStatus renderNodeSaveCount_;
823     std::shared_ptr<RSSingleFrameComposer> singleFrameComposer_ = nullptr;
824     bool isNodeSingleFrameComposer_ = false;
825     // if true, it means currently it's in partial render mode and this node is intersect with dirtyRegion
826     bool isRenderUpdateIgnored_ = false;
827     bool isShadowValidLastFrame_ = false;
828 
829     bool IsSelfDrawingNode() const;
830     bool isOnTheTree_ = false;
831     NodeId drawingCacheRootId_ = INVALID_NODEID;
832     bool mustRenewedInfo_ = false;
833     bool needClearSurface_ = false;
834 
835     ModifierDirtyTypes dirtyTypes_;
836     ModifierDirtyTypes curDirtyTypes_;
837     bool isBootAnimation_ = false;
838 
DrawPropertyDrawable(RSPropertyDrawableSlot slot,RSPaintFilterCanvas & canvas)839     inline void DrawPropertyDrawable(RSPropertyDrawableSlot slot, RSPaintFilterCanvas& canvas)
840     {
841         renderContent_->DrawPropertyDrawable(slot, canvas);
842     }
DrawPropertyDrawableRange(RSPropertyDrawableSlot begin,RSPropertyDrawableSlot end,RSPaintFilterCanvas & canvas)843     inline void DrawPropertyDrawableRange(
844         RSPropertyDrawableSlot begin, RSPropertyDrawableSlot end, RSPaintFilterCanvas& canvas)
845     {
846         renderContent_->DrawPropertyDrawableRange(begin, end, canvas);
847     }
848     bool isChildSupportUifirst_ = true;
849     bool childHasSharedTransition_ = false;
850     bool lastFrameSynced_ = true;
851     bool srcOrClipedAbsDrawRectChangeFlag_ = false;
852     bool startingWindowFlag_ = false;
853     bool isUifirstNode_ = true;
854     bool isForceFlag_ = false;
855     bool isUifirstEnable_ = false;
856     int isUifirstDelay_ = 0;
857     bool lastFrameHasAnimation_ = false;
858 
859     std::shared_ptr<DrawableV2::RSFilterDrawable> GetFilterDrawable(bool isForeground) const;
860     virtual void MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable,
861         RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync);
862     bool IsForceClearOrUseFilterCache(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable);
863     std::atomic<bool> isStaticCached_ = false;
864     bool lastFrameHasVisibleEffect_ = false;
865     RectI filterRegion_;
866     void UpdateDirtySlotsAndPendingNodes(RSDrawableSlot slot);
867     mutable bool isFullChildrenListValid_ = true;
868     NodeDirty dirtyStatus_ = NodeDirty::CLEAN;
869     NodeDirty curDirtyStatus_ = NodeDirty::CLEAN;
870     bool flagIntersectWithDRM_ = false;
871 private:
872     NodeId id_;
873     NodeId instanceRootNodeId_ = INVALID_NODEID;
874     NodeId firstLevelNodeId_ = INVALID_NODEID;
875     std::set<NodeId> preFirstLevelNodeIdSet_ = {};
876     NodeId uifirstRootNodeId_ = INVALID_NODEID;
877 
878     WeakPtr parent_;
879     void SetParent(WeakPtr parent);
880     void ResetParent();
881     void UpdateSrcOrClipedAbsDrawRectChangeState(const RectI& clipRect);
882     bool IsUifirstArkTsCardNode();
OnResetParent()883     virtual void OnResetParent() {}
884 
885     std::list<WeakPtr> children_;
886     std::list<std::pair<SharedPtr, uint32_t>> disappearingChildren_;
887 
888     // Note: Make sure that fullChildrenList_ is never nullptr. Otherwise, the caller using
889     // `for (auto child : *GetSortedChildren()) { ... }` will crash.
890     // When an empty list is needed, use EmptyChildrenList instead.
891     static const inline auto EmptyChildrenList = std::make_shared<const std::vector<std::shared_ptr<RSRenderNode>>>();
892     ChildrenListSharedPtr fullChildrenList_ = EmptyChildrenList ;
893     bool isChildrenSorted_ = true;
894 
895     void GenerateFullChildrenList();
896     void ResortChildren();
897     bool ShouldClearSurface();
898 
899     std::weak_ptr<RSContext> context_ = {};
900 
901     bool isContentDirty_ = false;
902     bool isNewOnTree_ = false;
903     bool isOnlyBasicGeoTransform_ = true;
904     friend class RSRenderPropertyBase;
905     friend class RSRenderTransition;
906     std::atomic<bool> isTunnelHandleChange_ = false;
907     // accumulate all children's region rect for dirty merging when any child has been removed
908     bool hasRemovedChild_ = false;
909     bool lastFrameSubTreeSkipped_ = false;
910     bool hasChildrenOutOfRect_ = false;
911     bool lastFrameHasChildrenOutOfRect_ = false;
912     bool isAccumulatedClipFlagChanged_ = false;
913     bool hasAccumulatedClipFlag_ = false;
914     RectI childrenRect_;
915     RectI oldChildrenRect_;
916     RectI oldClipRect_;
917     Drawing::Matrix oldAbsMatrix_;
918     bool childHasFilter_ = false;  // only collect children filter status
919 
920     // aim to record children rect in abs coords, without considering clip
921     RectI absChildrenRect_;
922     // aim to record current frame clipped children dirty region, in abs coords
923     RectI subTreeDirtyRegion_;
924 
925     bool childHasVisibleFilter_ = false;  // only collect visible children filter status
926     bool childHasVisibleEffect_ = false;  // only collect visible children has useeffect
927     std::vector<NodeId> visibleFilterChild_;
928     std::unordered_set<NodeId> visibleEffectChild_;
929 
930     void InternalRemoveSelfFromDisappearingChildren();
931     void FallbackAnimationsToRoot();
932     void FilterModifiersByPid(pid_t pid);
933 
934     bool UpdateBufferDirtyRegion(RectI& dirtyRect, const RectI& drawRegion);
935     void CollectAndUpdateLocalShadowRect();
936     void CollectAndUpdateLocalOutlineRect();
937     void CollectAndUpdateLocalPixelStretchRect();
938     void CollectAndUpdateLocalForegroundEffectRect();
939     void CollectAndUpdateLocalDistortionEffectRect();
940     // update drawrect based on self's info
941     void UpdateBufferDirtyRegion();
942     bool UpdateSelfDrawRect();
943     bool CheckAndUpdateGeoTrans(std::shared_ptr<RSObjAbsGeometry>& geoPtr);
944     void UpdateAbsDirtyRegion(RSDirtyRegionManager& dirtyManager, const RectI& clipRect);
945 
946     void UpdateDirtyRegion(RSDirtyRegionManager& dirtyManager, bool geoDirty, const std::optional<RectI>& clipRect);
947     void UpdateDrawRect(bool& accumGeoDirty, const RectI& clipRect, const Drawing::Matrix& parentSurfaceMatrix);
948     void UpdateFullScreenFilterCacheRect(RSDirtyRegionManager& dirtyManager, bool isForeground) const;
949 
950     void ValidateLightResources();
951     void UpdateShouldPaint(); // update node should paint state in apply modifier stage
952     bool shouldPaint_ = true;
953     bool isSubTreeDirty_ = false;
954 
955     bool isDirtyRegionUpdated_ = false;
956     bool isContainBootAnimation_ = false;
957     bool isLastVisible_ = false;
958     uint32_t disappearingTransitionCount_ = 0;
959     RectI oldDirty_;
960     RectI oldDirtyInSurface_;
961     RSAnimationManager animationManager_;
962     std::map<PropertyId, std::shared_ptr<RSRenderModifier>> modifiers_;
963     // bounds and frame modifiers must be unique
964     std::shared_ptr<RSRenderModifier> boundsModifier_;
965     std::shared_ptr<RSRenderModifier> frameModifier_;
966 
967     // opinc state
968     NodeCacheState nodeCacheState_ = NodeCacheState::STATE_INIT;
969     int unchangeCount_ = 0;
970     int unchangeCountUpper_ = 3; // 3 time is the default to cache
971     int tryCacheTimes_ = 0;
972     bool isUnchangeMarkInApp_ = false;
973     bool isUnchangeMarkEnable_ = false;
974 
975     bool isOpincNodeSupportFlag_ = true;
976     bool isSuggestOpincNode_ = false;
977     bool isNeedCalculate_ = false;
978     bool isOpincRootFlag_ = false;
979 
980     // opinc state func
981     void NodeCacheStateChange(NodeChangeType type);
982     void SetCacheStateByRetrytime();
983     void NodeCacheStateReset(NodeCacheState nodeCacheState);
984 
985     std::shared_ptr<Drawing::Image> GetCompletedImage(
986         RSPaintFilterCanvas& canvas, uint32_t threadIndex, bool isUIFirst);
987     std::shared_ptr<Drawing::Surface> cacheSurface_ = nullptr;
988     std::shared_ptr<Drawing::Surface> cacheCompletedSurface_ = nullptr;
989 #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)
990     Drawing::BackendTexture cacheBackendTexture_;
991     Drawing::BackendTexture cacheCompletedBackendTexture_;
992 #ifdef RS_ENABLE_VK
993     NativeBufferUtils::VulkanCleanupHelper* cacheCleanupHelper_ = nullptr;
994     NativeBufferUtils::VulkanCleanupHelper* cacheCompletedCleanupHelper_ = nullptr;
995 #endif
996     bool isTextureValid_ = false;
997 #endif
998     std::atomic<bool> isCacheSurfaceNeedUpdate_ = false;
999     std::string nodeName_ = "";
1000     CacheType cacheType_ = CacheType::NONE;
1001     // drawing group cache
1002     RSDrawingCacheType drawingCacheType_ = RSDrawingCacheType::DISABLED_CACHE;
1003     bool isDrawingCacheChanged_ = false;
1004     bool drawingCacheNeedUpdate_ = false;
1005     // since preparation optimization would skip child's dirtyFlag(geoDirty) update
1006     // it should be recorded and update if marked dirty again
1007     bool geoUpdateDelay_ = false;
1008 
1009     std::atomic<bool> commandExecuted_ = false;
1010     std::unordered_set<NodeId> curCacheFilterRects_ = {};
1011     std::unordered_set<NodeId> visitedCacheRoots_ = {};
1012     // collect subtree's surfaceNode including itself
1013     int subSurfaceCnt_ = 0;
1014     bool selfAddForSubSurfaceCnt_ = false;
1015     bool visitedForSubSurfaceCnt_ = false;
1016 
1017     mutable std::recursive_mutex surfaceMutex_;
1018     ClearCacheSurfaceFunc clearCacheSurfaceFunc_ = nullptr;
1019     uint32_t cacheSurfaceThreadIndex_ = UNI_MAIN_THREAD_INDEX;
1020     uint32_t completedSurfaceThreadIndex_ = UNI_MAIN_THREAD_INDEX;
1021     bool isMainThreadNode_ = true;
1022     bool isScale_ = false;
1023     bool isScaleInPreFrame_ = false;
1024     bool hasFilter_ = false;
1025     bool hasHardwareNode_ = false;
1026     bool hasAbilityComponent_ = false;
1027     bool isAncestorDirty_ = false;
1028     bool isParentLeashWindow_ = false;
1029     bool isParentScbScreen_ = false;
1030     NodePriorityType priority_ = NodePriorityType::MAIN_PRIORITY;
1031 
1032     OutOfParentType outOfParent_ = OutOfParentType::UNKNOWN;
1033     float globalAlpha_ = 1.0f;
1034     Vector4f globalCornerRadius_{ 0.f, 0.f, 0.f, 0.f };
1035 
1036     bool childrenHasSharedTransition_ = false;
1037     std::shared_ptr<SharedTransitionParam> sharedTransitionParam_;
1038 
1039     std::shared_ptr<RectF> drawRegion_ = nullptr;
1040     uint8_t nodeGroupType_ = NodeGroupType::NONE;
1041     bool nodeGroupIncludeProperty_ = false;
1042 
1043     // shadowRectOffset means offset between shadowRect and absRect of node
1044     int shadowRectOffsetX_ = 0;
1045     int shadowRectOffsetY_ = 0;
1046     // Only use in RSRenderNode::DrawCacheSurface to calculate scale factor
1047     float boundsWidth_ = 0.0f;
1048     float boundsHeight_ = 0.0f;
1049     bool hasCacheableAnim_ = false;
1050     bool geometryChangeNotPerceived_ = false;
1051     // node region, only used in selfdrawing node dirty
1052     bool isSelfDrawingNode_ = false;
1053     RectF selfDrawingNodeDirtyRect_;
1054     RectI selfDrawingNodeAbsDirtyRect_;
1055     RectI oldAbsDrawRect_;
1056     // used in old pipline
1057     RectI oldRectFromRenderProperties_;
1058     // including enlarged draw region
1059     RectF selfDrawRect_;
1060     RectI localShadowRect_;
1061     RectI localOutlineRect_;
1062     RectI localPixelStretchRect_;
1063     RectI localForegroundEffectRect_;
1064     RectI localDistortionEffectRect_;
1065     // map parentMatrix
1066     RectI absDrawRect_;
1067     pid_t appPid_ = 0;
1068 
1069     bool isTextureExportNode_ = false;
1070 
1071     std::atomic_bool isUsedBySubThread_ = false;
1072     bool lastIsNeedAssignToSubThread_ = false;
1073 
1074     std::shared_ptr<RSRenderDisplaySync> displaySync_ = nullptr;
1075 
1076     uint8_t drawableVecStatusV1_ = 0;
1077     uint8_t drawableVecStatus_ = 0;
1078     void UpdateDrawableVec();
1079     void UpdateDrawableVecInternal(std::unordered_set<RSPropertyDrawableSlot> dirtySlots);
1080     void UpdateDrawableVecV2();
1081     void UpdateDisplayList();
1082     void UpdateShadowRect();
1083     std::map<NodeId, std::vector<WeakPtr>> subSurfaceNodes_;
1084 
1085     const std::shared_ptr<RSRenderContent> renderContent_ = std::make_shared<RSRenderContent>();
1086 
1087     void OnRegister(const std::weak_ptr<RSContext>& context);
1088     // purge resource
1089     inline void SetPurgeStatus(bool flag);
1090     inline void SyncPurgeFunc();
1091 
1092     // Test pipeline
1093     bool addedToPendingSyncList_ = false;
1094     bool drawCmdListNeedSync_ = false;
1095     bool uifirstNeedSync_ = false; // both cmdlist&param
1096     bool uifirstSkipPartialSync_ = false;
1097     bool forceUpdateByUifirst_ = false;
1098     bool curFrameHasAnimation_ = false;
1099     MultiThreadCacheType lastFrameUifirstFlag_ = MultiThreadCacheType::NONE;
1100     DrawCmdIndex stagingDrawCmdIndex_;
1101     std::vector<Drawing::RecordingCanvas::DrawFunc> stagingDrawCmdList_;
1102 
1103     std::unordered_set<RSDrawableSlot> dirtySlots_;
1104     RSDrawable::Vec drawableVec_;
1105 
1106     // for blur cache
1107     RectI lastFilterRegion_;
1108     bool backgroundFilterRegionChanged_ = false;
1109     bool backgroundFilterInteractWithDirty_ = false;
1110     bool foregroundFilterRegionChanged_ = false;
1111     bool foregroundFilterInteractWithDirty_ = false;
1112     bool isOccluded_ = false;
1113 
1114     // for UIExtension info collection
1115     bool childrenHasUIExtension_ = false;
1116     const bool isPurgeable_;
1117     NodeId displayNodeId_ = INVALID_NODEID;
1118     // The angle at which the node rotates about the Z-axis
1119     float absRotation_ = 0.f;
1120 
1121     friend class DrawFuncOpItem;
1122     friend class RSAliasDrawable;
1123     friend class RSContext;
1124     friend class RSMainThread;
1125     friend class RSModifierDrawable;
1126     friend class RSProxyRenderNode;
1127     friend class RSRenderNodeMap;
1128     friend class RSRenderThread;
1129     friend class RSRenderTransition;
1130     friend class DrawableV2::RSRenderNodeDrawableAdapter;
1131     friend class DrawableV2::RSChildrenDrawable;
1132     friend class DrawableV2::RSRenderNodeShadowDrawable;
1133 #ifdef RS_PROFILER_ENABLED
1134     friend class RSProfiler;
1135 #endif
1136 };
1137 // backward compatibility
1138 using RSBaseRenderNode = RSRenderNode;
1139 
1140 struct SharedTransitionParam {
1141     SharedTransitionParam(RSRenderNode::SharedPtr inNode, RSRenderNode::SharedPtr outNode);
1142 
1143     RSRenderNode::SharedPtr GetPairedNode(const NodeId nodeId) const;
1144     bool UpdateHierarchyAndReturnIsLower(const NodeId nodeId);
IsInAppTranSitionSharedTransitionParam1145     bool IsInAppTranSition() const
1146     {
1147         return !crossApplication_;
1148     }
1149     void InternalUnregisterSelf();
1150     RSB_EXPORT std::string Dump() const;
1151     RSB_EXPORT void ResetRelation();
1152 
1153     std::weak_ptr<RSRenderNode> inNode_;
1154     std::weak_ptr<RSRenderNode> outNode_;
1155     NodeId inNodeId_;
1156     NodeId outNodeId_;
1157 
1158     RSB_EXPORT static std::map<NodeId, std::weak_ptr<SharedTransitionParam>> unpairedShareTransitions_;
1159     bool paired_ = true; // treated as paired by default, until we fail to pair them
1160 
1161 private:
1162     enum class NodeHierarchyRelation : uint8_t {
1163         UNKNOWN = -1,
1164         IN_NODE_BELOW_OUT_NODE = 0,
1165         IN_NODE_ABOVE_OUT_NODE = 1,
1166     };
1167     NodeHierarchyRelation relation_ = NodeHierarchyRelation::UNKNOWN;
1168     bool crossApplication_ = false;
1169 };
1170 } // namespace Rosen
1171 } // namespace OHOS
1172 
1173 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_NODE_H
1174