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_SCREEN_MANAGER_RS_SCREEN_INFO_H 17 #define RENDER_SERVICE_BASE_SCREEN_MANAGER_RS_SCREEN_INFO_H 18 19 #include <string> 20 #include <surface_type.h> 21 #include <unordered_set> 22 23 #include "screen_types.h" 24 #include "platform/common/rs_log.h" 25 26 namespace OHOS::Rosen { 27 enum class ScreenState : uint8_t { 28 HDI_OUTPUT_ENABLE, 29 SOFTWARE_OUTPUT_ENABLE, 30 DISABLED, 31 NOT_EXISTED, 32 UNKNOWN, 33 }; 34 35 struct ScreenInfo { 36 ScreenId id = INVALID_SCREEN_ID; 37 uint32_t width = 0; // render resolution 38 uint32_t height = 0; 39 uint32_t phyWidth = 0; // physical screen resolution 40 uint32_t phyHeight = 0; 41 ScreenColorGamut colorGamut = ScreenColorGamut::COLOR_GAMUT_SRGB; 42 ScreenState state = ScreenState::UNKNOWN; 43 ScreenRotation rotation = ScreenRotation::ROTATION_0; 44 std::unordered_set<uint64_t> whiteList = {}; 45 46 uint32_t skipFrameInterval = DEFAULT_SKIP_FRAME_INTERVAL; // skip frame interval for change screen refresh rate 47 48 GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888; 49 ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR; 50 GetRotatedWidthScreenInfo51 uint32_t GetRotatedWidth() const 52 { 53 return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? width : height; 54 } 55 GetRotatedHeightScreenInfo56 uint32_t GetRotatedHeight() const 57 { 58 return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? height : width; 59 } GetRotatedPhyWidthScreenInfo60 uint32_t GetRotatedPhyWidth() const 61 { 62 return (rotation == ScreenRotation::ROTATION_0 || 63 rotation == ScreenRotation::ROTATION_180) ? phyWidth : phyHeight; 64 } 65 GetRotatedPhyHeightScreenInfo66 uint32_t GetRotatedPhyHeight() const 67 { 68 return (rotation == ScreenRotation::ROTATION_0 || 69 rotation == ScreenRotation::ROTATION_180) ? phyHeight : phyWidth; 70 } 71 GetRogWidthRatioScreenInfo72 float GetRogWidthRatio() const 73 { 74 return (width == 0) ? 1.f : static_cast<float>(phyWidth) / width; 75 } 76 GetRogHeightRatioScreenInfo77 float GetRogHeightRatio() const 78 { 79 return (height == 0) ? 1.f : static_cast<float>(phyHeight) / height; 80 } 81 82 // dfx ToStringScreenInfo83 std::string ToString() const 84 { 85 std::string ret = "ScreenInfo:{\n"; 86 ret += " id:" + std::to_string(id); 87 ret += " width:" + std::to_string(width); 88 ret += " height:" + std::to_string(height); 89 ret += "\n}\n"; 90 return ret; 91 } 92 }; 93 } // namespace OHOS::Rosen 94 #endif // RENDER_SERVICE_BASE_SCREEN_MANAGER_RS_SCREEN_INFO_H