gsk: Always use RGBA on big-endian architectures
authorSimon McVittie <smcv@debian.org>
Fri, 8 Dec 2023 16:42:56 +0000 (16:42 +0000)
committerSimon McVittie <smcv@debian.org>
Sat, 9 Dec 2023 01:33:26 +0000 (01:33 +0000)
The memorytexture test started failing on big-endian CPUs while using
"desktop" GL (not GLES) in commit b0e26873 "gsk: Use has_bgra in more
places". The subsequent commit f5812808 "gsk: Restore bigendian support"
was meant to fix this, but it seems it did not.

Always taking the RGBA code-path on big-endian might not be optimal,
but it seems to result in the test passing again.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/6260
Bug-Debian: https://bugs.debian.org/1057782
Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6653

Gbp-Pq: Name gsk-Always-use-RGBA-on-big-endian-architectures.patch

gsk/gl/gskglglyphlibrary.c
gsk/gl/gskgliconlibrary.c

index 2e6d4da7fb7553e8c7a57a1d1a3690c0e69a886e..981a5f836253dc577902152ffaf8a0ed9cd3d73f 100644 (file)
@@ -95,6 +95,16 @@ gsk_gl_glyph_library_clear_cache (GskGLTextureLibrary *library)
   memset (self->front, 0, sizeof self->front);
 }
 
+static gboolean
+can_use_bgra (void)
+{
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+  return FALSE;
+#else
+  return gdk_gl_context_has_bgra (gdk_gl_context_get_current ());
+#endif
+}
+
 static void
 gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self,
                                  GskGLTextureAtlas   *atlas)
@@ -119,11 +129,7 @@ gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self,
 
   memset (pixel_data, 255, sizeof pixel_data);
 
-  if (!gdk_gl_context_has_bgra (gdk_gl_context_get_current ())
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-      || gdk_gl_context_get_use_es (gdk_gl_context_get_current ())
-#endif
-     )
+  if (!can_use_bgra ())
     {
       gl_format = GL_RGBA;
       gl_type = GL_UNSIGNED_BYTE;
index 9040d8e1d9122916bab6d515b4eb2e4c384c9419..9ea87da17eeb5af8b6e74b703f08a0c3532c874c 100644 (file)
@@ -71,6 +71,16 @@ gsk_gl_icon_library_init (GskGLIconLibrary *self)
                                     gsk_gl_icon_data_free);
 }
 
+static gboolean
+can_use_bgra (void)
+{
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+  return FALSE;
+#else
+  return gdk_gl_context_has_bgra (gdk_gl_context_get_current ());
+#endif
+}
+
 void
 gsk_gl_icon_library_add (GskGLIconLibrary     *self,
                          GdkTexture           *key,
@@ -111,11 +121,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_has_bgra (gdk_gl_context_get_current ())
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-      || gdk_gl_context_get_use_es (gdk_gl_context_get_current ())
-#endif
-     )
+  if (!can_use_bgra ())
     {
       pixel_data = free_data = g_malloc (width * height * 4);
       gdk_memory_convert (pixel_data, width * 4,