diff --git a/backends/drm/egl_gbm_backend.cpp b/backends/drm/egl_gbm_backend.cpp index aedd297e4b..f761aaea1f 100644 --- a/backends/drm/egl_gbm_backend.cpp +++ b/backends/drm/egl_gbm_backend.cpp @@ -39,8 +39,6 @@ EglGbmBackend::EglGbmBackend(DrmBackend *b) , AbstractEglBackend() , m_backend(b) { - initializeEgl(); - init(); // Egl is always direct rendering setIsDirectRendering(true); setSyncsToVBlank(true); @@ -117,6 +115,10 @@ bool EglGbmBackend::initializeEgl() void EglGbmBackend::init() { + if (!initializeEgl()) { + setFailed("Could not initialize egl"); + return; + } if (!initRenderingContext()) { setFailed("Could not initialize rendering context"); return; diff --git a/backends/drm/egl_gbm_backend.h b/backends/drm/egl_gbm_backend.h index 33eaf1e87b..6051cf59a4 100644 --- a/backends/drm/egl_gbm_backend.h +++ b/backends/drm/egl_gbm_backend.h @@ -48,13 +48,13 @@ public: bool usesOverlayWindow() const override; bool perScreenRendering() const override; QRegion prepareRenderingForScreen(int screenId) override; + void init() override; protected: void present() override; void cleanupSurfaces() override; private: - void init(); bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); diff --git a/backends/hwcomposer/egl_hwcomposer_backend.cpp b/backends/hwcomposer/egl_hwcomposer_backend.cpp index 3c4387f1c2..a1a9d5ef93 100644 --- a/backends/hwcomposer/egl_hwcomposer_backend.cpp +++ b/backends/hwcomposer/egl_hwcomposer_backend.cpp @@ -28,11 +28,6 @@ EglHwcomposerBackend::EglHwcomposerBackend(HwcomposerBackend *backend) : AbstractEglBackend() , m_backend(backend) { - if (!initializeEgl()) { - setFailed("Failed to initialize egl"); - return; - } - init(); // EGL is always direct rendering setIsDirectRendering(true); setSyncsToVBlank(true); @@ -60,6 +55,10 @@ bool EglHwcomposerBackend::initializeEgl() void EglHwcomposerBackend::init() { + if (!initializeEgl()) { + setFailed("Failed to initialize egl"); + return; + } if (!initRenderingContext()) { setFailed("Could not initialize rendering context"); return; diff --git a/backends/hwcomposer/egl_hwcomposer_backend.h b/backends/hwcomposer/egl_hwcomposer_backend.h index df30d64949..1fbbaabfa1 100644 --- a/backends/hwcomposer/egl_hwcomposer_backend.h +++ b/backends/hwcomposer/egl_hwcomposer_backend.h @@ -37,12 +37,12 @@ public: void screenGeometryChanged(const QSize &size) override; QRegion prepareRenderingFrame() override; void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; + void init() override; protected: void present() override; private: - void init(); bool initializeEgl(); bool initRenderingContext(); bool initBufferConfigs(); diff --git a/backends/virtual/egl_gbm_backend.cpp b/backends/virtual/egl_gbm_backend.cpp index 3e7eff73d1..15ad75ed3a 100644 --- a/backends/virtual/egl_gbm_backend.cpp +++ b/backends/virtual/egl_gbm_backend.cpp @@ -36,8 +36,6 @@ EglGbmBackend::EglGbmBackend(VirtualBackend *b) , AbstractEglBackend() , m_backend(b) { - initializeEgl(); - init(); // Egl is always direct rendering setIsDirectRendering(true); } @@ -75,6 +73,10 @@ bool EglGbmBackend::initializeEgl() void EglGbmBackend::init() { + if (!initializeEgl()) { + setFailed("Could not initialize egl"); + return; + } if (!initRenderingContext()) { setFailed("Could not initialize rendering context"); return; diff --git a/backends/virtual/egl_gbm_backend.h b/backends/virtual/egl_gbm_backend.h index 256d5213bd..2d979f4abe 100644 --- a/backends/virtual/egl_gbm_backend.h +++ b/backends/virtual/egl_gbm_backend.h @@ -42,12 +42,12 @@ public: QRegion prepareRenderingFrame() override; void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; + void init() override; protected: void present() override; private: - void init(); bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); diff --git a/backends/wayland/egl_wayland_backend.cpp b/backends/wayland/egl_wayland_backend.cpp index 0efe8709be..62754292e5 100644 --- a/backends/wayland/egl_wayland_backend.cpp +++ b/backends/wayland/egl_wayland_backend.cpp @@ -55,8 +55,6 @@ EglWaylandBackend::EglWaylandBackend(Wayland::WaylandBackend *b) return; } connect(m_wayland, SIGNAL(shellSurfaceSizeChanged(QSize)), SLOT(overlaySizeChanged(QSize))); - initializeEgl(); - init(); // Egl is always direct rendering setIsDirectRendering(true); } @@ -95,6 +93,10 @@ bool EglWaylandBackend::initializeEgl() void EglWaylandBackend::init() { + if (!initializeEgl()) { + setFailed("Could not initialize egl"); + return; + } if (!initRenderingContext()) { setFailed("Could not initialize rendering context"); return; diff --git a/backends/wayland/egl_wayland_backend.h b/backends/wayland/egl_wayland_backend.h index af2a4972d8..3057c2c384 100644 --- a/backends/wayland/egl_wayland_backend.h +++ b/backends/wayland/egl_wayland_backend.h @@ -58,6 +58,7 @@ public: virtual QRegion prepareRenderingFrame(); virtual void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion); virtual bool usesOverlayWindow() const override; + void init() override; protected: virtual void present(); @@ -66,7 +67,6 @@ private Q_SLOTS: void overlaySizeChanged(const QSize &size); private: - void init(); bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); diff --git a/eglonxbackend.cpp b/eglonxbackend.cpp index f7c9475cc1..eca0dcf9c7 100644 --- a/eglonxbackend.cpp +++ b/eglonxbackend.cpp @@ -63,7 +63,6 @@ EglOnXBackend::EglOnXBackend(xcb_connection_t *connection, Display *display, xcb , m_x11ScreenNumber(screenNumber) , m_renderingWindow(renderingWindow) { - init(); // Egl is always direct rendering setIsDirectRendering(true); } diff --git a/eglonxbackend.h b/eglonxbackend.h index e0572c10d8..4b8c5d2a0b 100644 --- a/eglonxbackend.h +++ b/eglonxbackend.h @@ -40,12 +40,12 @@ public: virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion); virtual OverlayWindow* overlayWindow() override; virtual bool usesOverlayWindow() const override; + void init() override; protected: virtual void present(); private: - void init(); bool initBufferConfigs(); bool initRenderingContext(); /** diff --git a/glxbackend.cpp b/glxbackend.cpp index 34408533e8..c59c647b1a 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -114,7 +114,6 @@ GlxBackend::GlxBackend() , m_bufferAge(0) , haveSwapInterval(false) { - init(); } static bool gs_tripleBufferUndetected = true; diff --git a/glxbackend.h b/glxbackend.h index e27693f8ef..77a4a7f830 100644 --- a/glxbackend.h +++ b/glxbackend.h @@ -71,12 +71,12 @@ public: virtual void doneCurrent() override; virtual OverlayWindow* overlayWindow() override; virtual bool usesOverlayWindow() const override; + void init() override; protected: virtual void present(); private: - void init(); bool initBuffer(); void waitSync(); bool initRenderingContext(); diff --git a/scene_opengl.cpp b/scene_opengl.cpp index fb639d4338..53fd0dcfe9 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -578,7 +578,13 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent) // no backend available return NULL; } - if (!backend || backend->isFailed()) { + if (!backend) { + return nullptr; + } + if (!backend->isFailed()) { + backend->init(); + } + if (backend->isFailed()) { delete backend; return NULL; } diff --git a/scene_opengl.h b/scene_opengl.h index 2991a5f287..e669a862a9 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -377,6 +377,8 @@ class KWIN_EXPORT OpenGLBackend public: OpenGLBackend(); virtual ~OpenGLBackend(); + + virtual void init() = 0; /** * @return Time passes since start of rendering current frame. * @see startRenderTimer