Merge pull request #26350 from jjd-uk/estuary_media_align
[xbmc.git] / xbmc / windowing / X11 / OptionalsReg.cpp
blob01ae37e124723b7675305b7b3fbf1bdcb9c4caa1
1 /*
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.
7 */
9 #include "OptionalsReg.h"
11 #include "cores/VideoPlayer/VideoReferenceClock.h"
13 //-----------------------------------------------------------------------------
14 // VAAPI
15 //-----------------------------------------------------------------------------
16 #if defined (HAVE_LIBVA)
17 #include <va/va_x11.h>
18 #include "cores/VideoPlayer/DVDCodecs/Video/VAAPI.h"
19 #if defined(HAS_GL)
20 #include "cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGL.h"
21 #endif
22 #if defined(HAS_GLES)
23 #include "cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGLES.h"
24 #endif
26 using namespace KODI::WINDOWING::X11;
28 namespace KODI
30 namespace WINDOWING
32 namespace X11
35 class CWinSystemX11GLContext;
37 class CVaapiProxy : public VAAPI::IVaapiWinSystem
39 public:
40 CVaapiProxy() = default;
41 virtual ~CVaapiProxy() = default;
42 VADisplay GetVADisplay() override { return vaGetDisplay(dpy); };
43 void *GetEGLDisplay() override { return eglDisplay; };
45 Display *dpy;
46 void *eglDisplay;
49 CVaapiProxy* VaapiProxyCreate()
51 return new CVaapiProxy();
54 void VaapiProxyDelete(CVaapiProxy *proxy)
56 delete proxy;
59 void VaapiProxyConfig(CVaapiProxy *proxy, void *dpy, void *eglDpy)
61 proxy->dpy = static_cast<Display*>(dpy);
62 proxy->eglDisplay = eglDpy;
65 void VAAPIRegister(CVaapiProxy *winSystem, bool deepColor)
67 VAAPI::CDecoder::Register(winSystem, deepColor);
70 #if defined(HAS_GL)
71 void VAAPIRegisterRenderGL(CVaapiProxy* winSystem, bool& general, bool& deepColor)
73 EGLDisplay eglDpy = winSystem->eglDisplay;
74 VADisplay vaDpy = vaGetDisplay(winSystem->dpy);
75 CRendererVAAPIGL::Register(winSystem, vaDpy, eglDpy, general, deepColor);
77 #endif
79 #if defined(HAS_GLES)
80 void VAAPIRegisterRenderGLES(CVaapiProxy* winSystem, bool& general, bool& deepColor)
82 EGLDisplay eglDpy = winSystem->eglDisplay;
83 VADisplay vaDpy = vaGetDisplay(winSystem->dpy);
84 CRendererVAAPIGLES::Register(winSystem, vaDpy, eglDpy, general, deepColor);
86 #endif
91 #else
92 namespace KODI
94 namespace WINDOWING
96 namespace X11
99 class CVaapiProxy
103 CVaapiProxy* VaapiProxyCreate()
105 return nullptr;
108 void VaapiProxyDelete(CVaapiProxy *proxy)
112 void VaapiProxyConfig(CVaapiProxy *proxy, void *dpy, void *eglDpy)
116 void VAAPIRegister(CVaapiProxy *winSystem, bool deepColor)
120 void VAAPIRegisterRenderGL(CVaapiProxy* winSystem, bool& general, bool& deepColor)
124 void VAAPIRegisterRenderGLES(CVaapiProxy* winSystem, bool& general, bool& deepColor)
131 #endif
133 //-----------------------------------------------------------------------------
134 // GLX
135 //-----------------------------------------------------------------------------
137 #ifdef HAS_GLX
138 #include <GL/glx.h>
139 #include "VideoSyncGLX.h"
140 #include "GLContextGLX.h"
142 namespace KODI
144 namespace WINDOWING
146 namespace X11
149 XID GLXGetWindow(void* context)
151 return static_cast<CGLContextGLX*>(context)->m_glxWindow;
154 void* GLXGetContext(void* context)
156 return static_cast<CGLContextGLX*>(context)->m_glxContext;
159 CGLContext* GLXContextCreate(Display *dpy)
161 return new CGLContextGLX(dpy);
164 CVideoSync* GLXVideoSyncCreate(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem)
166 return new CVideoSyncGLX(clock, winSystem);
172 #else
174 namespace KODI
176 namespace WINDOWING
178 namespace X11
181 XID GLXGetWindow(void* context)
183 return 0;
186 void* GLXGetContext(void* context)
188 return nullptr;
191 CGLContext* GLXContextCreate(Display *dpy)
193 return nullptr;
196 CVideoSync* GLXVideoSyncCreate(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem)
198 return nullptr;
204 #endif
206 //-----------------------------------------------------------------------------
207 // VDPAU
208 //-----------------------------------------------------------------------------
210 #if defined (HAVE_LIBVDPAU)
211 #include "cores/VideoPlayer/DVDCodecs/Video/VDPAU.h"
212 #include "cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVDPAU.h"
214 namespace KODI
216 namespace WINDOWING
218 namespace X11
221 void VDPAURegisterRender()
223 CRendererVDPAU::Register();
226 void VDPAURegister()
228 VDPAU::CDecoder::Register();
234 #else
236 namespace KODI
238 namespace WINDOWING
240 namespace X11
243 void VDPAURegisterRender()
248 void VDPAURegister()
256 #endif