xbmc
Resolution.h
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 
67 {
70 
73 
76 
78  int iWidth;
79 
81  int iHeight;
82 
84  int iBlanking;
85 
88 
91 
94 
96  uint32_t dwFlags;
97 
99  float fPixelRatio;
100 
103 
105  std::string strMode;
106 
108  std::string strOutput;
109 
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 
121 {
122 public:
123  static RESOLUTION ChooseBestResolution(float fps, int width, int height, bool is3D);
124  static bool HasWhitelist();
125  static void PrintWhitelist();
126 
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 };
uint32_t dwFlags
Pixel aspect ratio.
Definition: Resolution.h:96
bool bFullScreen
Width GUI resolution, may differ from the screen value if GUI resolution limit or 3D is set...
Definition: Resolution.h:75
std::string strMode
Resolution output description.
Definition: Resolution.h:105
EdgeInsets guiInsets
Specify if it is a fullscreen resolution, otherwise windowed.
Definition: Resolution.h:72
OVERSCAN Overscan
< Screen overscan boundary
Definition: Resolution.h:69
Definition: Resolution.h:120
int iScreenHeight
The vertical subtitle baseline position, may be changed by Video calibration.
Definition: Resolution.h:90
float fPixelRatio
Refresh rate.
Definition: Resolution.h:99
int iScreenWidth
Screen height.
Definition: Resolution.h:87
int iBlanking
Screen width.
Definition: Resolution.h:84
int iSubtitles
Properties of the resolution e.g. interlaced mode.
Definition: Resolution.h:93
Provide info of a resolution.
Definition: Resolution.h:66
int iWidth
Height GUI resolution, may differ from the screen value if GUI resolution limit or 3D is set...
Definition: Resolution.h:78
Definition: Resolution.h:26
Definition: Resolution.h:54
float fRefreshRate
Resolution mode description.
Definition: Resolution.h:102
std::string strOutput
Resolution ID.
Definition: Resolution.h:108
int iHeight
Number of pixels of padding between stereoscopic frames.
Definition: Resolution.h:81