1
0
Fork 0

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>
This commit is contained in:
Georges Basile Stavracas Neto 2023-01-24 11:51:23 -03:00 committed by Robert Mader
parent eeee654031
commit 82b037e74c
3 changed files with 37 additions and 0 deletions

View file

@ -33,4 +33,7 @@ CoglFramebuffer * clutter_paint_context_get_base_framebuffer (ClutterPaintContex
const GArray * const GArray *
clutter_paint_context_get_clip_frusta (ClutterPaintContext *paint_context); 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 */ #endif /* CLUTTER_PAINT_CONTEXT_PRIVATE_H */

View file

@ -18,6 +18,7 @@
#include "clutter-build-config.h" #include "clutter-build-config.h"
#include "clutter-paint-context-private.h" #include "clutter-paint-context-private.h"
#include "clutter-frame.h"
struct _ClutterPaintContext struct _ClutterPaintContext
{ {
@ -28,6 +29,7 @@ struct _ClutterPaintContext
GList *framebuffers; GList *framebuffers;
ClutterStageView *view; ClutterStageView *view;
ClutterFrame *frame;
cairo_region_t *redraw_clip; cairo_region_t *redraw_clip;
GArray *clip_frusta; GArray *clip_frusta;
@ -93,6 +95,7 @@ clutter_paint_context_dispose (ClutterPaintContext *paint_context)
paint_context->framebuffers = NULL; paint_context->framebuffers = NULL;
g_clear_pointer (&paint_context->redraw_clip, cairo_region_destroy); 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->clip_frusta, g_array_unref);
g_clear_pointer (&paint_context->frame, clutter_frame_unref);
} }
void void
@ -196,3 +199,31 @@ clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context)
{ {
return paint_context->paint_flags; 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;
}

View file

@ -75,4 +75,7 @@ const cairo_region_t * clutter_paint_context_get_redraw_clip (ClutterPaintContex
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterPaintFlag clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context); 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 */ #endif /* CLUTTER_PAINT_CONTEXT_H */