aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2017-09-07 22:16:01 -0700
committerLukas Rusak <lorusak@gmail.com>2017-09-18 15:50:16 -0700
commit53b30b8a9dbb89573171c5827fbceb92ea255221 (patch)
tree514edab8e8e2bdced3ef34f53aedca447c0495b1
parent56a260206a2c6abca0972fba8e43d779366cebcf (diff)
x11: factor out glx support
-rw-r--r--xbmc/windowing/X11/CMakeLists.txt11
-rw-r--r--xbmc/windowing/X11/WinSystemX11GLContext.cpp43
-rw-r--r--xbmc/windowing/X11/WinSystemX11GLContext.h6
3 files changed, 41 insertions, 19 deletions
diff --git a/xbmc/windowing/X11/CMakeLists.txt b/xbmc/windowing/X11/CMakeLists.txt
index ab13817839..965a06d580 100644
--- a/xbmc/windowing/X11/CMakeLists.txt
+++ b/xbmc/windowing/X11/CMakeLists.txt
@@ -1,23 +1,26 @@
set(SOURCES GLContextEGL.cpp
- GLContextGLX.cpp
GLContext.cpp
OSScreenSaverX11.cpp
WinEventsX11.cpp
WinSystemX11.cpp
WinSystemX11GLContext.cpp
XRandR.cpp
- VideoSyncGLX.cpp
VideoSyncDRM.cpp)
set(HEADERS GLContext.h
GLContextEGL.h
- GLContextGLX.h
OSScreenSaverX11.h
WinEventsX11.h
WinSystemX11.h
WinSystemX11GLContext.h
XRandR.h
- VideoSyncGLX.h
VideoSyncDRM.h)
+if(GLX_FOUND)
+ list(APPEND SOURCES GLContextGLX.cpp
+ VideoSyncGLX.cpp)
+ list(APPEND HEADERS GLContextGLX.h
+ VideoSyncGLX.h)
+endif()
+
core_add_library(windowing_X11)
diff --git a/xbmc/windowing/X11/WinSystemX11GLContext.cpp b/xbmc/windowing/X11/WinSystemX11GLContext.cpp
index 3936f423a0..bddfbd2ce7 100644
--- a/xbmc/windowing/X11/WinSystemX11GLContext.cpp
+++ b/xbmc/windowing/X11/WinSystemX11GLContext.cpp
@@ -23,7 +23,6 @@
#include <X11/Xutil.h>
#include "WinSystemX11GLContext.h"
-#include "GLContextGLX.h"
#include "GLContextEGL.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
@@ -33,7 +32,12 @@
#include <vector>
#include "Application.h"
#include "VideoSyncDRM.h"
+
+#ifdef HAS_GLX
#include "VideoSyncGLX.h"
+#include "GLContextGLX.h"
+#endif // HAS_GLX
+
#include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h"
#include "cores/VideoPlayer/Process/X11/ProcessInfoX11.h"
#include "cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h"
@@ -50,7 +54,7 @@ void CWinSystemX11GLContext::PresentRenderImpl(bool rendered)
{
if (rendered)
m_pGLContext->SwapBuffers();
-
+
if (m_delayDispReset && m_dispResetTimer.IsTimePast())
{
m_delayDispReset = false;
@@ -74,6 +78,7 @@ bool CWinSystemX11GLContext::IsExtSupported(const char* extension)
return m_pGLContext->IsExtSupported(extension);
}
+#ifdef HAS_GLX
GLXWindow CWinSystemX11GLContext::GetWindow() const
{
return static_cast<CGLContextGLX*>(m_pGLContext)->m_glxWindow;
@@ -83,6 +88,7 @@ GLXContext CWinSystemX11GLContext::GetGlxContext() const
{
return static_cast<CGLContextGLX*>(m_pGLContext)->m_glxContext;
}
+#endif // HAS_GLX
EGLDisplay CWinSystemX11GLContext::GetEGLDisplay() const
{
@@ -177,18 +183,20 @@ bool CWinSystemX11GLContext::DestroyWindow()
XVisualInfo* CWinSystemX11GLContext::GetVisual()
{
- GLint att[] =
- {
- GLX_RGBA,
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 24,
- GLX_DOUBLEBUFFER,
- None
- };
- return glXChooseVisual(m_dpy, m_nScreen, att);
+ int count = 0;
+ XVisualInfo vTemplate;
+ XVisualInfo *visual = nullptr;
+
+ int vMask = VisualScreenMask | VisualDepthMask | VisualClassMask | VisualBitsPerRGBMask;
+
+ vTemplate.screen = m_nScreen;
+ vTemplate.depth = 24;
+ vTemplate.c_class = TrueColor;
+ vTemplate.bits_per_rgb = 8;
+
+ visual = XGetVisualInfo(m_dpy, vMask, &vTemplate, &count);
+
+ return visual;
}
#if defined (HAVE_LIBVA)
@@ -236,9 +244,11 @@ bool CWinSystemX11GLContext::RefreshGLContext(bool force)
#endif
return success;
}
- delete m_pGLContext;
}
+#ifdef HAS_GLX
+ delete m_pGLContext;
+
// fallback for vdpau
m_pGLContext = new CGLContextGLX(m_dpy);
success = m_pGLContext->Refresh(force, m_nScreen, m_glWindow, m_newGlContext);
@@ -249,6 +259,7 @@ bool CWinSystemX11GLContext::RefreshGLContext(bool force)
CRendererVDPAU::Register();
#endif
}
+#endif // HAS_GLX
return success;
}
@@ -260,10 +271,12 @@ std::unique_ptr<CVideoSync> CWinSystemX11GLContext::GetVideoSync(void *clock)
{
pVSync.reset(new CVideoSyncDRM(clock));
}
+#ifdef HAS_GLX
else if (dynamic_cast<CGLContextGLX*>(m_pGLContext))
{
pVSync.reset(new CVideoSyncGLX(clock));
}
+#endif // HAS_GLX
return pVSync;
}
diff --git a/xbmc/windowing/X11/WinSystemX11GLContext.h b/xbmc/windowing/X11/WinSystemX11GLContext.h
index 4debaff3fa..405ac09771 100644
--- a/xbmc/windowing/X11/WinSystemX11GLContext.h
+++ b/xbmc/windowing/X11/WinSystemX11GLContext.h
@@ -21,7 +21,11 @@
#pragma once
#include "WinSystemX11.h"
+
+#ifdef HAS_GLX
#include "GL/glx.h"
+#endif // HAS_GLX
+
#include "EGL/egl.h"
#include "rendering/gl/RenderSystemGL.h"
#include "utils/GlobalsHandling.h"
@@ -44,8 +48,10 @@ public:
// videosync
std::unique_ptr<CVideoSync> GetVideoSync(void *clock) override;
+#ifdef HAS_GLX
GLXWindow GetWindow() const;
GLXContext GetGlxContext() const;
+#endif // HAS_GLX
EGLDisplay GetEGLDisplay() const;
EGLSurface GetEGLSurface() const;
EGLContext GetEGLContext() const;