diff options
author | Mikolaj Boc <mikolaj.boc@qt.io> | 2022-08-17 08:38:54 +0200 |
---|---|---|
committer | Mikolaj Boc <mikolaj.boc@qt.io> | 2022-10-05 00:36:41 +0200 |
commit | 9bf689e875ce1f5e80696cbc86d446074b01c705 (patch) | |
tree | 0d6f0c32cffb872fac60e6e98e71705e78fad97e | |
parent | b9887d51c396d126dd1dfc67a18a7de361db205b (diff) |
Remove dead code & cull public API in WASM compositor
- Remove the manual destroy methods - destructor should handle
destruction
- Remove the unused enum QWasmStateFlag
- Make public API private where possible
- Adjust handleTouch->processTouch to keep consistency with other
process methods
- Remove dead fields in compositor
- Don't keep a dead screen entry in m_screens in qwasmintegration
Change-Id: I98caf4dbdda5ebd25c4a9c22a40140c7ed1d7aa7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.cpp | 12 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.h | 49 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.cpp | 1 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmscreen.cpp | 10 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.cpp | 2 |
5 files changed, 30 insertions, 44 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 16435add9d..fe310618ce 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -199,8 +199,6 @@ void QWasmCompositor::setVisible(QWasmWindow *window, bool visible) return; m_windowVisibility[window] = visible; - if (!visible) - m_globalDamage = window->window()->geometry(); // repaint previously covered area. requestUpdateWindow(window, QWasmCompositor::ExposeEventDelivery); } @@ -212,15 +210,9 @@ void QWasmCompositor::raise(QWasmWindow *window) void QWasmCompositor::lower(QWasmWindow *window) { - m_globalDamage = window->window()->geometry(); // repaint previously covered area. m_windowStack.lower(window); } -int QWasmCompositor::windowCount() const -{ - return m_windowStack.size(); -} - QWindow *QWasmCompositor::windowAt(QPoint targetPointInScreenCoords, int padding) const { const auto found = std::find_if( @@ -578,7 +570,7 @@ int QWasmCompositor::wheel_cb(int eventType, const EmscriptenWheelEvent *wheelEv int QWasmCompositor::touchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) { auto compositor = reinterpret_cast<QWasmCompositor*>(userData); - return static_cast<int>(compositor->handleTouch(eventType, touchEvent)); + return static_cast<int>(compositor->processTouch(eventType, touchEvent)); } bool QWasmCompositor::processPointer(const PointerEvent& event) @@ -936,7 +928,7 @@ bool QWasmCompositor::processWheel(int eventType, const EmscriptenWheelEvent *wh return accepted; } -int QWasmCompositor::handleTouch(int eventType, const EmscriptenTouchEvent *touchEvent) +bool QWasmCompositor::processTouch(int eventType, const EmscriptenTouchEvent *touchEvent) { QList<QWindowSystemInterface::TouchPoint> touchPointList; touchPointList.reserve(touchEvent->numTouches); diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h index 07bce77a94..7342fd073b 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.h +++ b/src/plugins/platforms/wasm/qwasmcompositor.h @@ -32,23 +32,14 @@ class QOpenGLContext; class QOpenGLTexture; class QWasmEventTranslator; -class QWasmCompositor : public QObject +class QWasmCompositor final : public QObject { Q_OBJECT public: QWasmCompositor(QWasmScreen *screen); - ~QWasmCompositor(); - void initEventHandlers(); - void deregisterEventHandlers(); - void destroy(); + ~QWasmCompositor() final; - enum QWasmStateFlag { - State_None = 0x00000000, - State_Enabled = 0x00000001, - State_Raised = 0x00000002, - State_Sunken = 0x00000004 - }; - Q_DECLARE_FLAGS(StateFlags, QWasmStateFlag) + void initEventHandlers(); struct QWasmFrameOptions { QRect rect; @@ -66,8 +57,6 @@ public: void raise(QWasmWindow *window); void lower(QWasmWindow *window); - int windowCount() const; - QWindow *windowAt(QPoint globalPoint, int padding = 0) const; QWindow *keyWindow() const; @@ -77,20 +66,11 @@ public: 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(); - bool processKeyboard(int eventType, const EmscriptenKeyboardEvent *keyEvent); - bool processWheel(int eventType, const EmscriptenWheelEvent *wheelEvent); - int handleTouch(int eventType, const EmscriptenTouchEvent *touchEvent); + void setCapture(QWasmWindow *window); void releaseCapture(); - bool processMouseEnter(const EmscriptenMouseEvent *mouseEvent); - bool processMouseLeave(); - void enterWindow(QWindow* window, const QPoint &localPoint, const QPoint &globalPoint); - void leaveWindow(QWindow* window); + void handleBackingStoreFlush(); private slots: void frame(); @@ -146,6 +126,13 @@ private: }; void onTopWindowChanged(); + void deregisterEventHandlers(); + void destroy(); + + void requestUpdate(); + void deliverUpdateRequests(); + void deliverUpdateRequest(QWasmWindow *window, UpdateRequestDeliveryType updateType); + void drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, const QWasmWindow *window); void drawWindowContent(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, const QWasmWindow *window); @@ -165,6 +152,15 @@ private: static int touchCallback(int eventType, const EmscriptenTouchEvent *ev, void *userData); + bool processKeyboard(int eventType, const EmscriptenKeyboardEvent *keyEvent); + bool processWheel(int eventType, const EmscriptenWheelEvent *wheelEvent); + bool processMouseEnter(const EmscriptenMouseEvent *mouseEvent); + bool processMouseLeave(); + bool processTouch(int eventType, const EmscriptenTouchEvent *touchEvent); + + void enterWindow(QWindow *window, const QPoint &localPoint, const QPoint &globalPoint); + void leaveWindow(QWindow *window); + WindowManipulation m_windowManipulation; QWasmWasmWindowStack m_windowStack; @@ -172,9 +168,6 @@ private: QScopedPointer<QOpenGLTextureBlitter> m_blitter; QHash<const QWasmWindow *, bool> m_windowVisibility; - QRegion m_globalDamage; // damage caused by expose, window close, etc. - bool m_needComposit = false; - bool m_inFlush = false; bool m_isEnabled = true; QSize m_targetSize; qreal m_targetDevicePixelRatio = 1; diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index a29e18e98a..2cec4821f0 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -311,6 +311,7 @@ void QWasmIntegration::removeScreen(const emscripten::val &element) return; } it->second->deleteScreen(); + m_screens.erase(it); } void QWasmIntegration::resizeScreen(const emscripten::val &element) diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index ff51cafb06..6ac0ebb7d5 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -100,10 +100,7 @@ QWasmScreen::QWasmScreen(const emscripten::val &containerOrCanvas) QWasmScreen::~QWasmScreen() { - // Delete the compositor before removing the screen from specialHTMLTargets, - // since its destructor needs to look up the target when deregistering - // event handlers. - m_compositor = nullptr; + Q_ASSERT(!m_compositor); // deleteScreen should have been called to remove this screen if (hasSpecialHtmlTargets()) emscripten::val::module_property("specialHTMLTargets") @@ -114,7 +111,10 @@ QWasmScreen::~QWasmScreen() void QWasmScreen::deleteScreen() { - m_compositor->destroy(); + // Delete the compositor before removing the screen, since its destruction routine needs to use + // the fully operational screen. + m_compositor.reset(); + // Deletes |this|! QWindowSystemInterface::handleScreenRemoved(this); } diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 0ba7f44684..02298bb4a1 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -156,7 +156,7 @@ void QWasmWindow::setGeometry(const QRect &rect) if (shouldInvalidate) invalidate(); else - m_compositor->requestUpdate(); + m_compositor->requestUpdateWindow(this); } void QWasmWindow::setVisible(bool visible) |