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