From 3278eae5773f21f6b1cc059fa392609e28caa902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 10 May 2019 12:04:52 +0200 Subject: wasm: recreate backing store texture with valid gl context The compositor context is not current during the resize() call, but will be during updateTexture(). Change-Id: I29c2e06aa251b564b5d622dc9380ec994e15aab0 Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmbackingstore.cpp | 9 ++++++--- src/plugins/platforms/wasm/qwasmbackingstore.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp index e8eda2605f..7e8a382512 100644 --- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp +++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp @@ -81,6 +81,11 @@ void QWasmBackingStore::updateTexture() if (m_dirty.isNull()) return; + if (m_recreateTexture && m_texture->isCreated()) { + m_recreateTexture = false; + m_texture->destroy(); + } + if (!m_texture->isCreated()) { m_texture->setMinificationFilter(QOpenGLTexture::Nearest); m_texture->setMagnificationFilter(QOpenGLTexture::Nearest); @@ -146,9 +151,7 @@ void QWasmBackingStore::resize(const QSize &size, const QRegion &staticContents) m_image = QImage(size * window()->devicePixelRatio(), QImage::Format_RGB32); m_image.setDevicePixelRatio(window()->devicePixelRatio()); - - if (m_texture->isCreated()) - m_texture->destroy(); + m_recreateTexture = true; } QImage QWasmBackingStore::toImage() const diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.h b/src/plugins/platforms/wasm/qwasmbackingstore.h index 4bca83c457..b93c96b483 100644 --- a/src/plugins/platforms/wasm/qwasmbackingstore.h +++ b/src/plugins/platforms/wasm/qwasmbackingstore.h @@ -64,6 +64,7 @@ private: QImage m_image; QScopedPointer m_texture; QRegion m_dirty; + bool m_recreateTexture = false; }; QT_END_NAMESPACE -- cgit v1.2.3