diff options
| author | Morten Sørvig <morten.sorvig@qt.io> | 2024-01-26 11:46:26 +0100 |
|---|---|---|
| committer | Morten Sørvig <morten.sorvig@qt.io> | 2024-02-08 06:04:58 +0100 |
| commit | 5e5e6240c2dcb7d228fc68075c263f668a9ee963 (patch) | |
| tree | 91c3b224f61bd14b2cf493136e5b97058c946960 /src/plugins/platforms/wasm/qwasmcompositor.cpp | |
| parent | 74dac559c060ee24242a625fc46a8c463d06055f (diff) | |
wasm: fix onLoaded delay functionality
onLoaded and the initial expose/paint should be sequenced
such that onLoaded is fired first, followed by the expose.
This makes sure that we don't spend any time on painting
frames before Qt is completely initialized.
Add a "requestUpdateHold" mode to QWasmCompositor (initially
on) which disables requestUpdate calls, as well
as releaseRequestUpdateHold() which enables requestUpdate
calls again. This is a one-way transition; the mode
can't be enabled again.
This amends commit f2e22774 which implemented the concept
of startup tasks, where onLoaded can be delayed until
for instance font loading has been completed. After
this commit the expose event and initial commit will
be delayed as well.
Change-Id: Icc784306726174fbabe8785d54485860e968745a
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmcompositor.cpp')
| -rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 66eaea62faa..48445d5db95 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -4,6 +4,8 @@ #include "qwasmcompositor.h" #include "qwasmwindow.h" +#include <private/qeventdispatcher_wasm_p.h> + #include <qpa/qwindowsysteminterface.h> #include <emscripten/html5.h> @@ -41,6 +43,17 @@ void QWasmCompositor::setEnabled(bool enabled) m_isEnabled = enabled; } +// requestUpdate delivery is initially disabled at startup, while Qt completes +// startup tasks such as font loading. This function enables requestUpdate delivery +// again. +void QWasmCompositor::releaseRequesetUpdateHold() +{ + if (!m_requestUpdateHoldEnabled) + return; + m_requestUpdateHoldEnabled = false; + requestUpdate(); +} + void QWasmCompositor::requestUpdateWindow(QWasmWindow *window, UpdateRequestDeliveryType updateType) { auto it = m_requestUpdateWindows.find(window); @@ -62,6 +75,9 @@ void QWasmCompositor::requestUpdate() if (m_requestAnimationFrameId != -1) return; + if (m_requestUpdateHoldEnabled) + return; + static auto frame = [](double frameTime, void *context) -> int { Q_UNUSED(frameTime); |
