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 PRODUCER_SURFACE_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 uint32_t expectedRefreshRate = INVALID_EXPECTED_REFRESH_RATE; 48 SkipFrameStrategy skipFrameStrategy = SKIP_FRAME_BY_INTERVAL; 49 bool isEqualVsyncPeriod = true; 50 51 GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888; 52 ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR; 53 GetRotatedWidthScreenInfo54 uint32_t GetRotatedWidth() const 55 { 56 return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? width : height; 57 } 58 GetRotatedHeightScreenInfo59 uint32_t GetRotatedHeight() const 60 { 61 return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? height : width; 62 } GetRotatedPhyWidthScreenInfo63 uint32_t GetRotatedPhyWidth() const 64 { 65 return (rotation == ScreenRotation::ROTATION_0 || 66 rotation == ScreenRotation::ROTATION_180) ? phyWidth : phyHeight; 67 } 68 GetRotatedPhyHeightScreenInfo69 uint32_t GetRotatedPhyHeight() const 70 { 71 return (rotation == ScreenRotation::ROTATION_0 || 72 rotation == ScreenRotation::ROTATION_180) ? phyHeight : phyWidth; 73 } 74 GetRogWidthRatioScreenInfo75 float GetRogWidthRatio() const 76 { 77 return (width == 0) ? 1.f : static_cast<float>(phyWidth) / width; 78 } 79 GetRogHeightRatioScreenInfo80 float GetRogHeightRatio() const 81 { 82 return (height == 0) ? 1.f : static_cast<float>(phyHeight) / height; 83 } 84 85 // dfx ToStringScreenInfo86 std::string ToString() const 87 { 88 std::string ret = "ScreenInfo:{\n"; 89 ret += " id:" + std::to_string(id); 90 ret += " width:" + std::to_string(width); 91 ret += " height:" + std::to_string(height); 92 ret += "\n}\n"; 93 return ret; 94 } 95 }; 96 } // namespace OHOS::Rosen 97 #endif // RENDER_SERVICE_BASE_SCREEN_MANAGER_RS_SCREEN_INFO_H