gsk: Use has_bgra in more places
authorMatthias Clasen <mclasen@redhat.com>
Fri, 20 Oct 2023 01:41:44 +0000 (21:41 -0400)
committerChristian Hergert <chergert@redhat.com>
Tue, 31 Oct 2023 20:46:32 +0000 (13:46 -0700)
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
gsk/gl/gskgliconlibrary.c

index 9b8c78fc3011258e1c7de8449d19295bf52d5c3c..3c04b46973836b5532d00c904a9e24590545de6b 100644 (file)
@@ -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);
index 58e5a22be9ab42a54e070f8dcff74bcb32ae5fd5..156469dde0f249b311595363a643f76495c8d1fc 100644 (file)
@@ -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);