From 2b8453abb8667b31abe57e0114f38eb8e4a48756 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 15 Jun 2021 15:24:28 +0300 Subject: [PATCH] platforms/x11: Port away from GLTexture::discard() Currently, if discard() is called, kwin will crash because EglPixmapTexture does not override the discard method. In principle, neither GlxPixmapTexture nor EglPixmapTexture should mess around with internals of the GLTexture class. It is better to have a wrapper texture with a bind method, which will re-bind the pixmap to the opengl texture if necessary. --- src/plugins/platforms/x11/standalone/eglbackend.cpp | 9 ++++----- src/plugins/platforms/x11/standalone/glxbackend.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/x11/standalone/eglbackend.cpp b/src/plugins/platforms/x11/standalone/eglbackend.cpp index bab676cb5e..49cf664d27 100644 --- a/src/plugins/platforms/x11/standalone/eglbackend.cpp +++ b/src/plugins/platforms/x11/standalone/eglbackend.cpp @@ -127,10 +127,10 @@ EglSurfaceTextureX11::EglSurfaceTextureX11(EglBackend *backend, SurfacePixmapX11 bool EglSurfaceTextureX11::create() { auto texture = new EglPixmapTexture(static_cast(m_backend)); - texture->create(m_pixmap); - - m_texture.reset(texture); - return !m_texture->isNull(); + if (texture->create(m_pixmap)) { + m_texture.reset(texture); + } + return !m_texture.isNull(); } void EglSurfaceTextureX11::update(const QRegion ®ion) @@ -186,7 +186,6 @@ bool EglPixmapTexturePrivate::create(SurfacePixmapX11 *pixmap) if (EGL_NO_IMAGE_KHR == m_image) { qCDebug(KWIN_CORE) << "failed to create egl image"; q->unbind(); - q->discard(); return false; } glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, static_cast(m_image)); diff --git a/src/plugins/platforms/x11/standalone/glxbackend.cpp b/src/plugins/platforms/x11/standalone/glxbackend.cpp index 42cd9492c9..a52c1e9b6a 100644 --- a/src/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/src/plugins/platforms/x11/standalone/glxbackend.cpp @@ -797,10 +797,10 @@ GlxSurfaceTextureX11::GlxSurfaceTextureX11(GlxBackend *backend, SurfacePixmapX11 bool GlxSurfaceTextureX11::create() { auto texture = new GlxPixmapTexture(static_cast(m_backend)); - texture->create(m_pixmap); - - m_texture.reset(texture); - return !m_texture->isNull(); + if (texture->create(m_pixmap)) { + m_texture.reset(texture); + } + return !m_texture.isNull(); } void GlxSurfaceTextureX11::update(const QRegion ®ion)