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