diff options
Diffstat (limited to 'recipes-qt/qt5/qtdeclarative-5.0.2/0005-Avoid-swizzling-on-OpenGL-ES-when-possible.patch')
-rw-r--r-- | recipes-qt/qt5/qtdeclarative-5.0.2/0005-Avoid-swizzling-on-OpenGL-ES-when-possible.patch | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/recipes-qt/qt5/qtdeclarative-5.0.2/0005-Avoid-swizzling-on-OpenGL-ES-when-possible.patch b/recipes-qt/qt5/qtdeclarative-5.0.2/0005-Avoid-swizzling-on-OpenGL-ES-when-possible.patch new file mode 100644 index 00000000..92be7ef8 --- /dev/null +++ b/recipes-qt/qt5/qtdeclarative-5.0.2/0005-Avoid-swizzling-on-OpenGL-ES-when-possible.patch | |||
@@ -0,0 +1,88 @@ | |||
1 | From 9d85c3c5823c6f73db245d4de786d911fd96edfd Mon Sep 17 00:00:00 2001 | ||
2 | From: Florian Haenel <florian.haenel@lge.com> | ||
3 | Date: Sat, 8 Jun 2013 00:34:35 +0200 | ||
4 | Subject: [PATCH 5/5] Avoid swizzling on OpenGL ES when possible | ||
5 | |||
6 | Add support for APPLE_texture_format_BGRA8888, | ||
7 | IMG_texture_format_BGRA8888, | ||
8 | EXT_texture_format_BGRA8888 and EXT_bgra. The apple one acts | ||
9 | just like the desktop EXT_bgra one, so they need slightly | ||
10 | different handling than the ES extensions. | ||
11 | |||
12 | This change also has the benefit that we no longer have a dedicated | ||
13 | ES path. | ||
14 | |||
15 | Upstream-Status: Backport https://codereview.qt-project.org/46549 | ||
16 | Signed-off-by: Florian Haenel <florian.haenel@lge.com> | ||
17 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
18 | |||
19 | Change-Id: I5ecb0a02c3a7bd984d6752fa87163726118b93de | ||
20 | --- | ||
21 | src/quick/scenegraph/util/qsgtexture.cpp | 28 ++++++++++++++++++++++------ | ||
22 | 1 file changed, 22 insertions(+), 6 deletions(-) | ||
23 | |||
24 | diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp | ||
25 | index 16cc461..3d574f3 100644 | ||
26 | --- a/src/quick/scenegraph/util/qsgtexture.cpp | ||
27 | +++ b/src/quick/scenegraph/util/qsgtexture.cpp | ||
28 | @@ -65,6 +65,10 @@ | ||
29 | #include <QHash> | ||
30 | #endif | ||
31 | |||
32 | +#ifndef GL_BGRA | ||
33 | +#define GL_BGRA 0x80E1 | ||
34 | +#endif | ||
35 | + | ||
36 | QT_BEGIN_NAMESPACE | ||
37 | |||
38 | inline static bool isPowerOfTwo(int x) | ||
39 | @@ -523,7 +527,6 @@ QSGPlainTexture::~QSGPlainTexture() | ||
40 | glDeleteTextures(1, &m_texture_id); | ||
41 | } | ||
42 | |||
43 | -#ifdef QT_OPENGL_ES | ||
44 | void qsg_swizzleBGRAToRGBA(QImage *image) | ||
45 | { | ||
46 | const int width = image->width(); | ||
47 | @@ -534,7 +537,6 @@ void qsg_swizzleBGRAToRGBA(QImage *image) | ||
48 | p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); | ||
49 | } | ||
50 | } | ||
51 | -#endif | ||
52 | |||
53 | void QSGPlainTexture::setImage(const QImage &image) | ||
54 | { | ||
55 | @@ -621,12 +623,26 @@ void QSGPlainTexture::bind() | ||
56 | |||
57 | updateBindOptions(m_dirty_bind_options); | ||
58 | |||
59 | + GLenum externalFormat = GL_RGBA; | ||
60 | + GLenum internalFormat = GL_RGBA; | ||
61 | + | ||
62 | + const char *extensions = (const char *) glGetString(GL_EXTENSIONS); | ||
63 | + if (strstr(extensions, "GL_EXT_bgra")) { | ||
64 | + externalFormat = GL_BGRA; | ||
65 | #ifdef QT_OPENGL_ES | ||
66 | - qsg_swizzleBGRAToRGBA(&tmp); | ||
67 | - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmp.constBits()); | ||
68 | -#else | ||
69 | - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, tmp.constBits()); | ||
70 | + internalFormat = GL_BGRA; | ||
71 | #endif | ||
72 | + } else if (strstr(extensions, "GL_APPLE_texture_format_BGRA8888")) { | ||
73 | + externalFormat = GL_BGRA; | ||
74 | + } else if (strstr(extensions, "GL_EXT_texture_format_BGRA8888") | ||
75 | + || strstr(extensions, "GL_IMG_texture_format_BGRA8888")) { | ||
76 | + externalFormat = GL_BGRA; | ||
77 | + internalFormat = GL_BGRA; | ||
78 | + } else { | ||
79 | + qsg_swizzleBGRAToRGBA(&tmp); | ||
80 | + } | ||
81 | + | ||
82 | + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits()); | ||
83 | |||
84 | if (m_has_mipmaps) { | ||
85 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | ||
86 | -- | ||
87 | 1.8.2.1 | ||
88 | |||