QQuickCanvas renames
[profile/ivi/qtdeclarative.git] / src / quick / items / context2d / qquickcanvasitem_p.h
index 9a57733..4e592bc 100644 (file)
@@ -44,6 +44,8 @@
 
 #include <QtQuick/qquickitem.h>
 #include <private/qv8engine_p.h>
+#include <QtCore/QThread>
+#include <QtGui/QImage>
 
 QT_BEGIN_HEADER
 
@@ -52,15 +54,40 @@ QT_BEGIN_NAMESPACE
 class QQuickCanvasContext;
 
 class QQuickCanvasItemPrivate;
-class Q_QUICK_EXPORT QQuickCanvasItem : public QQuickItem
+class QSGTexture;
+class QQuickPixmap;
+
+class QQuickCanvasPixmap : public QQmlRefCount
+{
+public:
+    QQuickCanvasPixmap(const QImage& image, QQuickWindow *window);
+    QQuickCanvasPixmap(QQuickPixmap *pixmap, QQuickWindow *window);
+    ~QQuickCanvasPixmap();
+
+    QSGTexture *texture();
+    QImage image();
+
+    qreal width() const;
+    qreal height() const;
+    bool isValid() const;
+    QQuickPixmap *pixmap() const { return m_pixmap;}
+
+private:
+    QQuickPixmap *m_pixmap;
+    QImage m_image;
+    QSGTexture *m_texture;
+    QQuickWindow *m_window;
+};
+
+class QQuickCanvasItem : public QQuickItem
 {
     Q_OBJECT
     Q_ENUMS(RenderTarget)
     Q_ENUMS(RenderStrategy)
 
-    Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged);
+    Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged)
     Q_PROPERTY(QString contextType READ contextType WRITE setContextType NOTIFY contextTypeChanged)
-    Q_PROPERTY(QQmlV8Handle context READ context NOTIFY contextChanged);
+    Q_PROPERTY(QQmlV8Handle context READ context NOTIFY contextChanged)
     Q_PROPERTY(QSizeF canvasSize READ canvasSize WRITE setCanvasSize NOTIFY canvasSizeChanged)
     Q_PROPERTY(QSize tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged)
     Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged)
@@ -104,7 +131,7 @@ public:
     RenderStrategy renderStrategy() const;
     void setRenderStrategy(RenderStrategy strategy);
 
-    QQuickCanvasContextrawContext() const;
+    QQuickCanvasContext *rawContext() const;
 
     QImage toImage(const QRectF& rect = QRectF()) const;
 
@@ -118,7 +145,7 @@ public:
 
     Q_INVOKABLE bool save(const QString &filename) const;
     Q_INVOKABLE QString toDataURL(const QString& type = QLatin1String("image/png")) const;
-    QImage loadedImage(const QUrl& url);
+    QQmlRefPointer<QQuickCanvasPixmap> loadedPixmap(const QUrl& url);
 
 Q_SIGNALS:
     void paint(const QRect &region);
@@ -153,11 +180,27 @@ protected:
 
 private:
     Q_DECLARE_PRIVATE(QQuickCanvasItem)
-
     Q_INVOKABLE void delayedCreate();
     bool createContext(const QString &contextType);
     void initializeContext(QQuickCanvasContext *context, const QVariantMap &args = QVariantMap());
     QRect tiledRect(const QRectF &window, const QSize &tileSize);
+    bool isPaintConnected();
+};
+
+class QQuickContext2DRenderThread : public QThread
+{
+    Q_OBJECT
+public:
+    QQuickContext2DRenderThread(QQmlEngine *eng);
+    ~QQuickContext2DRenderThread();
+
+    static QQuickContext2DRenderThread *instance(QQmlEngine *engine);
+
+private:
+    QQmlEngine *m_engine;
+    QObject *m_eventLoopQuitHack;
+    static QHash<QQmlEngine *,QQuickContext2DRenderThread*> renderThreads;
+    static QMutex renderThreadsMutex;
 };
 
 QT_END_NAMESPACE