• 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_SCREEN_RENDER_PARAMS_H
17 #define RENDER_SERVICE_BASE_PARAMS_RS_SCREEN_RENDER_PARAMS_H
18 
19 #include <memory>
20 
21 #include "common/rs_macros.h"
22 #include "common/rs_occlusion_region.h"
23 #include "common/rs_special_layer_manager.h"
24 #include "params/rs_render_params.h"
25 #include "pipeline/rs_screen_render_node.h"
26 #include "pipeline/rs_render_node.h"
27 #include "screen_manager/rs_screen_info.h"
28 #include "pipeline/rs_surface_render_node.h"
29 namespace OHOS::Rosen {
30 class RSB_EXPORT RSScreenRenderParams : public RSRenderParams {
31 public:
32     explicit RSScreenRenderParams(NodeId id);
33     ~RSScreenRenderParams() override = default;
34 
35     void OnSync(const std::unique_ptr<RSRenderParams>& target) override;
36 
37     std::vector<RSBaseRenderNode::SharedPtr>& GetAllMainAndLeashSurfaces();
38     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetAllMainAndLeashSurfaceDrawables() override;
39     void SetAllMainAndLeashSurfaces(std::vector<RSBaseRenderNode::SharedPtr>& allMainAndLeashSurfaces);
40     void SetAllMainAndLeashSurfaceDrawables(
41         std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& allMainAndLeashSurfaces);
42 
GetScreenOffsetX()43     int32_t GetScreenOffsetX() const
44     {
45         return screenInfo_.offsetX;
46     }
GetScreenOffsetY()47     int32_t GetScreenOffsetY() const
48     {
49         return screenInfo_.offsetY;
50     }
GetScreenId()51     uint64_t GetScreenId() const
52     {
53         return screenInfo_.id;
54     }
55 
GetScreenInfo()56     const ScreenInfo& GetScreenInfo() const
57     {
58         return screenInfo_;
59     }
60 
IsDirtyAlignEnabled()61     bool IsDirtyAlignEnabled() const
62     {
63         return isDirtyAlignEnabled_;
64     }
65 
SetDirtyAlignEnabled(bool isDirtyAlignEnabled)66     void SetDirtyAlignEnabled(bool isDirtyAlignEnabled)
67     {
68         isDirtyAlignEnabled_ = isDirtyAlignEnabled;
69     }
70 
GetCompositeType()71     CompositeType GetCompositeType() const
72     {
73         return compositeType_;
74     }
75 
IsMirrorScreen()76     bool IsMirrorScreen() const
77     {
78         return isMirrorScreen_;
79     }
IsFirstVisitCrossNodeDisplay()80     bool IsFirstVisitCrossNodeDisplay() const
81     {
82         return isFirstVisitCrossNodeDisplay_;
83     }
HasChildCrossNode()84     bool HasChildCrossNode() const
85     {
86         return hasChildCrossNode_;
87     }
88 
GetChildDisplayCount()89     uint32_t GetChildDisplayCount() const
90     {
91         return childDisplayCount_;
92     }
93     void SetGlobalZOrder(float zOrder);
94     float GetGlobalZOrder() const;
95     void SetMainAndLeashSurfaceDirty(bool isDirty);
96     bool GetMainAndLeashSurfaceDirty() const;
97 
98     void SetFingerprint(bool hasFingerprint) override;
99     bool GetFingerprint() override;
100 
101     void SetFixVirtualBuffer10Bit(bool isFixVirtualBuffer10Bit);
102     bool GetFixVirtualBuffer10Bit() const;
103 
104     void SetExistHWCNode(bool isExistHWCNode);
105     bool GetExistHWCNode() const;
106 
107     void SetHDRPresent(bool hasHdrPresent);
108     bool GetHDRPresent() const;
109 
110     void SetHDRStatusChanged(bool isHDRStatusChanged);
111     bool IsHDRStatusChanged() const;
112 
113     void SetBrightnessRatio (float brightnessRatio);
114     float GetBrightnessRatio() const;
115 
116     void SetNewColorSpace(const GraphicColorGamut& newColorSpace);
117     GraphicColorGamut GetNewColorSpace() const;
118     void SetNewPixelFormat(const GraphicPixelFormat& newPixelFormat);
119     GraphicPixelFormat GetNewPixelFormat() const;
120 
121     void SetZoomed(bool isZoomed);
122     bool GetZoomed() const;
123 
124     bool HasMirrorScreen() const;
125     void SetHasMirrorScreen(bool hasMirrorScreen);
126 
127     void SetTargetSurfaceRenderNodeDrawable(DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr drawable);
128     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetTargetSurfaceRenderNodeDrawable() const;
129 
130     // Only used in virtual expand screen to record accumulate frame status
SetAccumulatedDirty(bool isAccumulatedDirty)131     void SetAccumulatedDirty(bool isAccumulatedDirty)
132     {
133         isAccumulatedDirty_ = isAccumulatedDirty;
134     }
135 
GetAccumulatedDirty()136     bool GetAccumulatedDirty() const
137     {
138         return isAccumulatedDirty_;
139     }
140 
SetAccumulatedHdrStatusChanged(bool isHdrStatusChanged)141     void SetAccumulatedHdrStatusChanged(bool isHdrStatusChanged)
142     {
143         isAccumulatedHdrStatusChanged_ = isHdrStatusChanged;
144     }
145 
GetAccumulatedHdrStatusChanged()146     bool GetAccumulatedHdrStatusChanged() const
147     {
148         return isAccumulatedHdrStatusChanged_;
149     }
150 
ResetVirtualExpandAccumulatedParams()151     void ResetVirtualExpandAccumulatedParams()
152     {
153         isAccumulatedDirty_ = false;
154         isAccumulatedHdrStatusChanged_ = false;
155     }
156 
GetRoundCornerDrawables()157     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetRoundCornerDrawables()
158     {
159         return roundCornerSurfaceDrawables_;
160     }
161 
162     void SetNeedForceUpdateHwcNodes(bool needForceUpdateHwcNodes);
163     bool GetNeedForceUpdateHwcNodes() const;
164 
SetSlrMatrix(Drawing::Matrix matrix)165     void SetSlrMatrix(Drawing::Matrix matrix)
166     {
167         slrMatrix_ = matrix;
168     }
GetSlrMatrix()169     Drawing::Matrix GetSlrMatrix() const
170     {
171         return slrMatrix_;
172     }
173 
SetHdrBrightnessRatio(float hdrBrightnessRatio)174     void SetHdrBrightnessRatio(float hdrBrightnessRatio)
175     {
176         hdrBrightnessRatio_ = hdrBrightnessRatio;
177     }
GetHdrBrightnessRatio()178     float GetHdrBrightnessRatio() const
179     {
180         return hdrBrightnessRatio_;
181     }
182 
183     void SetDrawnRegion(const Occlusion::Region& region);
184     const Occlusion::Region& GetDrawnRegion() const;
185 
186     // dfx
187     std::string ToString() const override;
188 
189     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetMirrorSourceDrawable() override;
GetDisplayDrawables()190     const std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetDisplayDrawables()
191     {
192         return logicalDisplayNodeDrawables_;
193     }
194 
195     bool GetForceFreeze() const;
196     void SetForceFreeze(bool forceFreeze);
197 
198 private:
199 
200     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> logicalDisplayNodeDrawables_;
201     std::vector<RSBaseRenderNode::SharedPtr> allMainAndLeashSurfaces_;
202     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> allMainAndLeashSurfaceDrawables_;
203     bool isDirtyAlignEnabled_ = false;
204     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr mirrorSourceDrawable_;
205     ScreenInfo screenInfo_;
206     CompositeType compositeType_ = CompositeType::HARDWARE_COMPOSITE;
207     uint32_t childDisplayCount_ = 0;
208     bool isMirrorScreen_ = false;
209     bool isFirstVisitCrossNodeDisplay_ = false;
210     bool hasChildCrossNode_ = false;
211     bool isMainAndLeashSurfaceDirty_ = false;
212     bool needForceUpdateHwcNodes_ = false;
213     bool hasFingerprint_ = false;
214     bool isFixVirtualBuffer10Bit_ = false;
215     bool existHWCNode_ = false;
216     bool hasHdrPresent_ = false;
217     bool isHDRStatusChanged_ = false;
218     // Only used in virtual expand screen to record accumulate frame status
219     bool isAccumulatedDirty_ = false;
220     bool isAccumulatedHdrStatusChanged_ = false;
221     float brightnessRatio_ = 1.0f;
222     float hdrBrightnessRatio_ = 1.0f;
223     float zOrder_ = 0.0f;
224     bool isZoomed_ = false;
225     uint32_t mirrorDstCount_ = 0;
226     bool hasMirrorScreen_ = false;
227     Drawing::Matrix slrMatrix_;
228     // vector of rcd drawable, should be removed in OH 6.0 rcd refactoring
229     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> roundCornerSurfaceDrawables_;
230     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr targetSurfaceRenderNodeDrawable_;
231     friend class RSUniRenderVisitor;
232     friend class RSScreenRenderNode;
233     GraphicColorGamut newColorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
234     GraphicPixelFormat newPixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888;
235     Occlusion::Region drawnRegion_;
236     bool forceFreeze_ = false;
237 };
238 } // namespace OHOS::Rosen
239 
240 #endif // RENDER_SERVICE_BASE_PARAMS_RS_SCREEN_RENDER_PARAMS_H