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>
This commit is contained in:
parent
c5e659be7c
commit
196c38a846
@ -36,14 +36,6 @@ using namespace emscripten;
|
|||||||
|
|
||||||
Q_GUI_EXPORT int qt_defaultDpiX();
|
Q_GUI_EXPORT int qt_defaultDpiX();
|
||||||
|
|
||||||
QWasmCompositedWindow::QWasmCompositedWindow()
|
|
||||||
: window(nullptr)
|
|
||||||
, parentWindow(nullptr)
|
|
||||||
, flushPending(false)
|
|
||||||
, visible(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool g_scrollingInvertedFromDevice = false;
|
bool g_scrollingInvertedFromDevice = false;
|
||||||
|
|
||||||
static void mouseWheelEvent(emscripten::val event)
|
static void mouseWheelEvent(emscripten::val event)
|
||||||
@ -176,32 +168,19 @@ void QWasmCompositor::setEnabled(bool enabled)
|
|||||||
m_isEnabled = enabled;
|
m_isEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWasmCompositor::addWindow(QWasmWindow *window, QWasmWindow *parentWindow)
|
void QWasmCompositor::addWindow(QWasmWindow *window)
|
||||||
{
|
{
|
||||||
QWasmCompositedWindow compositedWindow;
|
m_windowVisibility.insert(window, false);
|
||||||
compositedWindow.window = window;
|
|
||||||
compositedWindow.parentWindow = parentWindow;
|
|
||||||
m_compositedWindows.insert(window, compositedWindow);
|
|
||||||
|
|
||||||
if (parentWindow == 0)
|
|
||||||
m_windowStack.append(window);
|
m_windowStack.append(window);
|
||||||
else
|
|
||||||
m_compositedWindows[parentWindow].childWindows.append(window);
|
|
||||||
|
|
||||||
notifyTopWindowChanged(window);
|
notifyTopWindowChanged(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWasmCompositor::removeWindow(QWasmWindow *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_windowStack.removeAll(window);
|
||||||
m_compositedWindows.remove(window);
|
m_windowVisibility.remove(window);
|
||||||
m_requestUpdateWindows.remove(window);
|
m_requestUpdateWindows.remove(window);
|
||||||
|
|
||||||
if (!m_windowStack.isEmpty() && !QGuiApplication::focusWindow()) {
|
if (!m_windowStack.isEmpty() && !QGuiApplication::focusWindow()) {
|
||||||
@ -213,27 +192,22 @@ void QWasmCompositor::removeWindow(QWasmWindow *window)
|
|||||||
|
|
||||||
void QWasmCompositor::setVisible(QWasmWindow *window, bool visible)
|
void QWasmCompositor::setVisible(QWasmWindow *window, bool visible)
|
||||||
{
|
{
|
||||||
QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
|
const bool wasVisible = m_windowVisibility[window];
|
||||||
if (compositedWindow.visible == visible)
|
if (wasVisible == visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
compositedWindow.visible = visible;
|
m_windowVisibility[window] = visible;
|
||||||
compositedWindow.flushPending = true;
|
if (!visible)
|
||||||
if (visible)
|
m_globalDamage = window->window()->geometry(); // repaint previously covered area.
|
||||||
compositedWindow.damage = compositedWindow.window->geometry();
|
|
||||||
else
|
|
||||||
m_globalDamage = compositedWindow.window->geometry(); // repaint previously covered area.
|
|
||||||
|
|
||||||
requestUpdateWindow(window, QWasmCompositor::ExposeEventDelivery);
|
requestUpdateWindow(window, QWasmCompositor::ExposeEventDelivery);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWasmCompositor::raise(QWasmWindow *window)
|
void QWasmCompositor::raise(QWasmWindow *window)
|
||||||
{
|
{
|
||||||
if (m_compositedWindows.size() <= 1)
|
if (m_windowStack.size() <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
|
|
||||||
compositedWindow.damage = compositedWindow.window->geometry();
|
|
||||||
m_windowStack.removeAll(window);
|
m_windowStack.removeAll(window);
|
||||||
m_windowStack.append(window);
|
m_windowStack.append(window);
|
||||||
|
|
||||||
@ -242,24 +216,16 @@ void QWasmCompositor::raise(QWasmWindow *window)
|
|||||||
|
|
||||||
void QWasmCompositor::lower(QWasmWindow *window)
|
void QWasmCompositor::lower(QWasmWindow *window)
|
||||||
{
|
{
|
||||||
if (m_compositedWindows.size() <= 1)
|
if (m_windowStack.size() <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_windowStack.removeAll(window);
|
m_windowStack.removeAll(window);
|
||||||
m_windowStack.prepend(window);
|
m_windowStack.prepend(window);
|
||||||
QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
|
m_globalDamage = window->window()->geometry(); // repaint previously covered area.
|
||||||
m_globalDamage = compositedWindow.window->geometry(); // repaint previously covered area.
|
|
||||||
|
|
||||||
notifyTopWindowChanged(window);
|
notifyTopWindowChanged(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWasmCompositor::setParent(QWasmWindow *window, QWasmWindow *parent)
|
|
||||||
{
|
|
||||||
m_compositedWindows[window].parentWindow = parent;
|
|
||||||
|
|
||||||
requestUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QWasmCompositor::windowCount() const
|
int QWasmCompositor::windowCount() const
|
||||||
{
|
{
|
||||||
return m_windowStack.count();
|
return m_windowStack.count();
|
||||||
@ -271,13 +237,13 @@ QWindow *QWasmCompositor::windowAt(QPoint targetPointInScreenCoords, int padding
|
|||||||
// qDebug() << "window at" << "point" << p << "window count" << index;
|
// qDebug() << "window at" << "point" << p << "window count" << index;
|
||||||
|
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
const QWasmCompositedWindow &compositedWindow = m_compositedWindows[m_windowStack.at(index)];
|
const QWasmWindow *window = m_windowStack.at(index);
|
||||||
//qDebug() << "windwAt testing" << compositedWindow.window <<
|
//qDebug() << "windwAt testing" << compositedWindow.window <<
|
||||||
|
|
||||||
QRect geometry = compositedWindow.window->windowFrameGeometry()
|
QRect geometry = window->windowFrameGeometry()
|
||||||
.adjusted(-padding, -padding, padding, padding);
|
.adjusted(-padding, -padding, padding, padding);
|
||||||
|
|
||||||
if (compositedWindow.visible && geometry.contains(targetPointInScreenCoords))
|
if (m_windowVisibility[window] && geometry.contains(targetPointInScreenCoords))
|
||||||
return m_windowStack.at(index)->window();
|
return m_windowStack.at(index)->window();
|
||||||
--index;
|
--index;
|
||||||
}
|
}
|
||||||
@ -851,11 +817,7 @@ void QWasmCompositor::frame()
|
|||||||
m_blitter->setRedBlueSwizzle(true);
|
m_blitter->setRedBlueSwizzle(true);
|
||||||
|
|
||||||
for (QWasmWindow *window : qAsConst(m_windowStack)) {
|
for (QWasmWindow *window : qAsConst(m_windowStack)) {
|
||||||
QWasmCompositedWindow &compositedWindow = m_compositedWindows[window];
|
if (m_windowVisibility[window])
|
||||||
|
|
||||||
if (!compositedWindow.visible)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
drawWindow(m_blitter.data(), screen(), window);
|
drawWindow(m_blitter.data(), screen(), window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,19 +29,6 @@ class QOpenGLContext;
|
|||||||
class QOpenGLTexture;
|
class QOpenGLTexture;
|
||||||
class QWasmEventTranslator;
|
class QWasmEventTranslator;
|
||||||
|
|
||||||
class QWasmCompositedWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QWasmCompositedWindow();
|
|
||||||
|
|
||||||
QWasmWindow *window;
|
|
||||||
QWasmWindow *parentWindow;
|
|
||||||
QRegion damage;
|
|
||||||
bool flushPending;
|
|
||||||
bool visible;
|
|
||||||
QList<QWasmWindow *> childWindows;
|
|
||||||
};
|
|
||||||
|
|
||||||
class QWasmCompositor : public QObject
|
class QWasmCompositor : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -108,13 +95,12 @@ public:
|
|||||||
|
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
void addWindow(QWasmWindow *window, QWasmWindow *parentWindow = nullptr);
|
void addWindow(QWasmWindow *window);
|
||||||
void removeWindow(QWasmWindow *window);
|
void removeWindow(QWasmWindow *window);
|
||||||
|
|
||||||
void setVisible(QWasmWindow *window, bool visible);
|
void setVisible(QWasmWindow *window, bool visible);
|
||||||
void raise(QWasmWindow *window);
|
void raise(QWasmWindow *window);
|
||||||
void lower(QWasmWindow *window);
|
void lower(QWasmWindow *window);
|
||||||
void setParent(QWasmWindow *window, QWasmWindow *parent);
|
|
||||||
|
|
||||||
int windowCount() const;
|
int windowCount() const;
|
||||||
|
|
||||||
@ -217,7 +203,7 @@ private:
|
|||||||
QScopedPointer<QOpenGLContext> m_context;
|
QScopedPointer<QOpenGLContext> m_context;
|
||||||
QScopedPointer<QOpenGLTextureBlitter> m_blitter;
|
QScopedPointer<QOpenGLTextureBlitter> m_blitter;
|
||||||
|
|
||||||
QHash<QWasmWindow *, QWasmCompositedWindow> m_compositedWindows;
|
QHash<const QWasmWindow *, bool> m_windowVisibility;
|
||||||
QList<QWasmWindow *> m_windowStack;
|
QList<QWasmWindow *> m_windowStack;
|
||||||
QRegion m_globalDamage; // damage caused by expose, window close, etc.
|
QRegion m_globalDamage; // damage caused by expose, window close, etc.
|
||||||
bool m_needComposit = false;
|
bool m_needComposit = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user