1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_BASE_PARAMS_RS_SURFACE_RENDER_PARAMS_H 17 #define RENDER_SERVICE_BASE_PARAMS_RS_SURFACE_RENDER_PARAMS_H 18 19 #include <memory> 20 #include <string> 21 #include <unordered_map> 22 23 #include "common/rs_occlusion_region.h" 24 #include "common/rs_special_layer_manager.h" 25 #include "drawable/rs_render_node_drawable_adapter.h" 26 #include "params/rs_render_params.h" 27 #include "pipeline/rs_base_render_node.h" 28 #include "platform/common/rs_system_properties.h" 29 #ifndef ROSEN_CROSS_PLATFORM 30 #include "surface_buffer.h" 31 #include "sync_fence.h" 32 #endif 33 #include "surface_type.h" 34 35 namespace OHOS::Rosen { 36 class RSSurfaceRenderNode; 37 struct RSLayerInfo { 38 #ifndef ROSEN_CROSS_PLATFORM 39 GraphicIRect srcRect; 40 GraphicIRect dstRect; 41 GraphicIRect boundRect; 42 Drawing::Matrix matrix; 43 int32_t gravity = 0; 44 int32_t zOrder = 0; 45 float alpha = 1.f; 46 GraphicBlendType blendType = GraphicBlendType::GRAPHIC_BLEND_NONE; 47 GraphicTransformType transformType = GraphicTransformType::GRAPHIC_ROTATE_NONE; 48 GraphicLayerType layerType = GraphicLayerType::GRAPHIC_LAYER_TYPE_GRAPHIC; 49 int32_t layerSource; 50 bool arsrTag = true; 51 bool copybitTag = false; 52 uint32_t ancoFlags = 0; 53 GraphicIRect ancoCropRect{}; 54 bool useDeviceOffline = false; 55 56 bool operator==(const RSLayerInfo& layerInfo) const 57 { 58 return (srcRect == layerInfo.srcRect) && (dstRect == layerInfo.dstRect) && 59 (boundRect == layerInfo.boundRect) && (matrix == layerInfo.matrix) && (gravity == layerInfo.gravity) && 60 (zOrder == layerInfo.zOrder) && (blendType == layerInfo.blendType) && 61 (transformType == layerInfo.transformType) && (ROSEN_EQ(alpha, layerInfo.alpha)) && 62 (layerSource == layerInfo.layerSource) && (layerType == layerInfo.layerType) && 63 (arsrTag == layerInfo.arsrTag) && (copybitTag == layerInfo.copybitTag) && 64 (ancoCropRect == layerInfo.ancoCropRect) && (ancoFlags == layerInfo.ancoFlags) && 65 (useDeviceOffline == layerInfo.useDeviceOffline); 66 } 67 #endif 68 }; 69 struct RSWindowInfo { 70 bool isMainWindowType_ = false; 71 bool isLeashWindow_ = false; 72 bool isAppWindow_ = false; SetWindowInfoRSWindowInfo73 void SetWindowInfo(bool isMainWindowType, bool isLeashWindow, bool isAppWindow) 74 { 75 isMainWindowType_ = isMainWindowType; 76 isLeashWindow_ = isLeashWindow; 77 isAppWindow_ = isAppWindow; 78 } 79 }; 80 class RSB_EXPORT RSSurfaceRenderParams : public RSRenderParams { 81 public: 82 explicit RSSurfaceRenderParams(NodeId id); 83 ~RSSurfaceRenderParams() override = default; IsMainWindowType()84 inline bool IsMainWindowType() const 85 { 86 return windowInfo_.isMainWindowType_; 87 } IsLeashWindow()88 inline bool IsLeashWindow() const override 89 { 90 return windowInfo_.isLeashWindow_; 91 } IsAppWindow()92 bool IsAppWindow() const override 93 { 94 return windowInfo_.isAppWindow_; 95 } SetWindowInfo(bool isMainWindowType,bool isLeashWindow,bool isAppWindow)96 void SetWindowInfo(bool isMainWindowType, bool isLeashWindow, bool isAppWindow) 97 { 98 windowInfo_.SetWindowInfo(isMainWindowType, isLeashWindow, isAppWindow); 99 } IsLeashOrMainWindow()100 bool IsLeashOrMainWindow() const 101 { 102 return windowInfo_.isLeashWindow_ || windowInfo_.isMainWindowType_; 103 } 104 GetSurfaceNodeType()105 RSSurfaceNodeType GetSurfaceNodeType() const 106 { 107 return rsSurfaceNodeType_; 108 } GetSelfDrawingNodeType()109 SelfDrawingNodeType GetSelfDrawingNodeType() const 110 { 111 return selfDrawingType_; 112 } SetAncestorScreenNode(const RSRenderNode::WeakPtr & ancestorScreenNode)113 void SetAncestorScreenNode(const RSRenderNode::WeakPtr& ancestorScreenNode) 114 { 115 ancestorScreenNode_ = ancestorScreenNode; 116 auto node = ancestorScreenNode.lock(); 117 ancestorScreenDrawable_ = node ? node->GetRenderDrawable() : nullptr; 118 } 119 GetAncestorScreenNode()120 RSRenderNode::WeakPtr GetAncestorScreenNode() const 121 { 122 return ancestorScreenNode_; 123 } GetAncestorScreenDrawable()124 DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetAncestorScreenDrawable() const 125 { 126 return ancestorScreenDrawable_; 127 } 128 GetAlpha()129 float GetAlpha() const 130 { 131 return alpha_; 132 } IsClonedNodeOnTheTree()133 bool IsClonedNodeOnTheTree() const 134 { 135 return isClonedNodeOnTheTree_; 136 } IsCrossNode()137 bool IsCrossNode() const 138 { 139 return isCrossNode_; 140 } IsSpherizeValid()141 bool IsSpherizeValid() const 142 { 143 return isSpherizeValid_; 144 } IsAttractionValid()145 bool IsAttractionValid() const 146 { 147 return isAttractionValid_; 148 } NeedBilinearInterpolation()149 bool NeedBilinearInterpolation() const 150 { 151 return needBilinearInterpolation_; 152 } GetBackgroundColor()153 const Color& GetBackgroundColor() const 154 { 155 return backgroundColor_; 156 } GetRRect()157 const RRect& GetRRect() const 158 { 159 return rrect_; 160 } GetAnimateState()161 bool GetAnimateState() const 162 { 163 return animateState_; 164 } SetStencilVal(int64_t stencilVal)165 void SetStencilVal(int64_t stencilVal) 166 { 167 stencilVal_ = stencilVal; 168 } GetStencilVal()169 int64_t GetStencilVal() const 170 { 171 return stencilVal_; 172 } SetIsOutOfScreen(bool isOutOfScreen)173 void SetIsOutOfScreen(bool isOutOfScreen) 174 { 175 if (isOutOfScreen_ == isOutOfScreen) { 176 return; 177 } 178 isOutOfScreen_ = isOutOfScreen; 179 needSync_ = true; 180 } GetIsOutOfScreen()181 bool GetIsOutOfScreen() 182 { 183 return isOutOfScreen_; 184 } GetIsRotating()185 bool GetIsRotating() const 186 { 187 return isRotating_; 188 } GetMultableSpecialLayerMgr()189 RSSpecialLayerManager& GetMultableSpecialLayerMgr() 190 { 191 return specialLayerManager_; 192 } GetSpecialLayerMgr()193 const RSSpecialLayerManager& GetSpecialLayerMgr() const 194 { 195 return specialLayerManager_; 196 } 197 HasBlackListByScreenId(ScreenId screenId)198 bool HasBlackListByScreenId(ScreenId screenId) 199 { 200 if (blackListIds_.find(screenId) != blackListIds_.end()) { 201 return blackListIds_[screenId].size() != 0; 202 } 203 return false; 204 } 205 HasPrivacyContentLayer()206 bool HasPrivacyContentLayer() 207 { 208 return privacyContentLayerIds_.size() != 0; 209 } 210 GetLeashPersistentId()211 LeashPersistentId GetLeashPersistentId() const 212 { 213 return leashPersistentId_; 214 } 215 GetName()216 std::string GetName() const 217 { 218 return name_; 219 } 220 GetBundleName()221 std::string GetBundleName() const 222 { 223 return bundleName_; 224 } 225 226 // [Attention] The function only used for unlocking screen for PC currently 227 DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetClonedNodeRenderDrawable(); 228 SetUifirstNodeEnableParam(MultiThreadCacheType isUifirst)229 bool SetUifirstNodeEnableParam(MultiThreadCacheType isUifirst) 230 { 231 if (uiFirstFlag_ == isUifirst) { 232 return false; 233 } 234 uiFirstFlag_ = isUifirst; 235 needSync_ = true; 236 return true; 237 } 238 GetUifirstNodeEnableParam()239 MultiThreadCacheType GetUifirstNodeEnableParam() const 240 { 241 return uiFirstFlag_; 242 } 243 SetIsParentUifirstNodeEnableParam(bool isUifirstParent)244 void SetIsParentUifirstNodeEnableParam(bool isUifirstParent) 245 { 246 if (uiFirstParentFlag_ == isUifirstParent) { 247 return; 248 } 249 uiFirstParentFlag_ = isUifirstParent; 250 needSync_ = true; 251 } 252 SetUifirstUseStarting(NodeId id)253 void SetUifirstUseStarting(NodeId id) 254 { 255 if (uifirstUseStarting_ == id) { 256 return; 257 } 258 uifirstUseStarting_ = id; 259 needSync_ = true; 260 } 261 GetUifirstUseStarting()262 NodeId GetUifirstUseStarting() const 263 { 264 return uifirstUseStarting_; 265 } 266 SetUifirstChildrenDirtyRectParam(const RectI & rect)267 void SetUifirstChildrenDirtyRectParam(const RectI& rect) 268 { 269 childrenDirtyRect_ = rect; 270 needSync_ = true; 271 } 272 GetUifirstChildrenDirtyRectParam()273 RectI& GetUifirstChildrenDirtyRectParam() 274 { 275 return childrenDirtyRect_; 276 } GetDstRect()277 const RectI& GetDstRect() const 278 { 279 return dstRect_; 280 } 281 SetAncoSrcCrop(const Rect & srcCrop)282 void SetAncoSrcCrop(const Rect& srcCrop) { ancoSrcCrop_ = srcCrop; } GetAncoSrcCrop()283 const Rect& GetAncoSrcCrop() const { return ancoSrcCrop_; } SetAncoFlags(const uint32_t ancoFlags)284 void SetAncoFlags(const uint32_t ancoFlags) { ancoFlags_ = ancoFlags; } GetAncoFlags()285 uint32_t GetAncoFlags() const { return ancoFlags_; } 286 287 void SetSurfaceCacheContentStatic(bool contentStatic, bool lastFrameSynced); 288 bool GetSurfaceCacheContentStatic() const; 289 bool GetPreSurfaceCacheContentStatic() const; 290 291 float GetPositionZ() const; 292 293 void SetSurfaceSubTreeDirty(bool isSubTreeDirty); 294 bool GetSurfaceSubTreeDirty() const; 295 GetParentUifirstNodeEnableParam()296 bool GetParentUifirstNodeEnableParam() 297 { 298 return uiFirstParentFlag_; 299 } 300 SetUIFirstFrameGravity(Gravity gravity)301 void SetUIFirstFrameGravity(Gravity gravity) 302 { 303 if (uiFirstFrameGravity_ == gravity) { 304 return; 305 } 306 uiFirstFrameGravity_ = gravity; 307 needSync_ = true; 308 } 309 GetUIFirstFrameGravity()310 Gravity GetUIFirstFrameGravity() const 311 { 312 return uiFirstFrameGravity_; 313 } 314 315 RectI GetScreenRect() const; 316 void RecordScreenRect(RectI rect); 317 void RecordDirtyRegionMatrix(const Drawing::Matrix& matrix); 318 const Drawing::Matrix& GetDirtyRegionMatrix(); 319 320 void SetOcclusionVisible(bool visible); 321 bool GetOcclusionVisible() const override; 322 323 void SetIsParentScaling(bool isParentScaling); 324 bool IsParentScaling() const; 325 326 void SetTransparentRegion(const Occlusion::Region& transparentRegion); 327 const Occlusion::Region& GetTransparentRegion() const; 328 329 void SetOldDirtyInSurface(const RectI& oldDirtyInSurface) override; 330 RectI GetOldDirtyInSurface() const override; 331 332 void SetVisibleRegion(const Occlusion::Region& visibleRegion); 333 Occlusion::Region GetVisibleRegion() const override; 334 335 void SetVisibleRegionInVirtual(const Occlusion::Region& visibleRegion); 336 Occlusion::Region GetVisibleRegionInVirtual() const; 337 338 void SetOccludedByFilterCache(bool val); 339 bool GetOccludedByFilterCache() const; 340 341 void SetFilterCacheFullyCovered(bool val); 342 bool GetFilterCacheFullyCovered() const; 343 bool GetAttractionAnimation() const; 344 345 const std::vector<NodeId>& GetVisibleFilterChild() const; 346 bool IsTransparent() const; 347 void CheckValidFilterCacheFullyCoverTarget( 348 bool isFilterCacheValidForOcclusion, const RectI& filterCachedRect, const RectI& targetRect); 349 350 void SetLayerInfo(const RSLayerInfo& layerInfo); 351 const RSLayerInfo& GetLayerInfo() const override; 352 void SetHardwareEnabled(bool enabled); 353 bool GetHardwareEnabled() const override; 354 void SetNeedMakeImage(bool enabled); 355 bool GetNeedMakeImage() const override; 356 void SetHardCursorStatus(bool status); 357 bool GetHardCursorStatus() const override; 358 void SetPreSubHighPriorityType(bool enabledType); 359 bool GetPreSubHighPriorityType() const; 360 void SetLastFrameHardwareEnabled(bool enabled); 361 bool GetLastFrameHardwareEnabled() const override; 362 void SetFixRotationByUser(bool flag); 363 bool GetFixRotationByUser() const; 364 void SetInFixedRotation(bool flag); 365 bool IsInFixedRotation() const; 366 // source crop tuning 367 void SetLayerSourceTuning(int32_t needSourceTuning); 368 int32_t GetLayerSourceTuning() const; 369 void SetTunnelLayerId(const uint64_t& tunnelLayerId); 370 uint64_t GetTunnelLayerId() const; 371 372 void SetGpuOverDrawBufferOptimizeNode(bool overDrawNode); 373 bool IsGpuOverDrawBufferOptimizeNode() const; 374 void SetOverDrawBufferNodeCornerRadius(const Vector4f& radius); 375 const Vector4f& GetOverDrawBufferNodeCornerRadius() const; 376 377 void SetIsSubSurfaceNode(bool isSubSurfaceNode); 378 bool IsSubSurfaceNode() const; 379 380 void SetGlobalPositionEnabled(bool isEnabled); 381 bool GetGlobalPositionEnabled() const; 382 383 void SetHwcGlobalPositionEnabled(bool isEnabled); 384 bool GetHwcGlobalPositionEnabled() const; 385 386 void SetHwcCrossNode(bool isCrossNode); 387 bool IsHwcCrossNode() const; 388 389 void SetIsNodeToBeCaptured(bool isNodeToBeCaptured); 390 bool IsNodeToBeCaptured() const; 391 392 void SetSkipDraw(bool skip); 393 bool GetSkipDraw() const; 394 395 void SetHidePrivacyContent(bool needHidePrivacyContent); 396 bool GetHidePrivacyContent() const; 397 398 void SetLayerTop(bool isTop); 399 bool IsLayerTop() const; 400 401 void SetForceRefresh(bool isForceRefresh); 402 bool IsForceRefresh() const; 403 404 bool IsVisibleDirtyRegionEmpty(const Drawing::Region curSurfaceDrawRegion) const; 405 406 void SetWatermarkEnabled(const std::string& name, bool isEnabled); 407 const std::unordered_map<std::string, bool>& GetWatermarksEnabled() const; 408 bool IsWatermarkEmpty() const; 409 410 #ifndef ROSEN_CROSS_PLATFORM 411 void SetBuffer(const sptr<SurfaceBuffer>& buffer, const Rect& damageRect) override; 412 sptr<SurfaceBuffer> GetBuffer() const override; 413 void SetPreBuffer(const sptr<SurfaceBuffer>& preBuffer) override; 414 sptr<SurfaceBuffer> GetPreBuffer() override; 415 void SetAcquireFence(const sptr<SyncFence>& acquireFence) override; 416 sptr<SyncFence> GetAcquireFence() const override; 417 const Rect& GetBufferDamage() const override; SetBufferSynced(bool bufferSynced)418 inline void SetBufferSynced(bool bufferSynced) 419 { 420 bufferSynced_ = bufferSynced; 421 } IsBufferSynced()422 bool IsBufferSynced() const 423 { 424 return bufferSynced_; 425 } 426 #endif 427 428 virtual void OnSync(const std::unique_ptr<RSRenderParams>& target) override; 429 SetRoundedCornerRegion(const Occlusion::Region & roundedCornerRegion)430 void SetRoundedCornerRegion(const Occlusion::Region& roundedCornerRegion) 431 { 432 roundedCornerRegion_ = roundedCornerRegion; 433 } 434 GetRoundedCornerRegion()435 const Occlusion::Region& GetRoundedCornerRegion() const 436 { 437 return roundedCornerRegion_; 438 } 439 440 // DFX 441 std::string ToString() const override; 442 // Set/Get OpaqueRegion, currently only used for DFX 443 void SetOpaqueRegion(const Occlusion::Region& opaqueRegion); 444 const Occlusion::Region& GetOpaqueRegion() const; 445 SetNeedOffscreen(bool needOffscreen)446 void SetNeedOffscreen(bool needOffscreen) 447 { 448 if (needOffscreen_ == needOffscreen) { 449 return; 450 } 451 needOffscreen_ = needOffscreen; 452 needSync_ = true; 453 } 454 GetNeedOffscreen()455 bool GetNeedOffscreen() const 456 { 457 return RSSystemProperties::GetSurfaceOffscreenEnadbled() ? needOffscreen_ : false; 458 } 459 SetLayerCreated(bool layerCreated)460 void SetLayerCreated(bool layerCreated) override 461 { 462 layerCreated_ = layerCreated; 463 } 464 GetLayerCreated()465 bool GetLayerCreated() const override 466 { 467 return layerCreated_; 468 } SetTotalMatrix(const Drawing::Matrix & totalMatrix)469 void SetTotalMatrix(const Drawing::Matrix& totalMatrix) override 470 { 471 if (totalMatrix_ == totalMatrix) { 472 return; 473 } 474 totalMatrix_ = totalMatrix; 475 needSync_ = true; 476 } GetTotalMatrix()477 const Drawing::Matrix& GetTotalMatrix() override 478 { 479 return totalMatrix_; 480 } SetFingerprint(bool hasFingerprint)481 void SetFingerprint(bool hasFingerprint) override 482 { 483 if (hasFingerprint_ == hasFingerprint) { 484 return; 485 } 486 hasFingerprint_ = hasFingerprint; 487 needSync_ = true; 488 } GetFingerprint()489 bool GetFingerprint() override { 490 return false; 491 } 492 SetCornerRadiusInfoForDRM(const std::vector<float> & drmCornerRadiusInfo)493 void SetCornerRadiusInfoForDRM(const std::vector<float>& drmCornerRadiusInfo) 494 { 495 if (drmCornerRadiusInfo_ == drmCornerRadiusInfo) { 496 return; 497 } 498 drmCornerRadiusInfo_ = drmCornerRadiusInfo; 499 needSync_ = true; 500 } 501 SetForceDisableClipHoleForDRM(bool isForceDisable)502 void SetForceDisableClipHoleForDRM(bool isForceDisable) 503 { 504 if (isForceDisableClipHoleForDRM_ == isForceDisable) { 505 return; 506 } 507 isForceDisableClipHoleForDRM_ = isForceDisable; 508 needSync_ = true; 509 } 510 GetForceDisableClipHoleForDRM()511 bool GetForceDisableClipHoleForDRM() const 512 { 513 return isForceDisableClipHoleForDRM_; 514 } 515 GetCornerRadiusInfoForDRM()516 const std::vector<float>& GetCornerRadiusInfoForDRM() const 517 { 518 return drmCornerRadiusInfo_; 519 } 520 SetHDRPresent(bool hasHdrPresent)521 void SetHDRPresent(bool hasHdrPresent) 522 { 523 if (hasHdrPresent_ == hasHdrPresent) { 524 return; 525 } 526 hasHdrPresent_ = hasHdrPresent; 527 needSync_ = true; 528 } 529 GetHDRPresent()530 bool GetHDRPresent() const 531 { 532 return hasHdrPresent_; 533 } 534 SetSdrNit(float sdrNit)535 void SetSdrNit(float sdrNit) 536 { 537 if (ROSEN_EQ(sdrNit_, sdrNit)) { 538 return; 539 } 540 sdrNit_ = sdrNit; 541 needSync_ = true; 542 } 543 GetSdrNit()544 float GetSdrNit() const 545 { 546 return sdrNit_; 547 } 548 SetColorFollow(bool colorFollow)549 void SetColorFollow(bool colorFollow) 550 { 551 if (colorFollow_ == colorFollow) { 552 return; 553 } 554 colorFollow_ = colorFollow; 555 needSync_ = true; 556 } 557 GetColorFollow()558 bool GetColorFollow() const 559 { 560 return colorFollow_; 561 } 562 SetDisplayNit(float displayNit)563 void SetDisplayNit(float displayNit) 564 { 565 if (ROSEN_EQ(displayNit_, displayNit)) { 566 return; 567 } 568 displayNit_ = displayNit; 569 needSync_ = true; 570 } 571 GetDisplayNit()572 float GetDisplayNit() const 573 { 574 return displayNit_; 575 } 576 SetBrightnessRatio(float brightnessRatio)577 void SetBrightnessRatio(float brightnessRatio) 578 { 579 if (ROSEN_EQ(brightnessRatio_, brightnessRatio)) { 580 return; 581 } 582 brightnessRatio_ = brightnessRatio; 583 needSync_ = true; 584 } 585 GetBrightnessRatio()586 float GetBrightnessRatio() const 587 { 588 return brightnessRatio_; 589 } 590 SetLayerLinearMatrix(const std::vector<float> & layerLinearMatrix)591 void SetLayerLinearMatrix(const std::vector<float>& layerLinearMatrix) 592 { 593 if (layerLinearMatrix_ == layerLinearMatrix) { 594 return; 595 } 596 layerLinearMatrix_ = layerLinearMatrix; 597 needSync_ = true; 598 } 599 GetLayerLinearMatrix()600 std::vector<float> GetLayerLinearMatrix() const 601 { 602 return layerLinearMatrix_; 603 } 604 SetSdrHasMetadata(bool hasMetadata)605 void SetSdrHasMetadata(bool hasMetadata) 606 { 607 if (hasMetadata_ == hasMetadata) { 608 return; 609 } 610 hasMetadata_ = hasMetadata; 611 needSync_ = true; 612 } 613 GetSdrHasMetadata()614 bool GetSdrHasMetadata() const 615 { 616 return hasMetadata_; 617 } 618 619 // [Attention] The function only used for unlocking screen for PC currently 620 bool IsCloneNode() const; 621 GetIsHwcEnabledBySolidLayer()622 bool GetIsHwcEnabledBySolidLayer() const 623 { 624 return isHwcEnabledBySolidLayer_; 625 } 626 SetIsHwcEnabledBySolidLayer(bool isHwcEnabledBySolidLayer)627 void SetIsHwcEnabledBySolidLayer(bool isHwcEnabledBySolidLayer) 628 { 629 isHwcEnabledBySolidLayer_ = isHwcEnabledBySolidLayer; 630 } 631 GetSolidLayerColor()632 Color GetSolidLayerColor() const { return solidLayerColor_; } SetSolidLayerColor(const Color & solidLayerColor)633 void SetSolidLayerColor(const Color& solidLayerColor) { solidLayerColor_ = solidLayerColor; } 634 635 void SetNeedCacheSurface(bool needCacheSurface); 636 bool GetNeedCacheSurface() const; HasSubSurfaceNodes()637 inline bool HasSubSurfaceNodes() const 638 { 639 return hasSubSurfaceNodes_; 640 } GetAllSubSurfaceNodeIds()641 const std::unordered_set<NodeId>& GetAllSubSurfaceNodeIds() const 642 { 643 return allSubSurfaceNodeIds_; 644 } GetCrossNodeSkipDisplayConversionMatrix()645 const std::unordered_map<NodeId, Drawing::Matrix>& GetCrossNodeSkipDisplayConversionMatrix() const 646 { 647 return crossNodeSkipDisplayConversionMatrices_; 648 } 649 SetApiCompatibleVersion(uint32_t apiCompatibleVersion)650 void SetApiCompatibleVersion(uint32_t apiCompatibleVersion) 651 { 652 if (ROSEN_EQ(apiCompatibleVersion_, apiCompatibleVersion)) { 653 return; 654 } 655 apiCompatibleVersion_ = apiCompatibleVersion; 656 needSync_ = true; 657 } GetApiCompatibleVersion()658 uint32_t GetApiCompatibleVersion() const 659 { 660 return apiCompatibleVersion_; 661 } 662 IsOcclusionCullingOn()663 bool IsOcclusionCullingOn() const 664 { 665 return isOcclusionCullingOn_; 666 } 667 TakeCulledNodes()668 std::unordered_set<NodeId> TakeCulledNodes() 669 { 670 return std::move(culledNodes_); 671 } 672 GetCulledNodes()673 const std::unordered_set<NodeId>& GetCulledNodes() const 674 { 675 return culledNodes_; 676 } 677 TakeCulledEntireSubtree()678 std::unordered_set<NodeId> TakeCulledEntireSubtree() 679 { 680 return std::move(culledEntireSubtree_); 681 } 682 GetCulledEntireSubtree()683 const std::unordered_set<NodeId>& GetCulledEntireSubtree() const 684 { 685 return culledEntireSubtree_; 686 } 687 688 // [Attention] The function only used for unlocking screen for PC currently ClonedSourceNode()689 bool ClonedSourceNode() const 690 { 691 return clonedSourceNode_; 692 } 693 694 // [Attention] The function only used for unlocking screen for PC currently SetIsCloned(bool isCloned)695 void SetIsCloned(bool isCloned) 696 { 697 if (clonedSourceNode_ == isCloned) { 698 return; 699 } 700 clonedSourceNode_ = isCloned; 701 needSync_ = true; 702 } 703 SetIsBufferFlushed(bool isBufferFlushed)704 void SetIsBufferFlushed(bool isBufferFlushed) 705 { 706 if (isBufferFlushed_ == isBufferFlushed) { 707 return; 708 } 709 isBufferFlushed_ = isBufferFlushed; 710 needSync_ = true; 711 } 712 GetIsBufferFlushed()713 bool GetIsBufferFlushed() const 714 { 715 return isBufferFlushed_; 716 } 717 SetIsUnobscuredUEC(bool flag)718 void SetIsUnobscuredUEC(bool flag) 719 { 720 IsUnobscuredUIExtension_ = flag; 721 } 722 IsUnobscuredUIExtension()723 bool IsUnobscuredUIExtension() const 724 { 725 return IsUnobscuredUIExtension_; 726 } 727 GetSourceDisplayRenderNodeDrawable()728 DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetSourceDisplayRenderNodeDrawable() const 729 { 730 return sourceDisplayRenderNodeDrawable_; 731 } 732 IsAbilityMagnificationNode()733 bool IsAbilityMagnificationNode() 734 { 735 return rsSurfaceNodeType_ == RSSurfaceNodeType::ABILITY_MAGNIFICATION_NODE; 736 } 737 GetRegionToBeMagnified()738 const Vector4<int>& GetRegionToBeMagnified() const 739 { 740 return regionToBeMagnified_; 741 } 742 743 void SetFrameGravityNewVersionEnabled(bool isEnabled); 744 bool GetFrameGravityNewVersionEnabled() const; 745 SetUseDeviceOffline(bool useDeviceOffline)746 void SetUseDeviceOffline(bool useDeviceOffline) 747 { 748 #ifndef ROSEN_CROSS_PLATFORM 749 layerInfo_.useDeviceOffline = useDeviceOffline; 750 #endif 751 } 752 753 private: 754 RSSurfaceNodeType rsSurfaceNodeType_ = RSSurfaceNodeType::DEFAULT; 755 SelfDrawingNodeType selfDrawingType_ = SelfDrawingNodeType::DEFAULT; 756 RSRenderNode::WeakPtr ancestorScreenNode_; 757 DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr ancestorScreenDrawable_; 758 DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr clonedNodeRenderDrawable_; 759 DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr sourceDisplayRenderNodeDrawable_; 760 761 float alpha_ = 0; 762 bool isClonedNodeOnTheTree_ = false; 763 bool isCrossNode_ = false; 764 bool isCloneNode_ = false; 765 bool clonedSourceNode_ = false; 766 bool isTransparent_ = false; 767 bool isSpherizeValid_ = false; 768 bool isAttractionValid_ = false; 769 bool isParentScaling_ = false; 770 bool needBilinearInterpolation_ = false; 771 MultiThreadCacheType uiFirstFlag_ = MultiThreadCacheType::NONE; 772 bool uiFirstParentFlag_ = false; 773 Color backgroundColor_ = RgbPalette::Transparent(); 774 bool isHwcEnabledBySolidLayer_ = false; 775 RectI screenRect_; 776 Drawing::Matrix dirtyRegionMatrix_; 777 Color solidLayerColor_ = RgbPalette::Transparent(); 778 779 RectI dstRect_; 780 RectI oldDirtyInSurface_; 781 RectI childrenDirtyRect_; 782 RRect rrect_; 783 Rect ancoSrcCrop_{}; 784 uint32_t ancoFlags_ = 0; 785 Vector4<int> regionToBeMagnified_; 786 NodeId uifirstUseStarting_ = INVALID_NODEID; 787 Occlusion::Region transparentRegion_; 788 Occlusion::Region roundedCornerRegion_; 789 Occlusion::Region opaqueRegion_; 790 791 bool IsUnobscuredUIExtension_ = false; 792 793 LeashPersistentId leashPersistentId_ = INVALID_LEASH_PERSISTENTID; 794 795 bool surfaceCacheContentStatic_ = false; 796 bool preSurfaceCacheContentStatic_ = false; 797 bool isSubTreeDirty_ = false; 798 float positionZ_ = 0.0f; 799 bool occlusionVisible_ = false; 800 Occlusion::Region visibleRegion_; 801 Occlusion::Region visibleRegionInVirtual_; 802 bool isOccludedByFilterCache_ = false; 803 // if current surfaceNode has filter cache to occlude the back surfaceNode 804 bool isFilterCacheFullyCovered_ = false; 805 bool isAttractionAnimation_ = false; 806 std::vector<NodeId> visibleFilterChild_; 807 RSLayerInfo layerInfo_; 808 RSWindowInfo windowInfo_; 809 #ifndef ROSEN_CROSS_PLATFORM 810 sptr<SurfaceBuffer> buffer_ = nullptr; 811 sptr<SurfaceBuffer> preBuffer_ = nullptr; 812 sptr<SyncFence> acquireFence_ = SyncFence::InvalidFence(); 813 Rect damageRect_ = {0, 0, 0, 0}; 814 bool bufferSynced_ = true; 815 #endif 816 bool isHardwareEnabled_ = false; 817 bool needMakeImage_ = false; 818 bool isHardCursor_ = false; 819 bool isLastFrameHardwareEnabled_ = false; 820 bool subHighPriorityType_ = false; 821 bool isFixRotationByUser_ = false; 822 bool isInFixedRotation_ = false; 823 int32_t releaseInHardwareThreadTaskNum_ = 0; 824 bool animateState_ = false; 825 bool isOutOfScreen_ = false; 826 bool isRotating_ = false; 827 bool isSubSurfaceNode_ = false; 828 bool isGlobalPositionEnabled_ = false; 829 Gravity uiFirstFrameGravity_ = Gravity::TOP_LEFT; 830 bool isNodeToBeCaptured_ = false; 831 RSSpecialLayerManager specialLayerManager_; 832 std::unordered_map<ScreenId, std::unordered_set<NodeId>> blackListIds_ = {}; 833 std::set<NodeId> privacyContentLayerIds_ = {}; 834 std::set<int32_t> bufferCacheSet_ = {}; 835 std::string name_= ""; 836 std::string bundleName_= ""; 837 Vector4f overDrawBufferNodeCornerRadius_; 838 bool isGpuOverDrawBufferOptimizeNode_ = false; 839 bool isSkipDraw_ = false; 840 bool isLayerTop_ = false; 841 bool isForceRefresh_ = false; 842 bool needHidePrivacyContent_ = false; 843 bool needOffscreen_ = false; 844 bool layerCreated_ = false; 845 int32_t layerSource_ = 0; 846 uint64_t tunnelLayerId_ = 0; 847 int64_t stencilVal_ = -1; 848 std::unordered_map<std::string, bool> watermarkHandles_ = {}; 849 std::vector<float> drmCornerRadiusInfo_; 850 bool isForceDisableClipHoleForDRM_ = false; 851 852 bool isHwcGlobalPositionEnabled_ = false; 853 bool isHwcCrossNode_ = false; 854 855 Drawing::Matrix totalMatrix_; 856 float globalAlpha_ = 1.0f; 857 bool hasFingerprint_ = false; 858 // hdr 859 bool hasHdrPresent_ = false; 860 float sdrNit_ = 500.0f; // default sdrNit 861 float displayNit_ = 500.0f; // default displayNit_ 862 float brightnessRatio_ = 1.0f; // 1.0f means no discount. 863 bool colorFollow_ = false; 864 865 // color temperature 866 std::vector<float> layerLinearMatrix_; // matrix for linear colorspace 867 bool hasMetadata_ = false; // SDR with metadata 868 bool needCacheSurface_ = false; 869 870 bool hasSubSurfaceNodes_ = false; 871 std::unordered_set<NodeId> allSubSurfaceNodeIds_ = {}; 872 std::unordered_map<NodeId, Drawing::Matrix> crossNodeSkipDisplayConversionMatrices_ = {}; 873 874 uint32_t apiCompatibleVersion_ = 0; 875 876 bool isOcclusionCullingOn_ = false; 877 std::unordered_set<NodeId> culledNodes_; 878 std::unordered_set<NodeId> culledEntireSubtree_; 879 880 friend class RSSurfaceRenderNode; 881 friend class RSUniRenderProcessor; 882 friend class RSUniRenderThread; 883 884 bool isBufferFlushed_ = false; 885 bool isFrameGravityNewVersionEnabled_ = false; 886 }; 887 } // namespace OHOS::Rosen 888 #endif // RENDER_SERVICE_BASE_PARAMS_RS_SURFACE_RENDER_PARAMS_H 889