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"
27 int flags
; //< only D3DPRESENTFLAG_MODEMASK flags
38 class CGraphicContext
;
39 class CRenderSystemBase
;
48 virtual ~CWinSystemBase();
50 static std::unique_ptr
<CWinSystemBase
> CreateWinSystem();
52 // Access render system interface
53 virtual CRenderSystemBase
*GetRenderSystem() { return nullptr; }
55 virtual const std::string
GetName() { return "platform default"; }
57 // windowing interfaces
58 virtual bool InitWindowSystem();
59 virtual bool DestroyWindowSystem();
60 virtual bool CreateNewWindow(const std::string
& name
, bool fullScreen
, RESOLUTION_INFO
& res
) = 0;
61 virtual bool DestroyWindow(){ return false; }
62 virtual bool ResizeWindow(int newWidth
, int newHeight
, int newLeft
, int newTop
) = 0;
63 virtual bool SetFullScreen(bool fullScreen
, RESOLUTION_INFO
& res
, bool blankOtherDisplays
) = 0;
64 virtual bool DisplayHardwareScalingEnabled() { return false; }
65 virtual void UpdateDisplayHardwareScaling(const RESOLUTION_INFO
& resInfo
) { }
66 virtual bool MoveWindow(int topLeft
, int topRight
){return false;}
67 virtual void FinishModeChange(RESOLUTION res
){}
68 virtual void FinishWindowResize(int newWidth
, int newHeight
) {ResizeWindow(newWidth
, newHeight
, -1, -1);}
69 virtual bool CenterWindow(){return false;}
70 virtual bool IsCreated(){ return m_bWindowCreated
; }
71 virtual void NotifyAppFocusChange(bool bGaining
) {}
72 virtual void NotifyAppActiveChange(bool bActivated
) {}
73 virtual void ShowOSMouse(bool show
) {}
74 virtual bool HasCursor(){ return true; }
75 //some platforms have api for gesture inertial scrolling - default to false and use the InertialScrollingHandler
76 virtual bool HasInertialGestures(){ return false; }
77 //does the output expect limited color range (ie 16-235)
78 virtual bool UseLimitedColor();
79 //the number of presentation buffers
80 virtual int NoOfBuffers();
82 * Get average display latency
84 * The latency should be measured as the time between finishing the rendering
85 * of a frame, i.e. calling PresentRender, and the rendered content becoming
86 * visible on the screen.
88 * \return average display latency in seconds, or negative value if unknown
90 virtual float GetDisplayLatency() { return -1.0f
; }
92 * Get time that should be subtracted from the display latency for this frame
95 * Contrary to \ref GetDisplayLatency, this value is calculated ad-hoc
96 * for the frame currently being rendered and not a value that is calculated/
97 * averaged from past frames and their presentation times
99 virtual float GetFrameLatencyAdjustment() { return 0.0; }
101 virtual bool Minimize() { return false; }
102 virtual bool Restore() { return false; }
103 virtual bool Hide() { return false; }
104 virtual bool Show(bool raise
= true) { return false; }
107 virtual std::unique_ptr
<CVideoSync
> GetVideoSync(void *clock
) { return nullptr; }
110 virtual void OnMove(int x
, int y
) {}
113 * \brief Used to signal the windowing system about the intention of the user to change the main display
114 * \details triggered, for example, when the user manually changes the monitor setting
116 virtual void NotifyScreenChangeIntention() {}
118 // OS System screensaver
120 * Get OS screen saver inhibit implementation if available
122 * \return OS screen saver implementation that can be used with this windowing system
123 * or nullptr if unsupported.
124 * Lifetime of the returned object will usually end with \ref DestroyWindowSystem, so
125 * do not use any more after calling that.
127 KODI::WINDOWING::COSScreenSaverManager
* GetOSScreenSaver();
129 // resolution interfaces
130 unsigned int GetWidth() { return m_nWidth
; }
131 unsigned int GetHeight() { return m_nHeight
; }
132 virtual bool CanDoWindowed() { return true; }
133 bool IsFullScreen() { return m_bFullScreen
; }
135 /*! \brief Check if the windowing system supports moving windows across screens
136 \return true if the windowing system supports moving windows across screens, false otherwise
138 virtual bool SupportsScreenMove() { return true; }
140 virtual void UpdateResolutions();
141 void SetWindowResolution(int width
, int height
);
142 std::vector
<RESOLUTION_WHR
> ScreenResolutions(float refreshrate
);
143 std::vector
<REFRESHRATE
> RefreshRates(int width
, int height
, uint32_t dwFlags
);
144 REFRESHRATE
DefaultRefreshRate(std::vector
<REFRESHRATE
> rates
);
145 virtual bool HasCalibration(const RESOLUTION_INFO
& resInfo
) { return true; }
147 // text input interface
148 virtual std::string
GetClipboardText(void);
150 // Display event callback
151 virtual void Register(IDispResource
*resource
) = 0;
152 virtual void Unregister(IDispResource
*resource
) = 0;
155 void RegisterRenderLoop(IRenderLoop
*client
);
156 void UnregisterRenderLoop(IRenderLoop
*client
);
157 void DriveRenderLoop();
160 virtual bool MessagePump() { return false; }
162 // Access render system interface
163 CGraphicContext
& GetGfxContext();
166 * Get OS specific hardware context
168 * \return OS specific context or nullptr if OS not have
170 * \note This function is currently only related to Windows with DirectX,
171 * all other OS where use GL returns nullptr.
172 * Returned Windows class pointer is ID3D11DeviceContext1.
174 virtual void* GetHWContext() { return nullptr; }
176 std::shared_ptr
<CDPMSSupport
> GetDPMSManager();
179 * @brief Set the HDR metadata. Passing nullptr as the parameter should
183 virtual bool SetHDR(const VideoPicture
* videoPicture
) { return false; }
184 virtual bool IsHDRDisplay() { return false; }
185 virtual HDR_STATUS
ToggleHDR() { return HDR_STATUS::HDR_UNSUPPORTED
; }
186 virtual HDR_STATUS
GetOSHDRStatus() { return HDR_STATUS::HDR_UNSUPPORTED
; }
187 virtual CHDRCapabilities
GetDisplayHDRCapabilities() const { return {}; }
188 static const char* SETTING_WINSYSTEM_IS_HDR_DISPLAY
;
189 virtual bool HasSystemSdrPeakLuminance() { return false; }
191 // Gets debug info from video renderer
192 virtual DEBUG_INFO_RENDER
GetDebugInfo() { return {}; }
194 virtual std::vector
<std::string
> GetConnectedOutputs() { return {}; }
197 void UpdateDesktopResolution(RESOLUTION_INFO
& newRes
, const std::string
&output
, int width
, int height
, float refreshRate
, uint32_t dwFlags
);
198 virtual std::unique_ptr
<KODI::WINDOWING::IOSScreenSaver
> GetOSScreenSaverImpl() { return nullptr; }
204 bool m_bWindowCreated
= false;
205 bool m_bFullScreen
= false;
206 bool m_bBlankOtherDisplay
= false;
207 float m_fRefreshRate
= 0.0f
;
208 std::unique_ptr
<KODI::WINDOWING::COSScreenSaverManager
> m_screenSaverManager
;
209 CCriticalSection m_renderLoopSection
;
210 std::vector
<IRenderLoop
*> m_renderLoopClients
;
212 std::unique_ptr
<IWinEvents
> m_winEvents
;
213 std::unique_ptr
<CGraphicContext
> m_gfxContext
;
214 std::shared_ptr
<CDPMSSupport
> m_dpms
;