1 /* 2 * Copyright (c) 2022-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_CORE_PIPELINE_RS_UNI_RENDER_VISITOR_H 16 #define RENDER_SERVICE_CORE_PIPELINE_RS_UNI_RENDER_VISITOR_H 17 18 #include <cstdint> 19 #include <list> 20 #include <memory> 21 #include <mutex> 22 #include <optional> 23 #include <parameters.h> 24 #include <set> 25 26 #include "rs_base_render_engine.h" 27 28 #include "pipeline/driven_render/rs_driven_render_manager.h" 29 #include "pipeline/round_corner_display/rs_rcd_render_manager.h" 30 #include "pipeline/rs_dirty_region_manager.h" 31 #include "pipeline/rs_processor.h" 32 #include "platform/ohos/overdraw/rs_cpu_overdraw_canvas_listener.h" 33 #include "platform/ohos/overdraw/rs_gpu_overdraw_canvas_listener.h" 34 #include "platform/ohos/overdraw/rs_overdraw_controller.h" 35 #include "screen_manager/rs_screen_manager.h" 36 #include "system/rs_system_parameters.h" 37 #include "visitor/rs_node_visitor.h" 38 #include "pipeline/rs_recording_canvas.h" 39 40 class SkPicture; 41 namespace OHOS { 42 namespace Rosen { 43 class RSPaintFilterCanvas; 44 class RSUniRenderVisitor : public RSNodeVisitor { 45 public: 46 using SurfaceDirtyMgrPair = std::pair<std::shared_ptr<RSSurfaceRenderNode>, std::shared_ptr<RSSurfaceRenderNode>>; 47 RSUniRenderVisitor(); 48 RSUniRenderVisitor(std::shared_ptr<RSPaintFilterCanvas> canvas, uint32_t surfaceIndex); 49 explicit RSUniRenderVisitor(const RSUniRenderVisitor& visitor); 50 ~RSUniRenderVisitor() override; 51 52 void PrepareChildren(RSRenderNode& node) override; 53 void PrepareCanvasRenderNode(RSCanvasRenderNode& node) override; 54 void PrepareDisplayRenderNode(RSDisplayRenderNode& node) override; 55 void PrepareProxyRenderNode(RSProxyRenderNode& node) override; 56 void PrepareRootRenderNode(RSRootRenderNode& node) override; 57 void PrepareSurfaceRenderNode(RSSurfaceRenderNode& node) override; 58 void PrepareEffectRenderNode(RSEffectRenderNode& node) override; 59 60 void ProcessChildren(RSRenderNode& node) override; 61 void ProcessChildInner(RSRenderNode& node, const RSRenderNode::SharedPtr child); 62 void ProcessCanvasRenderNode(RSCanvasRenderNode& node) override; 63 void ProcessDisplayRenderNode(RSDisplayRenderNode& node) override; 64 void ProcessProxyRenderNode(RSProxyRenderNode& node) override; 65 void ProcessRootRenderNode(RSRootRenderNode& node) override; 66 void ProcessSurfaceRenderNode(RSSurfaceRenderNode& node) override; 67 void ProcessEffectRenderNode(RSEffectRenderNode& node) override; 68 69 bool DoDirectComposition(std::shared_ptr<RSBaseRenderNode> rootNode); 70 bool ParallelComposition(const std::shared_ptr<RSBaseRenderNode> rootNode); 71 void ChangeCacheRenderNodeMap(RSRenderNode& node, const uint32_t count = 0); 72 void UpdateCacheRenderNodeMap(RSRenderNode& node); 73 bool GenerateNodeContentCache(RSRenderNode& node); 74 bool InitNodeCache(RSRenderNode& node); 75 void CopyVisitorInfos(std::shared_ptr<RSUniRenderVisitor> visitor); 76 void CheckSkipRepeatShadow(RSRenderNode& node, const bool resetStatus); 77 void SetNodeSkipShadow(std::shared_ptr<RSRenderNode> node, const bool resetStatus); SetProcessorRenderEngine(std::shared_ptr<RSBaseRenderEngine> renderEngine)78 void SetProcessorRenderEngine(std::shared_ptr<RSBaseRenderEngine> renderEngine) 79 { 80 renderEngine_ = renderEngine; 81 } 82 SetAnimateState(bool doAnimate)83 void SetAnimateState(bool doAnimate) 84 { 85 doAnimate_ = doAnimate; 86 } 87 SetDirtyFlag(bool isDirty)88 void SetDirtyFlag(bool isDirty) 89 { 90 isDirty_ = isDirty; 91 } 92 SetFocusedNodeId(uint64_t nodeId,uint64_t leashId)93 void SetFocusedNodeId(uint64_t nodeId, uint64_t leashId) 94 { 95 currentFocusedNodeId_ = nodeId; 96 focusedLeashWindowId_ = leashId; 97 } 98 SetSubThreadConfig(uint32_t threadIndex)99 void SetSubThreadConfig(uint32_t threadIndex) 100 { 101 isSubThread_ = true; 102 isHardwareForcedDisabled_ = true; 103 threadIndex_ = threadIndex; 104 } 105 106 void DrawSurfaceLayer(const std::shared_ptr<RSDisplayRenderNode>& displayNode, 107 const std::list<std::shared_ptr<RSSurfaceRenderNode>>& subThreadNodes) const; 108 GetAnimateState()109 bool GetAnimateState() const 110 { 111 return doAnimate_; 112 } 113 MarkHardwareForcedDisabled()114 void MarkHardwareForcedDisabled() 115 { 116 isHardwareForcedDisabled_ = true; 117 } 118 SetDrivenRenderFlag(bool hasDrivenNodeOnUniTree,bool hasDrivenNodeMarkRender)119 void SetDrivenRenderFlag(bool hasDrivenNodeOnUniTree, bool hasDrivenNodeMarkRender) 120 { 121 if (!drivenInfo_) { 122 return; 123 } 124 drivenInfo_->prepareInfo.hasDrivenNodeOnUniTree = hasDrivenNodeOnUniTree; 125 drivenInfo_->hasDrivenNodeMarkRender = hasDrivenNodeMarkRender; 126 } 127 128 void UpdateHardwareEnabledInfoBeforeCreateLayer(); 129 void SetHardwareEnabledNodes(const std::vector<std::shared_ptr<RSSurfaceRenderNode>>& hardwareEnabledNodes); 130 void AssignGlobalZOrderAndCreateLayer(std::vector<std::shared_ptr<RSSurfaceRenderNode>>& nodesInZOrder); 131 void ScaleMirrorIfNeed(RSDisplayRenderNode& node, bool canvasRotation = false); 132 133 void CopyForParallelPrepare(std::shared_ptr<RSUniRenderVisitor> visitor); 134 // Some properties defined before ProcessSurfaceRenderNode() may be used in 135 // ProcessSurfaceRenderNode() method. We should copy these properties in parallel render. 136 void CopyPropertyForParallelVisitor(RSUniRenderVisitor *mainVisitor); GetIsPartialRenderEnabled()137 bool GetIsPartialRenderEnabled() const 138 { 139 return isPartialRenderEnabled_; 140 } GetIsOpDropped()141 bool GetIsOpDropped() const 142 { 143 return isOpDropped_; 144 } 145 // Use in vulkan parallel rendering GetColorGamut()146 GraphicColorGamut GetColorGamut() const 147 { 148 return newColorSpace_; 149 } 150 GetProcessor()151 std::shared_ptr<RSProcessor> GetProcessor() const 152 { 153 return processor_; 154 } 155 SetRenderFrame(std::unique_ptr<RSRenderFrame> renderFrame)156 void SetRenderFrame(std::unique_ptr<RSRenderFrame> renderFrame) 157 { 158 renderFrame_ = std::move(renderFrame); 159 } 160 void SetAppWindowNum(uint32_t num); 161 SetForceUpdateFlag(bool flag)162 void SetForceUpdateFlag(bool flag) 163 { 164 forceUpdateFlag_ = flag; 165 } 166 SetScreenInfo(ScreenInfo screenInfo)167 void SetScreenInfo(ScreenInfo screenInfo) 168 { 169 screenInfo_ = screenInfo; 170 } 171 172 static void ClearRenderGroupCache(); 173 174 using RenderParam = std::tuple<std::shared_ptr<RSRenderNode>, RSPaintFilterCanvas::CanvasStatus>; 175 private: 176 void PartialRenderOptionInit(); 177 void CalcChildFilterNodeDirtyRegion(std::shared_ptr<RSSurfaceRenderNode>& currentSurfaceNode, 178 std::shared_ptr<RSDisplayRenderNode>& displayNode); 179 void CalcSurfaceFilterNodeDirtyRegion(std::shared_ptr<RSSurfaceRenderNode>& currentSurfaceNode, 180 std::shared_ptr<RSDisplayRenderNode>& displayNode); 181 void DrawWatermarkIfNeed(RSDisplayRenderNode& node, bool isMirror = false); 182 #ifndef USE_ROSEN_DRAWING 183 void DrawDirtyRectForDFX(const RectI& dirtyRect, const SkColor color, 184 const SkPaint::Style fillType, float alpha, int edgeWidth); 185 #else 186 enum class RSPaintStyle { 187 FILL, 188 STROKE 189 }; 190 void DrawDirtyRectForDFX(const RectI& dirtyRect, const Drawing::Color color, 191 const RSPaintStyle fillType, float alpha, int edgeWidth); 192 #endif 193 void DrawDirtyRegionForDFX(std::vector<RectI> dirtyRects); 194 void DrawCacheRegionForDFX(std::vector<RectI> cacheRects); 195 void DrawAllSurfaceDirtyRegionForDFX(RSDisplayRenderNode& node, const Occlusion::Region& region); 196 void DrawTargetSurfaceDirtyRegionForDFX(RSDisplayRenderNode& node); 197 void DrawAllSurfaceOpaqueRegionForDFX(RSDisplayRenderNode& node); 198 void DrawSurfaceOpaqueRegionForDFX(RSSurfaceRenderNode& node); 199 void DrawTargetSurfaceVisibleRegionForDFX(RSDisplayRenderNode& node); 200 void DrawCurrentRefreshRate(uint32_t currentRefreshRate, uint32_t realtimeRefreshRate); 201 // check if surface name is in dfx target list CheckIfSurfaceTargetedForDFX(std::string nodeName)202 inline bool CheckIfSurfaceTargetedForDFX(std::string nodeName) 203 { 204 return (std::find(dfxTargetSurfaceNames_.begin(), dfxTargetSurfaceNames_.end(), 205 nodeName) != dfxTargetSurfaceNames_.end()); 206 } 207 208 bool DrawDetailedTypesOfDirtyRegionForDFX(RSSurfaceRenderNode& node); 209 void DrawAndTraceSingleDirtyRegionTypeForDFX(RSSurfaceRenderNode& node, 210 DirtyRegionType dirtyType, bool isDrawn = true); 211 212 bool IsNotDirtyHardwareEnabledTopSurface(std::shared_ptr<RSSurfaceRenderNode>& node) const; 213 std::vector<RectI> GetDirtyRects(const Occlusion::Region ®ion); 214 /* calculate display/global (between windows) level dirty region, current include: 215 * 1. window move/add/remove 2. transparent dirty region 216 * when process canvas culling, canvas intersect with surface's visibledirty region or 217 * global dirty region will be skipped 218 */ 219 void CalcDirtyDisplayRegion(std::shared_ptr<RSDisplayRenderNode>& node); 220 void CalcDirtyRegionForFilterNode(const RectI& filterRect, 221 std::shared_ptr<RSSurfaceRenderNode>& currentSurfaceNode, 222 std::shared_ptr<RSDisplayRenderNode>& displayNode); 223 224 // remove functions below when dirty region is enabled for foldable device 225 void UpdateHardwareNodeStatusBasedOnFilterRegion(RSDisplayRenderNode& displayNode); 226 void UpdateHardwareNodeStatusBasedOnFilter(std::shared_ptr<RSSurfaceRenderNode>& node, 227 std::vector<std::shared_ptr<RSSurfaceRenderNode>>& prevHwcEnabledNodes); 228 void UpdateHardwareEnableList(std::vector<RectI>& filterRects, 229 std::vector<std::shared_ptr<RSSurfaceRenderNode>>& validHwcNodes); 230 // remove functions above when dirty region is enabled for foldable device 231 232 void CalcDirtyFilterRegion(std::shared_ptr<RSDisplayRenderNode>& node); 233 /* Disable visible hwc surface if it intersects with filter region 234 * Save rest validNodes in prevHwcEnabledNodes 235 * [planning] Update hwc surface dirty status at the same time 236 */ 237 void UpdateHardwareNodeStatusBasedOnFilter(std::shared_ptr<RSSurfaceRenderNode>& node, 238 std::vector<SurfaceDirtyMgrPair>& prevHwcEnabledNodes, 239 std::shared_ptr<RSDirtyRegionManager>& displayDirtyManager); 240 /* Disable hwc surface intersect with filter rects and merge dirty filter region 241 * [planning] If invisible filterRects could be removed 242 */ 243 RectI UpdateHardwareEnableList(std::vector<RectI>& filterRects, 244 std::vector<SurfaceDirtyMgrPair>& validHwcNodes); 245 void MergeDirtyRectIfNeed(std::shared_ptr<RSSurfaceRenderNode> appNode, 246 std::shared_ptr<RSSurfaceRenderNode> hwcNode); 247 void AddContainerDirtyToGlobalDirty(std::shared_ptr<RSDisplayRenderNode>& node) const; 248 // merge last childRect as dirty if any child has been removed 249 void MergeRemovedChildDirtyRegion(RSRenderNode& node); 250 // Reset curSurface info as upper surfaceParent in case surfaceParent has multi children 251 void ResetCurSurfaceInfoAsUpperSurfaceParent(RSSurfaceRenderNode& node); 252 253 // set global dirty region to each surface node 254 void SetSurfaceGlobalDirtyRegion(std::shared_ptr<RSDisplayRenderNode>& node); 255 void SetSurfaceGlobalAlignedDirtyRegion(std::shared_ptr<RSDisplayRenderNode>& node, 256 const Occlusion::Region alignedDirtyRegion); 257 void AlignGlobalAndSurfaceDirtyRegions(std::shared_ptr<RSDisplayRenderNode>& node); 258 259 void CheckAndSetNodeCacheType(RSRenderNode& node); 260 bool UpdateCacheSurface(RSRenderNode& node); 261 void DrawSpherize(RSRenderNode& node); 262 void DrawChildRenderNode(RSRenderNode& node); 263 void DrawChildCanvasRenderNode(RSRenderNode& node); 264 265 void RotateMirrorCanvasIfNeed(RSDisplayRenderNode& node); 266 void CheckColorSpace(RSSurfaceRenderNode& node); 267 void HandleColorGamuts(RSDisplayRenderNode& node, const sptr<RSScreenManager>& screenManager); 268 void CheckPixelFormat(RSSurfaceRenderNode& node); 269 void HandlePixelFormat(RSDisplayRenderNode& node, const sptr<RSScreenManager>& screenManager); 270 void AddOverDrawListener(std::unique_ptr<RSRenderFrame>& renderFrame, 271 std::shared_ptr<RSCanvasListener>& overdrawListener); 272 /* Judge if surface render node could skip preparation: 273 * 1. not leash window 274 * 2. parent not dirty 275 * 3. no processWithCommands_ of node's corresponding pid 276 * If so, reset status flag and stop traversal 277 */ 278 bool CheckIfSurfaceRenderNodeStatic(RSSurfaceRenderNode& node); 279 /* Judge if uifirst surface render node could skip subtree preparation: 280 * mainwindow check if it has leashwindow parent 281 * If so, check parent or check itself 282 */ 283 bool CheckIfUIFirstSurfaceContentReusable(std::shared_ptr<RSSurfaceRenderNode>& node, bool& isAssigned); 284 // currently classify surface assigned subthread specific dirty case for preparation 285 void ClassifyUIFirstSurfaceDirtyStatus(RSSurfaceRenderNode& node); 286 287 void PrepareTypesOfSurfaceRenderNodeBeforeUpdate(RSSurfaceRenderNode& node); 288 void PrepareTypesOfSurfaceRenderNodeAfterUpdate(RSSurfaceRenderNode& node); 289 // judge if node's cache changes 290 // return false if cache static and simplify its subtree traversal 291 bool UpdateCacheChangeStatus(RSRenderNode& node); 292 bool IsDrawingCacheStatic(RSRenderNode& node); 293 // if cache root reuses, update its subtree 294 // [attention] check curSurfaceDirtyManager_ before function calls 295 void UpdateSubTreeInCache(const std::shared_ptr<RSRenderNode>& cacheRootNode, 296 const std::vector<RSRenderNode::SharedPtr>& children); 297 // set node cacheable animation after checking whold child tree 298 void SetNodeCacheChangeStatus(RSRenderNode& node); 299 void DisableNodeCacheInSetting(RSRenderNode& node); 300 // update rendernode's cache status and collect valid cache rect 301 void UpdateForegroundFilterCacheWithDirty(RSRenderNode& node, RSDirtyRegionManager& dirtyManager); 302 303 bool IsHardwareComposerEnabled(); 304 305 // choose to keep filter cache if node is filter occluded 306 bool CheckIfSurfaceRenderNodeNeedProcess(RSSurfaceRenderNode& node, bool& keepFilterCache); 307 308 void ClearTransparentBeforeSaveLayer(); 309 // mark surfaceNode's child surfaceView nodes hardware forced disabled 310 void MarkSubHardwareEnableNodeState(RSSurfaceRenderNode& surfaceNode); 311 void CollectAppNodeForHwc(std::shared_ptr<RSSurfaceRenderNode> surfaceNode); 312 void UpdateSecurityAndSkipLayerRecord(RSSurfaceRenderNode& node); 313 void PrepareEffectNodeIfCacheReuse(const std::shared_ptr<RSRenderNode>& cacheRootNode, 314 std::shared_ptr<RSEffectRenderNode> effectNode); 315 316 // offscreen render related 317 void PrepareOffscreenRender(RSRenderNode& node); 318 void FinishOffscreenRender(bool isMirror = false); 319 void ParallelPrepareDisplayRenderNodeChildrens(RSDisplayRenderNode& node); 320 bool AdaptiveSubRenderThreadMode(bool doParallel); 321 void ParallelRenderEnableHardwareComposer(RSSurfaceRenderNode& node); 322 // close partialrender when perform window animation 323 void ClosePartialRenderWhenAnimatingWindows(std::shared_ptr<RSDisplayRenderNode>& node); 324 bool DrawBlurInCache(RSRenderNode& node); 325 void UpdateCacheRenderNodeMapWithBlur(RSRenderNode& node); 326 bool IsFirstVisitedCacheForced() const; 327 bool IsRosenWebHardwareDisabled(RSSurfaceRenderNode& node, int rotation) const; 328 bool ForceHardwareComposer(RSSurfaceRenderNode& node) const; 329 bool UpdateSrcRectForHwcNode(RSSurfaceRenderNode& node); // return if srcRect is allowed by dss restriction 330 #ifndef USE_ROSEN_DRAWING 331 sk_sp<SkImage> GetCacheImageFromMirrorNode(std::shared_ptr<RSDisplayRenderNode> mirrorNode); 332 #else 333 std::shared_ptr<Drawing::Image> GetCacheImageFromMirrorNode(std::shared_ptr<RSDisplayRenderNode> mirrorNode); 334 #endif 335 336 void SwitchColorFilterDrawing(int currentSaveCount); 337 void ProcessShadowFirst(RSRenderNode& node, bool inSubThread); 338 void SaveCurSurface(std::shared_ptr<RSDirtyRegionManager> dirtyManager, 339 std::shared_ptr<RSSurfaceRenderNode> surfaceNode); 340 void RestoreCurSurface(std::shared_ptr<RSDirtyRegionManager> &dirtyManager, 341 std::shared_ptr<RSSurfaceRenderNode> &surfaceNode); 342 void PrepareSubSurfaceNodes(RSSurfaceRenderNode& node); 343 void ProcessSubSurfaceNodes(RSSurfaceRenderNode& node); 344 345 #ifndef USE_ROSEN_DRAWING 346 sk_sp<SkSurface> offscreenSurface_; // temporary holds offscreen surface 347 #else 348 std::shared_ptr<Drawing::Surface> offscreenSurface_; // temporary holds offscreen surface 349 #endif 350 std::shared_ptr<RSPaintFilterCanvas> canvasBackup_; // backup current canvas before offscreen render 351 352 // Use in vulkan parallel rendering 353 void ProcessParallelDisplayRenderNode(RSDisplayRenderNode& node); 354 bool IsOutOfScreenRegion(RectI rect); 355 356 ScreenInfo screenInfo_; 357 std::shared_ptr<RSDirtyRegionManager> curSurfaceDirtyManager_; 358 std::shared_ptr<RSSurfaceRenderNode> curSurfaceNode_; 359 std::stack<std::shared_ptr<RSDirtyRegionManager>> surfaceDirtyManager_; 360 std::stack<std::shared_ptr<RSSurfaceRenderNode>> surfaceNode_; 361 float curAlpha_ = 1.f; 362 Vector4f curCornerRadius_{ 0.f, 0.f, 0.f, 0.f }; 363 bool dirtyFlag_ { false }; 364 std::unique_ptr<RSRenderFrame> renderFrame_; 365 std::shared_ptr<RSPaintFilterCanvas> canvas_; 366 std::map<NodeId, std::shared_ptr<RSSurfaceRenderNode>> dirtySurfaceNodeMap_; 367 std::vector<RectI> cacheRenderNodeMapRects_; 368 #ifndef USE_ROSEN_DRAWING 369 SkRect boundsRect_ {}; 370 #else 371 Drawing::Rect boundsRect_ {}; 372 #endif 373 Gravity frameGravity_ = Gravity::DEFAULT; 374 375 int32_t offsetX_ { 0 }; 376 int32_t offsetY_ { 0 }; 377 std::shared_ptr<RSProcessor> processor_; 378 #ifndef USE_ROSEN_DRAWING 379 SkMatrix parentSurfaceNodeMatrix_; 380 #else 381 Drawing::Matrix parentSurfaceNodeMatrix_; 382 #endif 383 384 ScreenId currentVisitDisplay_ = INVALID_SCREEN_ID; 385 std::map<ScreenId, bool> displayHasSecSurface_; 386 std::map<ScreenId, bool> displayHasSkipSurface_; 387 std::map<ScreenId, bool> hasCaptureWindow_; 388 std::set<ScreenId> mirroredDisplays_; 389 bool isSecurityDisplay_ = false; 390 391 bool hasFingerprint_ = false; 392 bool mirrorAutoRotate_ = false; 393 394 std::shared_ptr<RSBaseRenderEngine> renderEngine_; 395 396 std::shared_ptr<RSDirtyRegionManager> curDisplayDirtyManager_; 397 std::shared_ptr<RSDisplayRenderNode> curDisplayNode_; 398 bool doAnimate_ = false; 399 bool isSurfaceRotationChanged_ = false; 400 bool isPartialRenderEnabled_ = false; 401 bool isOpDropped_ = false; 402 bool isDirtyRegionDfxEnabled_ = false; // dirtyRegion DFX visualization 403 bool isTargetDirtyRegionDfxEnabled_ = false; 404 bool isOpaqueRegionDfxEnabled_ = false; 405 bool isVisibleRegionDfxEnabled_ = false; 406 bool isDisplayDirtyDfxEnabled_ = false; 407 bool isCanvasNodeSkipDfxEnabled_ = false; 408 bool isQuickSkipPreparationEnabled_ = false; 409 bool isOcclusionEnabled_ = false; 410 bool isSkipCanvasNodeOutOfScreen_ = false; 411 bool isScreenRotationAnimating_ = false; 412 bool isTextNeedCached_ = false; 413 std::vector<std::string> dfxTargetSurfaceNames_; 414 PartialRenderType partialRenderType_; 415 QuickSkipPrepareType quickSkipPrepareType_; 416 DirtyRegionDebugType dirtyRegionDebugType_; 417 SurfaceRegionDebugType surfaceRegionDebugType_; 418 bool isRegionDebugEnabled_ = false; 419 bool isDirty_ = false; 420 // added for judge if drawing cache changes 421 bool isDrawingCacheEnabled_ = false; 422 std::stack<bool> isDrawingCacheChanged_ = {}; 423 std::vector<RectI> accumulatedDirtyRegions_ = {}; 424 bool isSubSurfaceEnabled_ = false; 425 426 bool needFilter_ = false; 427 GraphicColorGamut newColorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; 428 GraphicPixelFormat newPixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888; 429 std::vector<ScreenColorGamut> colorGamutModes_; 430 uint64_t currentFocusedNodeId_ = 0; 431 uint64_t focusedLeashWindowId_ = 0; 432 433 bool isSubThread_ = false; 434 bool isUIFirst_ = false; 435 uint32_t threadIndex_ = UNI_MAIN_THREAD_INDEX; 436 // check each surface could be reused per frame 437 // currently available to uiFirst 438 bool isCachedSurfaceReuse_ = false; 439 bool isSurfaceDirtyNodeLimited_ = false; 440 441 bool isDirtyRegionAlignedEnable_ = false; 442 std::shared_ptr<std::mutex> surfaceNodePrepareMutex_; 443 #if defined(RS_ENABLE_PARALLEL_RENDER) 444 uint32_t parallelRenderVisitorIndex_ = 0; 445 #endif 446 ParallelRenderingType parallelRenderType_; 447 448 RectI prepareClipRect_{0, 0, 0, 0}; // renderNode clip rect used in Prepare 449 450 // count prepared and processed canvasnode numbers per app 451 // unirender visitor resets every frame, no overflow risk here 452 unsigned int preparedCanvasNodeInCurrentSurface_ = 0; 453 unsigned int processedCanvasNodeInCurrentSurface_ = 0; 454 unsigned int processedPureContainerNode_ = 0; 455 456 float globalZOrder_ = 0.0f; 457 bool isUpdateCachedSurface_ = false; 458 bool isHardwareForcedDisabled_ = false; // indicates if hardware composer is totally disabled 459 std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledNodes_; 460 // vector of all app window nodes with surfaceView, sorted by zOrder 461 std::vector<std::shared_ptr<RSSurfaceRenderNode>> appWindowNodesInZOrder_; 462 // vector of hardwareEnabled nodes above displayNodeSurface like pointer window 463 std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledTopNodes_; 464 float localZOrder_ = 0.0f; // local zOrder for surfaceView under same app window node 465 466 // driven render 467 std::unique_ptr<DrivenInfo> drivenInfo_ = nullptr; 468 std::unique_ptr<RcdInfo> rcdInfo_ = nullptr; 469 470 std::unordered_map<NodeId, RenderParam> unpairedTransitionNodes_; 471 std::stack<RenderParam> curGroupedNodes_; 472 // return true if we should prepare/process, false if we should skip. 473 void PrepareSharedTransitionNode(RSBaseRenderNode& node); 474 bool ProcessSharedTransitionNode(RSBaseRenderNode& node); 475 void ProcessUnpairedSharedTransitionNode(); 476 477 std::weak_ptr<RSBaseRenderNode> logicParentNode_; 478 479 #if defined(RS_ENABLE_PARALLEL_RENDER) 480 bool isCalcCostEnable_ = false; 481 #endif 482 // adapt to sceneboard, mark if the canvasNode within the scope of surfaceNode 483 bool isSubNodeOfSurfaceInPrepare_ = false; 484 bool isSubNodeOfSurfaceInProcess_ = false; 485 486 uint32_t appWindowNum_ = 0; 487 488 bool isParallel_ = false; 489 #if defined(RS_ENABLE_PARALLEL_RENDER) 490 bool doParallelRender_ = false; 491 #endif 492 // displayNodeMatrix only used in offScreen render case to ensure correct composer layer info when with rotation, 493 // displayNodeMatrix indicates display node's matrix info 494 #ifndef USE_ROSEN_DRAWING 495 std::optional<SkMatrix> displayNodeMatrix_; 496 #else 497 std::optional<Drawing::Matrix> displayNodeMatrix_; 498 #endif 499 mutable std::mutex copyVisitorInfosMutex_; 500 bool resetRotate_ = false; 501 #ifndef USE_ROSEN_DRAWING 502 std::optional<SkIRect> effectRegion_ = std::nullopt; 503 #else 504 std::optional<Drawing::RectI> effectRegion_ = std::nullopt; 505 #endif 506 bool curDirty_ = false; 507 bool curContentDirty_ = false; 508 bool isPhone_ = false; 509 bool isPc_ = false; 510 bool isCacheBlurPartialRenderEnabled_ = false; 511 bool drawCacheWithBlur_ = false; 512 bool noNeedTodrawShadowAgain_ = false; 513 bool notRunCheckAndSetNodeCacheType_ = false; 514 int updateCacheProcessCnt_ = 0; 515 516 NodeId firstVisitedCache_ = INVALID_NODEID; 517 std::unordered_set<NodeId> visitedCacheNodeIds_ = {}; 518 std::unordered_map<NodeId, std::unordered_set<NodeId>> allCacheFilterRects_ = {}; 519 std::stack<std::unordered_set<NodeId>> curCacheFilterRects_ = {}; 520 bool forceUpdateFlag_ = false; 521 #ifdef ENABLE_RECORDING_DCL 522 void tryCapture(float width, float height); 523 void endCapture() const; 524 #ifndef USE_ROSEN_DRAWING 525 std::shared_ptr<RSRecordingCanvas> recordingCanvas_; 526 #else 527 std::shared_ptr<ExtendRecordingCanvas> recordingCanvas_; 528 #endif 529 #endif 530 bool isNodeSingleFrameComposer_ = false; 531 532 // use for screen recording optimization 533 #ifndef USE_ROSEN_DRAWING 534 sk_sp<SkImage> cacheImgForCapture_ = nullptr; 535 #else 536 std::shared_ptr<Drawing::Image> cacheImgForCapture_ = nullptr; 537 #endif 538 539 void SetHasSharedTransitionNode(RSSurfaceRenderNode& surfaceNode, bool hasSharedTransitionNode); 540 541 // attention: please synchronize the change of RSUniRenderVisitor::ProcessChildren to this func 542 void ProcessChildrenForScreenRecordingOptimization(RSDisplayRenderNode& node, NodeId rootIdOfCaptureWindow); 543 NodeId FindInstanceChildOfDisplay(std::shared_ptr<RSRenderNode> node); 544 bool CheckIfNeedResetRotate(); 545 546 // use for virtual screen app/window filtering ability 547 NodeId virtualScreenFilterAppRootId_ = INVALID_NODEID; 548 void UpdateVirtualScreenFilterAppRootId(const RSRenderNode::SharedPtr& node); 549 550 void UpdateSurfaceRenderNodeScale(RSSurfaceRenderNode& node); 551 552 // dfx for effect render node 553 void DrawEffectRenderNodeForDFX(); 554 std::vector<RectI> nodesUseEffectFallbackForDfx_; 555 std::vector<RectI> nodesUseEffectForDfx_; 556 // pair<ApplyBackgroundEffectNodeList, ApplyBackgroundEffectFallbackNodeList> 557 std::unordered_map<NodeId, std::pair<std::vector<RectI>, std::vector<RectI>>> effectNodeMapForDfx_; 558 }; 559 } // namespace Rosen 560 } // namespace OHOS 561 562 #endif // RENDER_SERVICE_CORE_PIPELINE_RS_UNI_RENDER_VISITOR_H 563