[gtk/texture-upload-bgra: 9/9] gl: Use GL_EXT_texture_format_BGRA8888
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/texture-upload-bgra: 9/9] gl: Use GL_EXT_texture_format_BGRA8888
- Date: Sat, 26 Sep 2020 14:04:08 +0000 (UTC)
commit 8bae90831a15623e3283275eb87d68898aa9b699
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 25 22:29:45 2020 -0400
gl: Use GL_EXT_texture_format_BGRA8888
In the gles case, use GL_EXT_texture_format_BGRA8888
when it is available. Strictly speaking, this might
violate the spec, since we use an internal / external
format combination of GL_RGBA + GL_BGRA_EXT, but it
works on my system.
Fixes: #3192
gdk/gdkglcontext.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 71a854816b..e4c3edaa0f 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -111,6 +111,7 @@ typedef struct {
guint has_khr_debug : 1;
guint use_khr_debug : 1;
guint has_unpack_subimage : 1;
+ guint has_texture_format_bgra : 1;
guint has_debug_output : 1;
guint extensions_checked : 1;
guint debug_enabled : 1;
@@ -241,8 +242,23 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
if (priv->use_es)
{
- /* GLES only supports rgba, so convert if necessary */
- if (data_format != GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
+ /* GLES only supports rgba (and sometime bgra),
+ * so convert if necessary
+ */
+ if (data_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
+ {
+ bpp = 4;
+ gl_format = GL_RGBA;
+ gl_type = GL_UNSIGNED_BYTE;
+ }
+ else if (data_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
+ priv->has_texture_format_bgra)
+ {
+ bpp = 4;
+ gl_format = GL_BGRA_EXT;
+ gl_type = GL_UNSIGNED_BYTE;
+ }
+ else
{
copy = g_malloc (width * height * 4);
gdk_memory_convert (copy, width * 4,
@@ -251,11 +267,11 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
width, height);
stride = width * 4;
data = copy;
- }
- bpp = 4;
- gl_format = GL_RGBA;
- gl_type = GL_UNSIGNED_BYTE;
+ bpp = 4;
+ gl_format = GL_RGBA;
+ gl_type = GL_UNSIGNED_BYTE;
+ }
}
else
{
@@ -1024,6 +1040,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
has_texture_rectangle = FALSE;
priv->has_unpack_subimage = epoxy_has_gl_extension ("GL_EXT_unpack_subimage");
+ priv->has_texture_format_bgra = epoxy_has_gl_extension ("GL_EXT_texture_format_BGRA8888");
priv->has_khr_debug = epoxy_has_gl_extension ("GL_KHR_debug");
}
else
@@ -1066,6 +1083,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
" - GL_ARB_texture_rectangle: %s\n"
" - GL_KHR_debug: %s\n"
" - GL_EXT_unpack_subimage: %s\n"
+ " - GL_EXT_texture_format_BGRA8888: %s\n"
"* Using texture rectangle: %s",
priv->use_es ? "OpenGL ES" : "OpenGL",
priv->gl_version / 10, priv->gl_version % 10,
@@ -1075,6 +1093,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
has_texture_rectangle ? "yes" : "no",
priv->has_khr_debug ? "yes" : "no",
priv->has_unpack_subimage ? "yes" : "no",
+ priv->has_texture_format_bgra ? "yes" : "no",
priv->use_texture_rectangle ? "yes" : "no"));
priv->extensions_checked = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]