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); SetIsOntheTreeOnlyFlag(bool flag)162 void SetIsOntheTreeOnlyFlag(bool flag) 163 { 164 SetIsOnTheTree(flag, instanceRootNodeId_, firstLevelNodeId_, drawingCacheRootId_, uifirstRootNodeId_); 165 } IsOnTheTree()166 inline bool IsOnTheTree() const 167 { 168 return isOnTheTree_; 169 } 170 IsNewOnTree()171 inline bool IsNewOnTree() const 172 { 173 return isNewOnTree_; 174 } 175 GetIsTextureExportNode()176 inline bool GetIsTextureExportNode() const 177 { 178 return isTextureExportNode_; 179 } 180 GetFilterRegion()181 inline RectI GetFilterRegion() const 182 { 183 return filterRegion_; 184 } 185 186 using ChildrenListSharedPtr = std::shared_ptr<const std::vector<std::shared_ptr<RSRenderNode>>>; 187 // return children and disappeared children, not guaranteed to be sorted by z-index 188 ChildrenListSharedPtr GetChildren() const; 189 // return children and disappeared children, sorted by z-index 190 virtual ChildrenListSharedPtr GetSortedChildren() const; 191 uint32_t GetChildrenCount() const; 192 std::shared_ptr<RSRenderNode> GetFirstChild() const; 193 194 void DumpTree(int32_t depth, std::string& ou) const; 195 196 virtual bool HasDisappearingTransition(bool recursive = true) const; 197 198 void SetTunnelHandleChange(bool change); 199 bool GetTunnelHandleChange() const; 200 201 void SetChildHasSharedTransition(bool val); 202 bool ChildHasSharedTransition() const; 203 204 // type-safe reinterpret_cast 205 template<typename T> IsInstanceOf()206 bool IsInstanceOf() const 207 { 208 constexpr auto targetType = static_cast<uint32_t>(T::Type); 209 return (static_cast<uint32_t>(GetType()) & targetType) == targetType; 210 } 211 template<typename T> ReinterpretCast(std::shared_ptr<RSRenderNode> node)212 static std::shared_ptr<T> ReinterpretCast(std::shared_ptr<RSRenderNode> node) 213 { 214 return node ? node->ReinterpretCastTo<T>() : nullptr; 215 } 216 template<typename T> ReinterpretCastTo()217 std::shared_ptr<T> ReinterpretCastTo() 218 { 219 return (IsInstanceOf<T>()) ? std::static_pointer_cast<T>(shared_from_this()) : nullptr; 220 } 221 template<typename T> ReinterpretCastTo()222 std::shared_ptr<const T> ReinterpretCastTo() const 223 { 224 return (IsInstanceOf<T>()) ? std::static_pointer_cast<const T>(shared_from_this()) : nullptr; 225 } 226 227 bool HasChildrenOutOfRect() const; 228 void UpdateChildrenOutOfRectFlag(bool flag); 229 230 void ResetHasRemovedChild(); 231 bool HasRemovedChild() const; ResetChildrenRect()232 inline void ResetChildrenRect() 233 { 234 childrenRect_.Clear(); 235 } 236 RectI GetChildrenRect() const; 237 238 bool ChildHasVisibleFilter() const; 239 void SetChildHasVisibleFilter(bool val); 240 bool ChildHasVisibleEffect() const; 241 void SetChildHasVisibleEffect(bool val); 242 const std::vector<NodeId>& GetVisibleFilterChild() const; 243 void UpdateVisibleFilterChild(RSRenderNode& childNode); 244 const std::unordered_set<NodeId>& GetVisibleEffectChild() const; 245 void UpdateVisibleEffectChild(RSRenderNode& childNode); 246 GetInstanceRootNodeId()247 inline NodeId GetInstanceRootNodeId() const 248 { 249 return instanceRootNodeId_; 250 } 251 const std::shared_ptr<RSRenderNode> GetInstanceRootNode() const; GetFirstLevelNodeId()252 inline NodeId GetFirstLevelNodeId() const 253 { 254 return firstLevelNodeId_; 255 } 256 const std::shared_ptr<RSRenderNode> GetFirstLevelNode() const; 257 GetPreFirstLevelNodeIdSet()258 inline const std::set<NodeId>& GetPreFirstLevelNodeIdSet() 259 { 260 return preFirstLevelNodeIdSet_; 261 } 262 GetMutablePreFirstLevelNodeIdSet()263 inline std::set<NodeId>& GetMutablePreFirstLevelNodeIdSet() 264 { 265 return preFirstLevelNodeIdSet_; 266 } 267 AddPreFirstLevelNodeIdSet(const std::set<NodeId> & preSet)268 inline void AddPreFirstLevelNodeIdSet(const std::set<NodeId>& preSet) 269 { 270 preFirstLevelNodeIdSet_.insert(preSet.begin(), preSet.end()); 271 } 272 273 // only use for ARKTS_CARD GetUifirstRootNodeId()274 inline NodeId GetUifirstRootNodeId() const 275 { 276 return uifirstRootNodeId_; 277 } 278 const std::shared_ptr<RSRenderNode> GetUifirstRootNode() const; 279 void UpdateTreeUifirstRootNodeId(NodeId id); 280 281 // reset accumulated vals before traverses children 282 void ResetChildRelevantFlags(); 283 // accumulate all valid children's area 284 void UpdateChildrenRect(const RectI& subRect); 285 void UpdateCurCornerRadius(Vector4f& curCornerRadius); 286 void SetDirty(bool forceAddToActiveList = false); 287 AddDirtyType(RSModifierType type)288 virtual void AddDirtyType(RSModifierType type) 289 { 290 dirtyTypes_.set(static_cast<int>(type), true); 291 } 292 293 std::tuple<bool, bool, bool> Animate(int64_t timestamp, int64_t period = 0, bool isDisplaySyncEnabled = false); 294 295 bool IsClipBound() const; 296 // clipRect has value in UniRender when calling PrepareCanvasRenderNode, else it is nullopt 297 const RectF& GetSelfDrawRect() const; 298 const RectI& GetAbsDrawRect() const; 299 void UpdateAbsDrawRect(); 300 301 void ResetChangeState(); 302 bool UpdateDrawRectAndDirtyRegion(RSDirtyRegionManager& dirtyManager, bool accumGeoDirty, const RectI& clipRect, 303 const Drawing::Matrix& parentSurfaceMatrix); 304 void UpdateDirtyRegionInfoForDFX(RSDirtyRegionManager& dirtyManager); 305 void UpdateSubTreeSkipDirtyForDFX(RSDirtyRegionManager& dirtyManager, const RectI& rect); 306 // update node's local draw region (based on node itself, including childrenRect) 307 bool UpdateLocalDrawRect(); 308 309 bool Update(RSDirtyRegionManager& dirtyManager, const std::shared_ptr<RSRenderNode>& parent, bool parentDirty, 310 std::optional<RectI> clipRect = std::nullopt); GetContextClipRegion()311 virtual std::optional<Drawing::Rect> GetContextClipRegion() const { return std::nullopt; } 312 313 RSProperties& GetMutableRenderProperties(); GetRenderProperties()314 inline const RSProperties& GetRenderProperties() const 315 { 316 return renderContent_->GetRenderProperties(); 317 } 318 void UpdateRenderStatus(RectI& dirtyRegion, bool isPartialRenderEnabled); 319 bool IsRenderUpdateIgnored() const; 320 321 // used for animation test 322 RSAnimationManager& GetAnimationManager(); 323 324 void ApplyBoundsGeometry(RSPaintFilterCanvas& canvas); 325 void ApplyAlpha(RSPaintFilterCanvas& canvas); 326 virtual void ProcessTransitionBeforeChildren(RSPaintFilterCanvas& canvas); 327 virtual void ProcessAnimatePropertyBeforeChildren(RSPaintFilterCanvas& canvas, bool includeProperty = true) {} 328 virtual void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas); 329 ProcessRenderContents(RSPaintFilterCanvas & canvas)330 virtual void ProcessRenderContents(RSPaintFilterCanvas& canvas) {} 331 332 virtual void ProcessTransitionAfterChildren(RSPaintFilterCanvas& canvas); ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas & canvas)333 virtual void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) {} 334 virtual void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas); 335 336 void RenderTraceDebug() const; ShouldPaint()337 inline bool ShouldPaint() const 338 { 339 return shouldPaint_; 340 } 341 342 // dirty rect of current frame after update dirty, last frame before update 343 RectI GetOldDirty() const; 344 // dirty rect in display of current frame after update dirty, last frame before update 345 RectI GetOldDirtyInSurface() const; 346 // clip rect of last frame before post prepare, current frame after post prepare 347 RectI GetOldClipRect() const; 348 349 bool IsDirtyRegionUpdated() const; 350 void CleanDirtyRegionUpdated(); 351 352 void AddModifier(const std::shared_ptr<RSRenderModifier>& modifier, bool isSingleFrameComposer = false); 353 void RemoveModifier(const PropertyId& id); 354 void RemoveAllModifiers(); 355 std::shared_ptr<RSRenderModifier> GetModifier(const PropertyId& id); 356 357 bool IsShadowValidLastFrame() const; SetShadowValidLastFrame(bool isShadowValidLastFrame)358 void SetShadowValidLastFrame(bool isShadowValidLastFrame) 359 { 360 isShadowValidLastFrame_ = isShadowValidLastFrame; 361 } 362 363 // update parent's children rect including childRect and itself 364 void MapAndUpdateChildrenRect(); 365 void UpdateSubTreeInfo(const RectI& clipRect); 366 void UpdateParentChildrenRect(std::shared_ptr<RSRenderNode> parentNode) const; 367 368 void SetStaticCached(bool isStaticCached); 369 virtual bool IsStaticCached() const; 370 void SetNodeName(const std::string& nodeName); 371 const std::string& GetNodeName() const; 372 // store prev surface subtree's must-renewed info that need prepare 373 virtual void StoreMustRenewedInfo(); 374 bool HasMustRenewedInfo() const; 375 bool HasSubSurface() const; 376 377 bool NeedInitCacheSurface() const; 378 bool NeedInitCacheCompletedSurface() const; 379 bool IsPureContainer() const; 380 bool IsContentNode() const; 381 GetDrawCmdModifiers()382 inline const RSRenderContent::DrawCmdContainer& GetDrawCmdModifiers() const 383 { 384 return renderContent_->drawCmdModifiers_; 385 } 386 387 using ClearCacheSurfaceFunc = 388 std::function<void(std::shared_ptr<Drawing::Surface>&&, 389 std::shared_ptr<Drawing::Surface>&&, uint32_t, uint32_t)>; 390 void InitCacheSurface(Drawing::GPUContext* grContext, ClearCacheSurfaceFunc func = nullptr, 391 uint32_t threadIndex = UNI_MAIN_THREAD_INDEX); 392 393 Vector2f GetOptionalBufferSize() const; 394 GetCacheSurface()395 std::shared_ptr<Drawing::Surface> GetCacheSurface() const 396 { 397 std::scoped_lock<std::recursive_mutex> lock(surfaceMutex_); 398 return cacheSurface_; 399 } 400 SetIsTextureExportNode(bool isTextureExportNode)401 void SetIsTextureExportNode(bool isTextureExportNode) 402 { 403 isTextureExportNode_ = isTextureExportNode; 404 } 405 406 // use for uni render visitor 407 std::shared_ptr<Drawing::Surface> GetCacheSurface(uint32_t threadIndex, bool needCheckThread, 408 bool releaseAfterGet = false); 409 410 void UpdateCompletedCacheSurface(); 411 void SetTextureValidFlag(bool isValid); 412 std::shared_ptr<Drawing::Surface> GetCompletedCacheSurface(uint32_t threadIndex = UNI_MAIN_THREAD_INDEX, 413 bool needCheckThread = true, bool releaseAfterGet = false); 414 void ClearCacheSurfaceInThread(); 415 void ClearCacheSurface(bool isClearCompletedCacheSurface = true); 416 bool IsCacheCompletedSurfaceValid() const; 417 bool IsCacheSurfaceValid() const; 418 419 #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) 420 void UpdateBackendTexture(); 421 #endif 422 423 void DrawCacheSurface(RSPaintFilterCanvas& canvas, uint32_t threadIndex = UNI_MAIN_THREAD_INDEX, 424 bool isUIFirst = false); 425 426 void SetCacheType(CacheType cacheType); 427 CacheType GetCacheType() const; 428 SetCacheSurfaceNeedUpdated(bool isCacheSurfaceNeedUpdate)429 void SetCacheSurfaceNeedUpdated(bool isCacheSurfaceNeedUpdate) 430 { 431 isCacheSurfaceNeedUpdate_ = isCacheSurfaceNeedUpdate; 432 } 433 GetCacheSurfaceNeedUpdated()434 bool GetCacheSurfaceNeedUpdated() const 435 { 436 return isCacheSurfaceNeedUpdate_; 437 } 438 439 int GetShadowRectOffsetX() const; 440 int GetShadowRectOffsetY() const; 441 442 void SetDrawingCacheType(RSDrawingCacheType cacheType); 443 RSDrawingCacheType GetDrawingCacheType() const; 444 void ResetFilterRectsInCache(const std::unordered_set<NodeId>& curRects); 445 void GetFilterRectsInCache(std::unordered_map<NodeId, std::unordered_set<NodeId>>& allRects) const; 446 bool IsFilterRectsInCache() const; 447 void SetDrawingCacheChanged(bool cacheChanged); 448 bool GetDrawingCacheChanged() const; 449 void ResetDrawingCacheNeedUpdate(); 450 void SetVisitedCacheRootIds(const std::unordered_set<NodeId>& visitedNodes); 451 const std::unordered_set<NodeId>& GetVisitedCacheRootIds() const; 452 // manage cache root nodeid 453 void SetDrawingCacheRootId(NodeId id); 454 NodeId GetDrawingCacheRootId() const; 455 // record cache geodirty for preparation optimization 456 void SetGeoUpdateDelay(bool val); 457 void ResetGeoUpdateDelay(); 458 bool GetGeoUpdateDelay() const; 459 460 bool HasAnimation() const; GetCurFrameHasAnimation()461 bool GetCurFrameHasAnimation() const 462 { 463 return curFrameHasAnimation_; 464 } SetCurFrameHasAnimation(bool b)465 void SetCurFrameHasAnimation(bool b) 466 { 467 curFrameHasAnimation_ = b; 468 } 469 470 bool HasFilter() const; 471 void SetHasFilter(bool hasFilter); GetCommandExecuted()472 bool GetCommandExecuted() const 473 { 474 return commandExecuted_; 475 } 476 SetCommandExecuted(bool commandExecuted)477 void SetCommandExecuted(bool commandExecuted) 478 { 479 commandExecuted_ = commandExecuted; 480 } 481 482 std::recursive_mutex& GetSurfaceMutex() const; 483 484 bool HasHardwareNode() const; 485 void SetHasHardwareNode(bool hasHardwareNode); 486 487 bool HasAbilityComponent() const; 488 void SetHasAbilityComponent(bool hasAbilityComponent); 489 490 uint32_t GetCacheSurfaceThreadIndex() const; 491 492 uint32_t GetCompletedSurfaceThreadIndex() const; 493 494 bool IsMainThreadNode() const; 495 void SetIsMainThreadNode(bool isMainThreadNode); 496 497 bool IsScale() const; 498 void SetIsScale(bool isScale); 499 500 bool IsScaleInPreFrame() const; 501 void SetIsScaleInPreFrame(bool isScale); 502 503 void SetPriority(NodePriorityType priority); 504 NodePriorityType GetPriority(); 505 506 bool IsAncestorDirty() const; 507 void SetIsAncestorDirty(bool isAncestorDirty); 508 509 bool IsParentLeashWindow() const; 510 void SetParentLeashWindow(); 511 512 bool IsParentScbScreen() const; 513 void SetParentScbScreen(); 514 515 bool HasCachedTexture() const; 516 517 void SetDrawRegion(const std::shared_ptr<RectF>& rect); 518 const std::shared_ptr<RectF>& GetDrawRegion() const; 519 void SetOutOfParent(OutOfParentType outOfParent); 520 OutOfParentType GetOutOfParent() const; 521 522 void UpdateEffectRegion(std::optional<Drawing::RectI>& region, bool isForced = false); MarkFilterHasEffectChildren()523 virtual void MarkFilterHasEffectChildren() {}; OnFilterCacheStateChanged()524 virtual void OnFilterCacheStateChanged() {}; 525 526 // for blur filter cache 527 virtual void CheckBlurFilterCacheNeedForceClearOrSave(bool rotationChanged = false, 528 bool rotationStatusChanged = false); 529 void UpdateLastFilterCacheRegion(); 530 void UpdateFilterRegionInSkippedSubTree(RSDirtyRegionManager& dirtyManager, 531 const RSRenderNode& subTreeRoot, RectI& filterRect, const RectI& clipRect); 532 void MarkFilterStatusChanged(bool isForeground, bool isFilterRegionChanged); 533 void UpdateFilterCacheWithBackgroundDirty(); 534 virtual void UpdateFilterCacheWithBelowDirty(RSDirtyRegionManager& dirtyManager, bool isForeground = false); 535 virtual void UpdateFilterCacheWithSelfDirty(); 536 bool IsBackgroundInAppOrNodeSelfDirty() const; 537 void PostPrepareForBlurFilterNode(RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync); 538 void CheckFilterCacheAndUpdateDirtySlots( 539 std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable, RSDrawableSlot slot); 540 bool IsFilterCacheValid() const; 541 bool IsAIBarFilterCacheValid() const; 542 void MarkForceClearFilterCacheWithInvisible(); 543 544 void CheckGroupableAnimation(const PropertyId& id, bool isAnimAdd); 545 bool IsForcedDrawInGroup() const; 546 bool IsSuggestedDrawInGroup() const; 547 void CheckDrawingCacheType(); HasCacheableAnim()548 bool HasCacheableAnim() const { return hasCacheableAnim_; } 549 enum NodeGroupType : uint8_t { 550 NONE = 0, 551 GROUPED_BY_ANIM = 1, 552 GROUPED_BY_UI = GROUPED_BY_ANIM << 1, 553 GROUPED_BY_USER = GROUPED_BY_UI << 1, 554 GROUPED_BY_FOREGROUND_FILTER = GROUPED_BY_USER << 1, 555 GROUP_TYPE_BUTT = GROUPED_BY_FOREGROUND_FILTER, 556 }; 557 void MarkNodeGroup(NodeGroupType type, bool isNodeGroup, bool includeProperty); 558 void MarkForegroundFilterCache(); 559 NodeGroupType GetNodeGroupType(); 560 bool IsNodeGroupIncludeProperty() const; 561 562 void MarkNodeSingleFrameComposer(bool isNodeSingleFrameComposer, pid_t pid = 0); 563 virtual bool GetNodeIsSingleFrameComposer() const; 564 565 // mark stable node 566 void OpincSetInAppStateStart(bool& unchangeMarkInApp); 567 void OpincSetInAppStateEnd(bool& unchangeMarkInApp); 568 void OpincQuickMarkStableNode(bool& unchangeMarkInApp, bool& unchangeMarkEnable); 569 bool IsOpincUnchangeState(); 570 std::string QuickGetNodeDebugInfo(); 571 572 // mark support node 573 void OpincUpdateNodeSupportFlag(bool supportFlag); OpincGetNodeSupportFlag()574 virtual bool OpincGetNodeSupportFlag() 575 { 576 return isOpincNodeSupportFlag_; 577 } 578 bool IsMarkedRenderGroup(); 579 bool OpincForcePrepareSubTree(); 580 581 // sync to drawable 582 void OpincUpdateRootFlag(bool& unchangeMarkEnable); 583 bool OpincGetRootFlag() const; 584 585 // arkui mark 586 void MarkSuggestOpincNode(bool isOpincNode, bool isNeedCalculate); 587 bool GetSuggestOpincNode() const; 588 589 ///////////////////////////////////////////// 590 591 void SetSharedTransitionParam(const std::shared_ptr<SharedTransitionParam>& sharedTransitionParam); 592 const std::shared_ptr<SharedTransitionParam>& GetSharedTransitionParam() const; 593 594 void SetGlobalAlpha(float alpha); 595 float GetGlobalAlpha() const; OnAlphaChanged()596 virtual void OnAlphaChanged() {} 597 GetGlobalCornerRadius()598 inline const Vector4f& GetGlobalCornerRadius() noexcept 599 { 600 return globalCornerRadius_; 601 } 602 SetGlobalCornerRadius(const Vector4f & globalCornerRadius)603 inline void SetGlobalCornerRadius(const Vector4f& globalCornerRadius) noexcept 604 { 605 globalCornerRadius_ = globalCornerRadius; 606 } 607 608 void ActivateDisplaySync(); InActivateDisplaySync()609 inline void InActivateDisplaySync() 610 { 611 displaySync_ = nullptr; 612 } 613 void UpdateDisplaySyncRange(); 614 615 void MarkNonGeometryChanged(); 616 617 void ApplyModifier(RSModifierContext& context, std::shared_ptr<RSRenderModifier> modifier); 618 void ApplyModifiers(); 619 void ApplyPositionZModifier(); 620 virtual void UpdateRenderParams(); 621 void UpdateDrawingCacheInfoBeforeChildren(bool isScreenRotation); 622 void UpdateDrawingCacheInfoAfterChildren(); 623 void DisableDrawingCacheByHwcNode(); 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 // arkui mark uifirst 725 void MarkUifirstNode(bool isUifirstNode); 726 727 void SetOccludedStatus(bool occluded); 728 const RectI GetFilterCachedRegion() const; EffectNodeShouldPaint()729 virtual bool EffectNodeShouldPaint() const { return true; }; FirstFrameHasEffectChildren()730 virtual bool FirstFrameHasEffectChildren() const { return false; } MarkClearFilterCacheIfEffectChildrenChanged()731 virtual void MarkClearFilterCacheIfEffectChildrenChanged() {} 732 bool HasBlurFilter() const; SkipFrame(uint32_t refreshRate,uint32_t skipFrameInterval)733 virtual bool SkipFrame(uint32_t refreshRate, uint32_t skipFrameInterval) { return false; } 734 void SetChildrenHasSharedTransition(bool hasSharedTransition); 735 void RemoveChildFromFulllist(NodeId nodeId); 736 void SetStartingWindowFlag(bool startingFlag); GetStartingWindowFlag()737 bool GetStartingWindowFlag() const 738 { 739 return startingWindowFlag_; 740 } 741 void SetChildrenHasUIExtension(bool SetChildrenHasUIExtension); ChildrenHasUIExtension()742 bool ChildrenHasUIExtension() const 743 { 744 return childrenHasUIExtension_; 745 } 746 747 // temporary used for dfx/surfaceHandler/canvas drawing render node GetRenderDrawable()748 DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr GetRenderDrawable() const 749 { 750 return renderDrawable_; 751 } 752 void MarkBlurIntersectWithDRM(bool intersectWithDRM, bool isDark); GetAbilityState()753 virtual RSSurfaceNodeAbilityState GetAbilityState() const { return RSSurfaceNodeAbilityState::FOREGROUND; } GetIsFullChildrenListValid()754 bool GetIsFullChildrenListValid() const 755 { 756 return isFullChildrenListValid_; 757 } 758 759 protected: OnApplyModifiers()760 virtual void OnApplyModifiers() {} 761 void SetOldDirtyInSurface(RectI oldDirtyInSurface); 762 763 enum class NodeDirty { 764 CLEAN = 0, 765 DIRTY, 766 }; SetClean()767 inline void SetClean() 768 { 769 isNewOnTree_ = false; 770 isContentDirty_ = false; 771 dirtyStatus_ = NodeDirty::CLEAN; 772 } 773 774 static void DumpNodeType(RSRenderNodeType nodeType, std::string& out); 775 776 void DumpSubClassNode(std::string& out) const; 777 void DumpDrawCmdModifiers(std::string& out) const; 778 void DumpModifiers(std::string& out) const; 779 780 virtual void OnTreeStateChanged(); 781 // recursive update subSurfaceCnt 782 void UpdateSubSurfaceCnt(SharedPtr curParent, SharedPtr preParent); 783 784 static void SendCommandFromRT(std::unique_ptr<RSCommand>& command, NodeId nodeId); 785 void AddGeometryModifier(const std::shared_ptr<RSRenderModifier>& modifier); 786 787 virtual void InitRenderParams(); 788 virtual void OnSync(); ClearResource()789 virtual void ClearResource() {}; 790 791 std::unique_ptr<RSRenderParams> stagingRenderParams_; 792 mutable std::shared_ptr<DrawableV2::RSRenderNodeDrawableAdapter> renderDrawable_; 793 794 RSPaintFilterCanvas::SaveStatus renderNodeSaveCount_; 795 std::shared_ptr<RSSingleFrameComposer> singleFrameComposer_ = nullptr; 796 bool isNodeSingleFrameComposer_ = false; 797 // if true, it means currently it's in partial render mode and this node is intersect with dirtyRegion 798 bool isRenderUpdateIgnored_ = false; 799 bool isShadowValidLastFrame_ = false; 800 801 bool IsSelfDrawingNode() const; 802 bool isOnTheTree_ = false; 803 NodeId drawingCacheRootId_ = INVALID_NODEID; 804 bool mustRenewedInfo_ = false; 805 bool needClearSurface_ = false; 806 807 ModifierDirtyTypes dirtyTypes_; 808 ModifierDirtyTypes curDirtyTypes_; 809 bool isBootAnimation_ = false; 810 DrawPropertyDrawable(RSPropertyDrawableSlot slot,RSPaintFilterCanvas & canvas)811 inline void DrawPropertyDrawable(RSPropertyDrawableSlot slot, RSPaintFilterCanvas& canvas) 812 { 813 renderContent_->DrawPropertyDrawable(slot, canvas); 814 } DrawPropertyDrawableRange(RSPropertyDrawableSlot begin,RSPropertyDrawableSlot end,RSPaintFilterCanvas & canvas)815 inline void DrawPropertyDrawableRange( 816 RSPropertyDrawableSlot begin, RSPropertyDrawableSlot end, RSPaintFilterCanvas& canvas) 817 { 818 renderContent_->DrawPropertyDrawableRange(begin, end, canvas); 819 } 820 bool isChildSupportUifirst_ = true; 821 bool childHasSharedTransition_ = false; 822 bool lastFrameSynced_ = true; 823 bool srcOrClipedAbsDrawRectChangeFlag_ = false; 824 bool startingWindowFlag_ = false; 825 bool isUifirstNode_ = true; 826 int isUifirstDelay_ = 0; 827 bool lastFrameHasAnimation_ = false; 828 829 std::shared_ptr<DrawableV2::RSFilterDrawable> GetFilterDrawable(bool isForeground) const; 830 virtual void MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable, 831 RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync); 832 bool IsForceClearOrUseFilterCache(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable); 833 std::atomic<bool> isStaticCached_ = false; 834 bool lastFrameHasVisibleEffect_ = false; 835 RectI filterRegion_; 836 void UpdateDirtySlotsAndPendingNodes(RSDrawableSlot slot); 837 mutable bool isFullChildrenListValid_ = true; 838 NodeDirty dirtyStatus_ = NodeDirty::CLEAN; 839 NodeDirty curDirtyStatus_ = NodeDirty::CLEAN; 840 bool flagIntersectWithDRM_ = false; 841 private: 842 NodeId id_; 843 NodeId instanceRootNodeId_ = INVALID_NODEID; 844 NodeId firstLevelNodeId_ = INVALID_NODEID; 845 std::set<NodeId> preFirstLevelNodeIdSet_ = {}; 846 NodeId uifirstRootNodeId_ = INVALID_NODEID; 847 848 WeakPtr parent_; 849 void SetParent(WeakPtr parent); 850 void ResetParent(); 851 void UpdateSrcOrClipedAbsDrawRectChangeState(const RectI& clipRect); 852 bool IsUifirstArkTsCardNode(); OnResetParent()853 virtual void OnResetParent() {} 854 855 std::list<WeakPtr> children_; 856 std::list<std::pair<SharedPtr, uint32_t>> disappearingChildren_; 857 858 // Note: Make sure that fullChildrenList_ is never nullptr. Otherwise, the caller using 859 // `for (auto child : *GetSortedChildren()) { ... }` will crash. 860 // When an empty list is needed, use EmptyChildrenList instead. 861 static const inline auto EmptyChildrenList = std::make_shared<const std::vector<std::shared_ptr<RSRenderNode>>>(); 862 ChildrenListSharedPtr fullChildrenList_ = EmptyChildrenList ; 863 bool isChildrenSorted_ = true; 864 865 void GenerateFullChildrenList(); 866 void ResortChildren(); 867 bool ShouldClearSurface(); 868 869 std::weak_ptr<RSContext> context_ = {}; 870 871 bool isContentDirty_ = false; 872 bool isNewOnTree_ = false; 873 bool isOnlyBasicGeoTransform_ = true; 874 friend class RSRenderPropertyBase; 875 friend class RSRenderTransition; 876 std::atomic<bool> isTunnelHandleChange_ = false; 877 // accumulate all children's region rect for dirty merging when any child has been removed 878 bool hasRemovedChild_ = false; 879 bool lastFrameSubTreeSkipped_ = false; 880 bool hasChildrenOutOfRect_ = false; 881 bool lastFrameHasChildrenOutOfRect_ = false; 882 bool isAccumulatedClipFlagChanged_ = false; 883 bool hasAccumulatedClipFlag_ = false; 884 RectI childrenRect_; 885 RectI oldChildrenRect_; 886 RectI oldClipRect_; 887 Drawing::Matrix oldAbsMatrix_; 888 bool childHasFilter_ = false; // only collect children filter status 889 890 // aim to record children rect in abs coords, without considering clip 891 RectI absChildrenRect_; 892 // aim to record current frame clipped children dirty region, in abs coords 893 RectI subTreeDirtyRegion_; 894 895 bool childHasVisibleFilter_ = false; // only collect visible children filter status 896 bool childHasVisibleEffect_ = false; // only collect visible children has useeffect 897 std::vector<NodeId> visibleFilterChild_; 898 std::unordered_set<NodeId> visibleEffectChild_; 899 900 void InternalRemoveSelfFromDisappearingChildren(); 901 void FallbackAnimationsToRoot(); 902 void FilterModifiersByPid(pid_t pid); 903 904 bool UpdateBufferDirtyRegion(RectI& dirtyRect, const RectI& drawRegion); 905 void CollectAndUpdateLocalShadowRect(); 906 void CollectAndUpdateLocalOutlineRect(); 907 void CollectAndUpdateLocalPixelStretchRect(); 908 void CollectAndUpdateLocalForegroundEffectRect(); 909 void CollectAndUpdateLocalDistortionEffectRect(); 910 // update drawrect based on self's info 911 void UpdateBufferDirtyRegion(); 912 bool UpdateSelfDrawRect(); 913 bool CheckAndUpdateGeoTrans(std::shared_ptr<RSObjAbsGeometry>& geoPtr); 914 void UpdateAbsDirtyRegion(RSDirtyRegionManager& dirtyManager, const RectI& clipRect); 915 916 void UpdateDirtyRegion(RSDirtyRegionManager& dirtyManager, bool geoDirty, const std::optional<RectI>& clipRect); 917 void UpdateDrawRect(bool& accumGeoDirty, const RectI& clipRect, const Drawing::Matrix& parentSurfaceMatrix); 918 void UpdateFullScreenFilterCacheRect(RSDirtyRegionManager& dirtyManager, bool isForeground) const; 919 920 void ValidateLightResources(); 921 void UpdateShouldPaint(); // update node should paint state in apply modifier stage 922 bool shouldPaint_ = true; 923 bool isSubTreeDirty_ = false; 924 925 bool isDirtyRegionUpdated_ = false; 926 bool isContainBootAnimation_ = false; 927 bool isLastVisible_ = false; 928 uint32_t disappearingTransitionCount_ = 0; 929 RectI oldDirty_; 930 RectI oldDirtyInSurface_; 931 RSAnimationManager animationManager_; 932 std::map<PropertyId, std::shared_ptr<RSRenderModifier>> modifiers_; 933 // bounds and frame modifiers must be unique 934 std::shared_ptr<RSRenderModifier> boundsModifier_; 935 std::shared_ptr<RSRenderModifier> frameModifier_; 936 937 // opinc state 938 NodeCacheState nodeCacheState_ = NodeCacheState::STATE_INIT; 939 int unchangeCount_ = 0; 940 int unchangeCountUpper_ = 3; // 3 time is the default to cache 941 int tryCacheTimes_ = 0; 942 bool isUnchangeMarkInApp_ = false; 943 bool isUnchangeMarkEnable_ = false; 944 945 bool isOpincNodeSupportFlag_ = true; 946 bool isSuggestOpincNode_ = false; 947 bool isNeedCalculate_ = false; 948 bool isOpincRootFlag_ = false; 949 950 // opinc state func 951 void NodeCacheStateChange(NodeChangeType type); 952 void SetCacheStateByRetrytime(); 953 void NodeCacheStateReset(NodeCacheState nodeCacheState); 954 955 std::shared_ptr<Drawing::Image> GetCompletedImage( 956 RSPaintFilterCanvas& canvas, uint32_t threadIndex, bool isUIFirst); 957 std::shared_ptr<Drawing::Surface> cacheSurface_ = nullptr; 958 std::shared_ptr<Drawing::Surface> cacheCompletedSurface_ = nullptr; 959 #if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK) 960 Drawing::BackendTexture cacheBackendTexture_; 961 Drawing::BackendTexture cacheCompletedBackendTexture_; 962 #ifdef RS_ENABLE_VK 963 NativeBufferUtils::VulkanCleanupHelper* cacheCleanupHelper_ = nullptr; 964 NativeBufferUtils::VulkanCleanupHelper* cacheCompletedCleanupHelper_ = nullptr; 965 #endif 966 bool isTextureValid_ = false; 967 #endif 968 std::atomic<bool> isCacheSurfaceNeedUpdate_ = false; 969 std::string nodeName_ = ""; 970 CacheType cacheType_ = CacheType::NONE; 971 // drawing group cache 972 RSDrawingCacheType drawingCacheType_ = RSDrawingCacheType::DISABLED_CACHE; 973 bool isDrawingCacheChanged_ = false; 974 bool drawingCacheNeedUpdate_ = false; 975 // since preparation optimization would skip child's dirtyFlag(geoDirty) update 976 // it should be recorded and update if marked dirty again 977 bool geoUpdateDelay_ = false; 978 979 std::atomic<bool> commandExecuted_ = false; 980 std::unordered_set<NodeId> curCacheFilterRects_ = {}; 981 std::unordered_set<NodeId> visitedCacheRoots_ = {}; 982 // collect subtree's surfaceNode including itself 983 uint32_t subSurfaceCnt_ = 0; 984 985 mutable std::recursive_mutex surfaceMutex_; 986 ClearCacheSurfaceFunc clearCacheSurfaceFunc_ = nullptr; 987 uint32_t cacheSurfaceThreadIndex_ = UNI_MAIN_THREAD_INDEX; 988 uint32_t completedSurfaceThreadIndex_ = UNI_MAIN_THREAD_INDEX; 989 bool isMainThreadNode_ = true; 990 bool isScale_ = false; 991 bool isScaleInPreFrame_ = false; 992 bool hasFilter_ = false; 993 bool hasHardwareNode_ = false; 994 bool hasAbilityComponent_ = false; 995 bool isAncestorDirty_ = false; 996 bool isParentLeashWindow_ = false; 997 bool isParentScbScreen_ = false; 998 NodePriorityType priority_ = NodePriorityType::MAIN_PRIORITY; 999 1000 OutOfParentType outOfParent_ = OutOfParentType::UNKNOWN; 1001 float globalAlpha_ = 1.0f; 1002 Vector4f globalCornerRadius_{ 0.f, 0.f, 0.f, 0.f }; 1003 1004 bool childrenHasSharedTransition_ = false; 1005 std::shared_ptr<SharedTransitionParam> sharedTransitionParam_; 1006 1007 std::shared_ptr<RectF> drawRegion_ = nullptr; 1008 uint8_t nodeGroupType_ = NodeGroupType::NONE; 1009 bool nodeGroupIncludeProperty_ = false; 1010 1011 // shadowRectOffset means offset between shadowRect and absRect of node 1012 int shadowRectOffsetX_ = 0; 1013 int shadowRectOffsetY_ = 0; 1014 // Only use in RSRenderNode::DrawCacheSurface to calculate scale factor 1015 float boundsWidth_ = 0.0f; 1016 float boundsHeight_ = 0.0f; 1017 bool hasCacheableAnim_ = false; 1018 bool geometryChangeNotPerceived_ = false; 1019 // node region, only used in selfdrawing node dirty 1020 bool isSelfDrawingNode_ = false; 1021 RectF selfDrawingNodeDirtyRect_; 1022 RectI selfDrawingNodeAbsDirtyRect_; 1023 RectI oldAbsDrawRect_; 1024 // used in old pipline 1025 RectI oldRectFromRenderProperties_; 1026 // including enlarged draw region 1027 RectF selfDrawRect_; 1028 RectI localShadowRect_; 1029 RectI localOutlineRect_; 1030 RectI localPixelStretchRect_; 1031 RectI localForegroundEffectRect_; 1032 RectI localDistortionEffectRect_; 1033 // map parentMatrix 1034 RectI absDrawRect_; 1035 pid_t appPid_ = 0; 1036 1037 bool isTextureExportNode_ = false; 1038 1039 std::atomic_bool isUsedBySubThread_ = false; 1040 bool lastIsNeedAssignToSubThread_ = false; 1041 1042 std::shared_ptr<RSRenderDisplaySync> displaySync_ = nullptr; 1043 1044 uint8_t drawableVecStatusV1_ = 0; 1045 uint8_t drawableVecStatus_ = 0; 1046 void UpdateDrawableVec(); 1047 void UpdateDrawableVecInternal(std::unordered_set<RSPropertyDrawableSlot> dirtySlots); 1048 void UpdateDrawableVecV2(); 1049 void UpdateDisplayList(); 1050 void UpdateShadowRect(); 1051 std::map<NodeId, std::vector<WeakPtr>> subSurfaceNodes_; 1052 1053 const std::shared_ptr<RSRenderContent> renderContent_ = std::make_shared<RSRenderContent>(); 1054 1055 void OnRegister(const std::weak_ptr<RSContext>& context); 1056 // purge resource 1057 inline void SetPurgeStatus(bool flag); 1058 inline void SyncPurgeFunc(); 1059 1060 // Test pipeline 1061 bool addedToPendingSyncList_ = false; 1062 bool drawCmdListNeedSync_ = false; 1063 bool uifirstNeedSync_ = false; // both cmdlist¶m 1064 bool uifirstSkipPartialSync_ = false; 1065 bool forceUpdateByUifirst_ = false; 1066 bool curFrameHasAnimation_ = false; 1067 MultiThreadCacheType lastFrameUifirstFlag_ = MultiThreadCacheType::NONE; 1068 DrawCmdIndex stagingDrawCmdIndex_; 1069 std::vector<Drawing::RecordingCanvas::DrawFunc> stagingDrawCmdList_; 1070 1071 std::unordered_set<RSDrawableSlot> dirtySlots_; 1072 RSDrawable::Vec drawableVec_; 1073 1074 // for blur cache 1075 RectI lastFilterRegion_; 1076 bool backgroundFilterRegionChanged_ = false; 1077 bool backgroundFilterInteractWithDirty_ = false; 1078 bool foregroundFilterRegionChanged_ = false; 1079 bool foregroundFilterInteractWithDirty_ = false; 1080 bool isOccluded_ = false; 1081 1082 // for UIExtension info collection 1083 bool childrenHasUIExtension_ = false; 1084 const bool isPurgeable_; 1085 1086 friend class DrawFuncOpItem; 1087 friend class RSAliasDrawable; 1088 friend class RSContext; 1089 friend class RSMainThread; 1090 friend class RSModifierDrawable; 1091 friend class RSProxyRenderNode; 1092 friend class RSRenderNodeMap; 1093 friend class RSRenderThread; 1094 friend class RSRenderTransition; 1095 friend class DrawableV2::RSRenderNodeDrawableAdapter; 1096 friend class DrawableV2::RSChildrenDrawable; 1097 friend class DrawableV2::RSRenderNodeShadowDrawable; 1098 #ifdef RS_PROFILER_ENABLED 1099 friend class RSProfiler; 1100 #endif 1101 }; 1102 // backward compatibility 1103 using RSBaseRenderNode = RSRenderNode; 1104 1105 struct SharedTransitionParam { 1106 SharedTransitionParam(RSRenderNode::SharedPtr inNode, RSRenderNode::SharedPtr outNode); 1107 1108 RSRenderNode::SharedPtr GetPairedNode(const NodeId nodeId) const; 1109 bool UpdateHierarchyAndReturnIsLower(const NodeId nodeId); IsInAppTranSitionSharedTransitionParam1110 bool IsInAppTranSition() const 1111 { 1112 return !crossApplication_; 1113 } 1114 void InternalUnregisterSelf(); 1115 RSB_EXPORT std::string Dump() const; 1116 RSB_EXPORT void ResetRelation(); 1117 1118 std::weak_ptr<RSRenderNode> inNode_; 1119 std::weak_ptr<RSRenderNode> outNode_; 1120 NodeId inNodeId_; 1121 NodeId outNodeId_; 1122 1123 RSB_EXPORT static std::map<NodeId, std::weak_ptr<SharedTransitionParam>> unpairedShareTransitions_; 1124 bool paired_ = true; // treated as paired by default, until we fail to pair them 1125 1126 private: 1127 enum class NodeHierarchyRelation : uint8_t { 1128 UNKNOWN = -1, 1129 IN_NODE_BELOW_OUT_NODE = 0, 1130 IN_NODE_ABOVE_OUT_NODE = 1, 1131 }; 1132 NodeHierarchyRelation relation_ = NodeHierarchyRelation::UNKNOWN; 1133 bool crossApplication_ = false; 1134 }; 1135 } // namespace Rosen 1136 } // namespace OHOS 1137 1138 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_NODE_H 1139