aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgcanvas_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/items/qsgcanvas_p.h')
-rw-r--r--src/declarative/items/qsgcanvas_p.h93
1 files changed, 72 insertions, 21 deletions
diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h
index 6b8034f922..87fae1c31a 100644
--- a/src/declarative/items/qsgcanvas_p.h
+++ b/src/declarative/items/qsgcanvas_p.h
@@ -78,6 +78,8 @@ public:
class QSGCanvasPrivate;
class QTouchEvent;
+class QSGCanvasRenderThread;
+
class QSGCanvasPrivate : public QGLWidgetPrivate
{
public:
@@ -115,8 +117,6 @@ public:
void sendHoverEvent(QEvent::Type, QSGItem *, QGraphicsSceneHoverEvent *);
void clearHover();
- void stopRenderingThread();
-
QDeclarativeGuard<QSGItem> hoverItem;
enum FocusOption {
DontChangeFocusProperty = 0x01,
@@ -135,11 +135,7 @@ public:
void initializeSceneGraph();
void polishItems();
void syncSceneGraph();
- void renderSceneGraph();
- void runThread();
-
- void _q_animationStarted();
- void _q_animationStopped();
+ void renderSceneGraph(const QSize &size);
QSGItem::UpdatePaintNodeData updatePaintNodeData;
@@ -156,24 +152,12 @@ public:
QSGContext *context;
- uint contextInThread : 1;
+ uint contextFailed : 1;
uint threadedRendering : 1;
- uint exitThread : 1;
uint animationRunning: 1;
- uint idle : 1; // Set to true when render thread sees no change and enters a wait()
- uint needsRepaint : 1; // Set by callback from render if scene needs repainting.
uint renderThreadAwakened : 1;
- uint inSync: 1;
- struct MyThread : public QThread {
- MyThread(QSGCanvasPrivate *r) : renderer(r) {}
- virtual void run() { renderer->runThread(); }
- static void doWait() { QThread::msleep(16); }
- QSGCanvasPrivate *renderer;
- };
- MyThread *thread;
- QMutex mutex;
- QWaitCondition wait;
+ QSGCanvasRenderThread *thread;
QSize widgetSize;
QSize viewportSize;
@@ -182,6 +166,73 @@ public:
QHash<int, QSGItem *> itemForTouchPointId;
};
+
+
+class QSGCanvasRenderThread : public QThread
+{
+ Q_OBJECT
+public:
+ QSGCanvasRenderThread()
+ : mutex(QMutex::NonRecursive)
+ , isGuiBlocked(0)
+ , isPaintCompleted(false)
+ , isGuiBlockPending(false)
+ , isRenderBlocked(false)
+ , isExternalUpdatePending(false)
+ , syncAlreadyHappened(false)
+ , doGrab(false)
+ , shouldExit(false)
+ , hasExited(false)
+ {}
+
+ inline void lock() { mutex.lock(); }
+ inline void unlock() { mutex.unlock(); }
+ inline void wait() { condition.wait(&mutex); }
+ inline void wake() { condition.wakeOne(); }
+
+ void lockInGui();
+ void unlockInGui();
+
+ void paint();
+ void resize(const QSize &size);
+ void startRenderThread();
+ void stopRenderThread();
+ void exhaustSyncEvent();
+ void sync(bool guiAlreadyLocked);
+
+ QImage grab();
+
+public slots:
+ void animationStarted();
+ void animationStopped();
+
+public:
+ QMutex mutex;
+ QWaitCondition condition;
+
+ QSize windowSize;
+ QSize renderedSize;
+
+ QSGCanvas *renderer;
+ QSGCanvasPrivate *d;
+
+ int isGuiBlocked;
+ uint isPaintCompleted : 1;
+ uint isGuiBlockPending : 1;
+ uint isRenderBlocked : 1;
+ uint isExternalUpdatePending : 1;
+ uint syncAlreadyHappened : 1;
+
+ uint doGrab : 1;
+ uint shouldExit : 1;
+ uint hasExited : 1;
+
+ QImage grabContent;
+
+ void run();
+};
+
+
Q_DECLARE_OPERATORS_FOR_FLAGS(QSGCanvasPrivate::FocusOptions)
QT_END_NAMESPACE