diff options
| author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2019-05-08 09:23:52 +0200 |
|---|---|---|
| committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2022-01-05 21:25:38 +0100 |
| commit | eb62b6ac02b86f11bc6bcbe1f37df003d2a46d02 (patch) | |
| tree | aad695a330fed62248e9307e6c402be265739c59 /src/plugins/platforms/wasm/qwasmcompositor.h | |
| parent | e3e2674100b1ecbad7117f15c7aa13a704a7d34e (diff) | |
wasm: always use requestAnimationFrame for updates
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 <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmcompositor.h')
| -rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h index b579059344e..1a51016c038 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.h +++ b/src/plugins/platforms/wasm/qwasmcompositor.h @@ -110,25 +110,24 @@ public: void lower(QWasmWindow *window); void setParent(QWasmWindow *window, QWasmWindow *parent); - void flush(QWasmWindow *surface, const QRegion ®ion); - int windowCount() const; - void redrawWindowContent(); - void requestRedraw(); - QWindow *windowAt(QPoint globalPoint, int padding = 0) const; QWindow *keyWindow() const; - bool event(QEvent *event); - static QWasmTitleBarOptions makeTitleBarOptions(const QWasmWindow *window); static QRect titlebarRect(QWasmTitleBarOptions tb, QWasmCompositor::SubControls subcontrol); QWasmScreen *screen(); QOpenGLContext *context(); -private slots: + enum UpdateRequestDeliveryType { ExposeEventDelivery, UpdateRequestDelivery }; + void requestUpdateAllWindows(); + void requestUpdateWindow(QWasmWindow *window, UpdateRequestDeliveryType updateType = ExposeEventDelivery); + void requestUpdate(); + void deliverUpdateRequests(); + void deliverUpdateRequest(QWasmWindow *window, UpdateRequestDeliveryType updateType); + void handleBackingStoreFlush(); void frame(); private: @@ -152,6 +151,10 @@ private: bool m_isEnabled; QSize m_targetSize; qreal m_targetDevicePixelRatio; + QMap<QWasmWindow *, UpdateRequestDeliveryType> m_requestUpdateWindows; + bool m_requestUpdateAllWindows = false; + int m_requestAnimationFrameId = -1; + bool m_inDeliverUpdateRequest = false; static QPalette makeWindowPalette(); |
