diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,10 +414,6 @@ wayland_cursor_theme.cpp ) -if(HAVE_EPOXY_GLX) - set(kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} glxbackend.cpp) -endif() - if(KWIN_BUILD_TABBOX) set( kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} diff --git a/overlaywindow.h b/overlaywindow.h --- a/overlaywindow.h +++ b/overlaywindow.h @@ -25,8 +25,10 @@ // xcb #include +#include + namespace KWin { -class OverlayWindow { +class KWIN_EXPORT OverlayWindow { public: OverlayWindow(); ~OverlayWindow(); diff --git a/plugins/platforms/x11/standalone/CMakeLists.txt b/plugins/platforms/x11/standalone/CMakeLists.txt --- a/plugins/platforms/x11/standalone/CMakeLists.txt +++ b/plugins/platforms/x11/standalone/CMakeLists.txt @@ -4,6 +4,10 @@ screens_xrandr.cpp ) +if(HAVE_EPOXY_GLX) + set(X11PLATFORM_SOURCES ${X11PLATFORM_SOURCES} glxbackend.cpp) +endif() + add_library(KWinX11Platform MODULE ${X11PLATFORM_SOURCES}) target_link_libraries(KWinX11Platform kwin Qt5::X11Extras) diff --git a/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h rename from glxbackend.h rename to plugins/platforms/x11/standalone/glxbackend.h diff --git a/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp rename from glxbackend.cpp rename to plugins/platforms/x11/standalone/glxbackend.cpp --- a/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -24,9 +24,9 @@ // own #include "glxbackend.h" +#include "logging.h" // kwin #include "options.h" -#include "utils.h" #include "overlaywindow.h" #include "composite.h" #include "screens.h" @@ -229,9 +229,9 @@ setBlocksForRetrace(true); haveWaitSync = true; } else - qCWarning(KWIN_CORE) << "NO VSYNC! glXSwapInterval is not supported, glXWaitVideoSync is supported but broken"; + qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! glXSwapInterval is not supported, glXWaitVideoSync is supported but broken"; } else - qCWarning(KWIN_CORE) << "NO VSYNC! neither glSwapInterval nor glXWaitVideoSync are supported"; + qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! neither glSwapInterval nor glXWaitVideoSync are supported"; } else { // disable v-sync (if possible) setSwapInterval(0); @@ -245,7 +245,7 @@ setIsDirectRendering(bool(glXIsDirect(display(), ctx))); - qCDebug(KWIN_CORE) << "Direct rendering:" << isDirectRendering(); + qCDebug(KWIN_X11STANDALONE) << "Direct rendering:" << isDirectRendering(); } bool GlxBackend::initRenderingContext() @@ -302,12 +302,12 @@ ctx = glXCreateNewContext(display(), fbconfig, GLX_RGBA_TYPE, NULL, direct); if (!ctx) { - qCDebug(KWIN_CORE) << "Failed to create an OpenGL context."; + qCDebug(KWIN_X11STANDALONE) << "Failed to create an OpenGL context."; return false; } if (!glXMakeCurrent(display(), glxWindow, ctx)) { - qCDebug(KWIN_CORE) << "Failed to make the OpenGL context current."; + qCDebug(KWIN_X11STANDALONE) << "Failed to make the OpenGL context current."; glXDestroyContext(display(), ctx); ctx = 0; return false; @@ -329,7 +329,7 @@ glXGetFBConfigAttrib(display(), fbconfig, GLX_VISUAL_ID, (int *) &visual); if (!visual) { - qCCritical(KWIN_CORE) << "The GLXFBConfig does not have an associated X visual"; + qCCritical(KWIN_X11STANDALONE) << "The GLXFBConfig does not have an associated X visual"; return false; } @@ -346,7 +346,7 @@ glxWindow = glXCreateWindow(display(), fbconfig, window, NULL); overlayWindow()->setup(window); } else { - qCCritical(KWIN_CORE) << "Failed to create overlay window"; + qCCritical(KWIN_X11STANDALONE) << "Failed to create overlay window"; return false; } @@ -415,12 +415,12 @@ glXGetFBConfigAttrib(display(), fbconfig, GLX_DEPTH_SIZE, &depth); glXGetFBConfigAttrib(display(), fbconfig, GLX_STENCIL_SIZE, &stencil); - qCDebug(KWIN_CORE, "Choosing GLXFBConfig %#x X visual %#x depth %d RGBA %d:%d:%d:%d ZS %d:%d", + qCDebug(KWIN_X11STANDALONE, "Choosing GLXFBConfig %#x X visual %#x depth %d RGBA %d:%d:%d:%d ZS %d:%d", fbconfig_id, visual_id, visualDepth(visual_id), red, green, blue, alpha, depth, stencil); } if (fbconfig == nullptr) { - qCCritical(KWIN_CORE) << "Failed to find a usable framebuffer configuration"; + qCCritical(KWIN_X11STANDALONE) << "Failed to find a usable framebuffer configuration"; return false; } @@ -466,7 +466,7 @@ const xcb_render_directformat_t *direct = XRenderUtils::findPictFormatInfo(format); if (!direct) { - qCCritical(KWIN_CORE).nospace() << "Could not find a picture format for visual 0x" << hex << visual; + qCCritical(KWIN_X11STANDALONE).nospace() << "Could not find a picture format for visual 0x" << hex << visual; return info; } @@ -499,7 +499,7 @@ GLXFBConfig *configs = glXChooseFBConfig(display(), DefaultScreen(display()), attribs, &count); if (count < 1) { - qCCritical(KWIN_CORE).nospace() << "Could not find a framebuffer configuration for visual 0x" << hex << visual; + qCCritical(KWIN_X11STANDALONE).nospace() << "Could not find a framebuffer configuration for visual 0x" << hex << visual; return info; } @@ -581,7 +581,7 @@ glXGetFBConfigAttrib(display(), info->fbconfig, GLX_FBCONFIG_ID, &fbc_id); glXGetFBConfigAttrib(display(), info->fbconfig, GLX_VISUAL_ID, &visual_id); - qCDebug(KWIN_CORE).nospace() << "Using FBConfig 0x" << hex << fbc_id << " for visual 0x" << hex << visual_id; + qCDebug(KWIN_X11STANDALONE).nospace() << "Using FBConfig 0x" << hex << fbc_id << " for visual 0x" << hex << visual_id; } return info; @@ -643,7 +643,7 @@ options->setGlPreferBufferSwap(0); setSwapInterval(0); result = 0; // hint proper behavior - qCWarning(KWIN_CORE) << "\nIt seems you are using the nvidia driver without triple buffering\n" + qCWarning(KWIN_X11STANDALONE) << "\nIt seems you are using the nvidia driver without triple buffering\n" "You must export __GL_YIELD=\"USLEEP\" to prevent large CPU overhead on synced swaps\n" "Preferably, enable the TripleBuffer Option in the xorg.conf Device\n" "For this reason, the tearing prevention has been disabled.\n" diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h --- a/plugins/platforms/x11/standalone/x11_platform.h +++ b/plugins/platforms/x11/standalone/x11_platform.h @@ -39,6 +39,7 @@ void init() override; Screens *createScreens(QObject *parent = nullptr) override; + OpenGLBackend *createOpenGLBackend() override; }; diff --git a/plugins/platforms/x11/standalone/x11_platform.cpp b/plugins/platforms/x11/standalone/x11_platform.cpp --- a/plugins/platforms/x11/standalone/x11_platform.cpp +++ b/plugins/platforms/x11/standalone/x11_platform.cpp @@ -18,7 +18,13 @@ along with this program. If not, see . *********************************************************************/ #include "x11_platform.h" +#include +#if HAVE_EPOXY_GLX +#include "glxbackend.h" +#endif +#include "eglonxbackend.h" #include "screens_xrandr.h" +#include "options.h" #include @@ -47,4 +53,19 @@ return new XRandRScreens(parent); } +OpenGLBackend *X11StandalonePlatform::createOpenGLBackend() +{ + switch (options->glPlatformInterface()) { +#if HAVE_EPOXY_GLX + case GlxPlatformInterface: + return new GlxBackend(); +#endif + case EglPlatformInterface: + return new EglOnXBackend(); + default: + // no backend available + return nullptr; + } +} + } diff --git a/scene_opengl.h b/scene_opengl.h --- a/scene_opengl.h +++ b/scene_opengl.h @@ -38,7 +38,7 @@ class SyncManager; class SyncObject; -class SceneOpenGL +class KWIN_EXPORT SceneOpenGL : public Scene { Q_OBJECT @@ -347,7 +347,7 @@ * @short Profiler to detect whether we have triple buffering * The strategy is to start setBlocksForRetrace(false) but assume blocking and have the system prove that assumption wrong **/ -class SwapProfiler +class KWIN_EXPORT SwapProfiler { public: SwapProfiler(); diff --git a/scene_opengl.cpp b/scene_opengl.cpp --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -27,10 +27,6 @@ along with this program. If not, see . *********************************************************************/ #include "scene_opengl.h" -#include "eglonxbackend.h" -#if HAVE_EPOXY_GLX -#include "glxbackend.h" -#endif #include "platform.h" #include "wayland_server.h" @@ -561,26 +557,7 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent) { - OpenGLBackend *backend = NULL; - OpenGLPlatformInterface platformInterface = options->glPlatformInterface(); - - switch (platformInterface) { - case GlxPlatformInterface: -#if HAVE_EPOXY_GLX - backend = new GlxBackend(); -#endif - break; - case EglPlatformInterface: - if (kwinApp()->shouldUseWaylandForCompositing()) { - backend = kwinApp()->platform()->createOpenGLBackend(); - } else { - backend = new EglOnXBackend(); - } - break; - default: - // no backend available - return NULL; - } + OpenGLBackend *backend = kwinApp()->platform()->createOpenGLBackend(); if (!backend) { return nullptr; }