diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2023-01-24 11:51:23 -0300 |
---|---|---|
committer | Robert Mader <robert.mader@collabora.com> | 2023-04-07 12:19:23 +0200 |
commit | 82b037e74cdff6a0710df5cf2c654ee30340ae53 (patch) | |
tree | 256f61116d3de5c41c6ff19d1cf74f69d880c914 | |
parent | eeee654031296398c903e3797b434e155948bdac (diff) | |
download | mutter-82b037e74cdff6a0710df5cf2c654ee30340ae53.tar.gz |
clutter/paint-context: Allow assigning a ClutterFrame
This is not yet used, but next commits will need to assign a frame
to the paint context whenever painting onscreens.
Assigning a frame to the paint context is a one-way operation, and
treats multiple assignments strictly as a programming error.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
-rw-r--r-- | clutter/clutter/clutter-paint-context-private.h | 3 | ||||
-rw-r--r-- | clutter/clutter/clutter-paint-context.c | 31 | ||||
-rw-r--r-- | clutter/clutter/clutter-paint-context.h | 3 |
3 files changed, 37 insertions, 0 deletions
diff --git a/clutter/clutter/clutter-paint-context-private.h b/clutter/clutter/clutter-paint-context-private.h index 25592a6fe..e15245ee6 100644 --- a/clutter/clutter/clutter-paint-context-private.h +++ b/clutter/clutter/clutter-paint-context-private.h @@ -33,4 +33,7 @@ CoglFramebuffer * clutter_paint_context_get_base_framebuffer (ClutterPaintContex const GArray * clutter_paint_context_get_clip_frusta (ClutterPaintContext *paint_context); +void clutter_paint_context_assign_frame (ClutterPaintContext *paint_context, + ClutterFrame *frame); + #endif /* CLUTTER_PAINT_CONTEXT_PRIVATE_H */ diff --git a/clutter/clutter/clutter-paint-context.c b/clutter/clutter/clutter-paint-context.c index b56d92aa7..486b3396c 100644 --- a/clutter/clutter/clutter-paint-context.c +++ b/clutter/clutter/clutter-paint-context.c @@ -18,6 +18,7 @@ #include "clutter-build-config.h" #include "clutter-paint-context-private.h" +#include "clutter-frame.h" struct _ClutterPaintContext { @@ -28,6 +29,7 @@ struct _ClutterPaintContext GList *framebuffers; ClutterStageView *view; + ClutterFrame *frame; cairo_region_t *redraw_clip; GArray *clip_frusta; @@ -93,6 +95,7 @@ clutter_paint_context_dispose (ClutterPaintContext *paint_context) paint_context->framebuffers = NULL; g_clear_pointer (&paint_context->redraw_clip, cairo_region_destroy); g_clear_pointer (&paint_context->clip_frusta, g_array_unref); + g_clear_pointer (&paint_context->frame, clutter_frame_unref); } void @@ -196,3 +199,31 @@ clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context) { return paint_context->paint_flags; } + +void +clutter_paint_context_assign_frame (ClutterPaintContext *paint_context, + ClutterFrame *frame) +{ + g_assert (paint_context != NULL); + g_assert (paint_context->frame == NULL); + g_assert (frame != NULL); + + paint_context->frame = clutter_frame_ref (frame); +} + +/** + * clutter_paint_context_get_frame: (skip) + * @paint_context: The #ClutterPaintContext + * + * Retrieves the #ClutterFrame assigned to @paint_context, if any. A frame is + * only assigned when the paint context is created as part of a frame scheduled + * by the frame clock, and won't be assigned e.g. on offscreen paints. + * + * Returns: (transfer none)(nullable): The #ClutterFrame associated with the + * @paint_context, or %NULL + */ +ClutterFrame * +clutter_paint_context_get_frame (ClutterPaintContext *paint_context) +{ + return paint_context->frame; +} diff --git a/clutter/clutter/clutter-paint-context.h b/clutter/clutter/clutter-paint-context.h index 2a36fe967..9370ae163 100644 --- a/clutter/clutter/clutter-paint-context.h +++ b/clutter/clutter/clutter-paint-context.h @@ -75,4 +75,7 @@ const cairo_region_t * clutter_paint_context_get_redraw_clip (ClutterPaintContex CLUTTER_EXPORT ClutterPaintFlag clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context); +CLUTTER_EXPORT +ClutterFrame * clutter_paint_context_get_frame (ClutterPaintContext *paint_context); + #endif /* CLUTTER_PAINT_CONTEXT_H */ |