[wayland] Create OpenGLBackend through the AbstractBackend

Replaces casting logic in the SceneOpenGL. Now the create is delegated
to the backend allowing also to move the ifdef logic to where it belongs.
This commit is contained in:
Martin Gräßlin 2015-03-27 08:51:56 +01:00
parent 00844ffba7
commit e1ae0b8bc4
7 changed files with 42 additions and 23 deletions

View file

@ -49,4 +49,9 @@ Screens *AbstractBackend::createScreens(QObject *parent)
return nullptr;
}
OpenGLBackend *AbstractBackend::createOpenGLBackend()
{
return nullptr;
}
}

View file

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
class OpenGLBackend;
class Screens;
class KWIN_EXPORT AbstractBackend : public QObject
@ -36,6 +37,7 @@ public:
virtual void installCursorFromServer();
virtual void installCursorImage(Qt::CursorShape shape);
virtual Screens *createScreens(QObject *parent = nullptr);
virtual OpenGLBackend *createOpenGLBackend();
protected:
explicit AbstractBackend(QObject *parent = nullptr);

View file

@ -29,22 +29,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "scene_opengl.h"
#ifdef KWIN_HAVE_EGL
#include "eglonxbackend.h"
// for Wayland
#if HAVE_WAYLAND
#include "wayland_server.h"
#if HAVE_WAYLAND_EGL
#include "egl_wayland_backend.h"
#include "wayland_backend.h"
#endif // HAVE_WAYLAND_EGL
#if HAVE_X11_XCB
#include "x11windowed_backend.h"
#endif // HAVE_X11_XCB
#endif // HAVE_WAYLAND
#endif // KWIN_HAVE_EGL
#ifndef KWIN_HAVE_OPENGLES
#include "glxbackend.h"
#endif // KWIN_HAVE_OPENGLES
#if HAVE_WAYLAND
#include "abstract_backend.h"
#include "wayland_server.h"
#endif // HAVE_WAYLAND
#include <kwinglcolorcorrection.h>
#include <kwinglplatform.h>
@ -503,18 +497,7 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
#ifdef KWIN_HAVE_EGL
#if HAVE_WAYLAND
if (kwinApp()->shouldUseWaylandForCompositing()) {
#if HAVE_WAYLAND_EGL
if (Wayland::WaylandBackend *b = dynamic_cast<Wayland::WaylandBackend*>(waylandServer()->backend())) {
backend = new EglWaylandBackend(b);
}
#endif // HAVE_WAYLAND_EGL
#if HAVE_X11_XCB
if (!backend) {
if (X11WindowedBackend *b = dynamic_cast<X11WindowedBackend*>(waylandServer()->backend())) {
backend = new EglOnXBackend(b);
}
}
#endif // HAVE_X11_XCB
backend = waylandServer()->backend()->createOpenGLBackend();
} else
#endif // HAVE_WAYLAND
{

View file

@ -26,6 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "screens_wayland.h"
#include "utils.h"
#include "wayland_server.h"
#if HAVE_WAYLAND_EGL
#include "egl_wayland_backend.h"
#endif
#include <KWayland/Client/buffer.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
@ -645,6 +648,15 @@ Screens *WaylandBackend::createScreens(QObject *parent)
return new WaylandScreens(this, parent);
}
OpenGLBackend *WaylandBackend::createOpenGLBackend()
{
#if HAVE_WAYLAND_EGL
return new EglWaylandBackend(this);
#else
return nullptr;
#endif
}
}
} // KWin

View file

@ -170,6 +170,7 @@ public:
void installCursorFromServer() override;
Screens *createScreens(QObject *parent = nullptr) override;
OpenGLBackend *createOpenGLBackend() override;
protected:
void connectNotify(const QMetaMethod &signal) override;

View file

@ -24,6 +24,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "utils.h"
#include "wayland_server.h"
#include "xcbutils.h"
#ifdef KWIN_HAVE_EGL
#if HAVE_X11_XCB
#include "eglonxbackend.h"
#endif
#endif
#include <kwinxrenderutils.h>
#include <QAbstractEventDispatcher>
#include <QCoreApplication>
@ -299,4 +304,14 @@ Screens *X11WindowedBackend::createScreens(QObject *parent)
return new X11WindowedScreens(this, parent);
}
OpenGLBackend *X11WindowedBackend::createOpenGLBackend()
{
#ifdef KWIN_HAVE_EGL
#if HAVE_X11_XCB
return new EglOnXBackend(this);
#endif
#endif
return nullptr;
}
}

View file

@ -67,6 +67,7 @@ public:
void installCursorFromServer() override;
Screens *createScreens(QObject *parent = nullptr) override;
OpenGLBackend *createOpenGLBackend() override;
Q_SIGNALS:
void sizeChanged();