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 "common/rs_rect.h" 24 #include "screen_types.h" 25 #include "platform/common/rs_log.h" 26 27 namespace OHOS::Rosen { 28 enum class ScreenState : uint8_t { 29 HDI_OUTPUT_ENABLE, 30 PRODUCER_SURFACE_ENABLE, 31 DISABLED, 32 NOT_EXISTED, 33 UNKNOWN, 34 }; 35 36 struct ScreenInfo { 37 ScreenId id = INVALID_SCREEN_ID; 38 uint32_t width = 0; // render resolution 39 uint32_t height = 0; 40 uint32_t phyWidth = 0; // physical screen resolution 41 uint32_t phyHeight = 0; 42 bool isSamplingOn = false; 43 int samplingDistance = 1; 44 float samplingTranslateX = 0.f; 45 float samplingTranslateY = 0.f; 46 float samplingScale = 1.f; 47 ScreenColorGamut colorGamut = ScreenColorGamut::COLOR_GAMUT_SRGB; 48 ScreenState state = ScreenState::UNKNOWN; 49 ScreenRotation rotation = ScreenRotation::ROTATION_0; 50 std::unordered_set<uint64_t> whiteList = {}; 51 RectI activeRect; 52 53 uint32_t skipFrameInterval = DEFAULT_SKIP_FRAME_INTERVAL; // skip frame interval for change screen refresh rate 54 uint32_t expectedRefreshRate = INVALID_EXPECTED_REFRESH_RATE; 55 SkipFrameStrategy skipFrameStrategy = SKIP_FRAME_BY_INTERVAL; 56 bool isEqualVsyncPeriod = true; 57 58 GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888; 59 ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR; 60 GetRotatedWidthScreenInfo61 uint32_t GetRotatedWidth() const 62 { 63 return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? width : height; 64 } 65 GetRotatedHeightScreenInfo66 uint32_t GetRotatedHeight() const 67 { 68 return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? height : width; 69 } GetRotatedPhyWidthScreenInfo70 uint32_t GetRotatedPhyWidth() const 71 { 72 return (rotation == ScreenRotation::ROTATION_0 || 73 rotation == ScreenRotation::ROTATION_180) ? phyWidth : phyHeight; 74 } 75 GetRotatedPhyHeightScreenInfo76 uint32_t GetRotatedPhyHeight() const 77 { 78 return (rotation == ScreenRotation::ROTATION_0 || 79 rotation == ScreenRotation::ROTATION_180) ? phyHeight : phyWidth; 80 } 81 GetRogWidthRatioScreenInfo82 float GetRogWidthRatio() const 83 { 84 return (width == 0) ? 1.f : static_cast<float>(phyWidth) / width; 85 } 86 GetRogHeightRatioScreenInfo87 float GetRogHeightRatio() const 88 { 89 return (height == 0) ? 1.f : static_cast<float>(phyHeight) / height; 90 } 91 92 // dfx ToStringScreenInfo93 std::string ToString() const 94 { 95 std::string ret = "ScreenInfo:{\n"; 96 ret += " id:" + std::to_string(id); 97 ret += " width:" + std::to_string(width); 98 ret += " height:" + std::to_string(height); 99 ret += "\n}\n"; 100 return ret; 101 } 102 }; 103 } // namespace OHOS::Rosen 104 #endif // RENDER_SERVICE_BASE_SCREEN_MANAGER_RS_SCREEN_INFO_H