Bind building of glx support on whether epoxy has a glx header

So far it was bound to whether we build for GLES. But this is
semantically wrong. It might be possible that even on desktop gl
epoxy is built without GLX support, thus we need to reflect this.

This change ensures that epoxy/glx.h is only included if available,
that relevant code is bound to it and that checks are in place to
enforce EGL if not build with glx support.

In addtion the glxbackend.cpp is now only included in the build set
if available.
icc-effect-5.14.5
Martin Gräßlin 2015-10-30 11:50:31 +01:00
parent 9919627106
commit 03231942bb
12 changed files with 46 additions and 19 deletions

View File

@ -272,6 +272,7 @@ endif()
include_directories(${XKB_INCLUDE_DIR}) include_directories(${XKB_INCLUDE_DIR})
include_directories(${epoxy_INCLUDE_DIR}) include_directories(${epoxy_INCLUDE_DIR})
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
# for things that are also used by kwin libraries # for things that are also used by kwin libraries
configure_file(libkwineffects/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects/kwinconfig.h ) configure_file(libkwineffects/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects/kwinconfig.h )
@ -355,7 +356,6 @@ set(kwin_KDEINIT_SRCS
scene_xrender.cpp scene_xrender.cpp
scene_opengl.cpp scene_opengl.cpp
scene_qpainter.cpp scene_qpainter.cpp
glxbackend.cpp
thumbnailitem.cpp thumbnailitem.cpp
lanczosfilter.cpp lanczosfilter.cpp
deleted.cpp deleted.cpp
@ -392,6 +392,10 @@ set(kwin_KDEINIT_SRCS
wayland_cursor_theme.cpp wayland_cursor_theme.cpp
) )
if(HAVE_EPOXY_GLX)
set(kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} glxbackend.cpp)
endif()
if(KWIN_BUILD_TABBOX) if(KWIN_BUILD_TABBOX)
set( set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}

View File

@ -5,6 +5,7 @@
# epoxy_LIBRARY - The libepoxy library # epoxy_LIBRARY - The libepoxy library
# epoxy_INCLUDE_DIR - The libepoxy include dir # epoxy_INCLUDE_DIR - The libepoxy include dir
# epoxy_DEFINITIONS - Compiler switches required for using libepoxy # epoxy_DEFINITIONS - Compiler switches required for using libepoxy
# epoxy_HAS_GLX - Whether GLX support is available
# Copyright (c) 2014 Fredrik Höglund <fredrik@kde.org> # Copyright (c) 2014 Fredrik Höglund <fredrik@kde.org>
# #
@ -40,9 +41,16 @@ if (NOT WIN32)
find_path(epoxy_INCLUDE_DIR NAMES epoxy/gl.h HINTS ${PKG_epoxy_INCLUDEDIR} ${PKG_epoxy_INCLUDE_DIRS}) find_path(epoxy_INCLUDE_DIR NAMES epoxy/gl.h HINTS ${PKG_epoxy_INCLUDEDIR} ${PKG_epoxy_INCLUDE_DIRS})
find_library(epoxy_LIBRARY NAMES epoxy HINTS ${PKG_epoxy_LIBDIR} ${PKG_epoxy_LIBRARY_DIRS}) find_library(epoxy_LIBRARY NAMES epoxy HINTS ${PKG_epoxy_LIBDIR} ${PKG_epoxy_LIBRARY_DIRS})
find_file(epoxy_GLX_HEADER NAMES epoxy/glx.h HINTS ${epoxy_INCLUDE_DIR})
if (epoxy_GLX_HEADER STREQUAL "epoxy_GLX_HEADER-NOTFOUND")
set(epoxy_HAS_GLX FALSE CACHE BOOL "whether glx is available")
else ()
set(epoxy_HAS_GLX TRUE CACHE BOOL "whether glx is available")
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(epoxy DEFAULT_MSG epoxy_LIBRARY epoxy_INCLUDE_DIR) find_package_handle_standard_args(epoxy DEFAULT_MSG epoxy_LIBRARY epoxy_INCLUDE_DIR)
mark_as_advanced(epoxy_INCLUDE_DIR epoxy_LIBRARY) mark_as_advanced(epoxy_INCLUDE_DIR epoxy_LIBRARY epoxy_HAS_GLX)
endif() endif()

View File

@ -241,7 +241,10 @@ void CompositorDBusInterface::suspend()
QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const
{ {
QStringList interfaces; QStringList interfaces;
bool supportsGlx = (kwinApp()->operationMode() == Application::OperationModeX11); bool supportsGlx = false;
#if HAVE_EPOXY_GLX
supportsGlx = (kwinApp()->operationMode() == Application::OperationModeX11);
#endif
#ifdef KWIN_HAVE_OPENGLES #ifdef KWIN_HAVE_OPENGLES
supportsGlx = false; supportsGlx = false;
#endif #endif

View File

@ -22,8 +22,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
// TODO: cmake magic
#ifndef KWIN_HAVE_OPENGLES
// own // own
#include "glxbackend.h" #include "glxbackend.h"
// kwin // kwin
@ -870,4 +868,3 @@ OpenGLBackend *GlxTexture::backend()
} }
} // namespace } // namespace
#endif

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "x11eventfilter.h" #include "x11eventfilter.h"
#include <xcb/glx.h> #include <xcb/glx.h>
#include <epoxy/glx.h>
#include <memory> #include <memory>
namespace KWin namespace KWin

