From a1163385db232879301d60ecd500f0cc4046d1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 7 Jun 2024 23:43:17 +0200 Subject: [PATCH] paint-nodes: Sanity check color transform in blit nodes Blitting cannot run with a shader, thus cannot do color state transformations, so log a warning when that happens. Part-of: --- clutter/clutter/clutter-color-state.c | 17 +++++++++++++++++ clutter/clutter/clutter-color-state.h | 4 ++++ clutter/clutter/clutter-paint-nodes.c | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/clutter/clutter/clutter-color-state.c b/clutter/clutter/clutter-color-state.c index 1c207dcac..d18b24033 100644 --- a/clutter/clutter/clutter-color-state.c +++ b/clutter/clutter/clutter-color-state.c @@ -843,3 +843,20 @@ clutter_color_state_get_transform_snippet (ClutterColorState *color_state, g_object_ref (snippet)); return snippet; } + +gboolean +clutter_color_state_equals (ClutterColorState *color_state, + ClutterColorState *other_color_state) +{ + ClutterColorStatePrivate *priv; + ClutterColorStatePrivate *other_priv; + + g_return_val_if_fail (CLUTTER_IS_COLOR_STATE (color_state), FALSE); + g_return_val_if_fail (CLUTTER_IS_COLOR_STATE (other_color_state), FALSE); + + priv = clutter_color_state_get_instance_private (color_state); + other_priv = clutter_color_state_get_instance_private (other_color_state); + + return (priv->colorspace == other_priv->colorspace && + priv->transfer_function == other_priv->transfer_function); +} diff --git a/clutter/clutter/clutter-color-state.h b/clutter/clutter/clutter-color-state.h index 1a7167f31..9f105e290 100644 --- a/clutter/clutter/clutter-color-state.h +++ b/clutter/clutter/clutter-color-state.h @@ -53,4 +53,8 @@ CLUTTER_EXPORT CoglSnippet * clutter_color_state_get_transform_snippet (ClutterColorState *color_state, ClutterColorState *target_color_state); +CLUTTER_EXPORT +gboolean clutter_color_state_equals (ClutterColorState *color_state, + ClutterColorState *other_color_state); + G_END_DECLS diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c index 02b70bd64..148f26355 100644 --- a/clutter/clutter/clutter-paint-nodes.c +++ b/clutter/clutter/clutter-paint-nodes.c @@ -1336,6 +1336,10 @@ clutter_blit_node_draw (ClutterPaintNode *node, if (node->operations == NULL) return; + g_warn_if_fail (clutter_color_state_equals ( + clutter_paint_context_get_color_state (paint_context), + clutter_paint_context_get_target_color_state (paint_context))); + framebuffer = get_target_framebuffer (node, paint_context); for (i = 0; i < node->operations->len; i++)