From 7c22994176d37b3f5c9505635b63ae502aafdfec Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 May 2015 16:38:34 +0200 Subject: [PATCH] qmlscene: Add options to control the GL renderer. Replace boolean option controlling context sharing by a vector of QCoreApplication attributes (bearing in mind that for example High DPI changes might add more attributes) and add the GL switching attributes. Task-number: QTBUG-46030 Change-Id: I934dd8910b7b50ec96ae9e00823649c9df6a00ef Reviewed-by: Alan Alpert --- tools/qmlscene/main.cpp | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index b8920cd85..ad5745465 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -148,8 +148,10 @@ struct Options , quitImmediately(false) , resizeViewToRootItem(false) , multisample(false) - , contextSharing(true) { + // QtWebEngine needs a shared context in order for the GPU thread to + // upload textures. + applicationAttributes.append(Qt::AA_ShareOpenGLContexts); } QUrl file; @@ -164,7 +166,7 @@ struct Options bool quitImmediately; bool resizeViewToRootItem; bool multisample; - bool contextSharing; + QVector applicationAttributes; QString translationFile; }; @@ -340,18 +342,22 @@ static void usage() puts("Usage: qmlscene [options] "); puts(" "); puts(" Options:"); - puts(" --maximized ............................... Run maximized"); - puts(" --fullscreen .............................. Run fullscreen"); - puts(" --transparent ............................. Make the window transparent"); - puts(" --multisample ............................. Enable multisampling (OpenGL anti-aliasing)"); - puts(" --no-version-detection .................... Do not try to detect the version of the .qml file"); - puts(" --slow-animations ......................... Run all animations in slow motion"); - puts(" --resize-to-root .......................... Resize the window to the size of the root item"); - puts(" --quit .................................... Quit immediately after starting"); - puts(" --disable-context-sharing ................. Disable the use of a shared GL context for QtQuick Windows"); - puts(" -I ................................. Add to the list of import paths"); - puts(" -P ................................. Add to the list of plugin paths"); - puts(" -translation ............ Set the language to run in"); + puts(" --maximized ...................... Run maximized"); + puts(" --fullscreen ..................... Run fullscreen"); + puts(" --transparent .................... Make the window transparent"); + puts(" --multisample .................... Enable multisampling (OpenGL anti-aliasing)"); + puts(" --no-version-detection ........... Do not try to detect the version of the .qml file"); + puts(" --slow-animations ................ Run all animations in slow motion"); + puts(" --resize-to-root ................. Resize the window to the size of the root item"); + puts(" --quit ........................... Quit immediately after starting"); + puts(" --disable-context-sharing ........ Disable the use of a shared GL context for QtQuick Windows\n" + " .........(remove AA_ShareOpenGLContexts)"); + puts(" --desktop..........................Force use of desktop GL (AA_UseDesktopOpenGL)"); + puts(" --gles.............................Force use of GLES (AA_UseOpenGLES)"); + puts(" --software.........................Force use of software rendering (AA_UseOpenGLES)"); + puts(" -I ........................ Add to the list of import paths"); + puts(" -P ........................ Add to the list of plugin paths"); + puts(" -translation ... Set the language to run in"); puts(" "); exit(1); @@ -389,7 +395,13 @@ int main(int argc, char ** argv) else if (lowerArgument == QLatin1String("--multisample")) options.multisample = true; else if (lowerArgument == QLatin1String("--disable-context-sharing")) - options.contextSharing = false; + options.applicationAttributes.removeAll(Qt::AA_ShareOpenGLContexts); + else if (lowerArgument == QLatin1String("--gles")) + options.applicationAttributes.append(Qt::AA_UseOpenGLES); + else if (lowerArgument == QLatin1String("--software")) + options.applicationAttributes.append(Qt::AA_UseSoftwareOpenGL); + else if (lowerArgument == QLatin1String("--desktop")) + options.applicationAttributes.append(Qt::AA_UseDesktopOpenGL); else if (lowerArgument == QLatin1String("-i") && i + 1 < argc) imports.append(QString::fromLatin1(argv[++i])); else if (lowerArgument == QLatin1String("-p") && i + 1 < argc) @@ -402,9 +414,8 @@ int main(int argc, char ** argv) } } - // QtWebEngine needs a shared context in order for the GPU thread to - // upload textures. - QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, options.contextSharing); + foreach (Qt::ApplicationAttribute a, options.applicationAttributes) + QCoreApplication::setAttribute(a); #ifdef QT_WIDGETS_LIB QApplication app(argc, argv); #else -- 2.34.1