From: Benjamin Otte Date: Fri, 21 Jul 2023 01:05:40 +0000 (+0200) Subject: memoryformat: Copy idea from tiff code X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~52^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7a58439977440522d20799fc1bacbcb822886ba4;p=gtk4.git memoryformat: Copy idea from tiff code The static assertion makes sure that newer formats get added. --- 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) {