From: Gunnar Sletta Date: Mon, 29 Aug 2011 07:29:40 +0000 (+0200) Subject: Respect QPlatformIntegration::ThreadedOpenGL and fix thread affinity of the QSGContext X-Git-Tag: qt-v5.0.0-alpha1~1697^2~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f37b38e4cd4aa9e0443640a1fd73c239cab0d45e;p=profile%2Fivi%2Fqtdeclarative.git Respect QPlatformIntegration::ThreadedOpenGL and fix thread affinity of the QSGContext Change-Id: I3a63e8a3d515bfb41895f7717d534a46e2ab2bde Reviewed-on: http://codereview.qt.nokia.com/3705 Reviewed-by: Samuel Rødal --- diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 052b439..e6cda60 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -452,14 +452,23 @@ void QSGCanvasPrivate::init(QSGCanvas *c) // has a canvas.. rootItem->setFocus(true); - thread = qmlNoThreadedRenderer() - ? static_cast(new QSGCanvasPlainRenderLoop()) - : static_cast(new QSGCanvasRenderThread()); + bool threaded = !qmlNoThreadedRenderer(); + + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL)) { + qWarning("QSGCanvas: platform does not support threaded rendering!"); + threaded = false; + } + + if (threaded) + thread = new QSGCanvasRenderThread(); + else + thread = new QSGCanvasPlainRenderLoop(); + thread->renderer = q; thread->d = this; context = QSGContext::createDefaultContext(); - thread->moveCanvasToThread(context); + thread->moveContextToThread(context); } void QSGCanvasPrivate::sceneMouseEventForTransform(QGraphicsSceneMouseEvent &sceneEvent, diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h index 7daa142..592e66b 100644 --- a/src/declarative/items/qsgcanvas_p.h +++ b/src/declarative/items/qsgcanvas_p.h @@ -200,7 +200,7 @@ public: virtual bool isRunning() const = 0; virtual void animationStarted() = 0; virtual void animationStopped() = 0; - virtual void moveCanvasToThread(QSGContext *) { } + virtual void moveContextToThread(QSGContext *) { } protected: void initializeSceneGraph() { d->initializeSceneGraph(); } @@ -262,7 +262,7 @@ public: bool isRunning() const { return QThread::isRunning(); } void setWindowSize(const QSize &size) { windowSize = size; } void maybeUpdate(); - void moveCanvasToThread(QSGCanvas *c) { c->moveToThread(this); } + void moveContextToThread(QSGContext *c) { c->moveToThread(this); } bool event(QEvent *);