From 97e7d95f1170e9b9322ffff603e419e868ab8360 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@digia.com>
Date: Fri, 26 Sep 2014 14:20:03 +0200
Subject: [PATCH] windeployqt: Deploy software rasterizer for dynamic Open GL
 builds.

Change-Id: I0bb260c7c8992ae24dda6f84eaf304329eb4159c
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
---
 src/windeployqt/main.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp
index eb2e68965..d0d40a8a5 100644
--- a/src/windeployqt/main.cpp
+++ b/src/windeployqt/main.cpp
@@ -1085,14 +1085,11 @@ static DeployResult deploy(const Options &options,
         if (isDebug)
             libEglName += QLatin1Char('d');
         libEglName += QLatin1String(windowsSharedLibrarySuffix);
-        bool deployAngle = options.angleDetection == Options::AngleDetectionForceOn;
-        if (options.angleDetection == Options::AngleDetectionAuto) {
-            // Deploy ANGLE if direct dependency is there or dynamic build (no dependency to any GL library).
-            const QStringList platformPluginLibraries = findDependentLibraries(platformPlugin, options.platform, errorMessage);
-            deployAngle = !platformPluginLibraries.filter(libEglName, Qt::CaseInsensitive).isEmpty()
-                || platformPluginLibraries.filter(QStringLiteral("opengl32"), Qt::CaseInsensitive).isEmpty();
-        }
-        if (deployAngle) {
+        const QStringList platformPluginLibraries = findDependentLibraries(platformPlugin, options.platform, errorMessage);
+        const bool dependsOnAngle = !platformPluginLibraries.filter(libEglName, Qt::CaseInsensitive).isEmpty();
+        const bool dependsOnOpenGl = !platformPluginLibraries.filter(QStringLiteral("opengl32"), Qt::CaseInsensitive).isEmpty();
+        if (options.angleDetection != Options::AngleDetectionForceOff
+            && (dependsOnAngle || !dependsOnOpenGl || options.angleDetection == Options::AngleDetectionForceOn)) {
             const QString libEglFullPath = qtBinDir + slash + libEglName;
             deployedQtLibraries.push_back(libEglFullPath);
             const QStringList libGLESv2 = findDependentLibraries(libEglFullPath, options.platform, errorMessage).filter(QStringLiteral("libGLESv2"), Qt::CaseInsensitive);
@@ -1111,6 +1108,11 @@ static DeployResult deploy(const Options &options,
                 }
             }
         } // deployAngle
+        if (!dependsOnOpenGl) {
+            const QFileInfo softwareRasterizer(qtBinDir + slash + QStringLiteral("opengl32sw") + QLatin1String(windowsSharedLibrarySuffix));
+            if (softwareRasterizer.isFile())
+                deployedQtLibraries.append(softwareRasterizer.absoluteFilePath());
+        }
     } // Windows
 
     // Update libraries
-- 
GitLab