Debian Codegraph @

xbmc/windowing/Resolution.h

raw
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include <stdint.h>
12 #include <string>
13
14 typedef int DisplayMode;
15 #define DM_WINDOWED -1
16 #define DM_FULLSCREEN 0
17
18 enum RESOLUTION
19 {
20 RES_INVALID = -1,
21 RES_WINDOW = 15,
22 RES_DESKTOP = 16, // Desktop resolution
23 RES_CUSTOM = 16 + 1, // First additional resolution
24 };
25
26 struct OVERSCAN
27 {
28 int left;
29 int top;
30 int right;
31 int bottom;
32 public:
33 OVERSCAN()
34 {
35 left = top = right = bottom = 0;
36 }
37 OVERSCAN(const OVERSCAN& os)
38 {
39 left = os.left; top = os.top;
40 right = os.right; bottom = os.bottom;
41 }
42 OVERSCAN& operator=(const OVERSCAN&) = default;
43
44 bool operator==(const OVERSCAN& other)
45 {
46 return left == other.left && right == other.right && top == other.top && bottom == other.bottom;
47 }
48 bool operator!=(const OVERSCAN& other)
49 {
50 return left != other.left || right != other.right || top != other.top || bottom != other.bottom;
51 }
52 };
53
54 struct EdgeInsets
55 {
56 float left = 0.0f;
57 float top = 0.0f;
58 float right = 0.0f;
59 float bottom = 0.0f;
60
61 EdgeInsets() = default;
62 EdgeInsets(float l, float t, float r, float b);
63 };
64
65 //! @brief Provide info of a resolution
66 struct RESOLUTION_INFO
67 {
68 //!< Screen overscan boundary
69 OVERSCAN Overscan;
70
71 //!< Edge insets to scale the GUI to prevent the display notch from hiding a part of the GUI
72 EdgeInsets guiInsets;
73
74 //!< Specify if it is a fullscreen resolution, otherwise windowed
75 bool bFullScreen;
76
77 //!< Width GUI resolution (pixels), may differ from the screen value if GUI resolution limit, 3D is set or in HiDPI screens
78 int iWidth;
79
80 //!< Height GUI resolution (pixels), may differ from the screen value if GUI resolution limit, 3D is set or in HiDPI screens
81 int iHeight;
82
83 //!< Number of pixels of padding between stereoscopic frames
84 int iBlanking;
85
86 //!< Screen width (logical width in pixels)
87 int iScreenWidth;
88
89 //!< Screen height (logical height in pixels)
90 int iScreenHeight;
91
92 //!< The vertical subtitle baseline position, may be changed by Video calibration
93 int iSubtitles;
94
95 //!< Properties of the resolution e.g. interlaced mode
96 uint32_t dwFlags;
97
98 //!< Pixel aspect ratio
99 float fPixelRatio;
100
101 //!< Refresh rate
102 float fRefreshRate;
103
104 //!< Resolution mode description
105 std::string strMode;
106
107 //!< Resolution output description
108 std::string strOutput;
109
110 //!< Resolution ID
111 std::string strId;
112
113 public:
114 RESOLUTION_INFO(int width = 1280, int height = 720, float aspect = 0, const std::string &mode = "");
115 float DisplayRatio() const;
116 RESOLUTION_INFO(const RESOLUTION_INFO& res);
117 RESOLUTION_INFO& operator=(const RESOLUTION_INFO&) = default;
118 };
119
120 class CResolutionUtils
121 {
122 public:
123 static RESOLUTION ChooseBestResolution(float fps, int width, int height, bool is3D);
124 static bool HasWhitelist();
125 static void PrintWhitelist();
126
127 /*!
128 * \brief Get the max allowed screen resolution, if fullscreen
129 * \param width [OUT] Max width resolution
130 * \param height [OUT] Max height resolution
131 */
132 static void GetMaxAllowedScreenResolution(unsigned int& width, unsigned int& height);
133
134 protected:
135 static void FindResolutionFromWhitelist(float fps, int width, int height, bool is3D, RESOLUTION &resolution);
136 static bool FindResolutionFromOverride(float fps, int width, bool is3D, RESOLUTION &resolution, float& weight, bool fallback);
137 static float RefreshWeight(float refresh, float fps);
138 };