Refactor context2d thread logic
[profile/ivi/qtdeclarative.git] / src / quick / items / context2d / qquickcontext2d_p.h
index 4112d4e..295be05 100644 (file)
@@ -53,7 +53,7 @@
 #include <QtCore/qstack.h>
 #include <QtCore/qqueue.h>
 #include <private/qv8engine_p.h>
-
+#include <QtCore/QWaitCondition>
 
 
 //#define QQUICKCONTEXT2D_DEBUG //enable this for just DEBUG purpose!
@@ -70,11 +70,15 @@ class QQuickContext2DCommandBuffer;
 class QQuickContext2DTexture;
 class QQuickPixmap;
 class QSGTexture;
+class QQuickWindowManager;
+class QSurface;
+class QOpenGLContext;
 
-
-class Q_QUICK_EXPORT QQuickContext2D : public QQuickCanvasContext
+class QQuickContext2D : public QQuickCanvasContext
 {
 public:
+    Q_DISABLE_COPY(QQuickContext2D)
+
     enum TextBaseLineType { Alphabetic=0, Top, Middle, Bottom, Hanging};
     enum TextAlignType { Start=0, End, Left, Right, Center};
     enum PaintCommand {
@@ -105,6 +109,7 @@ public:
         FillText,
         StrokeText,
         DrawImage,
+        DrawPixmap,
         GetImageData
     };
 
@@ -167,6 +172,7 @@ public:
     void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth);
     void flush();
     void sync();
+    QThread *thread() const {return m_thread;}
     QSGDynamicTexture *texture() const;
     QImage toImage(const QRectF& bounds);
 
@@ -219,7 +225,11 @@ public:
     bool isPointInPath(qreal x, qreal y) const;
 
     QPainterPath createTextGlyphs(qreal x, qreal y, const QString& text);
-    QImage createImage(const QUrl& url);
+    QQmlRefPointer<QQuickCanvasPixmap> createPixmap(const QUrl& url);
+
+    QOpenGLContext *glContext() { return m_glContext; }
+    QSurface *surface() { return m_surface; }
+    void setGrabbedImage(const QImage& grab);
 
     State state;
     QStack<QQuickContext2D::State> m_stateStack;
@@ -230,12 +240,19 @@ public:
     v8::Local<v8::Value> m_strokeStyle;
     v8::Handle<v8::Value> m_v8path;
     QV8Engine *m_v8engine;
+    QQuickWindowManager *m_windowManager;
+    QSurface *m_surface;
+    QOpenGLContext *m_glContext;
     v8::Persistent<v8::Object> m_v8value;
     QQuickContext2DTexture *m_texture;
     QQuickCanvasItem::RenderTarget m_renderTarget;
     QQuickCanvasItem::RenderStrategy m_renderStrategy;
     QQueue<QQuickContext2DCommandBuffer*> m_bufferQueue;
-    QMutex m_bufferMutex;
+    QThread *m_thread;
+    QImage m_grabbedImage;
+    bool m_grabbed:1;
+
+    QMutex m_mutex;
 };