mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
gpu: Introduce gsk_gpu_color_states_create_equal()
This is a function that's meant to be used whenever both color states of the shader are equal. In that case no colorspace conversion code needs to be created and shaders can be shared.
This commit is contained in:
parent
a14efce914
commit
77ed264714
@ -10,6 +10,16 @@
|
||||
#define COLOR_SPACE_ALT_SHIFT 16u
|
||||
#define COLOR_SPACE_COLOR_STATE_MASK 0xFFu
|
||||
|
||||
static inline GskGpuColorStates
|
||||
gsk_gpu_color_states_create_equal (gboolean output_is_premultiplied,
|
||||
gboolean alt_is_premultiplied)
|
||||
{
|
||||
/* We use ID 0 here for the colorspaces - if that ever becomes an issue
|
||||
* that it maps to SRGB, we need to invent something */
|
||||
return (output_is_premultiplied ? COLOR_SPACE_OUTPUT_PREMULTIPLIED : 0) |
|
||||
(alt_is_premultiplied ? COLOR_SPACE_ALT_PREMULTIPLIED : 0);
|
||||
}
|
||||
|
||||
static inline GskGpuColorStates
|
||||
gsk_gpu_color_states_create (GdkColorState *output_color_state,
|
||||
gboolean output_is_premultiplied,
|
||||
@ -19,6 +29,9 @@ gsk_gpu_color_states_create (GdkColorState *output_color_state,
|
||||
g_assert (GDK_IS_DEFAULT_COLOR_STATE (output_color_state));
|
||||
g_assert (GDK_IS_DEFAULT_COLOR_STATE (alt_color_state));
|
||||
|
||||
if (gdk_color_state_equal (output_color_state, alt_color_state))
|
||||
return gsk_gpu_color_states_create_equal (output_is_premultiplied, alt_is_premultiplied);
|
||||
|
||||
return (GDK_DEFAULT_COLOR_STATE_ID (output_color_state) << COLOR_SPACE_OUTPUT_SHIFT) |
|
||||
(output_is_premultiplied ? COLOR_SPACE_OUTPUT_PREMULTIPLIED : 0) |
|
||||
(GDK_DEFAULT_COLOR_STATE_ID (alt_color_state) << COLOR_SPACE_ALT_SHIFT) |
|
||||
|
@ -261,10 +261,7 @@ gsk_gpu_node_processor_color_states_explicit (GskGpuNodeProcessor *self,
|
||||
static inline GskGpuColorStates
|
||||
gsk_gpu_node_processor_color_states_self (GskGpuNodeProcessor *self)
|
||||
{
|
||||
return gsk_gpu_color_states_create (self->ccs,
|
||||
TRUE,
|
||||
self->ccs,
|
||||
TRUE);
|
||||
return gsk_gpu_color_states_create_equal (TRUE, TRUE);
|
||||
}
|
||||
|
||||
static inline GskGpuColorStates
|
||||
|
@ -38,11 +38,16 @@ void
|
||||
gsk_gpu_print_color_states (GString *string,
|
||||
GskGpuColorStates color_states)
|
||||
{
|
||||
g_string_append_printf (string, "%s%s -> %s%s ",
|
||||
gdk_color_state_get_name (gsk_gpu_color_states_get_alt (color_states)),
|
||||
gsk_gpu_color_states_is_alt_premultiplied (color_states) ? "(p)" : "",
|
||||
gdk_color_state_get_name (gsk_gpu_color_states_get_output (color_states)),
|
||||
gsk_gpu_color_states_is_output_premultiplied (color_states) ? "(p)" : "");
|
||||
if (gsk_gpu_color_states_get_alt (color_states) == gsk_gpu_color_states_get_output (color_states))
|
||||
g_string_append_printf (string, "any %s -> %s ",
|
||||
gsk_gpu_color_states_is_alt_premultiplied (color_states) ? "(p)" : "",
|
||||
gsk_gpu_color_states_is_output_premultiplied (color_states) ? "(p)" : "");
|
||||
else
|
||||
g_string_append_printf (string, "%s%s -> %s%s ",
|
||||
gdk_color_state_get_name (gsk_gpu_color_states_get_alt (color_states)),
|
||||
gsk_gpu_color_states_is_alt_premultiplied (color_states) ? "(p)" : "",
|
||||
gdk_color_state_get_name (gsk_gpu_color_states_get_output (color_states)),
|
||||
gsk_gpu_color_states_is_output_premultiplied (color_states) ? "(p)" : "");
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user