summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmbackingstore.h
blob: 54e9fe4cb3ea87a563afe15395602eab62325f32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QWASMBACKINGSTORE_H
#define QWASMBACKINGSTORE_H

#include <qpa/qplatformbackingstore.h>
#include <QtGui/qimage.h>

#include <emscripten/val.h>

QT_BEGIN_NAMESPACE

class QOpenGLTexture;
class QRegion;
class QWasmCompositor;
class QWasmWindow;

class QWasmBackingStore : public QPlatformBackingStore
{
public:
    QWasmBackingStore(QWasmCompositor *compositor, QWindow *window);
    ~QWasmBackingStore();

    QPaintDevice *paintDevice() override;

    void beginPaint(const QRegion &) override;
    void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;
    void resize(const QSize &size, const QRegion &staticContents) override;
    QImage toImage() const override;
    const QImage &getImageRef() const;

    emscripten::val getUpdatedWebImage(QWasmWindow *window);

protected:
    void updateTexture(QWasmWindow *window);

private:
    QWasmCompositor *m_compositor;
    QImage m_image;
    QRegion m_dirty;
    emscripten::val m_webImageDataArray = emscripten::val::undefined();
};

QT_END_NAMESPACE

#endif // QWASMBACKINGSTORE_H