OpenCoverage

qquickcanvasitem_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcanvasitem_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#ifndef QQUICKCANVASITEM_P_H-
41#define QQUICKCANVASITEM_P_H-
42-
43//-
44// W A R N I N G-
45// --------------
46//-
47// This file is not part of the Qt API. It exists purely as an-
48// implementation detail. This header file may change from version to-
49// version without notice, or even be removed.-
50//-
51// We mean it.-
52//-
53-
54#include <private/qtquickglobal_p.h>-
55-
56QT_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-
64QT_BEGIN_NAMESPACE-
65-
66class QQuickCanvasContext;-
67-
68class QQuickCanvasItemPrivate;-
69class QQuickPixmap;-
70-
71class QQuickCanvasPixmap : public QQmlRefCount-
72{-
73public:-
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-
85private:-
86 QQuickPixmap *m_pixmap;-
87 QImage m_image;-
88};-
89-
90class 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-
103public:-
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-
161Q_SIGNALS:-
162 void paint(const QRect &region);-
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-
174public 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-
181private Q_SLOTS:-
182 void sceneGraphInitialized();-
183 void checkAnimationCallbacks();-
184 void invalidateSceneGraph();-
185 void schedulePolish();-
186-
187protected:-
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;-
195private:-
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-
204class QQuickContext2DRenderThread : public QThread-
205{-
206 Q_OBJECT-
207public:-
208 QQuickContext2DRenderThread(QQmlEngine *eng);-
209 ~QQuickContext2DRenderThread();-
210-
211 static QQuickContext2DRenderThread *instance(QQmlEngine *engine);-
212-
213private:-
214 QQmlEngine *m_engine;-
215 QObject *m_eventLoopQuitHack;-
216 static QHash<QQmlEngine *,QQuickContext2DRenderThread*> renderThreads;-
217 static QMutex renderThreadsMutex;-
218};-
219-
220QT_END_NAMESPACE-
221-
222QML_DECLARE_TYPE(QQuickCanvasItem)-
223-
224#endif //QQUICKCANVASITEM_P_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0