1
0
Fork 0

clutter/color-state: Add a helper to print the color state

And use it in MetaRendererNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
This commit is contained in:
Sebastian Wick 2024-07-18 13:49:22 +02:00 committed by Marge Bot
parent 58cb44186d
commit 6a2ce066b0
3 changed files with 62 additions and 44 deletions

View file

@ -852,3 +852,44 @@ clutter_color_state_equals (ClutterColorState *color_state,
return (priv->colorspace == other_priv->colorspace &&
priv->transfer_function == other_priv->transfer_function);
}
static char *
enum_to_string (GType type,
unsigned int enum_value)
{
GEnumClass *enum_class;
GEnumValue *value;
char *retval = NULL;
enum_class = g_type_class_ref (type);
value = g_enum_get_value (enum_class, enum_value);
if (value)
retval = g_strdup (value->value_nick);
g_type_class_unref (enum_class);
return retval;
}
char *
clutter_color_state_to_string (ClutterColorState *color_state)
{
ClutterColorStatePrivate *priv;
g_autofree char *colorspace_name = NULL;
g_autofree char *transfer_function_name = NULL;
g_return_val_if_fail (CLUTTER_IS_COLOR_STATE (color_state), FALSE);
priv = clutter_color_state_get_instance_private (color_state);
colorspace_name = enum_to_string (CLUTTER_TYPE_COLORSPACE, priv->colorspace);
transfer_function_name = enum_to_string (CLUTTER_TYPE_TRANSFER_FUNCTION,
priv->transfer_function);
return g_strdup_printf ("ClutterColorState %d "
"(colorspace: %s, transfer function: %s)",
priv->id,
colorspace_name,
transfer_function_name);
}

View file

@ -43,6 +43,9 @@ ClutterColorState * clutter_color_state_new (ClutterContext *context,
ClutterColorspace colorspace,
ClutterTransferFunction transfer_function);
CLUTTER_EXPORT
char * clutter_color_state_to_string (ClutterColorState *color_state);
CLUTTER_EXPORT
unsigned int clutter_color_state_get_id (ClutterColorState *color_state);

View file

@ -125,25 +125,6 @@ meta_renderer_native_ensure_gpu_data (MetaRendererNative *renderer_native,
static void
meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
static char *
enum_to_string (GType type,
unsigned int enum_value)
{
GEnumClass *enum_class;
GEnumValue *value;
char *retval = NULL;
enum_class = g_type_class_ref (type);
value = g_enum_get_value (enum_class, enum_value);
if (value)
retval = g_strdup (value->value_nick);
g_type_class_unref (enum_class);
return retval;
}
static void
meta_renderer_native_gpu_data_free (MetaRendererNativeGpuData *renderer_gpu_data)
{
@ -1539,31 +1520,6 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
if (meta_debug_control_is_linear_blending_forced (debug_control))
view_transfer_function = CLUTTER_TRANSFER_FUNCTION_LINEAR;
if (meta_is_topic_enabled (META_DEBUG_RENDER))
{
g_autofree char *colorspace_name = NULL;
g_autofree char *view_transfer_function_name = NULL;
g_autofree char *output_transfer_function_name = NULL;
colorspace_name = enum_to_string (CLUTTER_TYPE_COLORSPACE,
colorspace);
view_transfer_function_name =
enum_to_string (CLUTTER_TYPE_TRANSFER_FUNCTION,
view_transfer_function);
output_transfer_function_name =
enum_to_string (CLUTTER_TYPE_TRANSFER_FUNCTION,
output_transfer_function);
meta_topic (META_DEBUG_RENDER,
"Using colorspace %s "
"and transfer functions %s (view) and %s (output) "
"for view %s",
colorspace_name,
view_transfer_function_name,
output_transfer_function_name,
meta_output_get_name (output));
}
view_color_state = clutter_color_state_new (clutter_context,
colorspace,
view_transfer_function);
@ -1571,6 +1527,24 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
colorspace,
output_transfer_function);
if (meta_is_topic_enabled (META_DEBUG_RENDER))
{
g_autofree char *view_cs_str =
clutter_color_state_to_string (view_color_state);
g_autofree char *output_cs_str =
clutter_color_state_to_string (view_color_state);
meta_topic (META_DEBUG_RENDER,
"ColorState for view %s:\n %s",
meta_output_get_name (output),
view_cs_str);
meta_topic (META_DEBUG_RENDER,
"ColorState for output %s:\n %s",
meta_output_get_name (output),
output_cs_str);
}
view_transform = calculate_view_transform (monitor_manager,
logical_monitor,
output,