mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
gdk: Make A8 and A16 formats premultiplied
The relevant question here is about details, because we have to choose if we declare alpha-only formats as having their (nonexistant) color channels premultiplied or not, so that the code paths using them can do the right thing. Because we are premultiplied by default, it makes sense to treat alpha like that, because then the alpha-only code doesn't need to do workarounds for straight alpha. Where this is relevant of course is when expanding the alpha channel into color channels, where we want to end up with white. So make sure we do color = alpha there instead of color = 1 like we did before.
This commit is contained in:
parent
7a58439977
commit
4a8122f685
@ -69,9 +69,9 @@ name ## _to_float (float *dest, \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *src = (T *) (src_data + i * bpp); \
|
||||
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = 1.0; \
|
||||
dest[1] = dest[2] = dest[0]; \
|
||||
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
|
||||
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = dest[3]; \
|
||||
dest[1] = dest[2] = dest[0]; \
|
||||
dest += 4; \
|
||||
} \
|
||||
} \
|
||||
@ -588,22 +588,22 @@ static const GdkMemoryFormatDescription memory_formats[] = {
|
||||
g16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
1,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_RED } },
|
||||
a8_to_float,
|
||||
a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A16] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
2,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_RED } },
|
||||
a16_to_float,
|
||||
a16_from_float,
|
||||
},
|
||||
|
@ -287,6 +287,8 @@ gdk_memory_format_is_premultiplied (GdkMemoryFormat format)
|
||||
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_A8:
|
||||
case GDK_MEMORY_A16:
|
||||
case GDK_MEMORY_A16_FLOAT:
|
||||
case GDK_MEMORY_A32_FLOAT:
|
||||
return TRUE;
|
||||
@ -307,8 +309,6 @@ gdk_memory_format_is_premultiplied (GdkMemoryFormat format)
|
||||
case GDK_MEMORY_G8A8:
|
||||
case GDK_MEMORY_G16:
|
||||
case GDK_MEMORY_G16A16:
|
||||
case GDK_MEMORY_A8:
|
||||
case GDK_MEMORY_A16:
|
||||
return FALSE;
|
||||
|
||||
case GDK_MEMORY_N_FORMATS:
|
||||
|
Loading…
Reference in New Issue
Block a user