Merge branch 'master' into qtquick2
authorAaron Kennedy <aaron.kennedy@nokia.com>
Thu, 9 Jun 2011 05:31:31 +0000 (15:31 +1000)
committerAaron Kennedy <aaron.kennedy@nokia.com>
Thu, 9 Jun 2011 05:31:31 +0000 (15:31 +1000)
Conflicts:
src/declarative/items/qsgcanvas.cpp
src/declarative/items/qsgcanvasitem.cpp

1  2 
src/declarative/items/qsgcanvas.cpp
src/declarative/items/qsgcanvas_p.h
src/declarative/items/qsgcanvasitem.cpp

@@@ -222,31 -248,25 +248,27 @@@ void QSGCanvas::showEvent(QShowEvent *e
  
      QGLWidget::showEvent(e);
  
 -    if (d->threadedRendering) {
 -        if (!d->animationDriver) {
 -            d->animationDriver = d->context->createAnimationDriver(this);
 -            connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection);
 -            connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection);
 -        }
 -        d->animationDriver->install();
 -        d->thread->startRenderThread();
 -        setUpdatesEnabled(true);
 -    } else {
 -        makeCurrent();
 +    if (!d->contextFailed) {
 +        if (d->threadedRendering) {
-             d->contextInThread = true;
-             doneCurrent();
 +            if (!d->animationDriver) {
 +                d->animationDriver = d->context->createAnimationDriver(this);
-                 connect(d->animationDriver, SIGNAL(started()), this, SLOT(_q_animationStarted()), Qt::DirectConnection);
-                 connect(d->animationDriver, SIGNAL(stopped()), this, SLOT(_q_animationStopped()), Qt::DirectConnection);
++                connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection);
++                connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection);
 +            }
 +            d->animationDriver->install();
-             d->mutex.lock();
-             d->thread->start();
-             d->wait.wait(&d->mutex);
-             d->mutex.unlock();
++            d->thread->startRenderThread();
++            setUpdatesEnabled(true);
 +        } else {
 +            makeCurrent();
 +
 +            if (!d->context || !d->context->isReady()) {
 +                d->initializeSceneGraph();
 +                d->animationDriver = d->context->createAnimationDriver(this);
 +                connect(d->animationDriver, SIGNAL(started()), this, SLOT(update()));
 +            }
  
 -        if (!d->context || !d->context->isReady()) {
 -            d->initializeSceneGraph();
 -            d->animationDriver = d->context->createAnimationDriver(this);
 -            connect(d->animationDriver, SIGNAL(started()), this, SLOT(update()));
 +            d->animationDriver->install();
          }
 -
 -        d->animationDriver->install();
      }
  }
  
@@@ -254,12 -274,11 +276,13 @@@ void QSGCanvas::hideEvent(QHideEvent *e
  {
      Q_D(QSGCanvas);
  
 -    if (d->threadedRendering) {
 -        d->thread->stopRenderThread();
 -    }
 +    if (!d->contextFailed) {
-         if (d->threadedRendering)
-             d->stopRenderingThread();
++        if (d->threadedRendering) {
++            d->thread->stopRenderThread();
++        }
  
 -    d->animationDriver->uninstall();
 +        d->animationDriver->uninstall();
 +    }
  
      QGLWidget::hideEvent(e);
  }
@@@ -464,16 -374,10 +378,11 @@@ QSGCanvasPrivate::QSGCanvasPrivate(
      , hoverItem(0)
      , dirtyItemList(0)
      , context(0)
-     , contextInThread(false)
 +    , contextFailed(false)
      , threadedRendering(false)
-     , exitThread(false)
      , animationRunning(false)
-     , idle(false)
-     , needsRepaint(true)
      , renderThreadAwakened(false)
-     , inSync(false)
-     , thread(new MyThread(this))
+     , thread(0)
      , animationDriver(0)
  {
      threadedRendering = !qmlNoThreadedRenderer();
@@@ -156,25 -152,12 +152,12 @@@ public
  
      QSGContext *context;
  
 -    uint contextInThread : 1;
 +    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;
  
@@@ -117,7 -111,7 +117,6 @@@ QScriptValue QSGCanvasItem::getContext(
  
  void QSGCanvasItem::requestPaint()
  {
-     //Q_D(QSGCanvasItem);
 -    // Q_D(QSGCanvasItem);
      //TODO:update(d->context->dirtyRect());
      update();
  }