diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-02-02 01:22:24 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-02-12 14:50:47 +0000 |
commit | 2b0af50c8ba534a6032a31297f1915b50a100241 (patch) | |
tree | b61daeccd0e857147ccbc0d7f83a71ad6060c98b /src/plugins/platforms/wasm/qwasmscreen.h | |
parent | e290ebae9ff2fe6064fdf2f5107221faff04f28b (diff) |
wasm: store and pass canvases as emscripten::val
Store and pass canvases as emscripten::val instead of
a QString containing the element id.
This simplifies code which interacts with the canvas
using the emscripten::val API, by removing the need to
look up with getElementById.
The Emscripten C event API does not accept emscripten::val,
and using the element id is still needed here.
emscripten::val does not provide a hash key suitable
for use with QHash, but does provide an equality-compare
in the form of val::equals(). Change the canvas->screen
mapping code to use a QVector instead of a QHash.
Change-Id: I1dbdbbc8fb06bb869031f1500e83ae2d64780a7f
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmscreen.h')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmscreen.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/platforms/wasm/qwasmscreen.h b/src/plugins/platforms/wasm/qwasmscreen.h index fcf693681c..ea7ffc4193 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.h +++ b/src/plugins/platforms/wasm/qwasmscreen.h @@ -37,6 +37,8 @@ #include <QtCore/qscopedpointer.h> #include <QtCore/qtextstream.h> +#include <emscripten/val.h> + QT_BEGIN_NAMESPACE class QPlatformOpenGLContext; @@ -50,12 +52,13 @@ class QWasmScreen : public QObject, public QPlatformScreen { Q_OBJECT public: - QWasmScreen(const QString &canvasId); + QWasmScreen(const emscripten::val &canvas); ~QWasmScreen(); void destroy(); static QWasmScreen *get(QPlatformScreen *screen); static QWasmScreen *get(QScreen *screen); + emscripten::val canvas() const; QString canvasId() const; QWasmCompositor *compositor(); @@ -80,7 +83,7 @@ public slots: void setGeometry(const QRect &rect); private: - QString m_canvasId; + emscripten::val m_canvas; QWasmCompositor *m_compositor = nullptr; QWasmEventTranslator *m_eventTranslator = nullptr; QRect m_geometry = QRect(0, 0, 100, 100); |