diff --git a/gsk/gpu/gskgpucolorstatesprivate.h b/gsk/gpu/gskgpucolorstatesprivate.h index 0efc8965ef..16e1b45415 100644 --- a/gsk/gpu/gskgpucolorstatesprivate.h +++ b/gsk/gpu/gskgpucolorstatesprivate.h @@ -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) | diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 6f153f9e82..8d8f08961c 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -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 diff --git a/gsk/gpu/gskgpuprint.c b/gsk/gpu/gskgpuprint.c index 277d8c5dca..c2169c5581 100644 --- a/gsk/gpu/gskgpuprint.c +++ b/gsk/gpu/gskgpuprint.c @@ -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