1 From 068c13d7f561f3bd88facb14093cdc88fe1b50f2 Mon Sep 17 00:00:00 2001
2 From: Marco Martin <mart@kde.org>
3 Date: Fri, 10 Feb 2017 15:00:23 +0100
4 Subject: [PATCH] Environment variable enabling the workaround FBO readback bug
5 Organization: O.S. Systems Software LTDA.
7 On some ARM devices the font glyph generation is broken
8 Add an environment variable to enable workaround_brokenFBOReadBack
9 in QOpenGLContext, to fix font rendering on such devices as
12 Change-Id: I9cc99ecb8b71a35bc369ec9dd11b877016b1179e
14 src/gui/kernel/qopenglcontext.cpp | 34 ++++++++++++++++++++++
15 .../android/qandroidplatformopenglcontext.cpp | 31 --------------------
16 .../android/qandroidplatformopenglcontext.h | 1 -
17 3 files changed, 34 insertions(+), 32 deletions(-)
19 diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
20 index 0f7bbfd2e1..2b0b1f7ff1 100644
21 --- a/src/gui/kernel/qopenglcontext.cpp
22 +++ b/src/gui/kernel/qopenglcontext.cpp
23 @@ -951,6 +951,7 @@ GLuint QOpenGLContext::defaultFramebufferObject() const
24 bool QOpenGLContext::makeCurrent(QSurface *surface)
31 @@ -972,6 +973,39 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
32 QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this);
34 if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
35 + static bool needsWorkaroundSet = false;
36 + static bool needsWorkaround = false;
38 + if (!needsWorkaroundSet) {
40 + const QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND");
41 + needsWorkaround = env.isEmpty() || env == "0" || env == "false";
43 + QByteArray env = qgetenv("QT_ENABLE_GLYPH_CACHE_WORKAROUND");
44 + if (env == "1" || env == "true")
45 + needsWorkaround = true;
47 + if (!needsWorkaround) {
48 + const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
51 + qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450
52 + || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205
53 + || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)'
54 + || qstrncmp(rendererString, "Adreno (TM) 30x", 14) == 0 // Adreno 302, 305
55 + || qstrncmp(rendererString, "Adreno 30x", 9) == 0 // Same as above but without the '(TM)'
56 + || qstrncmp(rendererString, "Adreno (TM) 4xx", 13) == 0 // Adreno 405, 418, 420, 430
57 + || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)'
58 + || qstrcmp(rendererString, "GC800 core") == 0
59 + || qstrcmp(rendererString, "GC1000 core") == 0
60 + || qstrcmp(rendererString, "Immersion.16") == 0;
62 + needsWorkaroundSet = true;
65 + if (needsWorkaround)
66 + d->workaround_brokenFBOReadBack = true;
70 d->shareGroup->d_func()->deletePendingResources(this);
71 diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
72 index 80693acf88..3edfd34f9a 100644
73 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
74 +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
75 @@ -64,34 +64,6 @@ void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface)
76 QEGLPlatformContext::swapBuffers(surface);
79 -bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaround()
81 - static bool set = false;
82 - static bool needsWorkaround = false;
85 - QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND");
86 - needsWorkaround = env.isEmpty() || env == "0" || env == "false";
88 - if (!needsWorkaround) {
89 - const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
91 - qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450
92 - || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205
93 - || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)'
94 - || qstrncmp(rendererString, "Adreno (TM) 30x", 14) == 0 // Adreno 302, 305
95 - || qstrncmp(rendererString, "Adreno 30x", 9) == 0 // Same as above but without the '(TM)'
96 - || qstrcmp(rendererString, "GC800 core") == 0
97 - || qstrcmp(rendererString, "GC1000 core") == 0
98 - || qstrcmp(rendererString, "Immersion.16") == 0;
104 - return needsWorkaround;
107 bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface)
109 bool ret = QEGLPlatformContext::makeCurrent(surface);
110 @@ -101,9 +73,6 @@ bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface)
111 if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0)
112 ctx_d->workaround_missingPrecisionQualifiers = true;
114 - if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround())
115 - ctx_d->workaround_brokenFBOReadBack = true;
120 diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.h b/src/plugins/platforms/android/qandroidplatformopenglcontext.h
121 index c88dbf327b..e0eaae6b16 100644
122 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.h
123 +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.h
124 @@ -55,7 +55,6 @@ public:
126 virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
128 - static bool needsFBOReadBackWorkaround();