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();
}
}
{
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);
}
, hoverItem(0)
, dirtyItemList(0)
, context(0)
+ , contextFailed(false)
- , contextInThread(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();
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;