• 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     }
GetDisplayHasProtectedSurface()84     const std::map<ScreenId, bool>& GetDisplayHasProtectedSurface() const
85     {
86         return displayHasProtectedSurface_;
87     }
GethasCaptureWindow()88     const std::map<ScreenId, bool>& GethasCaptureWindow() const
89     {
90         return hasCaptureWindow_;
91     }
GetHardwareEnabledDrawables()92     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetHardwareEnabledDrawables()
93     {
94         return hardwareEnabledDrawables_;
95     }
GetHardwareEnabledTopDrawables()96     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetHardwareEnabledTopDrawables()
97     {
98         return hardwareEnabledTopDrawables_;
99     }
100     void SetSecurityDisplay(bool isSecurityDisplay);
GetSecurityDisplay()101     bool GetSecurityDisplay() const override
102     {
103         return isSecurityDisplay_;
104     }
105     void SetGlobalZOrder(float zOrder);
106     float GetGlobalZOrder() const;
107     void SetMainAndLeashSurfaceDirty(bool isDirty);
108     bool GetMainAndLeashSurfaceDirty() const;
109     bool HasSecurityLayer() const;
110     bool HasSkipLayer() const;
111     bool HasProtectedLayer() const;
112     bool HasCaptureWindow() const;
113     void SetNeedOffscreen(bool needOffscreen);
114     bool GetNeedOffscreen() const;
115 
116     void SetRotationChanged(bool changed) override;
117     bool IsRotationChanged() const override;
118 
119     void SetHDRPresent(bool hasHdrPresent);
120     bool GetHDRPresent() const;
121 
122     void SetBrightnessRatio (float brightnessRatio);
123     float GetBrightnessRatio() const;
124 
125     void SetNewColorSpace(const GraphicColorGamut& newColorSpace);
126     GraphicColorGamut GetNewColorSpace() const;
127     void SetNewPixelFormat(const GraphicPixelFormat& newPixelFormat);
128     GraphicPixelFormat GetNewPixelFormat() const;
129 
130     void SetZoomed(bool isZoomed);
131     bool GetZoomed() const;
132 
IsSpecialLayerChanged()133     bool IsSpecialLayerChanged() const
134     {
135         auto iter = displaySpecailSurfaceChanged_.find(screenId_);
136         return iter == displaySpecailSurfaceChanged_.end() ? false : iter->second;
137     }
138 
GetSecurityExemption()139     bool GetSecurityExemption() const
140     {
141         return isSecurityExemption_;
142     }
143 
144     // dfx
145     std::string ToString() const override;
146 
147     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr GetMirrorSourceDrawable() override;
148 private:
149     std::map<ScreenId, bool> displayHasSecSurface_;
150     std::map<ScreenId, bool> displayHasSkipSurface_;
151     std::map<ScreenId, bool> displayHasProtectedSurface_;
152     std::map<ScreenId, bool> displaySpecailSurfaceChanged_;
153     std::map<ScreenId, bool> hasCaptureWindow_;
154     std::vector<RSBaseRenderNode::SharedPtr> allMainAndLeashSurfaces_;
155     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> allMainAndLeashSurfaceDrawables_;
156     int32_t offsetX_ = -1;
157     int32_t offsetY_ = -1;
158     ScreenRotation nodeRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION;
159     ScreenRotation screenRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION;
160     uint64_t screenId_ = 0;
161     bool isSecurityDisplay_ = false;
162     bool isSecurityExemption_ = false;
163     DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr mirrorSourceDrawable_;
164     NodeId mirrorSourceId_ = INVALID_NODEID;
165     ScreenInfo screenInfo_;
166     ScreenId mirroredId_ = INVALID_SCREEN_ID;
167     RSDisplayRenderNode::CompositeType compositeType_ = RSDisplayRenderNode::CompositeType::HARDWARE_COMPOSITE;
168     bool isMainAndLeashSurfaceDirty_ = false;
169     bool needOffscreen_ = false;
170     bool isRotationChanged_ = false;
171     bool hasHdrPresent_ = false;
172     float brightnessRatio_ = 1.0f;
173     float zOrder_ = 0.0f;
174     bool isZoomed_ = false;
175     friend class RSUniRenderVisitor;
176     friend class RSDisplayRenderNode;
177 
178     std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledNodes_;
179     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledDrawables_;
180     // vector of hardwareEnabled nodes above displayNodeSurface like pointer window
181     std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledTopNodes_;
182     std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledTopDrawables_;
183     GraphicColorGamut newColorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
184     GraphicPixelFormat newPixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888;
185 };
186 } // namespace OHOS::Rosen
187 #endif // RENDER_SERVICE_BASE_PARAMS_RS_DISPLAY_RENDER_PARAMS_H
188