• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef ROSEN_RENDER_SERVICE_PIPELINE_RS_OCCLUSION_HANDLER_H
17 #define ROSEN_RENDER_SERVICE_PIPELINE_RS_OCCLUSION_HANDLER_H
18 #include <unordered_map>
19 
20 #include "property/rs_properties.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 class OcclusionNode;
25 class RSB_EXPORT RSOcclusionHandler : public std::enable_shared_from_this<RSOcclusionHandler> {
26 public:
RSOcclusionHandler(NodeId id)27     RSOcclusionHandler(NodeId id) : rootNodeId_(id) {}
28 
GetRootNodeId()29     NodeId GetRootNodeId() const
30     {
31         return rootNodeId_;
32     }
33 
GetOcclusionNodes()34     const std::unordered_map<NodeId, std::shared_ptr<OcclusionNode>>& GetOcclusionNodes() const
35     {
36         return occlusionNodes_;
37     }
38 
TakeCulledNodes()39     std::unordered_set<NodeId> TakeCulledNodes()
40     {
41         return std::move(culledNodes_);
42     }
43 
TakeCulledEntireSubtree()44     std::unordered_set<NodeId> TakeCulledEntireSubtree()
45     {
46         return std::move(culledEntireSubtree_);
47     }
48 
49     // Tree maintenance
50     void ProcessOffTreeNodes(const std::unordered_set<NodeId>& ids);
51     void CollectNode(const RSRenderNode& node);
52     void CollectSubTree(const RSRenderNode& node, bool isSubTreeNeedPrepare);
53     void UpdateChildrenOutOfRectInfo(const RSRenderNode& node);
54     void UpdateSkippedSubTreeProp();
55 
56     // Occlusion detection
57     void CalculateFrameOcclusion();
58 
59 private:
60     RSOcclusionHandler(const RSOcclusionHandler&) = delete;
61     RSOcclusionHandler(const RSOcclusionHandler&&) = delete;
62     RSOcclusionHandler& operator=(const RSOcclusionHandler&) = delete;
63     RSOcclusionHandler& operator=(const RSOcclusionHandler&&) = delete;
64 
65     void CollectRootNode(const RSRenderNode& node);
66     void CollectNodeInner(const RSRenderNode& node);
67     void CollectSubTreeInner(const RSRenderNode& node);
68     void DumpSubTreeOcclusionInfo(const RSRenderNode& node);
69     void DebugPostOcclusionProcessing();
70 
71     int32_t debugLevel_ = 0;
72     NodeId keyOcclusionNodeId_ = INVALID_NODEID;
73     NodeId rootNodeId_ = INVALID_NODEID;
74     std::weak_ptr<const RSRenderNode> rootNode_;
75     std::shared_ptr<OcclusionNode> rootOcclusionNode_ = nullptr;
76     std::unordered_map<NodeId, std::shared_ptr<OcclusionNode>> occlusionNodes_;
77     std::unordered_set<uint64_t> subTreeSkipPrepareNodes_;
78     std::unordered_set<NodeId> culledNodes_;
79     std::unordered_set<NodeId> culledEntireSubtree_;
80 };
81 } // namespace Rosen
82 } // namespace OHOS
83 #endif // ROSEN_RENDER_SERVICE_PIPELINE_RS_OCCLUSION_HANDLER_H
84