]> code.ossystems Code Review - meta-freescale.git/blob
a056c8ed1c01f52f8da652eeacce8e566dc5de01
[meta-freescale.git] /
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.
6
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
10 Mali and Adreno
11
12 Change-Id: I9cc99ecb8b71a35bc369ec9dd11b877016b1179e
13 ---
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(-)
18
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)
25  {
26      Q_D(QOpenGLContext);
27 +
28      if (!isValid())
29          return false;
30  
31 @@ -972,6 +973,39 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
32      QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this);
33  
34      if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
35 +        static bool needsWorkaroundSet = false;
36 +        static bool needsWorkaround = false;
37 +
38 +        if (!needsWorkaroundSet) {
39 +#ifdef Q_OS_ANDROID
40 +            const QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND");
41 +            needsWorkaround = env.isEmpty() || env == "0" || env == "false";
42 +#endif
43 +            QByteArray env = qgetenv("QT_ENABLE_GLYPH_CACHE_WORKAROUND");
44 +            if (env == "1" || env == "true")
45 +                needsWorkaround = true;
46 +
47 +            if (!needsWorkaround) {
48 +                const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
49 +                if (rendererString)
50 +                    needsWorkaround =
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;
61 +            }
62 +            needsWorkaroundSet = true;
63 +        }
64 +
65 +        if (needsWorkaround)
66 +            d->workaround_brokenFBOReadBack = true;
67 +
68          d->surface = surface;
69  
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);
77  }
78  
79 -bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaround()
80 -{
81 -    static bool set = false;
82 -    static bool needsWorkaround = false;
83 -
84 -    if (!set) {
85 -        QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND");
86 -        needsWorkaround = env.isEmpty() || env == "0" || env == "false";
87 -
88 -        if (!needsWorkaround) {
89 -            const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
90 -            needsWorkaround =
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;
99 -        }
100 -
101 -        set = true;
102 -    }
103 -
104 -    return needsWorkaround;
105 -}
106 -
107  bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface)
108  {
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;
113  
114 -    if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround())
115 -        ctx_d->workaround_brokenFBOReadBack = true;
116 -
117      return ret;
118  }
119  
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:
125  private:
126      virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
127  
128 -    static bool needsFBOReadBackWorkaround();
129  };
130  
131  QT_END_NAMESPACE
132 -- 
133 2.12.0
134