xbmc
WinSystem.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 "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"
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
25 {
26  int width;
27  int height;
28  int m_screenWidth;
29  int m_screenHeight;
30  int flags; //< only D3DPRESENTFLAG_MODEMASK flags
31  int ResInfo_Index;
32  std::string id;
33 };
34 
36 {
37  float RefreshRate;
38  int ResInfo_Index;
39 };
40 
41 class CDPMSSupport;
42 class CGraphicContext;
43 class CRenderSystemBase;
44 class IRenderLoop;
46 
47 struct VideoPicture;
48 
50 {
51 public:
53  virtual ~CWinSystemBase();
54 
55  static std::unique_ptr<CWinSystemBase> CreateWinSystem();
56 
57  // Access render system interface
58  virtual CRenderSystemBase *GetRenderSystem() { return nullptr; }
59 
60  virtual const std::string GetName() { return "platform default"; }
61 
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();
86 
91  virtual void ForceFullScreen(const RESOLUTION_INFO& resInfo) {}
92 
102  virtual float GetDisplayLatency() { return -1.0f; }
103 
112  virtual float GetFrameLatencyAdjustment() { return 0.0; }
113 
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; }
118 
119  // videosync
120  virtual std::unique_ptr<CVideoSync> GetVideoSync(CVideoReferenceClock* clock) { return nullptr; }
121 
122  // notifications
123  virtual void OnMove(int x, int y) {}
124 
131  virtual unsigned int GetScreenId(const std::string& screen) { return 0; }
132 
138  virtual void MoveToScreen(unsigned int screenIdx) {}
139 
145  virtual void OnChangeScreen(unsigned int screenIdx) {}
146 
147  // OS System screensaver
156  KODI::WINDOWING::COSScreenSaverManager* GetOSScreenSaver();
157 
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; }
163 
169  virtual bool SupportsScreenMove() { return true; }
170 
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(std::vector<REFRESHRATE> rates);
176  virtual bool HasCalibration(const RESOLUTION_INFO& resInfo) { return true; }
177 
178  // text input interface
179  virtual std::string GetClipboardText(void);
180 
181  // Display event callback
182  virtual void Register(IDispResource *resource) = 0;
183  virtual void Unregister(IDispResource *resource) = 0;
184 
185  // render loop
186  void RegisterRenderLoop(IRenderLoop *client);
187  void UnregisterRenderLoop(IRenderLoop *client);
188  void DriveRenderLoop();
189 
190  // winsystem events
191  virtual bool MessagePump() { return false; }
192 
193  // Access render system interface
194  virtual CGraphicContext& GetGfxContext() const;
195 
205  virtual void* GetHWContext() { return nullptr; }
206 
207  std::shared_ptr<CDPMSSupport> GetDPMSManager();
208 
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 bool HasSystemSdrPeakLuminance() { return false; }
221 
227  virtual bool SupportsVideoSuperResolution() { return false; }
228 
233  virtual DEBUG_INFO_RENDER GetDebugInfo() { return {}; }
234 
235  virtual std::vector<std::string> GetConnectedOutputs() { return {}; }
236 
241  bool IsHDRDisplaySettingEnabled();
242 
247  bool IsVideoSuperResolutionSettingEnabled();
248 
253  bool IsHighPrecisionProcessingSettingEnabled();
254 
260  std::pair<bool, int> GetDitherSettings();
261 
262 protected:
263  void UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std::string &output, int width, int height, float refreshRate, uint32_t dwFlags);
264  void UpdateDesktopResolution(RESOLUTION_INFO& newRes,
265  const std::string& output,
266  int width,
267  int height,
268  int screenWidth,
269  int screenHeight,
270  float refreshRate,
271  uint32_t dwFlags);
272  virtual std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() { return nullptr; }
273 
274  int m_nWidth = 0;
275  int m_nHeight = 0;
276  int m_nTop = 0;
277  int m_nLeft = 0;
278  bool m_bWindowCreated = false;
279  bool m_bFullScreen = false;
280  bool m_bBlankOtherDisplay = false;
281  float m_fRefreshRate = 0.0f;
282  std::unique_ptr<KODI::WINDOWING::COSScreenSaverManager> m_screenSaverManager;
283  CCriticalSection m_renderLoopSection;
284  std::vector<IRenderLoop*> m_renderLoopClients;
285 
286  std::unique_ptr<IWinEvents> m_winEvents;
287  std::unique_ptr<CGraphicContext> m_gfxContext;
288  std::shared_ptr<CDPMSSupport> m_dpms;
289 };
Definition: WinSystem.h:24
Definition: WinSystem.h:35
Definition: DPMSSupport.h:18
Definition: DispResource.h:26
virtual float GetDisplayLatency()
Get average display latency.
Definition: WinSystem.h:102
Definition: WinSystem.h:49
virtual void ForceFullScreen(const RESOLUTION_INFO &resInfo)
Forces the window to fullscreen provided the window resolution.
Definition: WinSystem.h:91
virtual bool SetHDR(const VideoPicture *videoPicture)
Set the HDR metadata. Passing nullptr as the parameter should disable HDR.
Definition: WinSystem.h:214
Definition: RenderSystem.h:27
virtual bool SupportsVideoSuperResolution()
System supports Video Super Resolution HW upscaler i.e.: "NVIDIA RTX Video Super Resolution" or "Inte...
Definition: WinSystem.h:227
Definition: DispResource.h:14
Provide info of a resolution.
Definition: Resolution.h:66
virtual DEBUG_INFO_RENDER GetDebugInfo()
Gets debug info from video renderer for use in "Debug Info OSD" (Alt + O)
Definition: WinSystem.h:233
virtual float GetFrameLatencyAdjustment()
Get time that should be subtracted from the display latency for this frame in milliseconds.
Definition: WinSystem.h:112
virtual void * GetHWContext()
Get OS specific hardware context.
Definition: WinSystem.h:205
Definition: DebugInfo.h:30
Definition: VideoReferenceClock.h:19
virtual unsigned int GetScreenId(const std::string &screen)
Get the screen ID provided the screen name.
Definition: WinSystem.h:131
Manage the OS screen saver.
Definition: OSScreenSaver.h:92
virtual void MoveToScreen(unsigned int screenIdx)
Window was requested to move to the given screen.
Definition: WinSystem.h:138
Definition: DVDVideoCodec.h:36
virtual bool SupportsScreenMove()
Check if the windowing system supports moving windows across screens.
Definition: WinSystem.h:169
virtual void OnChangeScreen(unsigned int screenIdx)
Used to signal the windowing system about the change of the current screen.
Definition: WinSystem.h:145
Definition: HDRCapabilities.h:11
Definition: GraphicContext.h:60