From 7a58439977440522d20799fc1bacbcb822886ba4 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 21 Jul 2023 03:05:40 +0200 Subject: [PATCH] memoryformat: Copy idea from tiff code The static assertion makes sure that newer formats get added. --- gdk/gdkmemoryformat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c index 9c85ae2575..40fea6987e 100644 --- a/gdk/gdkmemoryformat.c +++ b/gdk/gdkmemoryformat.c @@ -346,7 +346,7 @@ struct _GdkMemoryFormatDescription # error "Define the right GL flags here" #endif -static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = { +static const GdkMemoryFormatDescription memory_formats[] = { [GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_ALPHA_PREMULTIPLIED, 4, @@ -629,6 +629,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = { } }; +/* if this fails, somebody forgot to add formats above */ +G_STATIC_ASSERT (G_N_ELEMENTS (memory_formats) == GDK_MEMORY_N_FORMATS); + gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format) { -- 2.30.2