From 0f61c52593f963f773cd630735350f75ceece86f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 00:08:55 -0400 Subject: [PATCH] gdk: Simplify gdk_memory_format_gl_format 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 | 3 +++ gdk/gdkmemoryformat.c | 3 --- gsk/gl/gskglcommandqueue.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c index 59244f4422..b51861b514 100644 --- a/gdk/gdkgltexture.c +++ b/gdk/gdkgltexture.c @@ -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; diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c index 9493f10eb6..191bb22db2 100644 --- a/gdk/gdkmemoryformat.c +++ b/gdk/gdkmemoryformat.c @@ -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 || diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index 60e9222fe0..645f32f7d9 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -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))