From cbf649ff92e7d3416cb9d03609648f96efdf76dd Mon Sep 17 00:00:00 2001
From: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
Date: Mon, 17 Mar 2014 19:43:41 -0300
Subject: [PATCH] Add workaround for GL on Android emulator

On the Android Emulator, the shaders will be compiled by a desktop
GL driver, since the GL driver in the emulator is just a thin
wrapper. The GL driver does not necessarily support the precision
qualifiers, which can cause applications to break. We detect this
at runtime in the platform plugin and set a workaround flag to

Upstream (9eeb1bd) just enabled the workaround when the android
backend is used, which is not true in our case (traditional desktop).
As a consequence, we also need a similar check in order to have
a functional Ubuntu Touch emulator.

Signed-off-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
---
 src/gui/kernel/qopenglcontext.cpp | 5 +++++
 1 file changed, 5 insertions(+)

--- qtbase/src/gui/kernel/qopenglcontext.cpp
+++ qtbase/src/gui/kernel/qopenglcontext.cpp
@@ -815,6 +815,11 @@
 
         d->shareGroup->d_func()->deletePendingResources(this);
 
+        const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
+        if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) {
+            QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(this);
+            ctx_d->workaround_missingPrecisionQualifiers = true;
+        }
 #ifndef QT_NO_DEBUG
         QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
 #endif
