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.
11 #include "HDRStatus.h"
12 #include "OSScreenSaver.h"
13 #include "Resolution.h"
14 #include "VideoSync.h"
15 #include "WinEvents.h"
16 #include "cores/VideoPlayer/VideoRenderers/DebugInfo.h"
17 #include "guilib/DispResource.h"
18 #include "utils/HDRCapabilities.h"
30 int flags
; //< only D3DPRESENTFLAG_MODEMASK flags
42 class CGraphicContext
;
43 class CRenderSystemBase
;
45 class CVideoReferenceClock
;
53 virtual ~CWinSystemBase();
55 static std::unique_ptr
<CWinSystemBase
> CreateWinSystem();
57 // Access render system interface
58 virtual CRenderSystemBase
*GetRenderSystem() { return nullptr; }
60 virtual const std::string
GetName() { return "platform default"; }
62 // windowing interfaces
63 virtual bool InitWindowSystem();
64 virtual bool DestroyWindowSystem();
65 virtual bool CreateNewWindow(const std::string
& name
, bool fullScreen
, RESOLUTION_INFO
& res
) = 0;
66 virtual bool DestroyWindow(){ return false; }
67 virtual bool ResizeWindow(int newWidth
, int newHeight
, int newLeft
, int newTop
) = 0;
68 virtual bool SetFullScreen(bool fullScreen
, RESOLUTION_INFO
& res
, bool blankOtherDisplays
) = 0;
69 virtual bool DisplayHardwareScalingEnabled() { return false; }
70 virtual void UpdateDisplayHardwareScaling(const RESOLUTION_INFO
& resInfo
) { }
71 virtual bool MoveWindow(int topLeft
, int topRight
){return false;}
72 virtual void FinishModeChange(RESOLUTION res
){}
73 virtual void FinishWindowResize(int newWidth
, int newHeight
) {ResizeWindow(newWidth
, newHeight
, -1, -1);}
74 virtual bool CenterWindow(){return false;}
75 virtual bool IsCreated(){ return m_bWindowCreated
; }
76 virtual void NotifyAppFocusChange(bool bGaining
) {}
77 virtual void NotifyAppActiveChange(bool bActivated
) {}
78 virtual void ShowOSMouse(bool show
) {}
79 virtual bool HasCursor(){ return true; }
80 //some platforms have api for gesture inertial scrolling - default to false and use the InertialScrollingHandler
81 virtual bool HasInertialGestures(){ return false; }
82 //does the output expect limited color range (ie 16-235)
83 virtual bool UseLimitedColor();
84 //the number of presentation buffers
85 virtual int NoOfBuffers();
88 * \brief Forces the window to fullscreen provided the window resolution
89 * \param resInfo - the resolution info
91 virtual void ForceFullScreen(const RESOLUTION_INFO
& resInfo
) {}
94 * \brief Get average display latency
96 * The latency should be measured as the time between finishing the rendering
97 * of a frame, i.e. calling PresentRender, and the rendered content becoming
98 * visible on the screen.
100 * \return average display latency in seconds, or negative value if unknown
102 virtual float GetDisplayLatency() { return -1.0f
; }
105 * \brief Get time that should be subtracted from the display latency for this frame
108 * Contrary to \ref GetDisplayLatency, this value is calculated ad-hoc
109 * for the frame currently being rendered and not a value that is calculated/
110 * averaged from past frames and their presentation times
112 virtual float GetFrameLatencyAdjustment() { return 0.0; }
114 virtual bool Minimize() { return false; }
115 virtual bool Restore() { return false; }
116 virtual bool Hide() { return false; }
117 virtual bool Show(bool raise
= true) { return false; }
120 virtual std::unique_ptr
<CVideoSync
> GetVideoSync(CVideoReferenceClock
* clock
) { return nullptr; }
123 virtual void OnMove(int x
, int y
) {}
126 * \brief Get the screen ID provided the screen name
128 * \param screen the name of the screen as presented on the application display settings
129 * \return the screen index as known by the windowing system implementation (or the default screen by default)
131 virtual unsigned int GetScreenId(const std::string
& screen
) { return 0; }
134 * \brief Window was requested to move to the given screen
136 * \param screenIdx the screen index as known by the windowing system implementation
138 virtual void MoveToScreen(unsigned int screenIdx
) {}
141 * \brief Used to signal the windowing system about the change of the current screen
143 * \param screenIdx the screen index as known by the windowing system implementation
145 virtual void OnChangeScreen(unsigned int screenIdx
) {}
147 // OS System screensaver
149 * \brief Get OS screen saver inhibit implementation if available
151 * \return OS screen saver implementation that can be used with this windowing system
152 * or nullptr if unsupported.
153 * Lifetime of the returned object will usually end with \ref DestroyWindowSystem, so
154 * do not use any more after calling that.
156 KODI::WINDOWING::COSScreenSaverManager
* GetOSScreenSaver();
158 // resolution interfaces
159 unsigned int GetWidth() { return m_nWidth
; }
160 unsigned int GetHeight() { return m_nHeight
; }
161 virtual bool CanDoWindowed() { return true; }
162 bool IsFullScreen() { return m_bFullScreen
; }
165 * \brief Check if the windowing system supports moving windows across screens
167 * \return true if the windowing system supports moving windows across screens, false otherwise
169 virtual bool SupportsScreenMove() { return true; }
171 virtual void UpdateResolutions();
172 void SetWindowResolution(int width
, int height
);
173 std::vector
<RESOLUTION_WHR
> ScreenResolutions(float refreshrate
);
174 std::vector
<REFRESHRATE
> RefreshRates(int width
, int height
, uint32_t dwFlags
);
175 REFRESHRATE
DefaultRefreshRate(const std::vector
<REFRESHRATE
>& rates
);
176 virtual bool HasCalibration(const RESOLUTION_INFO
& resInfo
) { return true; }
178 // text input interface
179 virtual std::string
GetClipboardText(void);
181 // Display event callback
182 virtual void Register(IDispResource
*resource
) = 0;
183 virtual void Unregister(IDispResource
*resource
) = 0;
186 void RegisterRenderLoop(IRenderLoop
*client
);
187 void UnregisterRenderLoop(IRenderLoop
*client
);
188 void DriveRenderLoop();
191 virtual bool MessagePump() { return false; }
193 // Access render system interface
194 virtual CGraphicContext
& GetGfxContext() const;
197 * \brief Get OS specific hardware context
199 * \return OS specific context or nullptr if OS not have
201 * \note This function is currently only related to Windows with DirectX,
202 * all other OS where use GL returns nullptr.
203 * Returned Windows class pointer is ID3D11DeviceContext1.
205 virtual void* GetHWContext() { return nullptr; }
207 std::shared_ptr
<CDPMSSupport
> GetDPMSManager();
210 * \brief Set the HDR metadata. Passing nullptr as the parameter should
214 virtual bool SetHDR(const VideoPicture
* videoPicture
) { return false; }
215 virtual bool IsHDRDisplay() { return false; }
216 virtual HDR_STATUS
ToggleHDR() { return HDR_STATUS::HDR_UNSUPPORTED
; }
217 virtual HDR_STATUS
GetOSHDRStatus() { return HDR_STATUS::HDR_UNSUPPORTED
; }
218 virtual CHDRCapabilities
GetDisplayHDRCapabilities() const { return {}; }
219 static const char* SETTING_WINSYSTEM_IS_HDR_DISPLAY
;
220 virtual float GetGuiSdrPeakLuminance() const { return .0f
; }
221 virtual bool HasSystemSdrPeakLuminance() { return false; }
224 * \brief System supports Video Super Resolution HW upscaler i.e.:
225 * "NVIDIA RTX Video Super Resolution" or "Intel Video Super Resolution"
228 virtual bool SupportsVideoSuperResolution() { return false; }
231 * \brief Gets debug info from video renderer for use in "Debug Info OSD" (Alt + O)
234 virtual DEBUG_INFO_RENDER
GetDebugInfo() { return {}; }
236 virtual std::vector
<std::string
> GetConnectedOutputs() { return {}; }
239 * \brief Return true when HDR display is available and enabled in settings
242 bool IsHDRDisplaySettingEnabled();
245 * \brief Return true when "Video Super Resolution" is supported and enabled in settings
248 bool IsVideoSuperResolutionSettingEnabled();
251 * \brief Return true when setting "High Precision Processing" is enabled
254 bool IsHighPrecisionProcessingSettingEnabled();
257 * \brief Get dither settings
259 * \return std::pair containing dither enabled (bool) and dither depth (int)
261 std::pair
<bool, int> GetDitherSettings();
264 void UpdateDesktopResolution(RESOLUTION_INFO
& newRes
, const std::string
&output
, int width
, int height
, float refreshRate
, uint32_t dwFlags
);
265 void UpdateDesktopResolution(RESOLUTION_INFO
& newRes
,
266 const std::string
& output
,
273 virtual std::unique_ptr
<KODI::WINDOWING::IOSScreenSaver
> GetOSScreenSaverImpl() { return nullptr; }
279 bool m_bWindowCreated
= false;
280 bool m_bFullScreen
= false;
281 bool m_bBlankOtherDisplay
= false;
282 float m_fRefreshRate
= 0.0f
;
283 std::unique_ptr
<KODI::WINDOWING::COSScreenSaverManager
> m_screenSaverManager
;
284 CCriticalSection m_renderLoopSection
;
285 std::vector
<IRenderLoop
*> m_renderLoopClients
;
287 std::unique_ptr
<IWinEvents
> m_winEvents
;
288 std::unique_ptr
<CGraphicContext
> m_gfxContext
;
289 std::shared_ptr
<CDPMSSupport
> m_dpms
;