aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/rendercontrol/main.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 /examples/quick/rendercontrol/main.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 'examples/quick/rendercontrol/main.cpp')
-rw-r--r--examples/quick/rendercontrol/main.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/examples/quick/rendercontrol/main.cpp b/examples/quick/rendercontrol/main.cpp
index d362278ddf..e61eb110aa 100644
--- a/examples/quick/rendercontrol/main.cpp
+++ b/examples/quick/rendercontrol/main.cpp
@@ -39,13 +39,24 @@
****************************************************************************/
#include <QGuiApplication>
-#include "window.h"
+#include "window_singlethreaded.h"
+#include "window_multithreaded.h"
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
- Window window;
- window.resize(1024, 768);
- window.show();
+
+ QScopedPointer<QWindow> window;
+ if (QCoreApplication::arguments().contains(QLatin1String("--threaded"))) {
+ qWarning("Using separate Qt Quick render thread");
+ window.reset(new WindowMultiThreaded);
+ } else {
+ qWarning("Using single-threaded rendering");
+ window.reset(new WindowSingleThreaded);
+ }
+
+ window->resize(1024, 768);
+ window->show();
+
return app.exec();
}