[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:
parent
00844ffba7
commit
e1ae0b8bc4
7 changed files with 42 additions and 23 deletions
|
@ -49,4 +49,9 @@ Screens *AbstractBackend::createScreens(QObject *parent)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGLBackend *AbstractBackend::createOpenGLBackend()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class OpenGLBackend;
|
||||||
class Screens;
|
class Screens;
|
||||||
|
|
||||||
class KWIN_EXPORT AbstractBackend : public QObject
|
class KWIN_EXPORT AbstractBackend : public QObject
|
||||||
|
@ -36,6 +37,7 @@ public:
|
||||||
virtual void installCursorFromServer();
|
virtual void installCursorFromServer();
|
||||||
virtual void installCursorImage(Qt::CursorShape shape);
|
virtual void installCursorImage(Qt::CursorShape shape);
|
||||||
virtual Screens *createScreens(QObject *parent = nullptr);
|
virtual Screens *createScreens(QObject *parent = nullptr);
|
||||||
|
virtual OpenGLBackend *createOpenGLBackend();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit AbstractBackend(QObject *parent = nullptr);
|
explicit AbstractBackend(QObject *parent = nullptr);
|
||||||
|
|
|
@ -29,22 +29,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "scene_opengl.h"
|
#include "scene_opengl.h"
|
||||||
#ifdef KWIN_HAVE_EGL
|
#ifdef KWIN_HAVE_EGL
|
||||||
#include "eglonxbackend.h"
|
#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
|
#endif // KWIN_HAVE_EGL
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
#ifndef KWIN_HAVE_OPENGLES
|
||||||
#include "glxbackend.h"
|
#include "glxbackend.h"
|
||||||
#endif // KWIN_HAVE_OPENGLES
|
#endif // KWIN_HAVE_OPENGLES
|
||||||
|
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
#include "abstract_backend.h"
|
||||||
|
#include "wayland_server.h"
|
||||||
|
#endif // HAVE_WAYLAND
|
||||||
|
|
||||||
#include <kwinglcolorcorrection.h>
|
#include <kwinglcolorcorrection.h>
|
||||||
#include <kwinglplatform.h>
|
#include <kwinglplatform.h>
|
||||||
|
|
||||||
|
@ -503,18 +497,7 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
|
||||||
#ifdef KWIN_HAVE_EGL
|
#ifdef KWIN_HAVE_EGL
|
||||||
#if HAVE_WAYLAND
|
#if HAVE_WAYLAND
|
||||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||||
#if HAVE_WAYLAND_EGL
|
backend = waylandServer()->backend()->createOpenGLBackend();
|
||||||
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
|
|
||||||
} else
|
} else
|
||||||
#endif // HAVE_WAYLAND
|
#endif // HAVE_WAYLAND
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "screens_wayland.h"
|
#include "screens_wayland.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
|
#if HAVE_WAYLAND_EGL
|
||||||
|
#include "egl_wayland_backend.h"
|
||||||
|
#endif
|
||||||
#include <KWayland/Client/buffer.h>
|
#include <KWayland/Client/buffer.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
|
@ -645,6 +648,15 @@ Screens *WaylandBackend::createScreens(QObject *parent)
|
||||||
return new WaylandScreens(this, parent);
|
return new WaylandScreens(this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGLBackend *WaylandBackend::createOpenGLBackend()
|
||||||
|
{
|
||||||
|
#if HAVE_WAYLAND_EGL
|
||||||
|
return new EglWaylandBackend(this);
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // KWin
|
} // KWin
|
||||||
|
|
|
@ -170,6 +170,7 @@ public:
|
||||||
void installCursorFromServer() override;
|
void installCursorFromServer() override;
|
||||||
|
|
||||||
Screens *createScreens(QObject *parent = nullptr) override;
|
Screens *createScreens(QObject *parent = nullptr) override;
|
||||||
|
OpenGLBackend *createOpenGLBackend() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void connectNotify(const QMetaMethod &signal) override;
|
void connectNotify(const QMetaMethod &signal) override;
|
||||||
|
|
|
@ -24,6 +24,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
#include "xcbutils.h"
|
#include "xcbutils.h"
|
||||||
|
#ifdef KWIN_HAVE_EGL
|
||||||
|
#if HAVE_X11_XCB
|
||||||
|
#include "eglonxbackend.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#include <kwinxrenderutils.h>
|
#include <kwinxrenderutils.h>
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
@ -299,4 +304,14 @@ Screens *X11WindowedBackend::createScreens(QObject *parent)
|
||||||
return new X11WindowedScreens(this, 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
void installCursorFromServer() override;
|
void installCursorFromServer() override;
|
||||||
|
|
||||||
Screens *createScreens(QObject *parent = nullptr) override;
|
Screens *createScreens(QObject *parent = nullptr) override;
|
||||||
|
OpenGLBackend *createOpenGLBackend() override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
|
|
Loading…
Reference in a new issue