qmlscene: Add options to control the GL renderer.
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Fri, 29 May 2015 14:38:34 +0000 (16:38 +0200)
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Thu, 4 Jun 2015 07:03:42 +0000 (07:03 +0000)
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 <aalpert@blackberry.com>
tools/qmlscene/main.cpp

index b8920cd8536035a73059524df2bb2762dd6da37e..ad574546515f3ef116a5dfdf61d20c7c58bac0f2 100644 (file)
@@ -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<Qt::ApplicationAttribute> applicationAttributes;
     QString translationFile;
 };
 
@@ -340,18 +342,22 @@ static void usage()
     puts("Usage: qmlscene [options] <filename>");
     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 <path> ................................. Add <path> to the list of import paths");
-    puts("  -P <path> ................................. Add <path> to the list of plugin paths");
-    puts("  -translation <translationfile> ............ 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 <path> ........................ Add <path> to the list of import paths");
+    puts("  -P <path> ........................ Add <path> to the list of plugin paths");
+    puts("  -translation <translationfile> ... 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