1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKWIDGET_P_H
5#define QQUICKWIDGET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qquickwidget.h"
19#include <private/qwidget_p.h>
20#include <rhi/qrhi.h>
21#include <private/qbackingstorerhisupport_p.h>
22
23#include <QtCore/qurl.h>
24#include <QtCore/qelapsedtimer.h>
25#include <QtCore/qtimer.h>
26#include <QtCore/qpointer.h>
27#include <QtCore/QWeakPointer>
28
29#include <QtQml/qqmlengine.h>
30
31#include "private/qquickitemchangelistener_p.h"
32
33QT_BEGIN_NAMESPACE
34
35class QQmlContext;
36class QQmlError;
37class QQuickItem;
38class QQmlComponent;
39class QQuickRenderControl;
40
41class QQuickWidgetPrivate
42 : public QWidgetPrivate,
43 public QSafeQuickItemChangeListener<QQuickWidgetPrivate>
44{
45 Q_DECLARE_PUBLIC(QQuickWidget)
46public:
47 static QQuickWidgetPrivate* get(QQuickWidget *view) { return view->d_func(); }
48 static const QQuickWidgetPrivate* get(const QQuickWidget *view) { return view->d_func(); }
49
50 QQuickWidgetPrivate();
51
52 void executeHelper();
53 void destroy();
54 void execute();
55 void execute(QAnyStringView uri, QAnyStringView typeName);
56 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override;
57 void initResize();
58 void updateSize();
59 void updatePosition();
60 void updateFrambufferObjectSize();
61 bool setRootObject(QObject *);
62 void render(bool needsSync);
63 void renderSceneGraph();
64 void initializeWithRhi();
65 void handleContextCreationFailure(const QSurfaceFormat &format);
66
67 QPlatformBackingStoreRhiConfig rhiConfig() const override;
68 TextureData texture() const override;
69 QPlatformTextureList::Flags textureListFlags() override;
70 QImage grabFramebuffer() override;
71
72 void init(QQmlEngine* e = nullptr);
73 void ensureBackingScene();
74 void initOffscreenWindow();
75 void ensureEngine() const;
76 void handleWindowChange();
77 void invalidateRenderControl();
78
79 QSize rootObjectSize() const;
80
81 QPointer<QQuickItem> root;
82
83 QUrl source;
84
85 mutable QPointer<QQmlEngine> engine;
86 QQmlComponent *component;
87 QBasicTimer resizetimer;
88 QQuickWindow *offscreenWindow;
89 QQuickRenderControl *renderControl;
90
91 QRhi *rhi;
92 QRhiTexture *outputTexture;
93 QRhiRenderBuffer *depthStencil;
94 QRhiRenderBuffer *msaaBuffer;
95 QRhiTextureRenderTarget *rt;
96 QRhiRenderPassDescriptor *rtRp;
97
98 QQuickWidget::ResizeMode resizeMode;
99 QSize initialSize;
100 QElapsedTimer frameTimer;
101
102 QBasicTimer updateTimer;
103 bool eventPending;
104 bool updatePending;
105 bool fakeHidden;
106
107 int requestedSamples;
108
109 bool useSoftwareRenderer;
110 QImage softwareImage;
111 QRegion updateRegion;
112 bool forceFullUpdate;
113 bool deviceLost;
114
115 QBackingStoreRhiSupport offscreenRenderer;
116
117 QVariantMap initialProperties;
118};
119
120class QQuickWidgetOffscreenWindow: public QQuickWindow
121{
122 Q_OBJECT
123
124public:
125 QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
126};
127
128QT_END_NAMESPACE
129
130#endif // QQuickWidget_P_H
131

source code of qtdeclarative/src/quickwidgets/qquickwidget_p.h