View File

@ -19,5 +19,7 @@
/* KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available */ /* KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available */
#cmakedefine KWIN_HAVE_XRENDER_COMPOSITING #cmakedefine KWIN_HAVE_XRENDER_COMPOSITING
#cmakedefine01 HAVE_EPOXY_GLX
#endif #endif

View File

@ -45,6 +45,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <math.h> #include <math.h>
#if HAVE_EPOXY_GLX
#include <epoxy/glx.h>
#endif
#define DEBUG_GLRENDERTARGET 0 #define DEBUG_GLRENDERTARGET 0
#define MAKE_GL_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) ) #define MAKE_GL_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) )
@ -77,7 +81,7 @@ int glTextureUnitsCount;
// Functions // Functions
void initGLX() void initGLX()
{ {
#ifndef KWIN_HAVE_OPENGLES #if HAVE_EPOXY_GLX
// Get GLX version // Get GLX version
int major, minor; int major, minor;
glXQueryVersion(display(), &major, &minor); glXQueryVersion(display(), &major, &minor);

View File

@ -21,6 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwinglutils.h" #include "kwinglutils.h"
#include <dlfcn.h> #include <dlfcn.h>
#if HAVE_EPOXY_GLX
#include <epoxy/glx.h>
#endif
// Resolves given function, using getProcAddress // Resolves given function, using getProcAddress
@ -56,10 +59,12 @@ glGetnUniformfv_func glGetnUniformfv;
typedef void (*glXFuncPtr)(); typedef void (*glXFuncPtr)();
#ifndef KWIN_HAVE_OPENGLES
static glXFuncPtr getProcAddress(const char* name) static glXFuncPtr getProcAddress(const char* name)
{ {
glXFuncPtr ret = glXGetProcAddress((const GLubyte*) name); glXFuncPtr ret = nullptr;
#if HAVE_EPOXY_GLX
ret = glXGetProcAddress((const GLubyte*) name);
#endif
if (ret == nullptr) if (ret == nullptr)
ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name); ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name);
return ret; return ret;
@ -72,7 +77,6 @@ void glxResolveFunctions()
else else
glXSwapIntervalMESA = nullptr; glXSwapIntervalMESA = nullptr;
} }
#endif
void eglResolveFunctions() void eglResolveFunctions()
{ {

View File

@ -27,10 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <epoxy/egl.h> #include <epoxy/egl.h>
#ifndef KWIN_HAVE_OPENGLES
#include <epoxy/glx.h>
#endif
#include <fixx11h.h> #include <fixx11h.h>
#include <epoxy/gl.h> #include <epoxy/gl.h>
@ -51,9 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
#ifndef KWIN_HAVE_OPENGLES
void KWINGLUTILS_EXPORT glxResolveFunctions(); void KWINGLUTILS_EXPORT glxResolveFunctions();
#endif
void KWINGLUTILS_EXPORT eglResolveFunctions(); void KWINGLUTILS_EXPORT eglResolveFunctions();

View File

@ -764,6 +764,10 @@ void Options::setGlPlatformInterface(OpenGLPlatformInterface interface)
qCDebug(KWIN_CORE) << "Forcing EGL native interface for Wayland mode"; qCDebug(KWIN_CORE) << "Forcing EGL native interface for Wayland mode";
interface = EglPlatformInterface; interface = EglPlatformInterface;
} }
#if !HAVE_EPOXY_GLX
qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled without GLX support";
interface = EglPlatformInterface;
#endif
#ifdef KWIN_HAVE_OPENGLES #ifdef KWIN_HAVE_OPENGLES
qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled against OpenGL ES"; qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled against OpenGL ES";
interface = EglPlatformInterface; interface = EglPlatformInterface;

View File

@ -28,9 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "scene_opengl.h" #include "scene_opengl.h"
#include "eglonxbackend.h" #include "eglonxbackend.h"
#ifndef KWIN_HAVE_OPENGLES #if HAVE_EPOXY_GLX
#include "glxbackend.h" #include "glxbackend.h"
#endif // KWIN_HAVE_OPENGLES #endif
#include "abstract_backend.h" #include "abstract_backend.h"
#include "wayland_server.h" #include "wayland_server.h"
@ -541,7 +541,7 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
switch (platformInterface) { switch (platformInterface) {
case GlxPlatformInterface: case GlxPlatformInterface:
#ifndef KWIN_HAVE_OPENGLES #if HAVE_EPOXY_GLX
backend = new GlxBackend(); backend = new GlxBackend();
#endif #endif
break; break;

View File

@ -1383,6 +1383,12 @@ QString Workspace::supportInformation() const
support.append(yes); support.append(yes);
#else #else
support.append(no); support.append(no);
#endif
support.append(QStringLiteral("HAVE_EPOXY_GLX: "));
#if HAVE_EPOXY_GLX
support.append(yes);
#else
support.append(no);
#endif #endif
support.append(QStringLiteral("\n")); support.append(QStringLiteral("\n"));