diff options
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurfacebuffer.cpp | 18 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurfacebuffer.h | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp index c4bad7662..6dd76532c 100644 --- a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp +++ b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp @@ -62,6 +62,7 @@ SurfaceBuffer::SurfaceBuffer(Surface *surface) , m_page_flipper_has_buffer(false) , m_is_displayed(false) , m_texture(0) + , m_guard(0) , m_is_shm_resolved(false) , m_is_shm(false) { @@ -77,6 +78,7 @@ void SurfaceBuffer::initialize(wl_buffer *buffer) { m_buffer = buffer; m_texture = 0; + m_guard = 0; m_is_registered_for_buffer = true; m_surface_has_buffer = true; m_page_flipper_has_buffer = false; @@ -180,10 +182,12 @@ void SurfaceBuffer::setDamage(const QRect &rect) void SurfaceBuffer::destroyTexture() { #ifdef QT_COMPOSITOR_WAYLAND_GL - if (m_texture) { - glDeleteTextures(1,&m_texture); - m_texture = 0; - } + if (m_texture) { + Q_ASSERT(m_guard); + m_guard->free(); + m_guard = 0; + m_texture = 0; + } #endif } @@ -232,10 +236,16 @@ void SurfaceBuffer::destroy_listener_callback(wl_listener *listener, void *data) d->m_buffer = 0; } +void freeTexture(QOpenGLFunctions *, GLuint id) +{ + glDeleteTextures(1, &id); +} + void SurfaceBuffer::createTexture(GraphicsHardwareIntegration *hwIntegration, QOpenGLContext *context) { #ifdef QT_COMPOSITOR_WAYLAND_GL m_texture = hwIntegration->createTextureFromBuffer(m_buffer, context); + m_guard = new QOpenGLSharedResourceGuard(QOpenGLContext::currentContext(), m_texture, freeTexture); #else Q_UNUSED(hwIntegration); Q_UNUSED(context); diff --git a/src/compositor/wayland_wrapper/wlsurfacebuffer.h b/src/compositor/wayland_wrapper/wlsurfacebuffer.h index 3ae351ae6..141fc4ca9 100644 --- a/src/compositor/wayland_wrapper/wlsurfacebuffer.h +++ b/src/compositor/wayland_wrapper/wlsurfacebuffer.h @@ -43,6 +43,7 @@ #include <QtCore/QRect> #include <QtGui/qopengl.h> +#include <QtGui/private/qopenglcontext_p.h> #include <qpa/qplatformscreenpageflipper.h> #include <wayland-server.h> @@ -117,6 +118,7 @@ private: bool m_is_displayed; #ifdef QT_COMPOSITOR_WAYLAND_GL GLuint m_texture; + QOpenGLSharedResourceGuard *m_guard; #else uint m_texture; #endif |