1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include <stdint.h>
#include <string>
typedef int DisplayMode;
#define DM_WINDOWED -1
#define DM_FULLSCREEN 0
enum RESOLUTION
{
RES_INVALID = -1,
RES_WINDOW = 15,
RES_DESKTOP = 16, // Desktop resolution
RES_CUSTOM = 16 + 1, // First additional resolution
};
struct OVERSCAN
{
int left;
int top;
int right;
int bottom;
public:
OVERSCAN()
{
left = top = right = bottom = 0;
}
OVERSCAN(const OVERSCAN& os)
{
left = os.left; top = os.top;
right = os.right; bottom = os.bottom;
}
OVERSCAN& operator=(const OVERSCAN&) = default;
bool operator==(const OVERSCAN& other)
{
return left == other.left && right == other.right && top == other.top && bottom == other.bottom;
}
bool operator!=(const OVERSCAN& other)
{
return left != other.left || right != other.right || top != other.top || bottom != other.bottom;
}
};
struct EdgeInsets
{
float left = 0.0f;
float top = 0.0f;
float right = 0.0f;
float bottom = 0.0f;
EdgeInsets() = default;
EdgeInsets(float l, float t, float r, float b);
};
struct RESOLUTION_INFO
{
OVERSCAN Overscan;
EdgeInsets guiInsets;
bool bFullScreen;
int iWidth;
int iHeight;
int iBlanking; /**< number of pixels of padding between stereoscopic frames */
int iScreenWidth;
int iScreenHeight;
int iSubtitles;
uint32_t dwFlags;
float fPixelRatio;
float fRefreshRate;
std::string strMode;
std::string strOutput;
std::string strId;
public:
RESOLUTION_INFO(int width = 1280, int height = 720, float aspect = 0, const std::string &mode = "");
float DisplayRatio() const;
RESOLUTION_INFO(const RESOLUTION_INFO& res);
RESOLUTION_INFO& operator=(const RESOLUTION_INFO&) = default;
};
class CResolutionUtils
{
public:
static RESOLUTION ChooseBestResolution(float fps, int width, int height, bool is3D);
static bool HasWhitelist();
static void PrintWhitelist();
/*!
* \brief Get the max allowed resolution, if fullscreen
* \param width [OUT] Max width resolution
* \param height [OUT] Max height resolution
*/
static void GetMaxAllowedResolution(unsigned int& width, unsigned int& height);
protected:
static void FindResolutionFromWhitelist(float fps, int width, int height, bool is3D, RESOLUTION &resolution);
static bool FindResolutionFromOverride(float fps, int width, bool is3D, RESOLUTION &resolution, float& weight, bool fallback);
static float RefreshWeight(float refresh, float fps);
};
|