From 869a199da9ba173e2dea948ec132d089b2513128 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 26 Mar 2014 12:30:34 +0100 Subject: 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 Reviewed-by: Gunnar Sletta --- tools/qmlscene/main.cpp | 15 +++++++++++++++ tools/qmlscene/qmlscene.pro | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) 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 #include +#include #ifdef QT_WIDGETS_LIB #include @@ -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 ................................. Add to the list of import paths"); qWarning(" -B .......................... Add a named bundle"); qWarning(" -translation ............ 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 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 -- cgit v1.2.3