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