clutter/stage-view: Add API to get view color state

This aims to provide the color state used for compositing for a specific
view. It's currently hard coded to default, but will eventually be
configured depending on the monitor and configuration. It's intended to
be used as a target color state for rendering with color awareness.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
This commit is contained in:
Jonas Ådahl 2023-11-09 13:01:26 +08:00 committed by Sebastian Wick
parent 2bd8216eb1
commit 1a52108c17
2 changed files with 19 additions and 0 deletions

View File

@ -81,3 +81,5 @@ CLUTTER_EXPORT
void clutter_stage_view_notify_ready (ClutterStageView *view);
void clutter_stage_view_invalidate_input_devices (ClutterStageView *view);
ClutterColorState * clutter_stage_view_get_color_state (ClutterStageView *view);

View File

@ -68,6 +68,7 @@ typedef struct _ClutterStageViewPrivate
MtkRectangle layout;
float scale;
CoglFramebuffer *framebuffer;
ClutterColorState *color_state;
CoglOffscreen *offscreen;
CoglPipeline *offscreen_pipeline;
@ -1088,6 +1089,7 @@ clutter_stage_view_constructed (GObject *object)
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
ClutterContext *context;
if (priv->use_shadowfb)
init_shadowfb (view);
@ -1098,6 +1100,11 @@ clutter_stage_view_constructed (GObject *object)
&frame_clock_listener_iface,
view);
context = clutter_actor_get_context (CLUTTER_ACTOR (priv->stage));
priv->color_state = clutter_color_state_new (context,
CLUTTER_COLORSPACE_DEFAULT,
CLUTTER_TRANSFER_FUNCTION_DEFAULT);
clutter_stage_view_add_redraw_clip (view, NULL);
clutter_stage_view_schedule_update (view);
@ -1117,6 +1124,7 @@ clutter_stage_view_dispose (GObject *object)
g_clear_object (&priv->shadow.framebuffer);
g_clear_object (&priv->color_state);
g_clear_object (&priv->offscreen);
g_clear_object (&priv->offscreen_pipeline);
g_clear_pointer (&priv->redraw_clip, mtk_region_unref);
@ -1258,3 +1266,12 @@ clutter_stage_view_get_default_paint_flags (ClutterStageView *view)
else
return CLUTTER_PAINT_FLAG_NONE;
}
ClutterColorState *
clutter_stage_view_get_color_state (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
return priv->color_state;
}