From 80c1406371d10cd8536de988195f00ddbc1c25a2 Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Fri, 24 Mar 2023 13:47:02 +0100 Subject: [PATCH] Remove the redundant QWasmCompositor::requestUpdateAllWindows Now that the browser compositor is used for rendering windows, the method has become redundant, as windows that got resized during screen resize will schedule their updates directly with the compositor. This also fixes an assertion in QPlatformWindow::hasPendingUpdateRequest as no windows without pending update requests will now have update requests delivered. Also offers a significant speedup with multiple restored window setups. Fixes: QTBUG-112289 Change-Id: Ie5dff69c04d66c4aef8351adef0da8530daf7ab8 Reviewed-by: Lorn Potter --- .../platforms/wasm/qwasmcompositor.cpp | 42 +++++-------------- src/plugins/platforms/wasm/qwasmcompositor.h | 5 +-- src/plugins/platforms/wasm/qwasmscreen.cpp | 1 - 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 922e802732c..5cb111d59ab 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -151,12 +151,6 @@ QWindow *QWasmCompositor::keyWindow() const return m_activeWindow ? m_activeWindow->window() : nullptr; } -void QWasmCompositor::requestUpdateAllWindows() -{ - m_requestUpdateAllWindows = true; - requestUpdate(); -} - void QWasmCompositor::requestUpdateWindow(QWasmWindow *window, UpdateRequestDeliveryType updateType) { auto it = m_requestUpdateWindows.find(window); @@ -198,36 +192,27 @@ void QWasmCompositor::deliverUpdateRequests() // update set. auto requestUpdateWindows = m_requestUpdateWindows; m_requestUpdateWindows.clear(); - bool requestUpdateAllWindows = m_requestUpdateAllWindows; - m_requestUpdateAllWindows = false; // Update window content, either all windows or a spesific set of windows. Use the correct // update type: QWindow subclasses expect that requested and delivered updateRequests matches // exactly. m_inDeliverUpdateRequest = true; - if (requestUpdateAllWindows) { - for (QWasmWindow *window : m_windowStack) { - auto it = requestUpdateWindows.find(window); - UpdateRequestDeliveryType updateType = - (it == m_requestUpdateWindows.end() ? ExposeEventDelivery : it.value()); - deliverUpdateRequest(window, updateType); - } - } else { - for (auto it = requestUpdateWindows.constBegin(); it != requestUpdateWindows.constEnd(); ++it) { - auto *window = it.key(); - UpdateRequestDeliveryType updateType = it.value(); - deliverUpdateRequest(window, updateType); - } + + for (auto it = requestUpdateWindows.constBegin(); it != requestUpdateWindows.constEnd(); ++it) { + auto *window = it.key(); + UpdateRequestDeliveryType updateType = it.value(); + deliverUpdateRequest(window, updateType); } + m_inDeliverUpdateRequest = false; - frame(requestUpdateAllWindows, requestUpdateWindows.keys()); + frame(requestUpdateWindows.keys()); } void QWasmCompositor::deliverUpdateRequest(QWasmWindow *window, UpdateRequestDeliveryType updateType) { // update by deliverUpdateRequest and expose event accordingly. if (updateType == UpdateRequestDelivery) { - window->QPlatformWindow::deliverUpdateRequest(); + window->deliverUpdateRequest(); } else { QWindow *qwindow = window->window(); QWindowSystemInterface::handleExposeEvent( @@ -248,17 +233,12 @@ int dpiScaled(qreal value) return value * (qreal(qt_defaultDpiX()) / 96.0); } -void QWasmCompositor::frame(bool all, const QList &windows) +void QWasmCompositor::frame(const QList &windows) { - if (!m_isEnabled || m_windowStack.empty() || !screen()) + if (!m_isEnabled || !screen()) return; - if (all) { - std::for_each(m_windowStack.rbegin(), m_windowStack.rend(), - [](QWasmWindow *window) { window->paint(); }); - } else { - std::for_each(windows.begin(), windows.end(), [](QWasmWindow *window) { window->paint(); }); - } + std::for_each(windows.begin(), windows.end(), [](QWasmWindow *window) { window->paint(); }); } void QWasmCompositor::onTopWindowChanged() diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h index 617d14eecea..251e9997ef7 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.h +++ b/src/plugins/platforms/wasm/qwasmcompositor.h @@ -47,13 +47,13 @@ public: QWasmScreen *screen(); enum UpdateRequestDeliveryType { ExposeEventDelivery, UpdateRequestDelivery }; - void requestUpdateAllWindows(); + void requestUpdateWindow(QWasmWindow *window, UpdateRequestDeliveryType updateType = ExposeEventDelivery); void handleBackingStoreFlush(QWindow *window); private: - void frame(bool all, const QList &windows); + void frame(const QList &windows); void onTopWindowChanged(); @@ -75,7 +75,6 @@ private: bool m_isEnabled = true; QMap m_requestUpdateWindows; - bool m_requestUpdateAllWindows = false; int m_requestAnimationFrameId = -1; bool m_inDeliverUpdateRequest = false; }; diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 6f8d1509ab8..fbe9ffdd713 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -261,7 +261,6 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize() }; setGeometry(QRect(getElementBodyPosition(m_shadowContainer), cssSize.toSize())); - m_compositor->requestUpdateAllWindows(); } void QWasmScreen::canvasResizeObserverCallback(emscripten::val entries, emscripten::val)