gdk: Simplify gdk_memory_format_gl_format
authorMatthias Clasen <mclasen@redhat.com>
Tue, 30 May 2023 04:08:55 +0000 (00:08 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 30 May 2023 18:49:45 +0000 (14:49 -0400)
Make the callers of this function check for
straight alpha themselves, and only do the
version compatibility check here. This makes
the function usable in contexts where straight
alpha is acceptable.

gdk/gdkgltexture.c
gdk/gdkmemoryformat.c
gsk/gl/gskglcommandqueue.c

index 59244f4422865535ba5a0b49e1115e3650709b49..b51861b51456762e75e0af98d27c7bc4af389c4e 100644 (file)
@@ -149,6 +149,9 @@ gdk_gl_texture_find_format (gboolean         use_es,
       GLenum q_internal_format, q_format, q_type;
       GLint q_swizzle[4];
 
+      if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT)
+        continue;
+
       if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type, &q_swizzle))
         continue;
 
index 9493f10eb63e58d0ca8f27bf05815c32db273f85..191bb22db287522eab8e23f21026432852973404 100644 (file)
@@ -600,9 +600,6 @@ gdk_memory_format_gl_format (GdkMemoryFormat  format,
   *out_type = memory_formats[format].gl.type;
   memcpy (out_swizzle, &memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
 
-  if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
-    return FALSE;
-
   if (gles)
     {
       if (memory_formats[format].min_gl_version.gles_major > gl_major ||
index 60e9222fe018cc71e67ba22c4131562b4ccee606..645f32f7d996f6fb8b1b4a89e27b62e8eac206ff 100644 (file)
@@ -1465,7 +1465,8 @@ memory_format_gl_format (GdkMemoryFormat  data_format,
                                    gl_internalformat,
                                    gl_format,
                                    gl_type,
-                                   gl_swizzle))
+                                   gl_swizzle) &&
+      gdk_memory_format_alpha (data_format) != GDK_MEMORY_ALPHA_STRAIGHT)
     return data_format;
 
   if (gdk_memory_format_prefers_high_depth (data_format))