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_SURFACE_RENDER_NODE_H 16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SURFACE_RENDER_NODE_H 17 18 #include <climits> 19 #include <functional> 20 #include <limits> 21 #include <memory> 22 #include <tuple> 23 #include <queue> 24 25 #include "surface_type.h" 26 27 #include "common/rs_macros.h" 28 #include "common/rs_occlusion_region.h" 29 #include "common/rs_special_layer_manager.h" 30 #include "common/rs_vector4.h" 31 #include "display_engine/rs_luminance_control.h" 32 #include "ipc_callbacks/buffer_available_callback.h" 33 #include "ipc_callbacks/buffer_clear_callback.h" 34 #include "memory/rs_memory_track.h" 35 #include "pipeline/rs_paint_filter_canvas.h" 36 #include "pipeline/rs_render_node.h" 37 #include "pipeline/rs_surface_handler.h" 38 #include "pipeline/rs_uni_render_judgement.h" 39 #include "platform/common/rs_surface_ext.h" 40 #include "platform/common/rs_system_properties.h" 41 #include "property/rs_properties_painter.h" 42 #include "screen_manager/screen_types.h" 43 #include "transaction/rs_occlusion_data.h" 44 45 #ifndef ROSEN_CROSS_PLATFORM 46 #include "surface_buffer.h" 47 #include "sync_fence.h" 48 #endif 49 #include "ipc_security/rs_ipc_interface_code_access_verifier_base.h" 50 51 namespace OHOS { 52 namespace Rosen { 53 class RSCommand; 54 class RSDirtyRegionManager; 55 class RSSurfaceHandler; 56 class RSB_EXPORT RSSurfaceRenderNode : public RSRenderNode { 57 public: 58 using WeakPtr = std::weak_ptr<RSSurfaceRenderNode>; 59 using SharedPtr = std::shared_ptr<RSSurfaceRenderNode>; 60 using TreeStateChangeCallback = std::function<void(RSSurfaceRenderNode&)>; 61 static inline constexpr RSRenderNodeType Type = RSRenderNodeType::SURFACE_NODE; GetType()62 RSRenderNodeType GetType() const override 63 { 64 return Type; 65 } 66 67 ~RSSurfaceRenderNode() override; 68 69 void PrepareRenderBeforeChildren(RSPaintFilterCanvas& canvas); 70 void PrepareRenderAfterChildren(RSPaintFilterCanvas& canvas); 71 72 void SetIsOnTheTree(bool onTree, NodeId instanceRootNodeId = INVALID_NODEID, 73 NodeId firstLevelNodeId = INVALID_NODEID, NodeId cacheNodeId = INVALID_NODEID, 74 NodeId uifirstRootNodeId = INVALID_NODEID, NodeId displayNodeId = INVALID_NODEID) override; IsAppWindow()75 bool IsAppWindow() const 76 { 77 return nodeType_ == RSSurfaceNodeType::APP_WINDOW_NODE; 78 } 79 IsStartingWindow()80 bool IsStartingWindow() const 81 { 82 return nodeType_ == RSSurfaceNodeType::STARTING_WINDOW_NODE; 83 } 84 85 void ResetRenderParams(); 86 GetScreenId()87 ScreenId GetScreenId() const 88 { 89 return screenId_; 90 } 91 IsAbilityComponent()92 bool IsAbilityComponent() const 93 { 94 return nodeType_ == RSSurfaceNodeType::ABILITY_COMPONENT_NODE; 95 } 96 IsLeashWindow()97 bool IsLeashWindow() const 98 { 99 return nodeType_ == RSSurfaceNodeType::LEASH_WINDOW_NODE; 100 } 101 IsRosenWeb()102 bool IsRosenWeb() const 103 { 104 return GetName().find("RosenWeb") != std::string::npos; 105 } 106 IsSubHighPriorityType()107 bool IsSubHighPriorityType() const 108 { 109 return GetName().find("hipreview") != std::string::npos; 110 } 111 IsScbScreen()112 bool IsScbScreen() const 113 { 114 return nodeType_ == RSSurfaceNodeType::SCB_SCREEN_NODE; 115 } 116 SetNodeDirty(bool isNodeDirty)117 void SetNodeDirty(bool isNodeDirty) 118 { 119 isNodeDirty_ = isNodeDirty || isNodeDirtyInLastFrame_; 120 isNodeDirtyInLastFrame_ = isNodeDirty; 121 } 122 IsNodeDirty()123 bool IsNodeDirty() const 124 { 125 return isNodeDirty_; 126 } 127 128 bool IsHardwareEnabledTopSurface() const; 129 void SetHardCursorStatus(bool status); 130 bool GetHardCursorStatus() const; 131 bool GetHardCursorLastStatus() const; 132 133 void SetLayerTop(bool isTop); 134 IsLayerTop()135 bool IsLayerTop() const 136 { 137 return isLayerTop_; 138 } 139 SetHardwareEnableHint(bool enable)140 void SetHardwareEnableHint(bool enable) 141 { 142 if (isHardwareEnableHint_ == enable) { 143 return; 144 } 145 isHardwareEnableHint_ = enable; 146 SetContentDirty(); 147 } 148 IsHardwareEnableHint()149 bool IsHardwareEnableHint() const 150 { 151 return isHardwareEnableHint_; 152 } 153 SetSourceDisplayRenderNodeId(NodeId nodeId)154 void SetSourceDisplayRenderNodeId(NodeId nodeId) 155 { 156 sourceDisplayRenderNodeId_ = nodeId; 157 } 158 GetSourceDisplayRenderNodeId()159 NodeId GetSourceDisplayRenderNodeId() const 160 { 161 return sourceDisplayRenderNodeId_; 162 } 163 164 void SetSourceDisplayRenderNodeDrawable(DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr drawable); 165 SetExistTransparentHardwareEnabledNode(bool exist)166 void SetExistTransparentHardwareEnabledNode(bool exist) 167 { 168 existTransparentHardwareEnabledNode_ = exist; 169 } 170 ExistTransparentHardwareEnabledNode()171 bool ExistTransparentHardwareEnabledNode() const 172 { 173 return existTransparentHardwareEnabledNode_; 174 } 175 176 // indicate if this node type can enable hardware composer IsHardwareEnabledType()177 bool IsHardwareEnabledType() const 178 { 179 return (nodeType_ == RSSurfaceNodeType::SELF_DRAWING_NODE && isHardwareEnabledNode_) || 180 IsLayerTop(); 181 } 182 183 void SetPreSubHighPriorityType(bool priorityType); 184 IsDynamicHardwareEnable()185 bool IsDynamicHardwareEnable() const 186 { 187 return dynamicHardwareEnable_; 188 } 189 void SetHardwareEnabled(bool isEnabled, SelfDrawingNodeType selfDrawingType = SelfDrawingNodeType::DEFAULT, 190 bool dynamicHardwareEnable = true) 191 { 192 isHardwareEnabledNode_ = isEnabled; 193 selfDrawingType_ = selfDrawingType; 194 dynamicHardwareEnable_ = dynamicHardwareEnable; 195 } 196 197 void SetForceHardwareAndFixRotation(bool flag); 198 bool GetFixRotationByUser() const; 199 bool IsInFixedRotation() const; 200 void SetInFixedRotation(bool isRotating); 201 GetSelfDrawingNodeType()202 SelfDrawingNodeType GetSelfDrawingNodeType() const 203 { 204 return selfDrawingType_; 205 } 206 NeedBilinearInterpolation()207 bool NeedBilinearInterpolation() const 208 { 209 return nodeType_ == RSSurfaceNodeType::SELF_DRAWING_NODE && isHardwareEnabledNode_; 210 } 211 SetSubNodeShouldPaint()212 void SetSubNodeShouldPaint() 213 { 214 hasSubNodeShouldPaint_ = true; 215 } 216 ResetSubNodeShouldPaint()217 void ResetSubNodeShouldPaint() 218 { 219 hasSubNodeShouldPaint_ = false; 220 } 221 HasSubNodeShouldPaint()222 bool HasSubNodeShouldPaint() const 223 { 224 return hasSubNodeShouldPaint_; 225 } 226 227 #ifndef ROSEN_CROSS_PLATFORM 228 void UpdateBufferInfo(const sptr<SurfaceBuffer>& buffer, const Rect& damageRect, 229 const sptr<SyncFence>& acquireFence, const sptr<SurfaceBuffer>& preBuffer); 230 #endif 231 IsLastFrameHardwareEnabled()232 bool IsLastFrameHardwareEnabled() const 233 { 234 return isLastFrameHardwareEnabled_; 235 } 236 IsCurrentFrameHardwareEnabled()237 bool IsCurrentFrameHardwareEnabled() const 238 { 239 return isCurrentFrameHardwareEnabled_; 240 } 241 SetCurrentFrameHardwareEnabled(bool enable)242 void SetCurrentFrameHardwareEnabled(bool enable) 243 { 244 isCurrentFrameHardwareEnabled_ = enable; 245 } 246 MarkCurrentFrameHardwareEnabled()247 void MarkCurrentFrameHardwareEnabled() 248 { 249 isCurrentFrameHardwareEnabled_ = true; 250 } 251 SetIsRotating(bool isRotating)252 void SetIsRotating(bool isRotating) 253 { 254 isRotating_ = isRotating; 255 } 256 IsRotating()257 bool IsRotating() const 258 { 259 return isRotating_; 260 } 261 ResetRotateState()262 void ResetRotateState() 263 { 264 isRotating_ = false; 265 } 266 ResetCurrentFrameHardwareEnabledState()267 void ResetCurrentFrameHardwareEnabledState() 268 { 269 isLastFrameHardwareEnabled_ = isCurrentFrameHardwareEnabled_; 270 isCurrentFrameHardwareEnabled_ = false; 271 } 272 ResetHardwareEnabledStates()273 void ResetHardwareEnabledStates() 274 { 275 isLastFrameHardwareEnabled_ = false; 276 isCurrentFrameHardwareEnabled_ = false; 277 } 278 SetHardwareForcedDisabledState(bool forcesDisabled)279 void SetHardwareForcedDisabledState(bool forcesDisabled) 280 { 281 isHardwareForcedDisabled_ = forcesDisabled; 282 } 283 SetNodeHasBackgroundColorAlpha(bool forcesDisabled)284 void SetNodeHasBackgroundColorAlpha(bool forcesDisabled) 285 { 286 isHardwareForcedByBackgroundAlpha_ = forcesDisabled; 287 } 288 IsNodeHasBackgroundColorAlpha()289 bool IsNodeHasBackgroundColorAlpha() const 290 { 291 return isHardwareForcedByBackgroundAlpha_; 292 } 293 SetHardwareDisabledByCache(bool disabledByCache)294 void SetHardwareDisabledByCache(bool disabledByCache) 295 { 296 isHardwareDisabledByCache_ = disabledByCache; 297 } 298 SetHardwareForcedDisabledStateByFilter(bool forcesDisabled)299 void SetHardwareForcedDisabledStateByFilter(bool forcesDisabled) 300 { 301 isHardwareForcedDisabledByFilter_ = forcesDisabled; 302 } 303 ResetMakeImageState()304 void ResetMakeImageState() 305 { 306 intersectWithAIBar_ = false; 307 hardwareNeedMakeImage_ = false; 308 } 309 SetHardwareNeedMakeImage(bool needMakeImage)310 void SetHardwareNeedMakeImage(bool needMakeImage) 311 { 312 hardwareNeedMakeImage_ = needMakeImage; 313 } 314 IsHardwareNeedMakeImage()315 bool IsHardwareNeedMakeImage() const 316 { 317 if (specialLayerManager_.Find(SpecialLayerType::PROTECTED)) { 318 return false; 319 } 320 return hardwareNeedMakeImage_; 321 } 322 SetIntersectWithAIBar(bool flag)323 void SetIntersectWithAIBar(bool flag) 324 { 325 intersectWithAIBar_ = flag; 326 } 327 GetIntersectWithAIBar()328 bool GetIntersectWithAIBar() const 329 { 330 return intersectWithAIBar_; 331 } 332 IsHardwareForcedDisabledByFilter()333 bool IsHardwareForcedDisabledByFilter() const 334 { 335 return isHardwareForcedDisabledByFilter_; 336 } 337 ResetHardwareForcedDisabledBySrcRect()338 void ResetHardwareForcedDisabledBySrcRect() 339 { 340 isHardwareForcedDisabledBySrcRect_ = false; 341 } 342 IsHardwareForcedDisabled()343 bool IsHardwareForcedDisabled() const 344 { 345 // a protected node not on the tree need to release buffer when producer produce buffers 346 // release buffer in ReleaseSelfDrawingNodeBuffer function 347 if ((specialLayerManager_.Find(SpecialLayerType::PROTECTED) || isHardwareEnableHint_) && IsOnTheTree()) { 348 constexpr float DRM_MIN_ALPHA = 0.1f; 349 return GetGlobalAlpha() < DRM_MIN_ALPHA; // if alpha less than 0.1, drm layer display black background. 350 } 351 return isHardwareForcedDisabled_; 352 } 353 IsLeashOrMainWindow()354 bool IsLeashOrMainWindow() const 355 { 356 return nodeType_ <= RSSurfaceNodeType::LEASH_WINDOW_NODE; 357 } 358 IsMainWindowType()359 bool IsMainWindowType() const 360 { 361 // a mainWindowType surfacenode will not mounted under another mainWindowType surfacenode 362 // including app main window, starting window, and selfdrawing window 363 return nodeType_ <= RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 364 } 365 GetIsLastFrameHwcEnabled()366 bool GetIsLastFrameHwcEnabled() const 367 { 368 return isLastFrameHwcEnabled_; 369 } 370 SetIsLastFrameHwcEnabled(bool enable)371 void SetIsLastFrameHwcEnabled(bool enable) 372 { 373 isLastFrameHwcEnabled_ = enable; 374 } 375 GetNeedCollectHwcNode()376 bool GetNeedCollectHwcNode() const 377 { 378 return needCollectHwcNode_; 379 } 380 SetNeedCollectHwcNode(bool needCollect)381 void SetNeedCollectHwcNode(bool needCollect) 382 { 383 needCollectHwcNode_ = needCollect; 384 } 385 ResetNeedCollectHwcNode()386 void ResetNeedCollectHwcNode() 387 { 388 needCollectHwcNode_ = false; 389 } 390 GetCalcRectInPrepare()391 bool GetCalcRectInPrepare() const 392 { 393 return calcRectInPrepare_; 394 } 395 SetCalcRectInPrepare(bool calc)396 void SetCalcRectInPrepare(bool calc) 397 { 398 calcRectInPrepare_ = calc; 399 } 400 IsSelfDrawingType()401 bool IsSelfDrawingType() const 402 { 403 // self drawing surfacenode has its own buffer, and rendered in its own progress/thread 404 // such as surfaceview (web/videos) and self draw windows (such as mouse pointer and boot animation) 405 return nodeType_ == RSSurfaceNodeType::SELF_DRAWING_NODE || 406 nodeType_ == RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 407 } 408 409 bool IsUIFirstSelfDrawCheck(); 410 void UpdateCacheSurfaceDirtyManager(int bufferAge = 2); 411 GetNeedSubmitSubThread()412 bool GetNeedSubmitSubThread() const 413 { 414 return isNeedSubmitSubThread_; 415 } 416 SetNeedSubmitSubThread(bool needSubmitSubThread)417 void SetNeedSubmitSubThread(bool needSubmitSubThread) 418 { 419 isNeedSubmitSubThread_ = needSubmitSubThread; 420 } 421 GetSurfaceNodeType()422 RSSurfaceNodeType GetSurfaceNodeType() const 423 { 424 return nodeType_; 425 } 426 427 void SetSurfaceNodeType(RSSurfaceNodeType nodeType); 428 429 void MarkUIHidden(bool isHidden); 430 bool IsUIHidden() const; 431 432 bool IsLeashWindowSurfaceNodeVisible(); 433 GetName()434 const std::string& GetName() const 435 { 436 return name_; 437 } 438 SetOffSetX(int32_t offset)439 void SetOffSetX(int32_t offset) 440 { 441 offsetX_ = offset; 442 } 443 GetSurfaceWindowType()444 enum SurfaceWindowType GetSurfaceWindowType() const 445 { 446 return surfaceWindowType_; 447 } 448 GetOffSetX()449 int32_t GetOffSetX() const 450 { 451 return offsetX_; 452 } 453 SetOffSetY(int32_t offset)454 void SetOffSetY(int32_t offset) 455 { 456 offsetY_ = offset; 457 } 458 GetOffSetY()459 int32_t GetOffSetY() const 460 { 461 return offsetY_; 462 } 463 SetOffset(int32_t offsetX,int32_t offsetY)464 void SetOffset(int32_t offsetX, int32_t offsetY) 465 { 466 offsetX_ = offsetX; 467 offsetY_ = offsetY; 468 } 469 GetArsrTag()470 bool GetArsrTag() const 471 { 472 return arsrTag_; 473 } 474 SetArsrTag(bool arsrTag)475 void SetArsrTag(bool arsrTag) 476 { 477 arsrTag_ = arsrTag; 478 } 479 480 void CollectSurface(const std::shared_ptr<RSBaseRenderNode>& node, std::vector<RSBaseRenderNode::SharedPtr>& vec, 481 bool isUniRender, bool onlyFirstLevel) override; 482 void CollectSelfDrawingChild(const std::shared_ptr<RSBaseRenderNode>& node, std::vector<NodeId>& vec) override; 483 void QuickPrepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 484 // keep specified nodetype preparation 485 virtual bool IsSubTreeNeedPrepare(bool filterInGloba, bool isOccluded = false) override; 486 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 487 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 488 ProcessTransitionBeforeChildren(RSPaintFilterCanvas & canvas)489 void ProcessTransitionBeforeChildren(RSPaintFilterCanvas& canvas) override {} 490 void ProcessAnimatePropertyBeforeChildren(RSPaintFilterCanvas& canvas, bool includeProperty) override; 491 void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override; 492 ProcessTransitionAfterChildren(RSPaintFilterCanvas & canvas)493 void ProcessTransitionAfterChildren(RSPaintFilterCanvas& canvas) override {} 494 void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) override; 495 void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override; 496 bool IsSCBNode() const; 497 void UpdateHwcNodeLayerInfo(GraphicTransformType transform, bool isHardCursorEnable = false); 498 void UpdateHardwareDisabledState(bool disabled); 499 void SetHwcChildrenDisabledState(); 500 501 void SetContextBounds(const Vector4f bounds); 502 bool CheckParticipateInOcclusion(); 503 504 void OnApplyModifiers() override; 505 506 void SetTotalMatrix(const Drawing::Matrix& totalMatrix); GetTotalMatrix()507 const Drawing::Matrix& GetTotalMatrix() const 508 { 509 return totalMatrix_; 510 } 511 512 // Transfer the rendering context variables (matrix, alpha, and clipRegion) from the 513 // source node (in the render thread) to the 514 // target node (in the render service). Note that: 515 // - All three variables are relative to their parent node. 516 // - Alpha can be processed as an absolute value, as its parent (surface) node's alpha should always be 1.0f. 517 // - The matrix and clipRegion should be applied according to the parent node's matrix. 518 void SetContextMatrix(const std::optional<Drawing::Matrix>& transform, bool sendMsg = true); 519 void SetContextAlpha(float alpha, bool sendMsg = true); 520 void SetContextClipRegion(const std::optional<Drawing::Rect>& clipRegion, bool sendMsg = true); 521 std::optional<Drawing::Rect> GetContextClipRegion() const override; 522 523 void SetBootAnimation(bool isBootAnimation) override; 524 bool GetBootAnimation() const override; 525 526 void SetGlobalPositionEnabled(bool isEnabled); 527 bool GetGlobalPositionEnabled() const override; 528 529 void SetSecurityLayer(bool isSecurityLayer); 530 void SetLeashPersistentId(uint64_t leashPersistentId); 531 void SetSkipLayer(bool isSkipLayer); 532 void SetSnapshotSkipLayer(bool isSnapshotSkipLayer); 533 void SetProtectedLayer(bool isProtectedLayer); 534 void SetIsOutOfScreen(bool isOutOfScreen); 535 536 // get whether it is a security/skip layer itself 537 LeashPersistentId GetLeashPersistentId() const; 538 539 // set ability state that surfaceNode belongs to as foreground or background 540 void SetAbilityState(RSSurfaceNodeAbilityState abilityState); 541 RSSurfaceNodeAbilityState GetAbilityState() const override; 542 543 // get whether it and it's subtree contain security layer 544 bool GetHasPrivacyContentLayer() const; 545 ResetSpecialLayerChangedFlag()546 void ResetSpecialLayerChangedFlag() 547 { 548 specialLayerChanged_ = false; 549 } 550 IsSpecialLayerChanged()551 bool IsSpecialLayerChanged() const 552 { 553 return specialLayerChanged_; 554 } 555 556 void UpdateSpecialLayerInfoByTypeChange(uint32_t type, bool isSpecialLayer); 557 void UpdateSpecialLayerInfoByOnTreeStateChange(); 558 void SyncPrivacyContentInfoToFirstLevelNode(); 559 void SyncColorGamutInfoToFirstLevelNode(); 560 561 void SetFingerprint(bool hasFingerprint); 562 bool GetFingerprint() const; 563 564 // [Attention] The function only used for unlocking screen for PC currently 565 void SetClonedNodeRenderDrawable(DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr clonedNodeRenderDrawable); 566 bool IsCloneNode() const; 567 void SetClonedNodeId(NodeId id); 568 void SetIsCloned(bool isCloned); 569 void SetIsClonedNodeOnTheTree(bool isOnTheTree); 570 571 void SetForceUIFirst(bool forceUIFirst); 572 bool GetForceUIFirst() const; 573 574 bool GetForceDrawWithSkipped() const; 575 void SetForceDrawWithSkipped(bool GetForceDrawWithSkipped); 576 SetUIFirstIsPurge(bool IsPurge)577 void SetUIFirstIsPurge(bool IsPurge) 578 { 579 UIFirstIsPurge_ = IsPurge; 580 } 581 GetUIFirstIsPurge()582 bool GetUIFirstIsPurge() const 583 { 584 return UIFirstIsPurge_; 585 } 586 void SetUifirstUseStarting(NodeId id); // only cache app window, first frame not wait 587 588 void SetForceUIFirstChanged(bool forceUIFirstChanged); 589 bool GetForceUIFirstChanged(); 590 591 static void SetAncoForceDoDirect(bool direct); 592 static bool GetOriAncoForceDoDirect(); 593 bool GetAncoForceDoDirect() const; 594 void SetAncoFlags(uint32_t flags); 595 uint32_t GetAncoFlags() const; 596 597 void SetHDRPresent(bool hasHdrPresent); 598 bool GetHDRPresent() const; 599 600 void IncreaseHDRNum(); 601 void ReduceHDRNum(); 602 603 const std::shared_ptr<RSDirtyRegionManager>& GetDirtyManager() const; 604 std::shared_ptr<RSDirtyRegionManager> GetCacheSurfaceDirtyManager() const; 605 SetSrcRect(const RectI & rect)606 void SetSrcRect(const RectI& rect) 607 { 608 srcRect_ = rect; 609 } 610 611 void NeedClearBufferCache(std::set<uint32_t>& bufferCacheSet); 612 613 void NeedClearPreBuffer(std::set<uint32_t>& bufferCacheSet); 614 GetSrcRect()615 const RectI& GetSrcRect() const 616 { 617 return srcRect_; 618 } 619 SetDstRect(const RectI & dstRect)620 void SetDstRect(const RectI& dstRect) 621 { 622 if (dstRect_ != dstRect) { 623 dstRectChanged_ = true; 624 } 625 dstRect_ = dstRect; 626 } 627 GetDstRect()628 const RectI& GetDstRect() const 629 { 630 return dstRect_; 631 } 632 SetDstRectWithoutRenderFit(const RectI & rect)633 void SetDstRectWithoutRenderFit(const RectI& rect) 634 { 635 dstRectWithoutRenderFit_ = Drawing::Rect(rect.left_, rect.top_, rect.GetRight(), rect.GetBottom()); 636 } 637 GetDstRectWithoutRenderFit()638 Drawing::Rect GetDstRectWithoutRenderFit() const 639 { 640 return dstRectWithoutRenderFit_; 641 } 642 GetOriginalDstRect()643 const RectI& GetOriginalDstRect() const 644 { 645 return originalDstRect_; 646 } 647 GetOriginalSrcRect()648 const RectI& GetOriginalSrcRect() const 649 { 650 return originalSrcRect_; 651 } 652 GetTransparentRegion()653 Occlusion::Region& GetTransparentRegion() 654 { 655 return transparentRegion_; 656 } 657 GetRoundedCornerRegion()658 const Occlusion::Region& GetRoundedCornerRegion() const 659 { 660 return roundedCornerRegion_; 661 } 662 GetOpaqueRegion()663 const Occlusion::Region& GetOpaqueRegion() const 664 { 665 return opaqueRegion_; 666 } 667 GetOpaqueRegion()668 Occlusion::Region& GetOpaqueRegion() 669 { 670 return opaqueRegion_; 671 } 672 GetContainerRegion()673 Occlusion::Region& GetContainerRegion() 674 { 675 return containerRegion_; 676 } 677 OnAlphaChanged()678 void OnAlphaChanged() override { 679 alphaChanged_ = true; 680 } 681 682 void SetStencilVal(int64_t stencilVal); 683 684 void SetOcclusionVisible(bool visible); 685 GetOcclusionVisible()686 bool GetOcclusionVisible() const 687 { 688 return isOcclusionVisible_; 689 } 690 SetOcclusionVisibleWithoutFilter(bool visible)691 void SetOcclusionVisibleWithoutFilter(bool visible) 692 { 693 isOcclusionVisibleWithoutFilter_ = visible; 694 } 695 SetOcclusionInSpecificScenes(bool isOcclusionInSpecificScenes)696 void SetOcclusionInSpecificScenes(bool isOcclusionInSpecificScenes) 697 { 698 isOcclusionInSpecificScenes_ = isOcclusionInSpecificScenes; 699 } 700 GetOcclusionInSpecificScenes()701 bool GetOcclusionInSpecificScenes() const 702 { 703 return isOcclusionInSpecificScenes_; 704 } 705 GetVisibleRegion()706 const Occlusion::Region& GetVisibleRegion() const 707 { 708 return visibleRegion_; 709 } 710 GetVisibleRegionInVirtual()711 const Occlusion::Region& GetVisibleRegionInVirtual() const 712 { 713 return visibleRegionInVirtual_; 714 } 715 GetVisibleRegionForCallBack()716 const Occlusion::Region& GetVisibleRegionForCallBack() const 717 { 718 return visibleRegionForCallBack_; 719 } 720 SetAbilityBGAlpha(uint8_t alpha)721 void SetAbilityBGAlpha(uint8_t alpha) 722 { 723 alphaChanged_ = (alpha == 255 && abilityBgAlpha_ != 255) || 724 (alpha != 255 && abilityBgAlpha_ == 255); 725 abilityBgAlpha_ = alpha; 726 } 727 GetAbilityBgAlpha()728 uint8_t GetAbilityBgAlpha() const 729 { 730 return abilityBgAlpha_; 731 } 732 setQosCal(bool qosPidCal)733 void setQosCal(bool qosPidCal) 734 { 735 qosPidCal_ = qosPidCal; 736 } 737 738 bool IsSurfaceInStartingWindowStage() const; 739 740 WINDOW_LAYER_INFO_TYPE GetVisibleLevelForWMS(RSVisibleLevel visibleLevel); 741 742 void SetVisibleRegionRecursive( 743 const Occlusion::Region& region, 744 VisibleData& visibleVec, 745 std::map<NodeId, RSVisibleLevel>& pidVisMap, 746 bool needSetVisibleRegion = true, 747 RSVisibleLevel visibleLevel = RSVisibleLevel::RS_UNKNOW_VISIBLE_LEVEL, 748 bool isSystemAnimatedScenes = false); 749 SetLeashWindowVisibleRegionEmpty(bool isLeashWindowVisibleRegionEmpty)750 void SetLeashWindowVisibleRegionEmpty(bool isLeashWindowVisibleRegionEmpty) 751 { 752 if (!IsLeashWindow()) { 753 return; 754 } 755 isLeashWindowVisibleRegionEmpty_ = isLeashWindowVisibleRegionEmpty; 756 SetLeashWindowVisibleRegionEmptyParam(); 757 } 758 GetLeashWindowVisibleRegionEmpty()759 bool GetLeashWindowVisibleRegionEmpty() const 760 { 761 return isLeashWindowVisibleRegionEmpty_; 762 } 763 764 void SetLeashWindowVisibleRegionEmptyParam(); 765 SetExtraDirtyRegionAfterAlignment(const Occlusion::Region & region)766 void SetExtraDirtyRegionAfterAlignment(const Occlusion::Region& region) 767 { 768 extraDirtyRegionAfterAlignment_ = region; 769 extraDirtyRegionAfterAlignmentIsEmpty_ = extraDirtyRegionAfterAlignment_.IsEmpty(); 770 } 771 GetDstRectChanged()772 bool GetDstRectChanged() const 773 { 774 return dstRectChanged_; 775 } 776 CleanDstRectChanged()777 void CleanDstRectChanged() 778 { 779 dstRectChanged_ = false; 780 } 781 GetAlphaChanged()782 bool GetAlphaChanged() const 783 { 784 return alphaChanged_; 785 } 786 CleanAlphaChanged()787 void CleanAlphaChanged() 788 { 789 alphaChanged_ = false; 790 } 791 792 void SetLocalZOrder(float localZOrder); 793 float GetLocalZOrder() const; 794 795 void SetColorSpace(GraphicColorGamut colorSpace); 796 GraphicColorGamut GetColorSpace() const; 797 // Only call this if the node is first level node. 798 GraphicColorGamut GetFirstLevelNodeColorGamut() const; 799 void SetFirstLevelNodeColorGamut(bool changeToP3); 800 801 // Only call this if the node is self-drawing surface node. 802 void UpdateColorSpaceWithMetadata(); 803 804 #ifndef ROSEN_CROSS_PLATFORM 805 void SetConsumer(const sptr<IConsumerSurface>& consumer); 806 void SetBlendType(GraphicBlendType blendType); 807 GraphicBlendType GetBlendType(); 808 #endif 809 810 void UpdateSurfaceDefaultSize(float width, float height); 811 812 void UpdateInfoForClonedNode(NodeId nodeId); 813 814 // Only SurfaceNode in RS calls "RegisterBufferAvailableListener" 815 // to save callback method sent by RT or UI which depends on the value of "isFromRenderThread". 816 void RegisterBufferAvailableListener(sptr<RSIBufferAvailableCallback> callback, bool isFromRenderThread); 817 818 void RegisterBufferClearListener(sptr<RSIBufferClearCallback> callback); 819 820 // Only SurfaceNode in RT calls "ConnectToNodeInRenderService" to send callback method to RS 821 void ConnectToNodeInRenderService(); 822 823 void NotifyRTBufferAvailable(bool isTextureExportNode = false); 824 bool IsNotifyRTBufferAvailable() const; 825 bool IsNotifyRTBufferAvailablePre() const; 826 827 void NotifyUIBufferAvailable(); 828 bool IsNotifyUIBufferAvailable() const; 829 void SetIsNotifyUIBufferAvailable(bool available); 830 831 // UI Thread would not be notified when SurfaceNode created by Video/Camera in RenderService has available buffer. 832 // And RenderThread does not call mainFunc_ if nothing in UI thread is changed 833 // which would cause callback for "clip" on parent SurfaceNode cannot be triggered 834 // for "clip" is executed in RenderThreadVisitor::ProcessSurfaceRenderNode. 835 // To fix this bug, we set callback which would call RSRenderThread::RequestNextVSync() to forcedly "refresh" 836 // RenderThread when SurfaceNode in RenderService has available buffer and execute RSIBufferAvailableCallback. 837 void SetCallbackForRenderThreadRefresh(bool isRefresh); 838 bool NeedSetCallbackForRenderThreadRefresh(); 839 ParallelVisitLock()840 void ParallelVisitLock() 841 { 842 parallelVisitMutex_.lock(); 843 } 844 ParallelVisitUnlock()845 void ParallelVisitUnlock() 846 { 847 parallelVisitMutex_.unlock(); 848 } 849 SubNodeVisible(const RectI & r)850 bool SubNodeVisible(const RectI& r) const 851 { 852 Occlusion::Rect nodeRect { r.left_, r.top_, r.GetRight(), r.GetBottom() }; 853 // if current node is in occluded region of the surface, it could be skipped in process step 854 return visibleRegion_.IsIntersectWith(nodeRect); 855 } 856 857 bool CheckIfOcclusionReusable(std::queue<NodeId>& surfaceNodesIds) const; 858 bool CheckIfOcclusionChanged() const; 859 SetVisibleRegion(const Occlusion::Region & region)860 void SetVisibleRegion(const Occlusion::Region& region) 861 { 862 visibleRegion_ = region; 863 } 864 SetVisibleRegionInVirtual(const Occlusion::Region & region)865 void SetVisibleRegionInVirtual(const Occlusion::Region& region) 866 { 867 visibleRegionInVirtual_ = region; 868 } 869 IsEmptyAppWindow()870 inline bool IsEmptyAppWindow() const 871 { 872 return IsAppWindow() && (GetChildrenCount() == 0 || HasOnlyOneRootNode()); 873 } 874 IsTransparent()875 inline bool IsTransparent() const 876 { 877 const uint8_t opacity = 255; 878 return !(GetAbilityBgAlpha() == opacity && ROSEN_EQ(GetGlobalAlpha(), 1.0f)) || 879 (IsEmptyAppWindow() && RSUniRenderJudgement::IsUniRender()) || NeedDrawBehindWindow(); 880 } 881 IsCurrentNodeInTransparentRegion(const Occlusion::Rect & nodeRect)882 inline bool IsCurrentNodeInTransparentRegion(const Occlusion::Rect& nodeRect) const 883 { 884 return transparentRegion_.IsIntersectWith(nodeRect); 885 } 886 887 // Used when the node is opaque, but not calculate in occlusion SetTreatedAsTransparent(bool isOcclusion)888 void SetTreatedAsTransparent(bool isOcclusion) 889 { 890 isTreatedAsTransparent_ = isOcclusion; 891 } 892 IsTreatedAsTransparent()893 bool IsTreatedAsTransparent() const 894 { 895 return isTreatedAsTransparent_; 896 } 897 GetZorderChanged()898 bool GetZorderChanged() const 899 { 900 return zOrderChanged_; 901 } 902 IsZOrderPromoted()903 bool IsZOrderPromoted() const 904 { 905 return GetRenderProperties().GetPositionZ() > positionZ_; 906 } 907 UpdatePositionZ()908 void UpdatePositionZ() 909 { 910 const auto& zProperties = GetRenderProperties().GetPositionZ(); 911 zOrderChanged_ = !ROSEN_EQ(zProperties, positionZ_); 912 positionZ_ = zProperties; 913 } 914 HasContainerWindow()915 inline bool HasContainerWindow() const 916 { 917 return containerConfig_.hasContainerWindow_; 918 } 919 920 void SetContainerWindow(bool hasContainerWindow, RRect rrect); 921 GetContainerConfigDump()922 std::string GetContainerConfigDump() const 923 { 924 return "[outR: " + std::to_string(containerConfig_.outR_) + 925 " inR: " + std::to_string(containerConfig_.inR_) + 926 " x: " + std::to_string(containerConfig_.innerRect_.left_) + 927 " y: " + std::to_string(containerConfig_.innerRect_.top_) + 928 " w: " + std::to_string(containerConfig_.innerRect_.width_) + 929 " h: " + std::to_string(containerConfig_.innerRect_.height_) + "]"; 930 } 931 IsOpaqueRegionChanged()932 bool IsOpaqueRegionChanged() const 933 { 934 return opaqueRegionChanged_; 935 } 936 CleanOpaqueRegionChanged()937 void CleanOpaqueRegionChanged() 938 { 939 opaqueRegionChanged_ = false; 940 } 941 942 // [planning] Remove this after skia is upgraded, the clipRegion is supported 943 void ResetChildrenFilterRects(); 944 void UpdateChildrenFilterRects(std::shared_ptr<RSRenderNode> filternode, const RectI& rect, bool cacheValid); 945 const std::vector<RectI>& GetChildrenNeedFilterRects() const; 946 const std::vector<bool>& GetChildrenNeedFilterRectsCacheValid() const; 947 const std::vector<std::shared_ptr<RSRenderNode>>& GetChildrenFilterNodes() const; 948 std::vector<RectI> GetChildrenNeedFilterRectsWithoutCacheValid(); 949 950 // manage abilities' nodeid info 951 void UpdateAbilityNodeIds(NodeId id, bool isAdded); 952 const std::unordered_set<NodeId>& GetAbilityNodeIds() const; 953 void AddAbilityComponentNodeIds(std::unordered_set<NodeId>& nodeIds); 954 void ResetAbilityNodeIds(); 955 956 // manage appWindowNode's child hardware enabled nodes info 957 void ResetChildHardwareEnabledNodes(); 958 void AddChildHardwareEnabledNode(WeakPtr childNode); 959 const std::vector<WeakPtr>& GetChildHardwareEnabledNodes() const; 960 IsFocusedNode(uint64_t focusedNodeId)961 bool IsFocusedNode(uint64_t focusedNodeId) 962 { 963 return GetId() == focusedNodeId; 964 } 965 966 void CheckAndUpdateOpaqueRegion(const RectI& screeninfo, const ScreenRotation screenRotation, 967 const bool isFocusWindow); 968 969 void ResetSurfaceOpaqueRegion(const RectI& screeninfo, const RectI& absRect, const ScreenRotation screenRotation, 970 const bool isFocusWindow, const Vector4<int>& cornerRadius); 971 Occlusion::Region ResetOpaqueRegion( 972 const RectI& absRect, const ScreenRotation screenRotation, const bool isFocusWindow) const; 973 Occlusion::Region SetUnfocusedWindowOpaqueRegion(const RectI& absRect, const ScreenRotation screenRotation) const; 974 Occlusion::Region SetFocusedWindowOpaqueRegion(const RectI& absRect, const ScreenRotation screenRotation) const; 975 void SetCornerRadiusOpaqueRegion(const RectI& absRect, const Vector4<int>& cornerRadius); 976 void ResetSurfaceContainerRegion(const RectI& screeninfo, const RectI& absRect, 977 const ScreenRotation screenRotation); 978 bool CheckOpaqueRegionBaseInfo(const RectI& screeninfo, const RectI& absRect, const ScreenRotation screenRotation, 979 const bool isFocusWindow, const Vector4<int>& cornerRadius) const; 980 void SetOpaqueRegionBaseInfo(const RectI& screeninfo, const RectI& absRect, const ScreenRotation screenRotation, 981 const bool isFocusWindow, const Vector4<int>& cornerRadius); 982 void DealWithDrawBehindWindowTransparentRegion(); 983 984 bool IsStartAnimationFinished() const; 985 void SetStartAnimationFinished(); 986 // if surfacenode's buffer has been consumed, it should be set dirty 987 bool UpdateDirtyIfFrameBufferConsumed(); 988 989 void UpdateSrcRect(const Drawing::Canvas& canvas, const Drawing::RectI& dstRect, bool hasRotation = false); 990 void UpdateHwcDisabledBySrcRect(bool hasRotation); 991 992 // if a surfacenode's dstrect is empty, its subnodes' prepare stage can be skipped 993 bool ShouldPrepareSubnodes(); 994 void StoreMustRenewedInfo() override; 995 SetNodeCost(int32_t cost)996 void SetNodeCost(int32_t cost) 997 { 998 nodeCost_ = cost; 999 } 1000 GetNodeCost()1001 int32_t GetNodeCost() const 1002 { 1003 return nodeCost_; 1004 } 1005 1006 std::string DirtyRegionDump() const; SetAnimateState()1007 void SetAnimateState() { 1008 animateState_ = true; 1009 } ResetAnimateState()1010 void ResetAnimateState() { 1011 animateState_ = false; 1012 } GetAnimateState()1013 bool GetAnimateState() const 1014 { 1015 return animateState_; 1016 } 1017 bool IsParentLeashWindowInScale() const; 1018 1019 Occlusion::Rect GetSurfaceOcclusionRect(bool isUniRender); 1020 1021 void AccumulateOcclusionRegion(Occlusion::Region& accumulatedRegion, 1022 Occlusion::Region& curRegion, 1023 bool& hasFilterCacheOcclusion, 1024 bool isUniRender, 1025 bool filterCacheOcclusionEnabled); 1026 1027 bool LeashWindowRelatedAppWindowOccluded(std::vector<std::shared_ptr<RSSurfaceRenderNode>>& appNode); 1028 1029 void FindScreenId(); 1030 1031 void OnTreeStateChanged() override; 1032 SetDrawingGPUContext(Drawing::GPUContext * grContext)1033 void SetDrawingGPUContext(Drawing::GPUContext* grContext) 1034 { 1035 grContext_ = grContext; 1036 } 1037 // UIFirst 1038 void UpdateUIFirstFrameGravity(); 1039 SetSubmittedSubThreadIndex(uint32_t index)1040 void SetSubmittedSubThreadIndex(uint32_t index) 1041 { 1042 submittedSubThreadIndex_ = index; 1043 } 1044 GetSubmittedSubThreadIndex()1045 uint32_t GetSubmittedSubThreadIndex() const 1046 { 1047 return submittedSubThreadIndex_; 1048 } 1049 1050 bool IsWaitUifirstFirstFrame() const; 1051 void SetWaitUifirstFirstFrame(bool wait); 1052 1053 void SetCacheSurfaceProcessedStatus(CacheProcessStatus cacheProcessStatus); 1054 CacheProcessStatus GetCacheSurfaceProcessedStatus() const; 1055 1056 void RegisterTreeStateChangeCallback(TreeStateChangeCallback callback); 1057 void NotifyTreeStateChange(); 1058 1059 /* For filter cache occlusion calculation */ GetFilterCacheFullyCovered()1060 bool GetFilterCacheFullyCovered() const 1061 { 1062 return isFilterCacheFullyCovered_; 1063 } 1064 SetFilterCacheFullyCovered(bool val)1065 void SetFilterCacheFullyCovered(bool val) 1066 { 1067 isFilterCacheFullyCovered_ = val; 1068 } 1069 GetFilterCacheValidForOcclusion()1070 bool GetFilterCacheValidForOcclusion() const 1071 { 1072 return isFilterCacheValidForOcclusion_; 1073 } 1074 1075 // mark if any valid filter cache within surface fully cover targer range 1076 void CheckValidFilterCacheFullyCoverTarget(const RSRenderNode& filterNode, const RectI& targetRect); 1077 void CalcFilterCacheValidForOcclusion(); 1078 // mark occluded by upper filtercache 1079 void UpdateOccludedByFilterCache(bool val); 1080 bool IsOccludedByFilterCache() const; 1081 IsFilterCacheStatusChanged()1082 bool IsFilterCacheStatusChanged() const 1083 { 1084 return isFilterCacheStatusChanged_; 1085 } 1086 ResetFilterNodes()1087 void ResetFilterNodes() 1088 { 1089 filterNodes_.clear(); 1090 } 1091 void UpdateFilterNodes(const std::shared_ptr<RSRenderNode>& nodePtr); 1092 // update static node's back&front-ground filter cache status 1093 void UpdateFilterCacheStatusWithVisible(bool visible); 1094 void UpdateFilterCacheStatusIfNodeStatic(const RectI& clipRect, bool isRotationChanged); 1095 void UpdateDrawingCacheNodes(const std::shared_ptr<RSRenderNode>& nodePtr); 1096 // reset static node's drawing cache status as not changed and get filter rects 1097 void ResetDrawingCacheStatusIfNodeStatic(std::unordered_map<NodeId, std::unordered_set<NodeId>>& allRects); 1098 1099 void SetNotifyRTBufferAvailable(bool isNotifyRTBufferAvailable); 1100 1101 // whether the subtree has only one root node 1102 bool HasOnlyOneRootNode() const; 1103 GetHwcDelayDirtyFlag()1104 bool GetHwcDelayDirtyFlag() const noexcept 1105 { 1106 return hwcDelayDirtyFlag_; 1107 } 1108 SetHwcDelayDirtyFlag(bool hwcDelayDirtyFlag)1109 void SetHwcDelayDirtyFlag(bool hwcDelayDirtyFlag) 1110 { 1111 hwcDelayDirtyFlag_ = hwcDelayDirtyFlag; 1112 } 1113 GetSurfaceCacheContentStatic()1114 bool GetSurfaceCacheContentStatic() 1115 { 1116 return surfaceCacheContentStatic_; 1117 } 1118 GetUifirstContentDirty()1119 bool GetUifirstContentDirty() 1120 { 1121 bool uifirstContentDirty = uifirstContentDirty_; 1122 uifirstContentDirty_ = false; 1123 return uifirstContentDirty; 1124 } 1125 1126 void UpdateSurfaceCacheContentStatic(); 1127 1128 void UpdateSurfaceCacheContentStatic( 1129 const std::unordered_map<NodeId, std::weak_ptr<RSRenderNode>>& activeNodeIds); 1130 // temperory limit situation: 1131 // subtree no drawingcache and geodirty 1132 // contentdirty 1 specifically for buffer update IsContentDirtyNodeLimited()1133 bool IsContentDirtyNodeLimited() const 1134 { 1135 return drawingCacheNodes_.empty() && dirtyGeoNodeNum_ == 0 && dirtyContentNodeNum_ <= 1; 1136 } 1137 GetLastFrameChildrenCnt()1138 size_t GetLastFrameChildrenCnt() 1139 { 1140 return lastFrameChildrenCnt_; 1141 } 1142 SetLastFrameChildrenCnt(size_t childrenCnt)1143 void SetLastFrameChildrenCnt(size_t childrenCnt) 1144 { 1145 lastFrameChildrenCnt_ = childrenCnt; 1146 } 1147 GetUifirstSupportFlag()1148 bool GetUifirstSupportFlag() override 1149 { 1150 return RSRenderNode::GetUifirstSupportFlag(); 1151 } 1152 OpincGetNodeSupportFlag()1153 bool OpincGetNodeSupportFlag() override 1154 { 1155 return false; 1156 } 1157 1158 void UpdateSurfaceCacheContentStaticFlag(bool isAccessibilityChanged); 1159 1160 void UpdateSurfaceSubTreeDirtyFlag(); 1161 MergeOldDirtyRect()1162 void MergeOldDirtyRect() override 1163 { 1164 if (IsAppWindow()) { 1165 this->GetDirtyManager()->MergeDirtyRect(this->GetOldDirtyInSurface()); 1166 } 1167 } 1168 1169 #ifdef USE_SURFACE_TEXTURE GetSurfaceTexture()1170 std::shared_ptr<RSSurfaceTexture> GetSurfaceTexture() const { return surfaceTexture_; }; SetSurfaceTexture(const std::shared_ptr<RSSurfaceTexture> & texture)1171 void SetSurfaceTexture(const std::shared_ptr<RSSurfaceTexture> &texture) { surfaceTexture_ = texture; } 1172 #endif 1173 SetForeground(bool isForeground)1174 void SetForeground(bool isForeground) 1175 { 1176 isForeground_ = isForeground; 1177 } 1178 SetSurfaceId(SurfaceId surfaceId)1179 void SetSurfaceId(SurfaceId surfaceId) 1180 { 1181 surfaceId_ = surfaceId; 1182 } 1183 GetSurfaceId()1184 SurfaceId GetSurfaceId() const 1185 { 1186 return surfaceId_; 1187 } 1188 GetIsForeground()1189 bool GetIsForeground() const 1190 { 1191 return isForeground_; 1192 } 1193 bool GetNodeIsSingleFrameComposer() const override; 1194 SetAncestorDisplayNode(const RSBaseRenderNode::WeakPtr & ancestorDisplayNode)1195 void SetAncestorDisplayNode(const RSBaseRenderNode::WeakPtr& ancestorDisplayNode) 1196 { 1197 ancestorDisplayNode_ = ancestorDisplayNode; 1198 } 1199 1200 bool SetUifirstNodeEnableParam(MultiThreadCacheType b); 1201 1202 void SetIsParentUifirstNodeEnableParam(bool b); 1203 1204 void SetUifirstChildrenDirtyRectParam(RectI rect); 1205 SetUifirstStartTime(int64_t startTime)1206 void SetUifirstStartTime(int64_t startTime) 1207 { 1208 uifirstStartTime_ = startTime; 1209 } 1210 GetUifirstStartTime()1211 int64_t GetUifirstStartTime() const 1212 { 1213 return uifirstStartTime_; 1214 } 1215 GetAncestorDisplayNode()1216 RSBaseRenderNode::WeakPtr GetAncestorDisplayNode() const 1217 { 1218 return ancestorDisplayNode_; 1219 } 1220 bool QuerySubAssignable(bool isRotation); 1221 bool QueryIfAllHwcChildrenForceDisabledByFilter(); 1222 bool GetHasSharedTransitionNode() const; 1223 void SetHasSharedTransitionNode(bool hasSharedTransitionNode); 1224 Vector2f GetGravityTranslate(float imgWidth, float imgHeight); 1225 void UpdateTransparentSurface(); 1226 bool GetHasTransparentSurface() const; 1227 void UpdatePartialRenderParams(); 1228 // This function is used for extending visibleRegion by dirty blurfilter node half-obscured 1229 void UpdateExtendVisibleRegion(Occlusion::Region& region); 1230 void UpdateAncestorDisplayNodeInRenderParams(); 1231 SetNeedDrawFocusChange(bool needDrawFocusChange)1232 void SetNeedDrawFocusChange(bool needDrawFocusChange) 1233 { 1234 needDrawFocusChange_ = needDrawFocusChange; 1235 } 1236 GetNeedDrawFocusChange()1237 bool GetNeedDrawFocusChange() const 1238 { 1239 return needDrawFocusChange_; 1240 } 1241 HasWindowCorner()1242 bool HasWindowCorner() 1243 { 1244 Vector4f cornerRadius; 1245 Vector4f::Max(GetWindowCornerRadius(), GetGlobalCornerRadius(), cornerRadius); 1246 return !cornerRadius.IsZero(); 1247 } SetBufferRelMatrix(const Drawing::Matrix & matrix)1248 void SetBufferRelMatrix(const Drawing::Matrix& matrix) 1249 { 1250 bufferRelMatrix_ = matrix; 1251 } 1252 GetBufferRelMatrix()1253 const Drawing::Matrix& GetBufferRelMatrix() const 1254 { 1255 return bufferRelMatrix_; 1256 } 1257 SetGpuOverDrawBufferOptimizeNode(bool overDrawNode)1258 void SetGpuOverDrawBufferOptimizeNode(bool overDrawNode) 1259 { 1260 isGpuOverDrawBufferOptimizeNode_ = overDrawNode; 1261 } IsGpuOverDrawBufferOptimizeNode()1262 bool IsGpuOverDrawBufferOptimizeNode() const 1263 { 1264 return isGpuOverDrawBufferOptimizeNode_; 1265 } 1266 SetOverDrawBufferNodeCornerRadius(const Vector4f & radius)1267 void SetOverDrawBufferNodeCornerRadius(const Vector4f& radius) 1268 { 1269 overDrawBufferNodeCornerRadius_ = radius; 1270 } GetOverDrawBufferNodeCornerRadius()1271 const Vector4f& GetOverDrawBufferNodeCornerRadius() const 1272 { 1273 return overDrawBufferNodeCornerRadius_; 1274 } 1275 1276 bool HasSubSurfaceNodes() const; 1277 void SetIsSubSurfaceNode(bool isSubSurfaceNode); 1278 bool IsSubSurfaceNode() const; 1279 const std::map<NodeId, RSSurfaceRenderNode::WeakPtr>& GetChildSubSurfaceNodes() const; 1280 void GetAllSubSurfaceNodes(std::vector<std::pair<NodeId, RSSurfaceRenderNode::WeakPtr>>& allSubSurfaceNodes) const; 1281 std::string SubSurfaceNodesDump() const; 1282 1283 void SetIsNodeToBeCaptured(bool isNodeToBeCaptured); 1284 bool IsNodeToBeCaptured() const; 1285 SetDoDirectComposition(bool flag)1286 void SetDoDirectComposition(bool flag) 1287 { 1288 doDirectComposition_ = flag; 1289 } 1290 GetDoDirectComposition()1291 bool GetDoDirectComposition() const 1292 { 1293 return doDirectComposition_; 1294 } 1295 SetHardWareDisabledByReverse(bool isHardWareDisabledByReverse)1296 void SetHardWareDisabledByReverse(bool isHardWareDisabledByReverse) 1297 { 1298 isHardWareDisabledByReverse_ = isHardWareDisabledByReverse; 1299 } 1300 GetHardWareDisabledByReverse()1301 bool GetHardWareDisabledByReverse() const 1302 { 1303 return isHardWareDisabledByReverse_; 1304 } 1305 1306 void SetSkipDraw(bool skip); 1307 bool GetSkipDraw() const; 1308 void SetHidePrivacyContent(bool needHidePrivacyContent); 1309 void SetNeedOffscreen(bool needOffscreen); 1310 void SetSdrNit(float sdrNit); 1311 void SetDisplayNit(float displayNit); 1312 void SetBrightnessRatio(float brightnessRatio); 1313 void SetLayerLinearMatrix(const std::vector<float>& layerLinearMatrix); 1314 void SetSdrHasMetadata(bool hasMetadata); 1315 bool GetSdrHasMetadata() const; 1316 static const std::unordered_map<NodeId, NodeId>& GetSecUIExtensionNodes(); IsSecureUIExtension()1317 bool IsSecureUIExtension() const 1318 { 1319 return nodeType_ == RSSurfaceNodeType::UI_EXTENSION_SECURE_NODE; 1320 } 1321 IsUnobscuredUIExtensionNode()1322 bool IsUnobscuredUIExtensionNode() const 1323 { 1324 return nodeType_ == RSSurfaceNodeType::UI_EXTENSION_COMMON_NODE && GetUIExtensionUnobscured(); 1325 } 1326 IsUIExtension()1327 bool IsUIExtension() const 1328 { 1329 return nodeType_ == RSSurfaceNodeType::UI_EXTENSION_COMMON_NODE || 1330 nodeType_ == RSSurfaceNodeType::UI_EXTENSION_SECURE_NODE; 1331 } 1332 1333 void SetCornerRadiusInfoForDRM(const std::vector<float>& drmCornerRadius); 1334 void SetForceDisableClipHoleForDRM(bool isForceDisable); GetCornerRadiusInfoForDRM()1335 const std::vector<float>& GetCornerRadiusInfoForDRM() const 1336 { 1337 return drmCornerRadiusInfo_; 1338 } 1339 1340 // [Attention] The function only used for unlocking screen for PC currently GetClonedNodeId()1341 NodeId GetClonedNodeId() const 1342 { 1343 return clonedSourceNodeId_; 1344 } 1345 GetRSSurfaceHandler()1346 const std::shared_ptr<RSSurfaceHandler> GetRSSurfaceHandler() const 1347 { 1348 return surfaceHandler_; 1349 } 1350 GetMutableRSSurfaceHandler()1351 std::shared_ptr<RSSurfaceHandler> GetMutableRSSurfaceHandler() 1352 { 1353 return surfaceHandler_; 1354 } 1355 CheckContainerDirtyStatusAndUpdateDirty(bool containerDirty)1356 void CheckContainerDirtyStatusAndUpdateDirty(bool containerDirty) 1357 { 1358 if (!IsLeashOrMainWindow()) { 1359 return; 1360 } 1361 dirtyStatus_ = containerDirty ? NodeDirty::DIRTY : dirtyStatus_; 1362 } 1363 1364 void SetWatermarkEnabled(const std::string& name, bool isEnabled); 1365 const std::unordered_map<std::string, bool>& GetWatermark() const; 1366 bool IsWatermarkEmpty() const; 1367 1368 template<class... Args> SetIntersectedRoundCornerAABBs(Args &&...args)1369 void SetIntersectedRoundCornerAABBs(Args&& ...args) 1370 { 1371 std::vector<RectI>(std::forward<Args>(args)...).swap(intersectedRoundCornerAABBs_); 1372 } 1373 GetIntersectedRoundCornerAABBs()1374 const std::vector<RectI>& GetIntersectedRoundCornerAABBs() const 1375 { 1376 return intersectedRoundCornerAABBs_; 1377 } 1378 GetIntersectedRoundCornerAABBsSize()1379 size_t GetIntersectedRoundCornerAABBsSize() const 1380 { 1381 return intersectedRoundCornerAABBs_.size(); 1382 } 1383 1384 void SetNeedCacheSurface(bool needCacheSurface); GetSubThreadAssignable()1385 bool GetSubThreadAssignable() const 1386 { 1387 return subThreadAssignable_; 1388 } SetSubThreadAssignable(bool subThreadAssignable)1389 void SetSubThreadAssignable(bool subThreadAssignable) 1390 { 1391 subThreadAssignable_ = subThreadAssignable; 1392 } GetMultableSpecialLayerMgr()1393 RSSpecialLayerManager& GetMultableSpecialLayerMgr() 1394 { 1395 return specialLayerManager_; 1396 } 1397 GetSpecialLayerMgr()1398 const RSSpecialLayerManager& GetSpecialLayerMgr() const 1399 { 1400 return specialLayerManager_; 1401 } 1402 1403 bool NeedUpdateDrawableBehindWindow() const override; 1404 void SetOldNeedDrawBehindWindow(bool val); 1405 bool NeedDrawBehindWindow() const override; 1406 bool GetBehindWindowFilterEnabled() const; 1407 void AddChildBlurBehindWindow(NodeId id) override; 1408 void RemoveChildBlurBehindWindow(NodeId id) override; 1409 void CalDrawBehindWindowRegion() override; 1410 RectI GetFilterRect() const override; 1411 RectI GetBehindWindowRegion() const override; UpdateCrossNodeSkipDisplayConversionMatrices(NodeId displayId,const Drawing::Matrix & matrix)1412 void UpdateCrossNodeSkipDisplayConversionMatrices(NodeId displayId, const Drawing::Matrix& matrix) 1413 { 1414 crossNodeSkipDisplayConversionMatrices_[displayId] = matrix; 1415 } GetCrossNodeSkipDisplayConversionMatrix(NodeId displayId)1416 const Drawing::Matrix& GetCrossNodeSkipDisplayConversionMatrix(NodeId displayId) 1417 { 1418 return crossNodeSkipDisplayConversionMatrices_[displayId]; 1419 } ClearCrossNodeSkipDisplayConversionMatrices()1420 void ClearCrossNodeSkipDisplayConversionMatrices() 1421 { 1422 crossNodeSkipDisplayConversionMatrices_.clear(); 1423 } GetVideoHdrStatus()1424 HdrStatus GetVideoHdrStatus() const 1425 { 1426 return hdrVideoSurface_; 1427 } 1428 SetVideoHdrStatus(HdrStatus hasHdrVideoSurface)1429 void SetVideoHdrStatus(HdrStatus hasHdrVideoSurface) 1430 { 1431 hdrVideoSurface_ = hasHdrVideoSurface; 1432 } 1433 1434 void SetApiCompatibleVersion(uint32_t apiCompatibleVersion); GetApiCompatibleVersion()1435 uint32_t GetApiCompatibleVersion() 1436 { 1437 return apiCompatibleVersion_; 1438 } 1439 GetIsHwcPendingDisabled()1440 bool GetIsHwcPendingDisabled() const 1441 { 1442 return isHwcPendingDisabled_; 1443 } 1444 SetIsHwcPendingDisabled(bool isHwcPendingDisabled)1445 void SetIsHwcPendingDisabled(bool isHwcPendingDisabled) 1446 { 1447 isHwcPendingDisabled_ = isHwcPendingDisabled; 1448 } 1449 1450 void ResetIsBufferFlushed(); 1451 1452 bool IsUIBufferAvailable(); 1453 1454 bool GetUIExtensionUnobscured() const; 1455 GetDirtyManagerForUifirst()1456 std::shared_ptr<RSDirtyRegionManager>& GetDirtyManagerForUifirst() 1457 { 1458 return dirtyManager_; 1459 } 1460 1461 // [Attention] Used in uifirst for checking whether node and parent should paint or not SetSelfAndParentShouldPaint(bool selfAndParentShouldPaint)1462 void SetSelfAndParentShouldPaint(bool selfAndParentShouldPaint) 1463 { 1464 selfAndParentShouldPaint_ = selfAndParentShouldPaint; 1465 } 1466 GetSelfAndParentShouldPaint()1467 bool GetSelfAndParentShouldPaint() const 1468 { 1469 return selfAndParentShouldPaint_; 1470 } 1471 SetAppWindowZOrder(int32_t appWindowZOrder)1472 void SetAppWindowZOrder(int32_t appWindowZOrder) 1473 { 1474 appWindowZOrder_ = appWindowZOrder; 1475 } 1476 GetAppWindowZOrder()1477 int32_t GetAppWindowZOrder() const 1478 { 1479 return appWindowZOrder_; 1480 } 1481 1482 protected: 1483 void OnSync() override; 1484 void OnSkipSync() override; 1485 // rotate corner by rotation degreee. Every 90 degrees clockwise rotation, the vector 1486 // of corner radius loops one element to the right 1487 void RotateCorner(int rotationDegree, Vector4<int>& cornerRadius) const; 1488 1489 private: 1490 explicit RSSurfaceRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {}, 1491 bool isTextureExportNode = false); 1492 explicit RSSurfaceRenderNode(const RSSurfaceRenderNodeConfig& config, const std::weak_ptr<RSContext>& context = {}); 1493 void OnResetParent() override; 1494 void ClearChildrenCache(); 1495 Vector4f GetWindowCornerRadius(); 1496 std::vector<std::shared_ptr<RSSurfaceRenderNode>> GetLeashWindowNestedSurfaces(); 1497 bool IsHistoryOccludedDirtyRegionNeedSubmit(); 1498 void ClearHistoryUnSubmittedDirtyInfo(); 1499 void UpdateHistoryUnsubmittedDirtyInfo(); 1500 void SetUIExtensionUnobscured(bool obscured); IsHardwareDisabledBySrcRect()1501 inline bool IsHardwareDisabledBySrcRect() const 1502 { 1503 return isHardwareForcedDisabledBySrcRect_; 1504 } 1505 void OnSubSurfaceChanged(); 1506 void UpdateChildSubSurfaceNodes(RSSurfaceRenderNode::SharedPtr node, bool isOnTheTree); 1507 bool IsYUVBufferFormat() const; 1508 void InitRenderParams() override; 1509 void UpdateRenderParams() override; 1510 void UpdateChildHardwareEnabledNode(NodeId id, bool isOnTree); 1511 std::unordered_set<NodeId> GetAllSubSurfaceNodeIds() const; 1512 bool IsCurFrameSwitchToPaint(); 1513 1514 RSSpecialLayerManager specialLayerManager_; 1515 bool specialLayerChanged_ = false; 1516 bool isGlobalPositionEnabled_ = false; 1517 bool hasFingerprint_ = false; 1518 // hdr video 1519 HdrStatus hdrVideoSurface_ = HdrStatus::NO_HDR; 1520 bool zOrderChanged_ = false; 1521 bool qosPidCal_ = false; 1522 RSSurfaceNodeAbilityState abilityState_ = RSSurfaceNodeAbilityState::FOREGROUND; 1523 RSSurfaceNodeType nodeType_ = RSSurfaceNodeType::DEFAULT; 1524 bool isLayerTop_ = false; 1525 // Specifying hardware enable is only a 'hint' to RS that 1526 // the self-drawing node use hardware composer in some condition, 1527 // such as transparent background. 1528 bool isHardwareEnableHint_ = false; 1529 NodeId sourceDisplayRenderNodeId_ = INVALID_NODEID; 1530 const enum SurfaceWindowType surfaceWindowType_ = SurfaceWindowType::DEFAULT_WINDOW; 1531 bool isNotifyRTBufferAvailablePre_ = false; 1532 bool isRefresh_ = false; 1533 bool isLeashWindowVisibleRegionEmpty_ = false; 1534 bool isOcclusionVisible_ = true; 1535 bool isOcclusionVisibleWithoutFilter_ = true; 1536 bool isOcclusionInSpecificScenes_ = false; 1537 bool dstRectChanged_ = false; 1538 uint8_t abilityBgAlpha_ = 0; 1539 bool alphaChanged_ = false; 1540 bool isUIHidden_ = false; 1541 // is hwc node disabled by filter rect 1542 bool isHwcPendingDisabled_ = false; 1543 bool extraDirtyRegionAfterAlignmentIsEmpty_ = true; 1544 bool opaqueRegionChanged_ = false; 1545 bool isFilterCacheFullyCovered_ = false; 1546 bool isFilterCacheValidForOcclusion_ = false; 1547 bool isOccludedByFilterCache_ = false; 1548 bool isFilterCacheStatusChanged_ = false; 1549 bool isTreatedAsTransparent_ = false; 1550 bool startAnimationFinished_ = false; 1551 // only used in hardware enabled pointer window, when gpu -> hardware composer 1552 bool isNodeDirtyInLastFrame_ = true; 1553 bool isNodeDirty_ = true; 1554 // used for hardware enabled nodes 1555 bool isHardwareEnabledNode_ = false; 1556 bool dynamicHardwareEnable_ = true; 1557 bool isFixRotationByUser_ = false; 1558 bool isInFixedRotation_ = false; 1559 SelfDrawingNodeType selfDrawingType_ = SelfDrawingNodeType::DEFAULT; 1560 bool isCurrentFrameHardwareEnabled_ = false; 1561 bool isLastFrameHardwareEnabled_ = false; 1562 bool isLastFrameHwcEnabled_ = false; 1563 bool needCollectHwcNode_ = false; 1564 bool intersectByFilterInApp_ = false; 1565 bool calcRectInPrepare_ = false; 1566 bool hasSubNodeShouldPaint_ = false; 1567 // mark if this self-drawing node is forced not to use hardware composer 1568 // in case where this node's parent window node is occluded or is appFreeze, this variable will be marked true 1569 bool isHardwareForcedDisabled_ = false; 1570 bool hardwareNeedMakeImage_ = false; 1571 bool intersectWithAIBar_ = false; 1572 bool isHardwareForcedDisabledByFilter_ = false; 1573 // For certain buffer format(YUV), dss restriction on src : srcRect % 2 == 0 1574 // To avoid switch between gpu and dss during sliding, we disable dss when srcHeight != bufferHeight 1575 bool isHardwareForcedDisabledBySrcRect_ = false; 1576 bool isHardwareDisabledByCache_ = false; 1577 // Mark if the leash or main window node has transparent self-drawing node 1578 bool existTransparentHardwareEnabledNode_ = false; 1579 bool animateState_ = false; 1580 bool isRotating_ = false; 1581 bool isParentScaling_ = false; 1582 bool needDrawAnimateProperty_ = false; 1583 bool prevVisible_ = false; 1584 bool isHardWareDisabledByReverse_ = false; 1585 // mark if this self-drawing node do not consume buffer when gpu -> hwc 1586 bool hwcDelayDirtyFlag_ = false; 1587 bool isForeground_ = false; 1588 bool UIFirstIsPurge_ = false; 1589 bool isTargetUIFirstDfxEnabled_ = false; 1590 bool hasSharedTransitionNode_ = false; 1591 bool lastFrameShouldPaint_ = true; 1592 // node only have translate and scale changes 1593 bool surfaceCacheContentStatic_ = false; 1594 bool uifirstContentDirty_ = false; 1595 // point window 1596 bool isHardCursor_ = false; 1597 bool isLastHardCursor_ = false; 1598 bool needDrawFocusChange_ = false; 1599 bool forceUIFirstChanged_ = false; 1600 bool forceUIFirst_ = false; 1601 bool uifirstForceDrawWithSkipped_ = false; 1602 bool hasTransparentSurface_ = false; 1603 bool isGpuOverDrawBufferOptimizeNode_ = false; 1604 bool isSubSurfaceNode_ = false; 1605 bool isNodeToBeCaptured_ = false; 1606 bool doDirectComposition_ = true; 1607 bool isSkipDraw_ = false; 1608 bool needHidePrivacyContent_ = false; 1609 bool isHardwareForcedByBackgroundAlpha_ = false; 1610 bool arsrTag_ = true; 1611 bool subThreadAssignable_ = false; 1612 bool oldNeedDrawBehindWindow_ = false; 1613 RectI skipFrameDirtyRect_; 1614 bool UIExtensionUnobscured_ = false; 1615 std::atomic<bool> isNotifyRTBufferAvailable_ = false; 1616 std::atomic<bool> isNotifyUIBufferAvailable_ = true; 1617 std::atomic_bool isBufferAvailable_ = false; 1618 std::atomic<CacheProcessStatus> cacheProcessStatus_ = CacheProcessStatus::WAITING; 1619 std::atomic<bool> isNeedSubmitSubThread_ = true; 1620 // whether to wait uifirst first frame finished when buffer available callback invoked. 1621 std::atomic<bool> isWaitUifirstFirstFrame_ = false; 1622 std::atomic<bool> hasUnSubmittedOccludedDirtyRegion_ = false; 1623 static inline std::atomic<bool> ancoForceDoDirect_ = false; 1624 float contextAlpha_ = 1.0f; 1625 // Count the number of hdr pictures. If hdrNum_ > 0, it means there are hdr pictures 1626 int hdrNum_ = 0; 1627 int32_t offsetX_ = 0; 1628 int32_t offsetY_ = 0; 1629 int64_t stencilVal_ = -1; 1630 float positionZ_ = 0.0f; 1631 // This variable can be set in two cases: 1632 // 1. The upper-layer IPC interface directly sets window colorspace. 1633 // 2. If it is a self-drawing node, the colorspace will be refreshed after hardware-enable calculation. 1634 GraphicColorGamut colorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; 1635 #ifndef ROSEN_CROSS_PLATFORM 1636 GraphicBlendType blendType_ = GraphicBlendType::GRAPHIC_BLEND_SRCOVER; 1637 #endif 1638 // hdr 1639 int32_t displayNit_ = 500; // default sdr luminance 1640 float brightnessRatio_ = 1.0f; // no ratio by default 1641 float localZOrder_ = 0.0f; 1642 uint32_t processZOrder_ = -1; 1643 int32_t nodeCost_ = 0; 1644 uint32_t submittedSubThreadIndex_ = INT_MAX; 1645 uint32_t wideColorGamutInChildNodeCount_ = 0; 1646 uint32_t apiCompatibleVersion_ = 0; 1647 std::atomic<uint32_t> ancoFlags_ = 0; 1648 Drawing::GPUContext* grContext_ = nullptr; 1649 ScreenId screenId_ = INVALID_SCREEN_ID; 1650 SurfaceId surfaceId_ = 0; 1651 uint64_t leashPersistentId_ = INVALID_LEASH_PERSISTENTID; 1652 size_t dirtyContentNodeNum_ = 0; 1653 size_t dirtyGeoNodeNum_ = 0; 1654 size_t dirtynodeNum_ = 0; 1655 // UIFirst 1656 int64_t uifirstStartTime_ = -1; 1657 size_t lastFrameChildrenCnt_ = 0; 1658 sptr<RSIBufferAvailableCallback> callbackFromRT_ = nullptr; 1659 sptr<RSIBufferAvailableCallback> callbackFromUI_ = nullptr; 1660 sptr<RSIBufferClearCallback> clearBufferCallback_ = nullptr; 1661 std::shared_ptr<RSDirtyRegionManager> dirtyManager_ = nullptr; 1662 std::shared_ptr<RSDirtyRegionManager> cacheSurfaceDirtyManager_ = nullptr; 1663 std::shared_ptr<RSSurfaceHandler> surfaceHandler_; 1664 #ifdef USE_SURFACE_TEXTURE 1665 std::shared_ptr<RSSurfaceTexture> surfaceTexture_ {}; 1666 #endif 1667 RSBaseRenderNode::WeakPtr ancestorDisplayNode_; 1668 RectI clipRegionFromParent_; 1669 RectI dstRect_; 1670 RectI srcRect_; 1671 RectI originalDstRect_; 1672 RectI originalSrcRect_; 1673 Drawing::Rect dstRectWithoutRenderFit_; 1674 RectI historyUnSubmittedOccludedDirtyRegion_; 1675 Vector4f overDrawBufferNodeCornerRadius_; 1676 RectI drawBehindWindowRegion_; 1677 1678 std::mutex mutexRT_; 1679 std::mutex mutexUI_; 1680 std::mutex mutexClear_; 1681 std::mutex mutex_; 1682 std::mutex mutexHDR_; 1683 std::mutex parallelVisitMutex_; 1684 std::optional<Drawing::Matrix> contextMatrix_; 1685 std::optional<Drawing::Rect> contextClipRect_; 1686 1687 std::set<NodeId> skipLayerIds_= {}; 1688 std::set<NodeId> snapshotSkipLayerIds_= {}; 1689 std::set<NodeId> securityLayerIds_= {}; 1690 std::set<NodeId> protectedLayerIds_= {}; 1691 std::set<NodeId> privacyContentLayerIds_ = {}; 1692 Drawing::Matrix totalMatrix_; 1693 std::vector<RectI> intersectedRoundCornerAABBs_; 1694 std::vector<float> drmCornerRadiusInfo_; 1695 1696 std::string name_; 1697 std::vector<NodeId> childSurfaceNodeIds_; 1698 friend class RSRenderThreadVisitor; 1699 /* 1700 visibleRegion: appwindow visible region after occlusion, used for rs opdrop and other optimization. 1701 visibleRegionForCallBack: appwindow visible region after occlusion (no filtercache occlusion), used in 1702 windowmanager, and web surfacenode visibility callback. 1703 These two values are the same in most cases. If there are filter cache occlusion, this two values will be 1704 different under filter cache surfacenode layer. 1705 */ 1706 Occlusion::Region visibleRegion_; 1707 Occlusion::Region extendVisibleRegion_; 1708 Occlusion::Region visibleRegionInVirtual_; 1709 Occlusion::Region visibleRegionForCallBack_; 1710 1711 // dirtyRegion caused by surfaceNode visible region after alignment 1712 Occlusion::Region extraDirtyRegionAfterAlignment_; 1713 1714 // region of rounded corner 1715 Occlusion::Region roundedCornerRegion_; 1716 // opaque region of the surface 1717 Occlusion::Region opaqueRegion_; 1718 // [planning] Remove this after skia is upgraded, the clipRegion is supported 1719 std::vector<RectI> childrenFilterRects_; 1720 std::vector<bool> childrenFilterRectsCacheValid_; 1721 std::vector<std::shared_ptr<RSRenderNode>> childrenFilterNodes_; 1722 // transparent region of the surface, floating window's container window is always treated as transparent 1723 Occlusion::Region transparentRegion_; 1724 1725 Occlusion::Region containerRegion_; 1726 std::unordered_set<NodeId> abilityNodeIds_; 1727 // valid filter nodes within, including itself 1728 std::vector<std::shared_ptr<RSRenderNode>> filterNodes_; 1729 std::unordered_map<NodeId, std::weak_ptr<RSRenderNode>> drawingCacheNodes_; 1730 int32_t appWindowZOrder_ = 0; 1731 1732 /* 1733 ContainerWindow configs acquired from arkui, including container window state, screen density, container border 1734 width, padding width, inner/outer radius, etc. 1735 */ 1736 class ContainerConfig { 1737 public: 1738 // rrect means content region, including padding to left and top, inner radius; 1739 void Update(bool hasContainer, RRect rrect); 1740 1741 bool operator==(const ContainerConfig& config) const 1742 { 1743 return hasContainerWindow_ == config.hasContainerWindow_ && 1744 outR_ == config.outR_ && 1745 inR_ == config.inR_ && 1746 innerRect_ == config.innerRect_; 1747 } 1748 private: RoundFloor(float length)1749 inline int RoundFloor(float length) 1750 { 1751 // if a float value is very close to a integer (< 0.05f), return round value 1752 return std::abs(length - std::round(length)) < 0.05f ? std::round(length) : std::floor(length); 1753 } 1754 public: 1755 bool hasContainerWindow_ = false; // set to false as default, set by arkui 1756 int outR_ = 0; // outer radius (int value) 1757 int inR_ = 0; // inner radius (int value) 1758 RectI innerRect_ = {}; // inner rect, value relative to outerRect 1759 }; 1760 1761 ContainerConfig containerConfig_; 1762 ContainerConfig GetAbsContainerConfig() const; 1763 1764 struct OpaqueRegionBaseInfo 1765 { 1766 RectI screenRect_; 1767 RectI absRect_; 1768 RectI oldDirty_; 1769 ScreenRotation screenRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION; 1770 bool isFocusWindow_ = false; 1771 bool isTransparent_ = false; 1772 bool hasContainerWindow_ = false; 1773 Vector4<int> cornerRadius_; 1774 ContainerConfig containerConfig_; 1775 bool needDrawBehindWindow_ = false; 1776 RectI absDrawBehindWindowRegion_ = RectI(); 1777 }; 1778 1779 //<screenRect, absRect, screenRotation, isFocusWindow, isTransparent, hasContainerWindow> 1780 OpaqueRegionBaseInfo opaqueRegionBaseInfo_; 1781 1782 std::vector<WeakPtr> childHardwareEnabledNodes_; 1783 1784 TreeStateChangeCallback treeStateChangeCallback_; 1785 Drawing::Matrix bufferRelMatrix_ = Drawing::Matrix(); 1786 1787 // [Attention] The variable only used for unlocking screen for PC currently 1788 bool isCloneNode_ = false; 1789 NodeId clonedSourceNodeId_ = INVALID_NODEID; 1790 bool isClonedNodeOnTheTree_ = false; 1791 1792 std::map<NodeId, RSSurfaceRenderNode::WeakPtr> childSubSurfaceNodes_; 1793 std::unordered_map<std::string, bool> watermarkHandles_ = {}; 1794 std::unordered_set<NodeId> childrenBlurBehindWindow_ = {}; 1795 std::unordered_map<NodeId, Drawing::Matrix> crossNodeSkipDisplayConversionMatrices_ = {}; 1796 1797 // used in uifirst for checking whether node and parents should paint or not 1798 bool selfAndParentShouldPaint_ = true; 1799 1800 // UIExtension record, <UIExtension, hostAPP> 1801 inline static std::unordered_map<NodeId, NodeId> secUIExtensionNodes_ = {}; 1802 friend class SurfaceNodeCommandHelper; 1803 friend class RSUifirstManager; 1804 friend class RSUniRenderVisitor; 1805 friend class RSRenderNode; 1806 friend class RSRenderService; 1807 #ifdef RS_PROFILER_ENABLED 1808 friend class RSProfiler; 1809 #endif 1810 }; 1811 } // namespace Rosen 1812 } // namespace OHOS 1813 1814 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SURFACE_RENDER_NODE_H 1815