summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-07-21 15:52:31 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-08-20 23:31:51 +0200
commit196c38a84653763db4647b2dcc835587303c2093 (patch)
tree9a43ff4e5d59ab599da676a2b320c934f51ed722
parentc5e659be7ca8689f4536953b37078af1fa936bc9 (diff)
Remove QWasmCompositedWindow as dead code
No fields in QWasmCompositedWindow, apart from visible, are used for any computation. They were write-only. Remove the class entirely and create a hash of visibility state instead. Fixes for z-order will follow. Change-Id: Icb7ff1865d1f9a67c0fde43cfa331ca1242ebcaa Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit 4b165c6bcc0e2d29dda230854766a5359a7e8db9) Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp72
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.h18
2 files changed, 19 insertions, 71 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp
index 684d769c1c..ef0d38801b 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp
@@ -36,14 +36,6 @@ using namespace emscripten;
Q_GUI_EXPORT int qt_defaultDpiX();
-QWasmCompositedWindow::QWasmCompositedWindow()
- : window(nullptr)
- , parentWindow(nullptr)
- , flushPending(false)
- , visible(false)
-{
-}
-
bool g_scrollingInvertedFromDevice = false;
static void mouseWheelEvent(emscripten::val event)
@@ -176,32 +168,19 @@ void QWasmCompositor::setEnabled(bool enabled)
m_isEnabled = enabled;
}
-void QWasmCompositor::addWindow(QWasmWindow *window, QWasmWindow *parentWindow)
+void QWasmCompositor::addWindow(QWasmWindow *window)
{
- QWasmCompositedWindow compositedWindow;
- compositedWindow.window = window;
- compositedWindow.parentWindow = parentWindow;
- m_compositedWindows.insert(window, compositedWindow);
+ m_windowVisibility.insert(window, false);
- if (parentWindow == 0)
- m_windowStack.append(window);
- else
- m_compositedWindows[parentWindow].childWindows.append(window);
+ m_windowStack.append(window);
notifyTopWindowChanged(window);
}
void QWasmCompositor::removeWindow(QWasmWindow *window)
{
- QWasmWindow *platformWindow = m_compositedWindows[window].parentWindow;
-
- if (platformWindow) {
- QWasmWindow *parentWindow = window;
- m_compositedWindows[parentWindow].childWindows.removeAll(window);
- }
-
m_windowStack.removeAll(window);
- m_compositedWindows.remove(window);
+ m_windowVisibility.remove(window);
m_requestUpdateWindows.remove(window);
if (!m_windowStack.isEmpty() && !QGuiApplication::focusWindow()) {
@@ -213,27 +192,22 @@ void QWasmCompositor::removeWindow(QWasmWindow *window)
void QWasmCompositor::setVisible(QWasmWindow *window, bool visible)
{
- QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
- if (compositedWindow.visible == visible)
+ const bool wasVisible = m_windowVisibility[window];
+ if (wasVisible == visible)
return;
- compositedWindow.visible = visible;
- compositedWindow.flushPending = true;
- if (visible)
- compositedWindow.damage = compositedWindow.window->geometry();
- else
- m_globalDamage = compositedWindow.window->geometry(); // repaint previously covered area.
+ m_windowVisibility[window] = visible;
+ if (!visible)
+ m_globalDamage = window->window()->geometry(); // repaint previously covered area.
requestUpdateWindow(window, QWasmCompositor::ExposeEventDelivery);
}
void QWasmCompositor::raise(QWasmWindow *window)
{
- if (m_compositedWindows.size() <= 1)
+ if (m_windowStack.size() <= 1)
return;
- QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
- compositedWindow.damage = compositedWindow.window->geometry();
m_windowStack.removeAll(window);
m_windowStack.append(window);
@@ -242,24 +216,16 @@ void QWasmCompositor::raise(QWasmWindow *window)
void QWasmCompositor::lower(QWasmWindow *window)
{
- if (m_compositedWindows.size() <= 1)
+ if (m_windowStack.size() <= 1)
return;
m_windowStack.removeAll(window);
m_windowStack.prepend(window);
- QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
- m_globalDamage = compositedWindow.window->geometry(); // repaint previously covered area.
+ m_globalDamage = window->window()->geometry(); // repaint previously covered area.
notifyTopWindowChanged(window);
}
-void QWasmCompositor::setParent(QWasmWindow *window, QWasmWindow *parent)
-{
- m_compositedWindows[window].parentWindow = parent;
-
- requestUpdate();
-}
-
int QWasmCompositor::windowCount() const
{
return m_windowStack.count();
@@ -271,13 +237,13 @@ QWindow *QWasmCompositor::windowAt(QPoint targetPointInScreenCoords, int padding
// qDebug() << "window at" << "point" << p << "window count" << index;
while (index >= 0) {
- const QWasmCompositedWindow &compositedWindow = m_compositedWindows[m_windowStack.at(index)];
+ const QWasmWindow *window = m_windowStack.at(index);
//qDebug() << "windwAt testing" << compositedWindow.window <<
- QRect geometry = compositedWindow.window->windowFrameGeometry()
+ QRect geometry = window->windowFrameGeometry()
.adjusted(-padding, -padding, padding, padding);
- if (compositedWindow.visible && geometry.contains(targetPointInScreenCoords))
+ if (m_windowVisibility[window] && geometry.contains(targetPointInScreenCoords))
return m_windowStack.at(index)->window();
--index;
}
@@ -851,12 +817,8 @@ void QWasmCompositor::frame()
m_blitter->setRedBlueSwizzle(true);
for (QWasmWindow *window : qAsConst(m_windowStack)) {
- QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
-
- if (!compositedWindow.visible)
- continue;
-
- drawWindow(m_blitter.data(), screen(), window);
+ if (m_windowVisibility[window])
+ drawWindow(m_blitter.data(), screen(), window);
}
m_blitter->release();
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h
index 2cfd355b61..c883fc310d 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.h
+++ b/src/plugins/platforms/wasm/qwasmcompositor.h
@@ -29,19 +29,6 @@ class QOpenGLContext;
class QOpenGLTexture;
class QWasmEventTranslator;
-class QWasmCompositedWindow
-{
-public:
- QWasmCompositedWindow();
-
- QWasmWindow *window;
- QWasmWindow *parentWindow;
- QRegion damage;
- bool flushPending;
- bool visible;
- QList<QWasmWindow *> childWindows;
-};
-
class QWasmCompositor : public QObject
{
Q_OBJECT
@@ -108,13 +95,12 @@ public:
void setEnabled(bool enabled);
- void addWindow(QWasmWindow *window, QWasmWindow *parentWindow = nullptr);
+ void addWindow(QWasmWindow *window);
void removeWindow(QWasmWindow *window);
void setVisible(QWasmWindow *window, bool visible);
void raise(QWasmWindow *window);
void lower(QWasmWindow *window);
- void setParent(QWasmWindow *window, QWasmWindow *parent);
int windowCount() const;
@@ -217,7 +203,7 @@ private:
QScopedPointer<QOpenGLContext> m_context;
QScopedPointer<QOpenGLTextureBlitter> m_blitter;
- QHash<QWasmWindow *, QWasmCompositedWindow> m_compositedWindows;
+ QHash<const QWasmWindow *, bool> m_windowVisibility;
QList<QWasmWindow *> m_windowStack;
QRegion m_globalDamage; // damage caused by expose, window close, etc.
bool m_needComposit = false;