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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/*
* 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 "HDRStatus.h"
#include "OSScreenSaver.h"
#include "Resolution.h"
#include "VideoSync.h"
#include "WinEvents.h"
#include "cores/VideoPlayer/VideoRenderers/DebugInfo.h"
#include "guilib/DispResource.h"
#include "utils/HDRCapabilities.h"
#include <memory>
#include <vector>
struct RESOLUTION_WHR
{
int width;
int height;
int flags; //< only D3DPRESENTFLAG_MODEMASK flags
int ResInfo_Index;
};
struct REFRESHRATE
{
float RefreshRate;
int ResInfo_Index;
};
class CDPMSSupport;
class CGraphicContext;
class CRenderSystemBase;
class IRenderLoop;
struct VideoPicture;
class CWinSystemBase
{
public:
CWinSystemBase();
virtual ~CWinSystemBase();
static std::unique_ptr<CWinSystemBase> CreateWinSystem();
// Access render system interface
virtual CRenderSystemBase *GetRenderSystem() { return nullptr; }
virtual const std::string GetName() { return "platform default"; }
// windowing interfaces
virtual bool InitWindowSystem();
virtual bool DestroyWindowSystem();
virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) = 0;
virtual bool DestroyWindow(){ return false; }
virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) = 0;
virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) = 0;
virtual bool DisplayHardwareScalingEnabled() { return false; }
virtual void UpdateDisplayHardwareScaling(const RESOLUTION_INFO& resInfo) { }
virtual bool MoveWindow(int topLeft, int topRight){return false;}
virtual void FinishModeChange(RESOLUTION res){}
virtual void FinishWindowResize(int newWidth, int newHeight) {ResizeWindow(newWidth, newHeight, -1, -1);}
virtual bool CenterWindow(){return false;}
virtual bool IsCreated(){ return m_bWindowCreated; }
virtual void NotifyAppFocusChange(bool bGaining) {}
virtual void NotifyAppActiveChange(bool bActivated) {}
virtual void ShowOSMouse(bool show) {}
virtual bool HasCursor(){ return true; }
//some platforms have api for gesture inertial scrolling - default to false and use the InertialScrollingHandler
virtual bool HasInertialGestures(){ return false; }
//does the output expect limited color range (ie 16-235)
virtual bool UseLimitedColor();
//the number of presentation buffers
virtual int NoOfBuffers();
/**
* Get average display latency
*
* The latency should be measured as the time between finishing the rendering
* of a frame, i.e. calling PresentRender, and the rendered content becoming
* visible on the screen.
*
* \return average display latency in seconds, or negative value if unknown
*/
virtual float GetDisplayLatency() { return -1.0f; }
/**
* Get time that should be subtracted from the display latency for this frame
* in milliseconds
*
* Contrary to \ref GetDisplayLatency, this value is calculated ad-hoc
* for the frame currently being rendered and not a value that is calculated/
* averaged from past frames and their presentation times
*/
virtual float GetFrameLatencyAdjustment() { return 0.0; }
virtual bool Minimize() { return false; }
virtual bool Restore() { return false; }
virtual bool Hide() { return false; }
virtual bool Show(bool raise = true) { return false; }
// videosync
virtual std::unique_ptr<CVideoSync> GetVideoSync(void *clock) { return nullptr; }
// notifications
virtual void OnMove(int x, int y) {}
// OS System screensaver
/**
* Get OS screen saver inhibit implementation if available
*
* \return OS screen saver implementation that can be used with this windowing system
* or nullptr if unsupported.
* Lifetime of the returned object will usually end with \ref DestroyWindowSystem, so
* do not use any more after calling that.
*/
KODI::WINDOWING::COSScreenSaverManager* GetOSScreenSaver();
// resolution interfaces
unsigned int GetWidth() { return m_nWidth; }
unsigned int GetHeight() { return m_nHeight; }
virtual bool CanDoWindowed() { return true; }
bool IsFullScreen() { return m_bFullScreen; }
virtual void UpdateResolutions();
void SetWindowResolution(int width, int height);
std::vector<RESOLUTION_WHR> ScreenResolutions(float refreshrate);
std::vector<REFRESHRATE> RefreshRates(int width, int height, uint32_t dwFlags);
REFRESHRATE DefaultRefreshRate(std::vector<REFRESHRATE> rates);
virtual bool HasCalibration(const RESOLUTION_INFO& resInfo) { return true; }
// text input interface
virtual std::string GetClipboardText(void);
// Display event callback
virtual void Register(IDispResource *resource) = 0;
virtual void Unregister(IDispResource *resource) = 0;
// render loop
void RegisterRenderLoop(IRenderLoop *client);
void UnregisterRenderLoop(IRenderLoop *client);
void DriveRenderLoop();
// winsystem events
virtual bool MessagePump() { return false; }
// Access render system interface
CGraphicContext& GetGfxContext();
/**
* Get OS specific hardware context
*
* \return OS specific context or nullptr if OS not have
*
* \note This function is currently only related to Windows with DirectX,
* all other OS where use GL returns nullptr.
* Returned Windows class pointer is ID3D11DeviceContext1.
*/
virtual void* GetHWContext() { return nullptr; }
std::shared_ptr<CDPMSSupport> GetDPMSManager();
/**
* @brief Set the HDR metadata. Passing nullptr as the parameter should
* disable HDR.
*
*/
virtual bool SetHDR(const VideoPicture* videoPicture) { return false; }
virtual bool IsHDRDisplay() { return false; }
virtual HDR_STATUS ToggleHDR() { return HDR_STATUS::HDR_UNSUPPORTED; }
virtual HDR_STATUS GetOSHDRStatus() { return HDR_STATUS::HDR_UNSUPPORTED; }
virtual CHDRCapabilities GetDisplayHDRCapabilities() const { return {}; }
static const char* SETTING_WINSYSTEM_IS_HDR_DISPLAY;
// Gets debug info from video renderer
virtual DEBUG_INFO_RENDER GetDebugInfo() { return {}; }
virtual std::vector<std::string> GetConnectedOutputs() { return {}; }
protected:
void UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std::string &output, int width, int height, float refreshRate, uint32_t dwFlags);
virtual std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() { return nullptr; }
int m_nWidth = 0;
int m_nHeight = 0;
int m_nTop = 0;
int m_nLeft = 0;
bool m_bWindowCreated = false;
bool m_bFullScreen = false;
bool m_bBlankOtherDisplay = false;
float m_fRefreshRate = 0.0f;
std::unique_ptr<KODI::WINDOWING::COSScreenSaverManager> m_screenSaverManager;
CCriticalSection m_renderLoopSection;
std::vector<IRenderLoop*> m_renderLoopClients;
std::unique_ptr<IWinEvents> m_winEvents;
std::unique_ptr<CGraphicContext> m_gfxContext;
std::shared_ptr<CDPMSSupport> m_dpms;
};
|