1 /* 2 * Copyright (c) 2025 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_LOGICAL_DISPLAY_RENDER_NODE_H 16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_LOGICAL_DISPLAY_RENDER_NODE_H 17 18 #include <memory> 19 20 #include "common/rs_common_def.h" 21 #include "common/rs_macros.h" 22 #include "common/rs_special_layer_manager.h" 23 24 #include "params/rs_logical_display_render_params.h" 25 #include "pipeline/rs_render_node.h" 26 27 28 namespace OHOS { 29 namespace Rosen { 30 class RSB_EXPORT RSLogicalDisplayRenderNode : public RSRenderNode { 31 public: 32 using WeakPtr = std::weak_ptr<RSLogicalDisplayRenderNode>; 33 using SharedPtr = std::shared_ptr<RSLogicalDisplayRenderNode>; 34 static inline constexpr auto Type = RSRenderNodeType::LOGICAL_DISPLAY_NODE; 35 36 ~RSLogicalDisplayRenderNode() override; 37 38 void QuickPrepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 39 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 40 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 41 void UpdateRenderParams() override; 42 43 RSRenderNode::ChildrenListSharedPtr GetSortedChildren() const override; 44 GetType()45 RSRenderNodeType GetType() const override 46 { 47 return Type; 48 } 49 SetScreenId(ScreenId screenId)50 void SetScreenId(ScreenId screenId) 51 { 52 screenId_ = screenId; 53 } 54 GetScreenId()55 ScreenId GetScreenId() const 56 { 57 return screenId_; 58 } 59 IsValidScreenId()60 bool IsValidScreenId() const 61 { 62 return screenId_ != INVALID_SCREEN_ID; 63 } 64 SetScbNodePid(const std::vector<int32_t> & oldScbPids,int32_t currentScbPid)65 void SetScbNodePid(const std::vector<int32_t>& oldScbPids, int32_t currentScbPid) 66 { 67 oldScbPids_ = oldScbPids; 68 lastScbPid_ = currentScbPid_; 69 currentScbPid_ = currentScbPid; 70 isNeedWaitNewScbPid_ = true; 71 isFullChildrenListValid_ = false; 72 } 73 GetOldScbPids()74 std::vector<int32_t> GetOldScbPids() const 75 { 76 return oldScbPids_; 77 } 78 GetCurrentScbPid()79 int32_t GetCurrentScbPid() const 80 { 81 return currentScbPid_; 82 } 83 SetScreenRotation(const ScreenRotation & screenRotation)84 void SetScreenRotation(const ScreenRotation& screenRotation) 85 { 86 screenRotation_ = screenRotation; 87 } 88 GetScreenRotation()89 ScreenRotation GetScreenRotation() const 90 { 91 return screenRotation_; 92 } 93 94 void SetIsOnTheTree(bool flag, NodeId instanceRootNodeId = INVALID_NODEID, 95 NodeId firstLevelNodeId = INVALID_NODEID, NodeId cacheNodeId = INVALID_NODEID, 96 NodeId uifirstRootNodeId = INVALID_NODEID, NodeId screenNodeId = INVALID_NODEID, 97 NodeId logicalDisplayNodeId = INVALID_NODEID) override; 98 99 // Window Container 100 void SetWindowContainer(std::shared_ptr<RSBaseRenderNode> container); 101 std::shared_ptr<RSBaseRenderNode> GetWindowContainer() const; 102 103 using ScreenStatusNotifyTask = std::function<void(bool)>; 104 105 static void SetScreenStatusNotifyTask(ScreenStatusNotifyTask task); 106 107 void NotifyScreenNotSwitching(); 108 109 ScreenRotation GetRotation() const; 110 void UpdateRotation(); 111 bool IsRotationChanged() const; 112 bool IsLastRotationChanged() const; 113 bool GetPreRotationStatus() const; 114 bool GetCurRotationStatus() const; 115 116 void UpdateOffscreenRenderParams(bool needOffscreen); 117 118 void SetSecurityDisplay(bool isSecurityDisplay); 119 bool GetSecurityDisplay() const; 120 void SetMirrorSource(SharedPtr node); 121 void ResetMirrorSource(); 122 WeakPtr GetMirrorSource() const; 123 void SetIsMirrorDisplay(bool isMirror); 124 bool IsMirrorDisplay() const; 125 bool IsMirrorDisplayChanged() const; 126 void ResetMirrorDisplayChangedFlag(); 127 void SetVirtualScreenMuteStatus(bool virtualScreenMuteStatus); 128 bool GetVirtualScreenMuteStatus() const; 129 void SetDisplaySpecialSurfaceChanged(bool displaySpecialSurfaceChanged); 130 131 RSSpecialLayerManager& GetMultableSpecialLayerMgr(); 132 const RSSpecialLayerManager& GetSpecialLayerMgr() const; 133 134 void AddSecurityLayer(NodeId id); 135 void ClearSecurityLayerList(); 136 const std::vector<NodeId>& GetSecurityLayerList(); 137 138 void AddSecurityVisibleLayer(NodeId id); 139 void ClearSecurityVisibleLayerList(); 140 const std::vector<NodeId>& GetSecurityVisibleLayerList(); 141 142 void SetSecurityExemption(bool isSecurityExemption); 143 bool GetSecurityExemption() const; 144 void SetHasSecLayerInVisibleRect(bool hasSecLayer); 145 146 void SetCompositeType(CompositeType type); 147 CompositeType GetCompositeType() const; 148 149 Occlusion::Region GetTopSurfaceOpaqueRegion() const; 150 RecordTopSurfaceOpaqueRects(Occlusion::Rect rect)151 void RecordTopSurfaceOpaqueRects(Occlusion::Rect rect) 152 { 153 topSurfaceOpaqueRects_.push_back(rect); 154 } 155 SetHasCaptureWindow(bool hasCaptureWindow)156 void SetHasCaptureWindow(bool hasCaptureWindow) 157 { 158 hasCaptureWindow_ = hasCaptureWindow; 159 } 160 NotifySetOnTreeFlag()161 void NotifySetOnTreeFlag() 162 { 163 waitToSetOnTree_ = true; 164 } 165 ResetSetOnTreeFlag()166 void ResetSetOnTreeFlag() 167 { 168 waitToSetOnTree_ = false; 169 } 170 IsWaitToSetOnTree()171 bool IsWaitToSetOnTree() 172 { 173 return waitToSetOnTree_; 174 } 175 176 protected: 177 void OnSync() override; 178 private: 179 explicit RSLogicalDisplayRenderNode(NodeId id, const RSDisplayNodeConfig& config, 180 const std::weak_ptr<RSContext>& context = {}, bool isTextureExportNode = false); 181 void InitRenderParams() override; 182 183 ScreenId screenId_ = INVALID_SCREEN_ID; 184 std::vector<Occlusion::Rect> topSurfaceOpaqueRects_; 185 186 // bounds rotation 187 bool preRotationStatus_ = false; 188 bool curRotationStatus_ = false; 189 bool lastRotationChanged_ = false; 190 float lastRotation_ = 0.f; 191 192 int32_t currentScbPid_ = -1; 193 int32_t lastScbPid_ = -1; 194 std::vector<int32_t> oldScbPids_ {}; 195 mutable bool isNeedWaitNewScbPid_ = false; 196 mutable std::shared_ptr<std::vector<std::shared_ptr<RSRenderNode>>> currentChildrenList_ = 197 std::make_shared<std::vector<std::shared_ptr<RSRenderNode>>>(); 198 199 ScreenRotation screenRotation_ = ScreenRotation::ROTATION_0; 200 201 bool isSecurityDisplay_ = false; 202 bool isMirrorDisplay_ = false; 203 WeakPtr mirrorSource_; 204 bool isMirrorDisplayChanged_ = false; 205 bool virtualScreenMuteStatus_ = false; 206 bool isSecurityExemption_ = false; 207 bool hasSecLayerInVisibleRect_ = false; 208 bool hasSecLayerInVisibleRectChanged_ = false; 209 CompositeType compositeType_ = CompositeType::HARDWARE_COMPOSITE; 210 bool hasCaptureWindow_ = false; 211 212 bool waitToSetOnTree_ = false; 213 214 // Use in virtual screen security exemption 215 std::vector<NodeId> securityLayerList_; // leashPersistentId and surface node id 216 RSSpecialLayerManager specialLayerManager_; 217 bool displaySpecialSurfaceChanged_ = false; 218 // Use in mirror screen visible rect projection 219 std::vector<NodeId> securityVisibleLayerList_; // surface node id 220 221 // window Container 222 std::shared_ptr<RSBaseRenderNode> windowContainer_; 223 224 static inline ScreenStatusNotifyTask screenStatusNotifyTask_ = nullptr; 225 226 friend class DisplayNodeCommandHelper; 227 }; 228 } // namespace Rosen 229 } // namespace OHOS 230 231 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_LOGICAL_DISPLAY_RENDER_NODE_H 232