gdk: Add function to query alpha format for depth

It's meant to be used in renderers.
This commit is contained in:
Benjamin Otte 2023-07-22 01:11:19 +02:00
parent 4a8122f685
commit b1b8a98568
2 changed files with 28 additions and 0 deletions

View File

@ -704,6 +704,33 @@ gdk_memory_depth_merge (GdkMemoryDepth depth1,
}
}
/*
* gdk_memory_depth_get_alpha_format:
* @depth: the depth
*
* Gets the preferred format to use for rendering masks and other
* alpha-only content.
*
* Returns: the format
**/
GdkMemoryFormat
gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth)
{
switch (depth)
{
case GDK_MEMORY_U8:
return GDK_MEMORY_A8;
case GDK_MEMORY_U16:
return GDK_MEMORY_A16;
case GDK_MEMORY_FLOAT16:
return GDK_MEMORY_A16_FLOAT;
case GDK_MEMORY_FLOAT32:
return GDK_MEMORY_A32_FLOAT;
default:
g_return_val_if_reached (GDK_MEMORY_A8);
}
}
gboolean
gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,

View File

@ -44,6 +44,7 @@ gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format) G_GNUC_CONST;
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
GdkMemoryDepth depth2) G_GNUC_CONST;
GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth depth) G_GNUC_CONST;
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
guint gl_major,