• 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 "params/rs_render_params.h"
23 #include "pipeline/rs_display_render_node.h"
24 #include "pipeline/rs_render_node.h"
25 #include "screen_manager/rs_screen_info.h"
26 #include "pipeline/rs_surface_render_node.h"
27 namespace OHOS::Rosen {
28 class RSB_EXPORT RSDisplayRenderParams : public RSRenderParams {
29 public:
30     explicit RSDisplayRenderParams(NodeId id);
31     ~RSDisplayRenderParams() override = default;
32 
33     void OnSync(const std::unique_ptr<RSRenderParams>& target) override;
34 
35     std::vector<RSBaseRenderNode::SharedPtr>& GetAllMainAndLeashSurfaces();
36     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetAllMainAndLeashSurfaceDrawables() override;
37     void SetAllMainAndLeashSurfaces(std::vector<RSBaseRenderNode::SharedPtr>& allMainAndLeashSurfaces);
38     void SetAllMainAndLeashSurfaceDrawables(
39         std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& allMainAndLeashSurfaces);
GetDisplayOffsetX()40     int32_t GetDisplayOffsetX() const
41     {
42         return offsetX_;
43     }
GetDisplayOffsetY()44     int32_t GetDisplayOffsetY() const
45     {
46         return offsetY_;
47     }
GetScreenId()48     uint64_t GetScreenId() const override
49     {
50         return screenId_;
51     }
GetMirroredId()52     uint64_t GetMirroredId() const
53     {
54         return mirroredId_;
55     }
GetScreenInfo()56     const ScreenInfo& GetScreenInfo() const override
57     {
58         return screenInfo_;
59     }
GetMirrorSourceId()60     NodeId GetMirrorSourceId() const
61     {
62         return mirrorSourceId_;
63     }
GetCompositeType()64     RSDisplayRenderNode::CompositeType GetCompositeType() const
65     {
66         return compositeType_;
67     };
GetScreenRotation()68     ScreenRotation GetScreenRotation() const override
69     {
70         return screenRotation_;
71     }
GetNodeRotation()72     ScreenRotation GetNodeRotation() const
73     {
74         return nodeRotation_;
75     }
GetDisplayHasSecSurface()76     const std::map<ScreenId, bool>& GetDisplayHasSecSurface() const
77     {
78         return displayHasSecSurface_;
79     }
GetDisplayHasSkipSurface()80     const std::map<ScreenId, bool>& GetDisplayHasSkipSurface() const
81     {
82         return displayHasSkipSurface_;
83     }
GetDisplayHasSnapshotSkipSurface()84     const std::map<ScreenId, bool>& GetDisplayHasSnapshotSkipSurface() const
85     {
86         return displayHasSnapshotSkipSurface_;
87     }
GetDisplayHasProtectedSurface()88     const std::map<ScreenId, bool>& GetDisplayHasProtectedSurface() const
89     {
90         return displayHasProtectedSurface_;
91     }
GethasCaptureWindow()92     const std::map<ScreenId, bool>& GethasCaptureWindow() const
93     {
94         return hasCaptureWindow_;
95     }
GetHardwareEnabledDrawables()96     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetHardwareEnabledDrawables()
97     {
98         return hardwareEnabledDrawables_;
99     }
GetHardwareEnabledTopDrawables()100     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetHardwareEnabledTopDrawables()
101     {
102         return hardwareEnabledTopDrawables_;
103     }
IsMirrorScreen()104     bool IsMirrorScreen() const
105     {
106         return isMirrorScreen_;
107     }
108     void SetSecurityDisplay(bool isSecurityDisplay);
GetSecurityDisplay()109     bool GetSecurityDisplay() const override
110     {
111         return isSecurityDisplay_;
112     }
113     void SetGlobalZOrder(float zOrder);
114     float GetGlobalZOrder() const;
115     void SetMainAndLeashSurfaceDirty(bool isDirty);
116     bool GetMainAndLeashSurfaceDirty() const;
117     bool HasSecurityLayer() const;
118     bool HasSkipLayer() const;
119     bool HasSnapshotSkipLayer() const;
120     bool HasProtectedLayer() const;
121     bool HasCaptureWindow() const;
122     void SetNeedOffscreen(bool needOffscreen);
123     bool GetNeedOffscreen() const;
124 
125     void SetRotationChanged(bool changed) override;
126     bool IsRotationChanged() const override;
127 
128     void SetHDRPresent(bool hasHdrPresent);
129     bool GetHDRPresent() const;
130 
131     void SetBrightnessRatio (float brightnessRatio);
132     float GetBrightnessRatio() const;
133 
134     void SetNewColorSpace(const GraphicColorGamut& newColorSpace);
135     GraphicColorGamut GetNewColorSpace() const;
136     void SetNewPixelFormat(const GraphicPixelFormat& newPixelFormat);
137     GraphicPixelFormat GetNewPixelFormat() const;
138 
139     void SetZoomed(bool isZoomed);
140     bool GetZoomed() const;
141 
IsSpecialLayerChanged()142     bool IsSpecialLayerChanged() const
143     {
144         auto iter = displaySpecailSurfaceChanged_.find(screenId_);
145         return iter == displaySpecailSurfaceChanged_.end() ? false : iter->second;
146     }
147 
GetSecurityExemption()148     bool GetSecurityExemption() const
149     {
150         return isSecurityExemption_;
151     }
152 
153     // dfx
154     std::string ToString() const override;
155 
156     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetMirrorSourceDrawable() override;
157 private:
158     std::map<ScreenId, bool> displayHasSecSurface_;
159     std::map<ScreenId, bool> displayHasSkipSurface_;
160     std::map<ScreenId, bool> displayHasSnapshotSkipSurface_;
161     std::map<ScreenId, bool> displayHasProtectedSurface_;
162     std::map<ScreenId, bool> displaySpecailSurfaceChanged_;
163     std::map<ScreenId, bool> hasCaptureWindow_;
164     std::vector<RSBaseRenderNode::SharedPtr> allMainAndLeashSurfaces_;
165     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> allMainAndLeashSurfaceDrawables_;
166     int32_t offsetX_ = -1;
167     int32_t offsetY_ = -1;
168     ScreenRotation nodeRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION;
169     ScreenRotation screenRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION;
170     uint64_t screenId_ = 0;
171     bool isSecurityDisplay_ = false;
172     bool isSecurityExemption_ = false;
173     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr mirrorSourceDrawable_;
174     NodeId mirrorSourceId_ = INVALID_NODEID;
175     ScreenInfo screenInfo_;
176     ScreenId mirroredId_ = INVALID_SCREEN_ID;
177     RSDisplayRenderNode::CompositeType compositeType_ = RSDisplayRenderNode::CompositeType::HARDWARE_COMPOSITE;
178     bool isMirrorScreen_ = false;
179     bool isMainAndLeashSurfaceDirty_ = false;
180     bool needOffscreen_ = false;
181     bool isRotationChanged_ = false;
182     bool hasHdrPresent_ = false;
183     float brightnessRatio_ = 1.0f;
184     float zOrder_ = 0.0f;
185     bool isZoomed_ = false;
186     friend class RSUniRenderVisitor;
187     friend class RSDisplayRenderNode;
188 
189     std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledNodes_;
190     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledDrawables_;
191     // vector of hardwareEnabled nodes above displayNodeSurface like pointer window
192     std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledTopNodes_;
193     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledTopDrawables_;
194     GraphicColorGamut newColorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
195     GraphicPixelFormat newPixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888;
196 };
197 } // namespace OHOS::Rosen
198 #endif // RENDER_SERVICE_BASE_PARAMS_RS_DISPLAY_RENDER_PARAMS_H
199