1 /* 2 * Copyright (c) 2021-2022 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 FOUNDATION_DM_SCREEN_H 17 #define FOUNDATION_DM_SCREEN_H 18 19 #include <cstdint> 20 #include <screen_manager/screen_types.h> 21 #include <string> 22 #include <surface.h> 23 #include <vector> 24 25 #include "dm_common.h" 26 #include "noncopyable.h" 27 28 namespace OHOS::Rosen { 29 class ScreenInfo; 30 31 struct VirtualScreenOption { 32 std::string name_; 33 uint32_t width_; 34 uint32_t height_; 35 float density_; 36 sptr<Surface> surface_; 37 int32_t flags_; 38 bool isForShot_ {true}; 39 std::vector<uint64_t> missionIds_ {}; 40 }; 41 42 class Screen : public RefBase { 43 friend class ScreenManager; 44 public: 45 ~Screen(); 46 Screen(const Screen&) = delete; 47 Screen(Screen&&) = delete; 48 Screen& operator=(const Screen&) = delete; 49 Screen& operator=(Screen&&) = delete; 50 bool IsGroup() const; 51 std::string GetName() const; 52 53 /** 54 * @brief Get screen id. 55 * 56 * @return Screen id. 57 */ 58 ScreenId GetId() const; 59 60 /** 61 * @brief Get width of the screen. 62 * 63 * @return Width of the screen. 64 */ 65 uint32_t GetWidth() const; 66 67 /** 68 * @brief Get height of the screen. 69 * 70 * @return Height of the screen. 71 */ 72 uint32_t GetHeight() const; 73 74 /** 75 * @brief Get virtual width of the screen. 76 * 77 * @return Virtual width of the screen. 78 */ 79 uint32_t GetVirtualWidth() const; 80 81 /** 82 * @brief Get virtual height of the screen. 83 * 84 * @return Virtual height of the screen. 85 */ 86 uint32_t GetVirtualHeight() const; 87 88 /** 89 * @brief Get virtual pixel ratio of the screen. 90 * 91 * @return Virtual pixel ratio of the screen. 92 */ 93 float GetVirtualPixelRatio() const; 94 95 /** 96 * @brief Get the Rotation of the screen. 97 * 98 * @return The Rotation of the screen. 99 */ 100 Rotation GetRotation() const; 101 102 /** 103 * @brief Get the orientation of the screen. 104 * 105 * @return Orientation of the screen. 106 */ 107 Orientation GetOrientation() const; 108 109 /** 110 * @brief Is a real screen. 111 * 112 * @return True means screen is real, false means the opposite. 113 */ 114 bool IsReal() const; 115 116 /** 117 * @brief Get screen parent id. 118 * 119 * @return Screen parent id. 120 */ 121 ScreenId GetParentId() const; 122 123 /** 124 * @brief Get screen mode id. 125 * 126 * @return Screen mode id. 127 */ 128 uint32_t GetModeId() const; 129 130 /** 131 * @brief Get supported modes of the screen. 132 * 133 * @return Supported modes of the screen. 134 */ 135 std::vector<sptr<SupportedScreenModes>> GetSupportedModes() const; 136 137 /** 138 * @brief Set screen active mode. 139 * 140 * @param modeId Mode id. 141 * @return DM_OK means set success, others means set failed. 142 */ 143 DMError SetScreenActiveMode(uint32_t modeId); 144 145 /** 146 * @brief Set orientation for the screen. 147 * 148 * @param orientation Orientation for the screen. 149 * @return DM_OK means set success, others means set failed. 150 */ 151 DMError SetOrientation(Orientation orientation) const; 152 153 /** 154 * @brief Set the density dpi of the screen. 155 * 156 * @param dpi Density dpi of the screen. 157 * @return DM_OK means set success, others means set failed. 158 */ 159 DMError SetDensityDpi(uint32_t dpi) const; 160 161 /** 162 * @brief Set the density dpi of the screen system window. 163 * 164 * @param dpi Density dpi of the screen. 165 * @return DM_OK means set success, others means set failed. 166 */ 167 DMError SetDensityDpiSystem(uint32_t dpi) const; 168 169 /** 170 * @brief Get the screen info. 171 * 172 * @return Screen info. 173 */ 174 sptr<ScreenInfo> GetScreenInfo() const; 175 176 // colorspace, gamut 177 /** 178 * @brief Get the supported color gamuts of the screen. 179 * 180 * @param colorGamuts Supported color gamuts of the screen. 181 * @return DM_OK means get success, others means get failed. 182 */ 183 DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts) const; 184 185 /** 186 * @brief Get the color gamut of the screen. 187 * 188 * @param colorGamut Color gamut of the screen. 189 * @return DM_OK means get success, others means get failed. 190 */ 191 DMError GetScreenColorGamut(ScreenColorGamut& colorGamut) const; 192 193 /** 194 * @brief Set the color gamut of the screen. 195 * 196 * @param colorGamutIdx Color gamut of the screen. 197 * @return DM_OK means set success, others means set failed. 198 */ 199 DMError SetScreenColorGamut(int32_t colorGamutIdx); 200 201 /** 202 * @brief Get the gamut map of the screen. 203 * 204 * @param gamutMap Gamut map of the screen. 205 * @return DM_OK means get success, others means get failed. 206 */ 207 DMError GetScreenGamutMap(ScreenGamutMap& gamutMap) const; 208 209 /** 210 * @brief Set the gamut map of the screen. 211 * 212 * @param gamutMap Gamut map of the screen. 213 * @return DM_OK means set success, others means set failed. 214 */ 215 DMError SetScreenGamutMap(ScreenGamutMap gamutMap); 216 217 /** 218 * @brief Set color transform for the screen. 219 * 220 * @return DM_OK means set success, others means set failed. 221 */ 222 DMError SetScreenColorTransform(); 223 224 /** 225 * @brief Set the resolution for the screen. 226 * 227 * @param width width of the screen 228 * @param height height of the screen 229 * @param dpi dpi of the screen 230 * @return DM_OK means set success, others means set failed. 231 */ 232 DMError SetResolution(uint32_t width, uint32_t height, uint32_t dpi) const; 233 234 /** 235 * @brief get Density in current resolution 236 * @param virtualPixelRatio virtualPixelRatio of the screen 237 * @return DM_OK means set success, others means set failed. 238 */ 239 DMError GetDensityInCurResolution(float& virtualPixelRatio) const; 240 241 /** 242 * @brief Get the pixel format of the screen. 243 * 244 * @return DM_OK means set success, others means set failed. 245 */ 246 DMError GetPixelFormat(GraphicPixelFormat& pixelFormat) const; 247 248 /** 249 * @brief Set the pixel format of the screen. 250 * 251 * @return DM_OK means set success, others means set failed. 252 */ 253 DMError SetPixelFormat(GraphicPixelFormat pixelFormat); 254 255 /** 256 * @brief Get the supported HDR format of the screen. 257 * 258 * @param colorSpaces Supported HDR format of the screen. 259 * @return DM_OK means get success, others means get failed. 260 */ 261 DMError GetSupportedHDRFormats(std::vector<ScreenHDRFormat>& hdrFormats) const; 262 263 /** 264 * @brief Get the HDR format of the screen. 265 * 266 * @return DM_OK means set success, others means set failed. 267 */ 268 DMError GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) const; 269 270 /** 271 * @brief Set the HDR format of the screen. 272 * 273 * @return DM_OK means set success, others means set failed. 274 */ 275 DMError SetScreenHDRFormat(int32_t modeIdx); 276 277 /** 278 * @brief Get the supported color space of the screen. 279 * 280 * @param colorSpaces Supported color space of the screen. 281 * @return DM_OK means get success, others means get failed. 282 */ 283 DMError GetSupportedColorSpaces(std::vector<GraphicCM_ColorSpaceType>& colorSpaces) const; 284 285 /** 286 * @brief Get the color space of the screen. 287 * 288 * @param colorSpace Color space of the screen. 289 * @return DM_OK means get success, others means get failed. 290 */ 291 DMError GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) const; 292 293 /** 294 * @brief Set the color space of the screen. 295 * 296 * @param colorSpace Color space of the screen. 297 * @return DM_OK means set success, others means set failed. 298 */ 299 DMError SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace); 300 301 protected: 302 // No more methods or variables can be defined here. 303 explicit Screen(sptr<ScreenInfo> info); 304 void UpdateScreenInfo() const; 305 void UpdateScreenInfo(sptr<ScreenInfo> info) const; 306 private: 307 // No more methods or variables can be defined here. 308 class Impl; 309 sptr<Impl> pImpl_; 310 }; 311 } // namespace OHOS::Rosen 312 313 #endif // FOUNDATION_DM_SCREEN_H