aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickrendercontrol.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2014-11-25 11:38:46 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2014-12-12 12:19:14 +0100
commit6179550a0ca761bfabd4f6c67103f5397a306df0 (patch)
treeeaf4a12431769a77ff3fed7945d1d0bf37144fcd /src/quick/items/qquickrendercontrol.cpp
parent2a6f6eee104ef66e4e236fa82fe71bb77f151ee8 (diff)
Support threading with QQuickRenderControl
Reorganize the rendercontrol example to demonstrate both the single and multi threaded approaches. A small helper function is introduced to the QQuickRenderControl API: The QSGRenderContext has to live on the render thread. Previously there was no way for applications to move it to the desired thread. This is now possible. Pass --threaded to the rendercontrol example to use a separate render thread. [ChangeLog][QtQuick] QQuickRenderControl can now be used to render the Qt Quick scene on a dedicated render thread, similarly to how the built-in threaded render loop operates. Task-number: QTBUG-42813 Change-Id: I01c3b2ffca8a174d9d2c267a51f2e484ed7b34b3 Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickrendercontrol.cpp')
-rw-r--r--src/quick/items/qquickrendercontrol.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index a666bb59c9..656678a035 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -36,7 +36,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QTime>
-#include <QtCore/private/qabstractanimation_p.h>
+#include <QtQuick/private/qquickanimatorcontroller_p.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/private/qguiapplication_p.h>
@@ -170,6 +170,20 @@ void QQuickRenderControlPrivate::windowDestroyed()
}
/*!
+ Prepares rendering the Qt Quick scene outside the gui thread.
+
+ \a targetThread specifies the thread on which synchronization and
+ rendering will happen. There is no need to call this function in a
+ single threaded scenario.
+ */
+void QQuickRenderControl::prepareThread(QThread *targetThread)
+{
+ Q_D(QQuickRenderControl);
+ d->rc->moveToThread(targetThread);
+ QQuickWindowPrivate::get(d->window)->animationController->moveToThread(targetThread);
+}
+
+/*!
Initializes the scene graph resources. The context \a gl has to
be the current context.