diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-28 03:01:54 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-28 03:01:54 +0200 |
commit | 9db98c7e0a2656988d5c549f0618b2ba882f1fc9 (patch) | |
tree | a65528ce2b2adbf553685bdd99e3c4accecd9291 /src | |
parent | bd5917025fe7491c9f24e99c20484c7ffce9f172 (diff) | |
parent | 51472970ce519fb39f492238b879d67ad9505f28 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Ib0b8d303b86e9a7bee8df45733cd9b5b1b2d666d
Diffstat (limited to 'src')
-rw-r--r-- | src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index 6de664564..2cadf8503 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -180,12 +180,15 @@ public: bool initEglStream(WaylandEglClientBuffer *buffer, struct ::wl_resource *bufferHandle); void handleEglstreamTexture(WaylandEglClientBuffer *buffer, wl_resource *bufferHandle); void registerBuffer(struct ::wl_resource *buffer, BufferState state); + void deleteGLTextureWhenPossible(QOpenGLTexture *texture) { orphanedTextures << texture; } + void deleteOrphanedTextures(); EGLDisplay egl_display = EGL_NO_DISPLAY; bool valid = false; bool display_bound = false; QOffscreenSurface *offscreenSurface = nullptr; QOpenGLContext *localContext = nullptr; + QVector<QOpenGLTexture *> orphanedTextures; PFNEGLBINDWAYLANDDISPLAYWL egl_bind_wayland_display = nullptr; PFNEGLUNBINDWAYLANDDISPLAYWL egl_unbind_wayland_display = nullptr; @@ -376,6 +379,13 @@ void WaylandEglClientBufferIntegrationPrivate::handleEglstreamTexture(WaylandEgl localContext->doneCurrent(); } +void WaylandEglClientBufferIntegrationPrivate::deleteOrphanedTextures() +{ + Q_ASSERT(QOpenGLContext::currentContext()); + qDeleteAll(orphanedTextures); + orphanedTextures.clear(); +} + WaylandEglClientBufferIntegration::WaylandEglClientBufferIntegration() : d_ptr(new WaylandEglClientBufferIntegrationPrivate) { @@ -484,7 +494,7 @@ WaylandEglClientBuffer::~WaylandEglClientBuffer() p->funcs->destroy_stream(p->egl_display, d->egl_stream); for (auto *texture : d->textures) - delete texture; + p->deleteGLTextureWhenPossible(texture); } delete d; } @@ -526,6 +536,10 @@ QWaylandBufferRef::BufferFormatEgl WaylandEglClientBuffer::bufferFormatEgl() con QOpenGLTexture *WaylandEglClientBuffer::toOpenGlTexture(int plane) { + auto *p = WaylandEglClientBufferIntegrationPrivate::get(m_integration); + // At this point we should have a valid OpenGL context, so it's safe to destroy textures + p->deleteOrphanedTextures(); + if (!m_buffer) return nullptr; @@ -533,7 +547,6 @@ QOpenGLTexture *WaylandEglClientBuffer::toOpenGlTexture(int plane) if (d->eglMode == BufferState::ModeEGLStream) return texture; // EGLStreams texture is maintained by handle_eglstream_texture() - auto *p = WaylandEglClientBufferIntegrationPrivate::get(m_integration); const auto target = static_cast<QOpenGLTexture::Target>(d->egl_format == EGL_TEXTURE_EXTERNAL_WL ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); if (!texture) { |