From eb62b6ac02b86f11bc6bcbe1f37df003d2a46d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 8 May 2019 09:23:52 +0200 Subject: wasm: always use requestAnimationFrame for updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compositor was posting update events and flushing/redrawing using a zero-timer. Change this to use the request_animation_frame API from Emscripten, which makes sure we flush window content at the next native paint event. This has the additional benefit that hidden canvases (e.g on hidden tabs) won’t get frame events, and then stop painting. We support both well-behaved QWindows, where the window calls requestUpate() and then paints/flushes on the following deliverUpdateRequest(), and also less well behaved windows which paints at any point during event processing. Pick-to: 6.3 Change-Id: I747d6f7ace86ceddaa18ab86b6a0ee833f98991b Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmwindow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/wasm/qwasmwindow.cpp') diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 9c5f1e4e74e..3819e8daa6d 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -111,8 +111,6 @@ void QWasmWindow::setGeometry(const QRect &rect) } QWindowSystemInterface::handleGeometryChange(window(), r); QPlatformWindow::setGeometry(r); - - QWindowSystemInterface::flushWindowSystemEvents(); invalidate(); } @@ -128,7 +126,6 @@ void QWasmWindow::setVisible(bool visible) else if (m_windowState & Qt::WindowMaximized) newGeom = platformScreen()->availableGeometry(); } - QPlatformWindow::setVisible(visible); m_compositor->setVisible(this, visible); @@ -366,7 +363,7 @@ QRegion QWasmWindow::titleControlRegion() const void QWasmWindow::invalidate() { - m_compositor->requestRedraw(); + m_compositor->requestUpdateWindow(this); } QWasmCompositor::SubControls QWasmWindow::activeSubControl() const @@ -397,6 +394,11 @@ qreal QWasmWindow::devicePixelRatio() const void QWasmWindow::requestUpdate() { + if (m_compositor) { + m_compositor->requestUpdateWindow(this, QWasmCompositor::UpdateRequestDelivery); + return; + } + static auto frame = [](double time, void *context) -> int { Q_UNUSED(time); QWasmWindow *window = static_cast(context); -- cgit v1.2.3