Merge pull request #26350 from jjd-uk/estuary_media_align
[xbmc.git] / xbmc / windowing / Resolution.h
blob0edf0ffe81b8ff6eb577f603fe79ef1f52b223a7
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <stdint.h>
12 #include <string>
14 typedef int DisplayMode;
15 #define DM_WINDOWED -1
16 #define DM_FULLSCREEN 0
18 enum RESOLUTION
20 RES_INVALID = -1,
21 RES_WINDOW = 15,
22 RES_DESKTOP = 16, // Desktop resolution
23 RES_CUSTOM = 16 + 1, // First additional resolution
26 struct OVERSCAN
28 int left;
29 int top;
30 int right;
31 int bottom;
32 public:
33 OVERSCAN()
35 left = top = right = bottom = 0;
37 OVERSCAN(const OVERSCAN& os)
39 left = os.left; top = os.top;
40 right = os.right; bottom = os.bottom;
42 OVERSCAN& operator=(const OVERSCAN&) = default;
44 bool operator==(const OVERSCAN& other)
46 return left == other.left && right == other.right && top == other.top && bottom == other.bottom;
48 bool operator!=(const OVERSCAN& other)
50 return left != other.left || right != other.right || top != other.top || bottom != other.bottom;
54 struct EdgeInsets
56 float left = 0.0f;
57 float top = 0.0f;
58 float right = 0.0f;
59 float bottom = 0.0f;
61 EdgeInsets() = default;
62 EdgeInsets(float l, float t, float r, float b);
65 //! @brief Provide info of a resolution
66 struct RESOLUTION_INFO
68 //!< Screen overscan boundary
69 OVERSCAN Overscan;
71 //!< Edge insets to scale the GUI to prevent the display notch from hiding a part of the GUI
72 EdgeInsets guiInsets;
74 //!< Specify if it is a fullscreen resolution, otherwise windowed
75 bool bFullScreen;
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;
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;
83 //!< Number of pixels of padding between stereoscopic frames
84 int iBlanking;
86 //!< Screen width (logical width in pixels)
87 int iScreenWidth;
89 //!< Screen height (logical height in pixels)
90 int iScreenHeight;
92 //!< The vertical subtitle baseline position, may be changed by Video calibration
93 int iSubtitles;
95 //!< Properties of the resolution e.g. interlaced mode
96 uint32_t dwFlags;
98 //!< Pixel aspect ratio
99 float fPixelRatio;
101 //!< Refresh rate
102 float fRefreshRate;
104 //!< Resolution mode description
105 std::string strMode;
107 //!< Resolution output description
108 std::string strOutput;
110 //!< Resolution ID
111 std::string strId;
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;
120 class CResolutionUtils
122 public:
123 static RESOLUTION ChooseBestResolution(float fps, int width, int height, bool is3D);
124 static bool HasWhitelist();
125 static void PrintWhitelist();
128 * \brief Get the max allowed screen resolution, if fullscreen
129 * \param width [OUT] Max width resolution
130 * \param height [OUT] Max height resolution
132 static void GetMaxAllowedScreenResolution(unsigned int& width, unsigned int& height);
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);