~chris.gagnon/+junk/qtbase-521

« back to all changes in this revision

Viewing changes to debian/patches/Add-workaround-for-GL-on-Android-emulator.patch

  • Committer: Jonathan Riddell
  • Date: 2013-12-10 15:28:07 UTC
  • Revision ID: jriddell@ubuntu.com-20131210152807-0cq03j2sta5l926m
sync with archive

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 6fd6369328f66b426680d115be961fba0bcd2b8e Mon Sep 17 00:00:00 2001
 
2
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
 
3
Date: Mon, 29 Jul 2013 13:49:42 +0200
 
4
Subject: [PATCH] Add workaround for GL on Android emulator
 
5
 
 
6
On the Android Emulator, the shaders will be compiled by a desktop
 
7
GL driver, since the GL driver in the emulator is just a thin
 
8
wrapper. The GL driver does not necessarily support the precision
 
9
qualifiers, which can cause applications to break. We detect this
 
10
at runtime in the platform plugin and set a workaround flag to
 
11
 
 
12
Backport from upstream patch 9eeb1bd (5.1.1+, Android specific).
 
13
 
 
14
Task-number: QTBUG-32557
 
15
Change-Id: Ied00cfe8e804d1f7862697dd379a14f3bed3d980
 
16
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
 
17
Signed-off-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
 
18
---
 
19
 src/gui/kernel/qopenglcontext.cpp       | 5 +++++
 
20
 src/gui/kernel/qopenglcontext_p.h       | 7 +++++++
 
21
 src/gui/opengl/qopenglshaderprogram.cpp | 3 ++-
 
22
 3 files changed, 14 insertions(+), 1 deletion(-)
 
23
 
 
24
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
 
25
index 645c13a..a440730 100644
 
26
--- a/src/gui/kernel/qopenglcontext.cpp
 
27
+++ b/src/gui/kernel/qopenglcontext.cpp
 
28
@@ -523,6 +523,11 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
 
29
 
 
30
         d->shareGroup->d_func()->deletePendingResources(this);
 
31
 
 
32
+        const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
 
33
+        if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) {
 
34
+            QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(this);
 
35
+            ctx_d->workaround_missingPrecisionQualifiers = true;
 
36
+        }
 
37
 #ifndef QT_NO_DEBUG
 
38
         QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
 
39
 #endif
 
40
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
 
41
index fb81412..5e51a38 100644
 
42
--- a/src/gui/kernel/qopenglcontext_p.h
 
43
+++ b/src/gui/kernel/qopenglcontext_p.h
 
44
@@ -205,6 +205,7 @@ public:
 
45
         , max_texture_size(-1)
 
46
         , workaround_brokenFBOReadBack(false)
 
47
         , workaround_brokenTexSubImage(false)
 
48
+        , workaround_missingPrecisionQualifiers(false)
 
49
         , active_engine(0)
 
50
     {
 
51
     }
 
52
@@ -232,6 +233,7 @@ public:
 
53
 
 
54
     bool workaround_brokenFBOReadBack;
 
55
     bool workaround_brokenTexSubImage;
 
56
+    bool workaround_missingPrecisionQualifiers;
 
57
 
 
58
     QPaintEngineEx *active_engine;
 
59
 
 
60
@@ -239,6 +241,11 @@ public:
 
61
 
 
62
     int maxTextureSize();
 
63
 
 
64
+    static QOpenGLContextPrivate *get(QOpenGLContext *context)
 
65
+    {
 
66
+        return context->d_func();
 
67
+    }
 
68
+
 
69
 #if !defined(QT_NO_DEBUG)
 
70
     static bool toggleMakeCurrentTracker(QOpenGLContext *context, bool value)
 
71
     {
 
72
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
 
73
index 88c9c80..0c36973 100644
 
74
--- a/src/gui/opengl/qopenglshaderprogram.cpp
 
75
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
 
76
@@ -385,7 +385,8 @@ bool QOpenGLShader::compileSourceCode(const char *source)
 
77
         srclen.append(GLint(sizeof(qualifierDefines) - 1));
 
78
 #endif
 
79
 #ifdef QOpenGL_REDEFINE_HIGHP
 
80
-        if (d->shaderType == Fragment) {
 
81
+        QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(QOpenGLContext::currentContext());
 
82
+        if (d->shaderType == Fragment && !ctx_d->workaround_missingPrecisionQualifiers) {
 
83
             src.append(redefineHighp);
 
84
             srclen.append(GLint(sizeof(redefineHighp) - 1));
 
85
         }
 
86
-- 
 
87
1.8.4.3
 
88