diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-09 15:31:31 +1000 |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-09 15:31:31 +1000 |
commit | 2d16155bb8fef642ce6bb5cab7cb26b1289a1e6b (patch) | |
tree | 5fce8dae2a55ee46f5e5e6f99bde376517f964f9 /src/declarative/items/qsgcanvas_p.h | |
parent | 7cf421d04d19441a6e17ab9460dc4560374a5bcc (diff) | |
parent | 6a6242b30550b45180d74ddee82448cdf795eb21 (diff) |
Merge branch 'master' into qtquick2
Conflicts:
src/declarative/items/qsgcanvas.cpp
src/declarative/items/qsgcanvasitem.cpp
Diffstat (limited to 'src/declarative/items/qsgcanvas_p.h')
-rw-r--r-- | src/declarative/items/qsgcanvas_p.h | 92 |
1 files changed, 71 insertions, 21 deletions
diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h index 9d37391f57..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; @@ -157,24 +153,11 @@ public: QSGContext *context; uint contextFailed : 1; - uint contextInThread : 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; @@ -183,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 |