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 <vector>
22 
24 {
25  int width;
26  int height;
27  int flags; //< only D3DPRESENTFLAG_MODEMASK flags
28  int ResInfo_Index;
29 };
30 
32 {
33  float RefreshRate;
34  int ResInfo_Index;
35 };
36 
37 class CDPMSSupport;
38 class CGraphicContext;
39 class CRenderSystemBase;
40 class IRenderLoop;
41 
42 struct VideoPicture;
43 
45 {
46 public:
48  virtual ~CWinSystemBase();
49 
50  static std::unique_ptr<CWinSystemBase> CreateWinSystem();
51 
52  // Access render system interface
53  virtual CRenderSystemBase *GetRenderSystem() { return nullptr; }
54 
55  virtual const std::string GetName() { return "platform default"; }
56 
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();
90  virtual float GetDisplayLatency() { return -1.0f; }
99  virtual float GetFrameLatencyAdjustment() { return 0.0; }
100 
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; }
105 
106  // videosync
107  virtual std::unique_ptr<CVideoSync> GetVideoSync(void *clock) { return nullptr; }
108 
109  // notifications
110  virtual void OnMove(int x, int y) {}
111 
112  // OS System screensaver
121  KODI::WINDOWING::COSScreenSaverManager* GetOSScreenSaver();
122 
123  // resolution interfaces
124  unsigned int GetWidth() { return m_nWidth; }
125  unsigned int GetHeight() { return m_nHeight; }
126  virtual bool CanDoWindowed() { return true; }
127  bool IsFullScreen() { return m_bFullScreen; }
128  virtual void UpdateResolutions();
129  void SetWindowResolution(int width, int height);
130  std::vector<RESOLUTION_WHR> ScreenResolutions(float refreshrate);
131  std::vector<REFRESHRATE> RefreshRates(int width, int height, uint32_t dwFlags);
132  REFRESHRATE DefaultRefreshRate(std::vector<REFRESHRATE> rates);
133  virtual bool HasCalibration(const RESOLUTION_INFO& resInfo) { return true; }
134 
135  // text input interface
136  virtual std::string GetClipboardText(void);
137 
138  // Display event callback
139  virtual void Register(IDispResource *resource) = 0;
140  virtual void Unregister(IDispResource *resource) = 0;
141 
142  // render loop
143  void RegisterRenderLoop(IRenderLoop *client);
144  void UnregisterRenderLoop(IRenderLoop *client);
145  void DriveRenderLoop();
146 
147  // winsystem events
148  virtual bool MessagePump() { return false; }
149 
150  // Access render system interface
151  CGraphicContext& GetGfxContext();
152 
162  virtual void* GetHWContext() { return nullptr; }
163 
164  std::shared_ptr<CDPMSSupport> GetDPMSManager();
165 
171  virtual bool SetHDR(const VideoPicture* videoPicture) { return false; }
172  virtual bool IsHDRDisplay() { return false; }
173  virtual HDR_STATUS ToggleHDR() { return HDR_STATUS::HDR_UNSUPPORTED; }
174  virtual HDR_STATUS GetOSHDRStatus() { return HDR_STATUS::HDR_UNSUPPORTED; }
175  virtual CHDRCapabilities GetDisplayHDRCapabilities() const { return {}; }
176 
177  static const char* SETTING_WINSYSTEM_IS_HDR_DISPLAY;
178 
179  // Gets debug info from video renderer
180  virtual DEBUG_INFO_RENDER GetDebugInfo() { return {}; }
181 
182  virtual std::vector<std::string> GetConnectedOutputs() { return {}; }
183 
184 protected:
185  void UpdateDesktopResolution(RESOLUTION_INFO& newRes, const std::string &output, int width, int height, float refreshRate, uint32_t dwFlags);
186  virtual std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() { return nullptr; }
187 
188  int m_nWidth = 0;
189  int m_nHeight = 0;
190  int m_nTop = 0;
191  int m_nLeft = 0;
192  bool m_bWindowCreated = false;
193  bool m_bFullScreen = false;
194  bool m_bBlankOtherDisplay = false;
195  float m_fRefreshRate = 0.0f;
196  std::unique_ptr<KODI::WINDOWING::COSScreenSaverManager> m_screenSaverManager;
197  CCriticalSection m_renderLoopSection;
198  std::vector<IRenderLoop*> m_renderLoopClients;
199 
200  std::unique_ptr<IWinEvents> m_winEvents;
201  std::unique_ptr<CGraphicContext> m_gfxContext;
202  std::shared_ptr<CDPMSSupport> m_dpms;
203 };
Definition: WinSystem.h:23
Definition: WinSystem.h:31
Definition: DPMSSupport.h:18
Definition: DispResource.h:26
virtual float GetDisplayLatency()
Get average display latency.
Definition: WinSystem.h:90
Definition: WinSystem.h:44
virtual bool SetHDR(const VideoPicture *videoPicture)
Set the HDR metadata.
Definition: WinSystem.h:171
Definition: RenderSystem.h:27
Definition: DispResource.h:14
Provide info of a resolution.
Definition: Resolution.h:66
virtual float GetFrameLatencyAdjustment()
Get time that should be subtracted from the display latency for this frame in milliseconds.
Definition: WinSystem.h:99
virtual void * GetHWContext()
Get OS specific hardware context.
Definition: WinSystem.h:162
Definition: DebugInfo.h:29
Manage the OS screen saver.
Definition: OSScreenSaver.h:92
Definition: DVDVideoCodec.h:36
Definition: HDRCapabilities.h:11
Definition: GraphicContext.h:60