diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-08-29 09:29:40 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-08-29 09:31:57 +0200 |
commit | f37b38e4cd4aa9e0443640a1fd73c239cab0d45e (patch) | |
tree | 52dfb139c737d5973cc0c52f7a07dc5de2cd78c2 /src | |
parent | 93553bc31df1ed70cf587e43b8fa31e442fb8249 (diff) |
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 <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qsgcanvas.cpp | 17 | ||||
-rw-r--r-- | src/declarative/items/qsgcanvas_p.h | 4 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 052b439066..e6cda60c2b 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<QSGCanvasRenderLoop *>(new QSGCanvasPlainRenderLoop()) - : static_cast<QSGCanvasRenderLoop *>(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 7daa1423d3..592e66b454 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 *); |