blob: 8fc290dda3be586250a8a69b5f9677a0ed398005 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWASMCOMPOSITOR_H
#define QWASMCOMPOSITOR_H
#include "qwasmwindowstack.h"
#include <qpa/qplatformwindow.h>
#include <QMap>
#include <tuple>
#include <emscripten/val.h>
QT_BEGIN_NAMESPACE
class QWasmWindow;
class QWasmScreen;
enum class QWasmWindowTreeNodeChangeType;
class QWasmAnimationFrameHandler
{
public:
QWasmAnimationFrameHandler(std::function<void(double)> handler);
~QWasmAnimationFrameHandler();
int64_t requestAnimationFrame();
void cancelAnimationFrame(int64_t id);
private:
uint32_t m_handlerIndex;
};
class QWasmCompositor final : public QObject
{
Q_OBJECT
public:
QWasmCompositor(QWasmScreen *screen);
~QWasmCompositor() final;
void setVisible(QWasmWindow *window, bool visible);
void onScreenDeleting();
QWasmScreen *screen();
void setEnabled(bool enabled);
static bool releaseRequestUpdateHold();
void requestUpdate();
enum UpdateRequestDeliveryType { ExposeEventDelivery, UpdateRequestDelivery };
void requestUpdateWindow(QWasmWindow *window, const QRect &updateRect, UpdateRequestDeliveryType updateType = ExposeEventDelivery);
void handleBackingStoreFlush(QWindow *window, const QRect &updateRect);
void onWindowTreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindow *window);
private:
void frame(const QList<QWasmWindow *> &windows);
void deregisterEventHandlers();
void deliverUpdateRequests();
void deliverUpdateRequest(QWasmWindow *window, const QRect &updateRect, UpdateRequestDeliveryType updateType);
bool m_isEnabled = true;
QMap<QWasmWindow *, std::tuple<QRect, UpdateRequestDeliveryType>> m_requestUpdateWindows;
QWasmAnimationFrameHandler m_animationFrameHandler;
int64_t m_requestAnimationFrameId = -1;
bool m_inDeliverUpdateRequest = false;
static bool m_requestUpdateHoldEnabled;
};
QT_END_NAMESPACE
#endif
|