Line | Source | Count |
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 | #ifndef QQUICKCANVASITEM_P_H | - |
41 | #define QQUICKCANVASITEM_P_H | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | #include <private/qtquickglobal_p.h> | - |
55 | | - |
56 | QT_REQUIRE_CONFIG(quick_canvas); | - |
57 | | - |
58 | #include <QtQuick/qquickitem.h> | - |
59 | #include <private/qv8engine_p.h> | - |
60 | #include <private/qqmlrefcount_p.h> | - |
61 | #include <QtCore/QThread> | - |
62 | #include <QtGui/QImage> | - |
63 | | - |
64 | QT_BEGIN_NAMESPACE | - |
65 | | - |
66 | class QQuickCanvasContext; | - |
67 | | - |
68 | class QQuickCanvasItemPrivate; | - |
69 | class QQuickPixmap; | - |
70 | | - |
71 | class QQuickCanvasPixmap : public QQmlRefCount | - |
72 | { | - |
73 | public: | - |
74 | QQuickCanvasPixmap(const QImage& image); | - |
75 | QQuickCanvasPixmap(QQuickPixmap *pixmap); | - |
76 | ~QQuickCanvasPixmap(); | - |
77 | | - |
78 | QImage image(); | - |
79 | | - |
80 | qreal width() const; | - |
81 | qreal height() const; | - |
82 | bool isValid() const; | - |
83 | QQuickPixmap *pixmap() const { return m_pixmap;} never executed: return m_pixmap; | 0 |
84 | | - |
85 | private: | - |
86 | QQuickPixmap *m_pixmap; | - |
87 | QImage m_image; | - |
88 | }; | - |
89 | | - |
90 | class QQuickCanvasItem : public QQuickItem | - |
91 | { | - |
92 | Q_OBJECT | - |
93 | | - |
94 | Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged) | - |
95 | Q_PROPERTY(QString contextType READ contextType WRITE setContextType NOTIFY contextTypeChanged) | - |
96 | Q_PROPERTY(QQmlV4Handle context READ context NOTIFY contextChanged) | - |
97 | Q_PROPERTY(QSizeF canvasSize READ canvasSize WRITE setCanvasSize NOTIFY canvasSizeChanged) | - |
98 | Q_PROPERTY(QSize tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged) | - |
99 | Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged) | - |
100 | Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged) | - |
101 | Q_PROPERTY(RenderStrategy renderStrategy READ renderStrategy WRITE setRenderStrategy NOTIFY renderStrategyChanged) | - |
102 | | - |
103 | public: | - |
104 | enum RenderTarget { | - |
105 | Image, | - |
106 | FramebufferObject | - |
107 | }; | - |
108 | Q_ENUM(RenderTarget) | - |
109 | | - |
110 | enum RenderStrategy { | - |
111 | Immediate, | - |
112 | Threaded, | - |
113 | Cooperative | - |
114 | }; | - |
115 | Q_ENUM(RenderStrategy) | - |
116 | | - |
117 | QQuickCanvasItem(QQuickItem *parent = nullptr); | - |
118 | ~QQuickCanvasItem(); | - |
119 | | - |
120 | bool isAvailable() const; | - |
121 | | - |
122 | QString contextType() const; | - |
123 | void setContextType(const QString &contextType); | - |
124 | | - |
125 | QQmlV4Handle context() const; | - |
126 | | - |
127 | QSizeF canvasSize() const; | - |
128 | void setCanvasSize(const QSizeF &); | - |
129 | | - |
130 | QSize tileSize() const; | - |
131 | void setTileSize(const QSize &); | - |
132 | | - |
133 | QRectF canvasWindow() const; | - |
134 | void setCanvasWindow(const QRectF& rect); | - |
135 | | - |
136 | RenderTarget renderTarget() const; | - |
137 | void setRenderTarget(RenderTarget target); | - |
138 | | - |
139 | RenderStrategy renderStrategy() const; | - |
140 | void setRenderStrategy(RenderStrategy strategy); | - |
141 | | - |
142 | QQuickCanvasContext *rawContext() const; | - |
143 | | - |
144 | QImage toImage(const QRectF& rect = QRectF()) const; | - |
145 | | - |
146 | Q_INVOKABLE void getContext(QQmlV4Function *args); | - |
147 | | - |
148 | Q_INVOKABLE void requestAnimationFrame(QQmlV4Function *args); | - |
149 | Q_INVOKABLE void cancelRequestAnimationFrame(QQmlV4Function *args); | - |
150 | | - |
151 | Q_INVOKABLE void requestPaint(); | - |
152 | Q_INVOKABLE void markDirty(const QRectF& dirtyRect = QRectF()); | - |
153 | | - |
154 | Q_INVOKABLE bool save(const QString &filename) const; | - |
155 | Q_INVOKABLE QString toDataURL(const QString& type = QLatin1String("image/png")) const; | - |
156 | QQmlRefPointer<QQuickCanvasPixmap> loadedPixmap(const QUrl& url); | - |
157 | | - |
158 | bool isTextureProvider() const override; | - |
159 | QSGTextureProvider *textureProvider() const override; | - |
160 | | - |
161 | Q_SIGNALS: | - |
162 | void paint(const QRect ®ion); | - |
163 | void painted(); | - |
164 | void availableChanged(); | - |
165 | void contextTypeChanged(); | - |
166 | void contextChanged(); | - |
167 | void canvasSizeChanged(); | - |
168 | void tileSizeChanged(); | - |
169 | void canvasWindowChanged(); | - |
170 | void renderTargetChanged(); | - |
171 | void renderStrategyChanged(); | - |
172 | void imageLoaded(); | - |
173 | | - |
174 | public Q_SLOTS: | - |
175 | void loadImage(const QUrl& url); | - |
176 | void unloadImage(const QUrl& url); | - |
177 | bool isImageLoaded(const QUrl& url) const; | - |
178 | bool isImageLoading(const QUrl& url) const; | - |
179 | bool isImageError(const QUrl& url) const; | - |
180 | | - |
181 | private Q_SLOTS: | - |
182 | void sceneGraphInitialized(); | - |
183 | void checkAnimationCallbacks(); | - |
184 | void invalidateSceneGraph(); | - |
185 | void schedulePolish(); | - |
186 | | - |
187 | protected: | - |
188 | void componentComplete() override; | - |
189 | void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) override; | - |
190 | void updatePolish() override; | - |
191 | QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; | - |
192 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; | - |
193 | void releaseResources() override; | - |
194 | bool event(QEvent *event) override; | - |
195 | private: | - |
196 | Q_DECLARE_PRIVATE(QQuickCanvasItem) never executed: return reinterpret_cast<QQuickCanvasItemPrivate *>(qGetPtrHelper(d_ptr)); never executed: return reinterpret_cast<const QQuickCanvasItemPrivate *>(qGetPtrHelper(d_ptr)); | 0 |
197 | Q_INVOKABLE void delayedCreate(); | - |
198 | bool createContext(const QString &contextType); | - |
199 | void initializeContext(QQuickCanvasContext *context, const QVariantMap &args = QVariantMap()); | - |
200 | static QRect tiledRect(const QRectF &window, const QSize &tileSize); | - |
201 | bool isPaintConnected(); | - |
202 | }; | - |
203 | | - |
204 | class QQuickContext2DRenderThread : public QThread | - |
205 | { | - |
206 | Q_OBJECT | - |
207 | public: | - |
208 | QQuickContext2DRenderThread(QQmlEngine *eng); | - |
209 | ~QQuickContext2DRenderThread(); | - |
210 | | - |
211 | static QQuickContext2DRenderThread *instance(QQmlEngine *engine); | - |
212 | | - |
213 | private: | - |
214 | QQmlEngine *m_engine; | - |
215 | QObject *m_eventLoopQuitHack; | - |
216 | static QHash<QQmlEngine *,QQuickContext2DRenderThread*> renderThreads; | - |
217 | static QMutex renderThreadsMutex; | - |
218 | }; | - |
219 | | - |
220 | QT_END_NAMESPACE | - |
221 | | - |
222 | QML_DECLARE_TYPE(QQuickCanvasItem) | - |
223 | | - |
224 | #endif //QQUICKCANVASITEM_P_H | - |
| | |