aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlscene
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-26 12:30:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-29 15:14:07 +0100
commit869a199da9ba173e2dea948ec132d089b2513128 (patch)
tree78b4084cbf0d1fd31041ffc869126ecbcf9fec55 /tools/qmlscene
parentc19962a142c529998ff7c6261fa098f33c646c3d (diff)
Enable GL context sharing for QtQuick windows by default
This is required for running QWebEngine inside qmlscene. It can be disabled with --disable-context-sharing and it remains off in QtQuick. Instead apps have to use QWebEngine API to enable this, where this patch here is merely convenience. Change-Id: I123893a7c8c644c49c66fe2b42d2b7b2e03622d9 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tools/qmlscene')
-rw-r--r--tools/qmlscene/main.cpp15
-rw-r--r--tools/qmlscene/qmlscene.pro2
2 files changed, 16 insertions, 1 deletions
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 531c894ada..f128e399b5 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -58,6 +58,7 @@
#include <QtQuick/qquickview.h>
#include <private/qabstractanimation_p.h>
+#include <private/qsgcontext_p.h>
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/QApplication>
@@ -155,6 +156,7 @@ struct Options
, quitImmediately(false)
, resizeViewToRootItem(false)
, multisample(false)
+ , contextSharing(true)
{
}
@@ -171,6 +173,7 @@ struct Options
bool quitImmediately;
bool resizeViewToRootItem;
bool multisample;
+ bool contextSharing;
QString translationFile;
};
@@ -354,6 +357,7 @@ static void usage()
qWarning(" --slow-animations ......................... Run all animations in slow motion");
qWarning(" --resize-to-root .......................... Resize the window to the size of the root item");
qWarning(" --quit .................................... Quit immediately after starting");
+ qWarning(" --disable-context-sharing ................. Disable the use of a shared GL context for QtQuick Windows");
qWarning(" -I <path> ................................. Add <path> to the list of import paths");
qWarning(" -B <name> <file> .......................... Add a named bundle");
qWarning(" -translation <translationfile> ............ Set the language to run in");
@@ -393,6 +397,8 @@ int main(int argc, char ** argv)
options.resizeViewToRootItem = true;
else if (lowerArgument == QLatin1String("--multisample"))
options.multisample = true;
+ else if (lowerArgument == QLatin1String("--disable-context-sharing"))
+ options.contextSharing = false;
else if (lowerArgument == QLatin1String("-i") && i + 1 < argc)
imports.append(QString::fromLatin1(argv[++i]));
else if (lowerArgument == QLatin1String("-b") && i + 2 < argc) {
@@ -448,6 +454,15 @@ int main(int argc, char ** argv)
displayFileDialog(&options);
#endif
+ // QWebEngine needs a shared context in order for the GPU thread to
+ // upload textures.
+ QScopedPointer<QOpenGLContext> shareContext;
+ if (options.contextSharing) {
+ shareContext.reset(new QOpenGLContext);
+ shareContext->create();
+ QSGContext::setSharedOpenGLContext(shareContext.data());
+ }
+
int exitCode = 0;
if (!options.file.isEmpty()) {
diff --git a/tools/qmlscene/qmlscene.pro b/tools/qmlscene/qmlscene.pro
index 07208ea703..0411fd8e31 100644
--- a/tools/qmlscene/qmlscene.pro
+++ b/tools/qmlscene/qmlscene.pro
@@ -1,4 +1,4 @@
-QT += qml quick core-private
+QT += qml quick quick-private gui-private core-private
qtHaveModule(widgets): QT += widgets
CONFIG += no_import_scan