summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-02-28 08:40:53 +0100
committerLars Knoll <lars.knoll@qt.io>2020-02-28 09:48:30 +0100
commita450cce6b670dbcac84fcc4a66fc632b31ce8414 (patch)
tree35b77fa22c4def97b619bd3a87f6d394e452bb2e /src/plugins/platforms/wasm
parentf6f6eab89f57fb0db8f623f4a92a7b9c4ba6e9ea (diff)
parent4c86e667d220e27bb4b6e370675ffb2872e8521c (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'src/plugins/platforms/wasm')
-rw-r--r--src/plugins/platforms/wasm/qwasmbackingstore.cpp27
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp7
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.h5
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp5
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.h1
5 files changed, 36 insertions, 9 deletions
diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp
index a7423e9c47..cef15543d4 100644
--- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp
+++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp
@@ -36,7 +36,7 @@
#include <QtGui/qpainter.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformscreen.h>
-
+#include <QtGui/qoffscreensurface.h>
#include <QtGui/qbackingstore.h>
QT_BEGIN_NAMESPACE
@@ -53,12 +53,29 @@ QWasmBackingStore::QWasmBackingStore(QWasmCompositor *compositor, QWindow *windo
QWasmBackingStore::~QWasmBackingStore()
{
+ auto window = this->window();
+ QWasmIntegration::get()->removeBackingStore(window);
+ destroy();
+ QWasmWindow *wasmWindow = static_cast<QWasmWindow *>(window->handle());
+ if (wasmWindow)
+ wasmWindow->setBackingStore(nullptr);
}
void QWasmBackingStore::destroy()
{
- if (m_texture->isCreated())
- m_texture->destroy();
+ if (m_texture->isCreated()) {
+ auto context = m_compositor->context();
+ auto currentContext = QOpenGLContext::currentContext();
+ if (!currentContext || !QOpenGLContext::areSharing(context, currentContext)) {
+ QOffscreenSurface offScreenSurface(m_compositor->screen()->screen());
+ offScreenSurface.setFormat(context->format());
+ offScreenSurface.create();
+ context->makeCurrent(&offScreenSurface);
+ m_texture->destroy();
+ } else {
+ m_texture->destroy();
+ }
+ }
}
QPaintDevice *QWasmBackingStore::paintDevice()
@@ -81,9 +98,9 @@ void QWasmBackingStore::updateTexture()
if (m_dirty.isNull())
return;
- if (m_recreateTexture && m_texture->isCreated()) {
+ if (m_recreateTexture) {
m_recreateTexture = false;
- m_texture->destroy();
+ destroy();
}
if (!m_texture->isCreated()) {
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp
index 74890ead82..a4cfaa85a8 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp
@@ -58,7 +58,6 @@ QWasmCompositedWindow::QWasmCompositedWindow()
QWasmCompositor::QWasmCompositor(QWasmScreen *screen)
:QObject(screen)
- , m_frameBuffer(nullptr)
, m_blitter(new QOpenGLTextureBlitter)
, m_needComposit(false)
, m_inFlush(false)
@@ -70,7 +69,6 @@ QWasmCompositor::QWasmCompositor(QWasmScreen *screen)
QWasmCompositor::~QWasmCompositor()
{
- delete m_frameBuffer;
destroy();
}
@@ -747,3 +745,8 @@ QWasmScreen *QWasmCompositor::screen()
{
return static_cast<QWasmScreen *>(parent());
}
+
+QOpenGLContext *QWasmCompositor::context()
+{
+ return m_context.data();
+}
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h
index 250d244c9f..a07c747a98 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.h
+++ b/src/plugins/platforms/wasm/qwasmcompositor.h
@@ -124,11 +124,13 @@ public:
static QWasmTitleBarOptions makeTitleBarOptions(const QWasmWindow *window);
static QRect titlebarRect(QWasmTitleBarOptions tb, QWasmCompositor::SubControls subcontrol);
+ QWasmScreen *screen();
+ QOpenGLContext *context();
+
private slots:
void frame();
private:
- QWasmScreen *screen();
void notifyTopWindowChanged(QWasmWindow *window);
void drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window);
void drawWindowContent(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window);
@@ -137,7 +139,6 @@ private:
void drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window);
void drwPanelButton();
- QImage *m_frameBuffer;
QScopedPointer<QOpenGLContext> m_context;
QScopedPointer<QOpenGLTextureBlitter> m_blitter;
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index d1901d840e..37cc6185c5 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -189,6 +189,11 @@ QPlatformBackingStore *QWasmIntegration::createPlatformBackingStore(QWindow *win
#endif
}
+void QWasmIntegration::removeBackingStore(QWindow* window)
+{
+ m_backingStores.remove(window);
+}
+
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QWasmIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h
index 08b68cb5f7..cb8639086a 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.h
+++ b/src/plugins/platforms/wasm/qwasmintegration.h
@@ -89,6 +89,7 @@ public:
void resizeScreen(const emscripten::val &canvas);
void resizeAllScreens();
void updateDpi();
+ void removeBackingStore(QWindow* window);
private:
mutable QWasmFontDatabase *m_fontDb;