• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     SOFTWARE_OUTPUT_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     RectI maskRect;
53     RectI reviseRect;
54 
55     uint32_t skipFrameInterval = DEFAULT_SKIP_FRAME_INTERVAL; // skip frame interval for change screen refresh rate
56     uint32_t expectedRefreshRate = INVALID_EXPECTED_REFRESH_RATE;
57     SkipFrameStrategy skipFrameStrategy = SKIP_FRAME_BY_INTERVAL;
58     bool isEqualVsyncPeriod = true;
59 
60     GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888;
61     ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR;
62 
63     bool enableVisibleRect = false;
64 
GetRotatedWidthScreenInfo65     uint32_t GetRotatedWidth() const
66     {
67         return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? width : height;
68     }
69 
GetRotatedHeightScreenInfo70     uint32_t GetRotatedHeight() const
71     {
72         return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? height : width;
73     }
GetRotatedPhyWidthScreenInfo74     uint32_t GetRotatedPhyWidth() const
75     {
76         return (rotation == ScreenRotation::ROTATION_0 ||
77             rotation == ScreenRotation::ROTATION_180) ? phyWidth : phyHeight;
78     }
79 
GetRotatedPhyHeightScreenInfo80     uint32_t GetRotatedPhyHeight() const
81     {
82         return (rotation == ScreenRotation::ROTATION_0 ||
83             rotation == ScreenRotation::ROTATION_180) ? phyHeight : phyWidth;
84     }
85 
GetRogWidthRatioScreenInfo86     float GetRogWidthRatio() const
87     {
88         return (width == 0) ? 1.f : static_cast<float>(phyWidth) / width;
89     }
90 
GetRogHeightRatioScreenInfo91     float GetRogHeightRatio() const
92     {
93         return (height == 0) ? 1.f : static_cast<float>(phyHeight) / height;
94     }
95 
96     // dfx
ToStringScreenInfo97     std::string ToString() const
98     {
99         std::string ret = "ScreenInfo:{\n";
100         ret += "  id:" + std::to_string(id);
101         ret += "  width:" + std::to_string(width);
102         ret += "  height:" + std::to_string(height);
103         ret += "\n}\n";
104         return ret;
105     }
106 };
107 } // namespace OHOS::Rosen
108 #endif // RENDER_SERVICE_BASE_SCREEN_MANAGER_RS_SCREEN_INFO_H