• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DISPLAY_RENDER_PARAMS_H
17 #define RENDER_SERVICE_BASE_PARAMS_RS_DISPLAY_RENDER_PARAMS_H
18 
19 #include <memory>
20 
21 #include "common/rs_macros.h"
22 #include "common/rs_special_layer_manager.h"
23 #include "params/rs_render_params.h"
24 #include "pipeline/rs_display_render_node.h"
25 #include "pipeline/rs_render_node.h"
26 #include "screen_manager/rs_screen_info.h"
27 #include "pipeline/rs_surface_render_node.h"
28 namespace OHOS::Rosen {
29 class RSB_EXPORT RSDisplayRenderParams : public RSRenderParams {
30 public:
31     explicit RSDisplayRenderParams(NodeId id);
32     ~RSDisplayRenderParams() override = default;
33 
34     void OnSync(const std::unique_ptr<RSRenderParams>& target) override;
35 
36     std::vector<RSBaseRenderNode::SharedPtr>& GetAllMainAndLeashSurfaces();
37     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetAllMainAndLeashSurfaceDrawables() override;
38     void SetAllMainAndLeashSurfaces(std::vector<RSBaseRenderNode::SharedPtr>& allMainAndLeashSurfaces);
39     void SetAllMainAndLeashSurfaceDrawables(
40         std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& allMainAndLeashSurfaces);
41 
SetTopSurfaceOpaqueRects(const std::vector<Occlusion::Rect> & topSurfaceOpaqueRects)42     inline void SetTopSurfaceOpaqueRects(const std::vector<Occlusion::Rect>& topSurfaceOpaqueRects)
43     {
44         topSurfaceOpaqueRects_ = topSurfaceOpaqueRects;
45     }
46 
SetTopSurfaceOpaqueRects(std::vector<Occlusion::Rect> && topSurfaceOpaqueRects)47     inline void SetTopSurfaceOpaqueRects(std::vector<Occlusion::Rect>&& topSurfaceOpaqueRects)
48     {
49         topSurfaceOpaqueRects_ = std::move(topSurfaceOpaqueRects);
50     }
51 
52     const std::vector<Occlusion::Rect>& GetTopSurfaceOpaqueRects() const;
GetDisplayOffsetX()53     int32_t GetDisplayOffsetX() const
54     {
55         return offsetX_;
56     }
GetDisplayOffsetY()57     int32_t GetDisplayOffsetY() const
58     {
59         return offsetY_;
60     }
GetScreenId()61     uint64_t GetScreenId() const override
62     {
63         return screenId_;
64     }
GetMirroredId()65     uint64_t GetMirroredId() const
66     {
67         return mirroredId_;
68     }
GetScreenInfo()69     const ScreenInfo& GetScreenInfo() const override
70     {
71         return screenInfo_;
72     }
GetMirrorSourceId()73     NodeId GetMirrorSourceId() const
74     {
75         return mirrorSourceId_;
76     }
77 
IsDirtyAlignEnabled()78     bool IsDirtyAlignEnabled() const
79     {
80         return isDirtyAlignEnabled_;
81     }
82 
SetDirtyAlignEnabled(bool isDirtyAlignEnabled)83     void SetDirtyAlignEnabled(bool isDirtyAlignEnabled)
84     {
85         isDirtyAlignEnabled_ = isDirtyAlignEnabled;
86     }
87 
GetCompositeType()88     RSDisplayRenderNode::CompositeType GetCompositeType() const
89     {
90         return compositeType_;
91     };
GetScreenRotation()92     ScreenRotation GetScreenRotation() const override
93     {
94         return screenRotation_;
95     }
GetNodeRotation()96     ScreenRotation GetNodeRotation() const
97     {
98         return nodeRotation_;
99     }
IsMirrorScreen()100     bool IsMirrorScreen() const
101     {
102         return isMirrorScreen_;
103     }
IsFirstVisitCrossNodeDisplay()104     bool IsFirstVisitCrossNodeDisplay() const
105     {
106         return isFirstVisitCrossNodeDisplay_;
107     }
HasChildCrossNode()108     bool HasChildCrossNode() const
109     {
110         return hasChildCrossNode_;
111     }
GetMultableSpecialLayerMgr()112     RSSpecialLayerManager& GetMultableSpecialLayerMgr()
113     {
114         return specialLayerManager_;
115     }
GetSpecialLayerMgr()116     const RSSpecialLayerManager& GetSpecialLayerMgr() const
117     {
118         return specialLayerManager_;
119     }
GethasCaptureWindow()120     const std::map<ScreenId, bool>& GethasCaptureWindow() const
121     {
122         return hasCaptureWindow_;
123     }
124 
GetHardwareEnabledDrawables()125     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetHardwareEnabledDrawables()
126     {
127         return hardwareEnabledDrawables_;
128     }
129 
GetHardwareEnabledTopDrawables()130     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetHardwareEnabledTopDrawables()
131     {
132         return hardwareEnabledTopDrawables_;
133     }
134 
135     void SetSecurityDisplay(bool isSecurityDisplay);
GetSecurityDisplay()136     bool GetSecurityDisplay() const override
137     {
138         return isSecurityDisplay_;
139     }
140     void SetGlobalZOrder(float zOrder);
141     float GetGlobalZOrder() const;
142     void SetMainAndLeashSurfaceDirty(bool isDirty);
143     bool GetMainAndLeashSurfaceDirty() const;
144     bool HasCaptureWindow() const;
145 
146     void SetNeedOffscreen(bool needOffscreen);
147     bool GetNeedOffscreen() const;
148 
149     void SetRotationChanged(bool changed) override;
150     bool IsRotationChanged() const override;
151 
152     bool IsRotationFinished() const;
153     void SetRotationFinished(bool finished);
154 
155     void SetFingerprint(bool hasFingerprint) override;
156     bool GetFingerprint() override;
157 
158     void SetHDRPresent(bool hasHdrPresent);
159     bool GetHDRPresent() const;
160 
161     void SetBrightnessRatio (float brightnessRatio);
162     float GetBrightnessRatio() const;
163 
164     void SetNewColorSpace(const GraphicColorGamut& newColorSpace);
165     GraphicColorGamut GetNewColorSpace() const;
166     void SetNewPixelFormat(const GraphicPixelFormat& newPixelFormat);
167     GraphicPixelFormat GetNewPixelFormat() const;
168 
169     void SetZoomed(bool isZoomed);
170     bool GetZoomed() const;
171 
172     void SetTargetSurfaceRenderNodeDrawable(DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr drawable);
173     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetTargetSurfaceRenderNodeDrawable() const;
174 
IsSpecialLayerChanged()175     bool IsSpecialLayerChanged() const
176     {
177         auto iter = displaySpecailSurfaceChanged_.find(screenId_);
178         return iter == displaySpecailSurfaceChanged_.end() ? false : iter->second;
179     }
180 
GetSecurityExemption()181     bool GetSecurityExemption() const
182     {
183         return isSecurityExemption_;
184     }
185 
HasSecLayerInVisibleRect()186     bool HasSecLayerInVisibleRect() const
187     {
188         return hasSecLayerInVisibleRect_;
189     }
190 
HasSecLayerInVisibleRectChanged()191     bool HasSecLayerInVisibleRectChanged() const
192     {
193         return hasSecLayerInVisibleRectChanged_;
194     }
195 
GetRoundCornerDrawables()196     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetRoundCornerDrawables()
197     {
198         return roundCornerSurfaceDrawables_;
199     }
200 
GetVirtualScreenMuteStatus()201     bool GetVirtualScreenMuteStatus() const
202     {
203         return virtualScreenMuteStatus_;
204     }
205 
206     // dfx
207     std::string ToString() const override;
208 
209     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetMirrorSourceDrawable() override;
210 private:
211     RSSpecialLayerManager specialLayerManager_;
212     std::map<ScreenId, bool> displaySpecailSurfaceChanged_;
213     std::map<ScreenId, bool> hasCaptureWindow_;
214     std::vector<RSBaseRenderNode::SharedPtr> allMainAndLeashSurfaces_;
215     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> allMainAndLeashSurfaceDrawables_;
216     std::vector<Occlusion::Rect> topSurfaceOpaqueRects_;
217     int32_t offsetX_ = -1;
218     int32_t offsetY_ = -1;
219     ScreenRotation nodeRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION;
220     ScreenRotation screenRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION;
221     uint64_t screenId_ = 0;
222     bool isSecurityDisplay_ = false;
223     bool isSecurityExemption_ = false;
224     bool hasSecLayerInVisibleRect_ = false;
225     bool hasSecLayerInVisibleRectChanged_ = false;
226     bool isDirtyAlignEnabled_ = false;
227     std::weak_ptr<RSDisplayRenderNode> mirrorSource_;
228     std::shared_ptr<DrawableV2::RSRenderNodeDrawableAdapter> mirrorSourceDrawable_ = nullptr;
229     NodeId mirrorSourceId_ = INVALID_NODEID;
230     ScreenInfo screenInfo_;
231     ScreenId mirroredId_ = INVALID_SCREEN_ID;
232     RSDisplayRenderNode::CompositeType compositeType_ = RSDisplayRenderNode::CompositeType::HARDWARE_COMPOSITE;
233     bool isMirrorScreen_ = false;
234     bool isFirstVisitCrossNodeDisplay_ = false;
235     bool hasChildCrossNode_ = false;
236     bool isMainAndLeashSurfaceDirty_ = false;
237     bool needOffscreen_ = false;
238     bool isRotationChanged_ = false;
239     bool isRotationFinished_ = false;
240     bool hasFingerprint_ = false;
241     bool hasHdrPresent_ = false;
242     bool virtualScreenMuteStatus_ = false;
243     float brightnessRatio_ = 1.0f;
244     float zOrder_ = 0.0f;
245     bool isZoomed_ = false;
246     // vector of rcd drawable, should be removed in OH 6.0 rcd refactoring
247     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> roundCornerSurfaceDrawables_;
248     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr targetSurfaceRenderNodeDrawable_;
249     friend class RSUniRenderVisitor;
250     friend class RSDisplayRenderNode;
251     std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledNodes_;
252     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledDrawables_;
253     // vector of hardwareEnabled nodes above displayNodeSurface like pointer window
254     std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledTopNodes_;
255     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledTopDrawables_;
256     GraphicColorGamut newColorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
257     GraphicPixelFormat newPixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888;
258 };
259 } // namespace OHOS::Rosen
260 #endif // RENDER_SERVICE_BASE_PARAMS_RS_DISPLAY_RENDER_PARAMS_H
261