From b0e26873f66a8f5248386565cffa409e854a12b1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 19 Oct 2023 21:41:44 -0400 Subject: [PATCH] gsk: Use has_bgra in more places The glyph and icon libaries were also checking for GLES to decide if data needs to be transformed from BGRA to RGBA. Use the new has_bgra getter instead. This will probably break on bigendian, because the GL_BGRA + GL_UNSIGNED_BYTE combination is not equivalent to the cairo format on bigendian, but this was already broken for the gl format information that we get from gdk_memory_format_gl_format. --- gsk/gl/gskglglyphlibrary.c | 9 ++++----- gsk/gl/gskgliconlibrary.c | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gsk/gl/gskglglyphlibrary.c b/gsk/gl/gskglglyphlibrary.c index 9b8c78fc30..3c04b46973 100644 --- a/gsk/gl/gskglglyphlibrary.c +++ b/gsk/gl/gskglglyphlibrary.c @@ -119,7 +119,7 @@ gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self, memset (pixel_data, 255, sizeof pixel_data); - if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ())) + if (!gdk_gl_context_has_bgra (gdk_gl_context_get_current ())) { gl_format = GL_RGBA; gl_type = GL_UNSIGNED_BYTE; @@ -127,9 +127,8 @@ gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self, else { gl_format = GL_BGRA; - gl_type = GL_UNSIGNED_INT_8_8_8_8_REV; + gl_type = GL_UNSIGNED_BYTE; } - glBindTexture (GL_TEXTURE_2D, atlas->texture_id); glTexSubImage2D (GL_TEXTURE_2D, 0, @@ -277,7 +276,7 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self, g_assert (texture_id > 0); - if G_UNLIKELY (gdk_gl_context_get_use_es (gdk_gl_context_get_current ())) + if (G_UNLIKELY (!gdk_gl_context_has_bgra (gdk_gl_context_get_current ()))) { pixel_data = free_data = g_malloc (width * height * 4); gdk_memory_convert (pixel_data, width * 4, @@ -294,7 +293,7 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self, { pixel_data = cairo_image_surface_get_data (surface); gl_format = GL_BGRA; - gl_type = GL_UNSIGNED_INT_8_8_8_8_REV; + gl_type = GL_UNSIGNED_BYTE; } glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4); diff --git a/gsk/gl/gskgliconlibrary.c b/gsk/gl/gskgliconlibrary.c index 58e5a22be9..156469dde0 100644 --- a/gsk/gl/gskgliconlibrary.c +++ b/gsk/gl/gskgliconlibrary.c @@ -111,7 +111,7 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self, gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (), "Uploading texture"); - if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ())) + if (!gdk_gl_context_has_bgra (gdk_gl_context_get_current ())) { pixel_data = free_data = g_malloc (width * height * 4); gdk_memory_convert (pixel_data, width * 4, @@ -125,7 +125,7 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self, { pixel_data = surface_data; gl_format = GL_BGRA; - gl_type = GL_UNSIGNED_INT_8_8_8_8_REV; + gl_type = GL_UNSIGNED_BYTE; } texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);