diff --git a/gdk/gdkenums.h b/gdk/gdkenums.h index 9ccb651742..03c6d16f99 100644 --- a/gdk/gdkenums.h +++ b/gdk/gdkenums.h @@ -298,6 +298,8 @@ typedef enum * The color values are premultiplied with the alpha value. * @GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: 4 bytes; for red, green, blue, alpha * The color values are premultiplied with the alpha value. + * @GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: 4 bytes; for alpha, blue, green, red, + * The color values are premultiplied with the alpha value. Since 4.14 * @GDK_MEMORY_B8G8R8A8: 4 bytes; for blue, green, red, alpha. * @GDK_MEMORY_A8R8G8B8: 4 bytes; for alpha, red, green, blue. * @GDK_MEMORY_R8G8B8A8: 4 bytes; for red, green, blue, alpha. @@ -382,6 +384,7 @@ typedef enum { GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12, GDK_MEMORY_A16_FLOAT GDK_AVAILABLE_ENUMERATOR_IN_4_12, GDK_MEMORY_A32_FLOAT GDK_AVAILABLE_ENUMERATOR_IN_4_12, + GDK_MEMORY_A8B8G8R8_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_14, GDK_MEMORY_N_FORMATS } GdkMemoryFormat; diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c index 6a7c1bde44..154e5c94ea 100644 --- a/gdk/gdkmemoryformat.c +++ b/gdk/gdkmemoryformat.c @@ -94,6 +94,7 @@ name ## _from_float (guchar *dest_data, \ TYPED_FUNCS (b8g8r8a8_premultiplied, guchar, 2, 1, 0, 3, 4, 255) TYPED_FUNCS (a8r8g8b8_premultiplied, guchar, 1, 2, 3, 0, 4, 255) TYPED_FUNCS (r8g8b8a8_premultiplied, guchar, 0, 1, 2, 3, 4, 255) +TYPED_FUNCS (a8b8g8r8_premultiplied, guchar, 3, 2, 1, 0, 4, 255) TYPED_FUNCS (b8g8r8a8, guchar, 2, 1, 0, 3, 4, 255) TYPED_FUNCS (a8r8g8b8, guchar, 1, 2, 3, 0, 4, 255) TYPED_FUNCS (r8g8b8a8, guchar, 0, 1, 2, 3, 4, 255) @@ -378,6 +379,16 @@ static const GdkMemoryFormatDescription memory_formats[] = { r8g8b8a8_premultiplied_to_float, r8g8b8a8_premultiplied_from_float, }, + [GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = { + GDK_MEMORY_ALPHA_PREMULTIPLIED, + 4, + G_ALIGNOF (guchar), + GDK_MEMORY_U8, + { 0, 0, G_MAXUINT, G_MAXUINT }, + { GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } }, + a8b8g8r8_premultiplied_to_float, + a8b8g8r8_premultiplied_from_float, + }, [GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_ALPHA_STRAIGHT, 4, diff --git a/gdk/loaders/gdkpng.c b/gdk/loaders/gdkpng.c index ebaa103b67..e725e64a00 100644 --- a/gdk/loaders/gdkpng.c +++ b/gdk/loaders/gdkpng.c @@ -329,6 +329,7 @@ gdk_save_png (GdkTexture *texture) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: diff --git a/gdk/loaders/gdktiff.c b/gdk/loaders/gdktiff.c index 59d33f11e7..d0683e1063 100644 --- a/gdk/loaders/gdktiff.c +++ b/gdk/loaders/gdktiff.c @@ -236,6 +236,7 @@ static const FormatData format_data[] = { [GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB }, [GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB }, [GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB }, + [GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB }, [GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB }, [GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB }, [GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB }, diff --git a/gsk/vulkan/gskvulkanimage.c b/gsk/vulkan/gskvulkanimage.c index 1b92caec67..0b29f2e5fc 100644 --- a/gsk/vulkan/gskvulkanimage.c +++ b/gsk/vulkan/gskvulkanimage.c @@ -80,6 +80,15 @@ gsk_memory_format_get_vk_format_infos (GdkMemoryFormat format) return info; } + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: + { + static const GskMemoryFormatInfo info[] = { + { VK_FORMAT_R8G8B8A8_UNORM, SWIZZLE(A, B, G, R), 0 }, + { VK_FORMAT_UNDEFINED } + }; + return info; + } + case GDK_MEMORY_B8G8R8A8: { static const GskMemoryFormatInfo info[] = { @@ -324,6 +333,7 @@ gsk_memory_format_get_fallback (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index c42bda7024..5b4c092db5 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -102,6 +102,7 @@ gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: @@ -145,6 +146,7 @@ gdk_memory_format_get_channel_type (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: @@ -197,6 +199,7 @@ gdk_memory_format_n_colors (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: @@ -247,6 +250,7 @@ gdk_memory_format_has_alpha (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: @@ -282,6 +286,7 @@ gdk_memory_format_is_premultiplied (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED: case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED: case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED: @@ -326,6 +331,7 @@ gdk_memory_format_is_deep (GdkMemoryFormat format) case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_G8A8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8: case GDK_MEMORY_B8G8R8: @@ -373,6 +379,7 @@ gdk_memory_format_pixel_equal (GdkMemoryFormat format, case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8: case GDK_MEMORY_B8G8R8: case GDK_MEMORY_B8G8R8A8: @@ -581,6 +588,9 @@ texture_builder_set_pixel (TextureBuilder *builder, case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: set_pixel_u8 (data, 0, 1, 2, 3, TRUE, color); break; + case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: + set_pixel_u8 (data, 3, 2, 1, 0, TRUE, color); + break; case GDK_MEMORY_B8G8R8A8: set_pixel_u8 (data, 2, 1, 0, 3, FALSE, color); break;