clutter: Pass 'ClutterFrame' in all stage update signals

That means before-update, prepare-paint, before-paint, paint-view, after-paint,
after-update. While yet to be used, it will be used as a transient frame
book keeping object, to maintain object and state that is only valid
during a frame dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
This commit is contained in:
Jonas Ådahl 2022-10-13 17:50:34 +02:00
parent 24f44aa33e
commit 08b0e563d4
30 changed files with 126 additions and 64 deletions

View File

@ -45,18 +45,24 @@ ClutterStageWindow *_clutter_stage_get_default_window (void);
CLUTTER_EXPORT
void clutter_stage_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip);
const cairo_region_t *redraw_clip,
ClutterFrame *frame);
void clutter_stage_emit_before_update (ClutterStage *stage,
ClutterStageView *view);
ClutterStageView *view,
ClutterFrame *frame);
void clutter_stage_emit_prepare_frame (ClutterStage *stage,
ClutterStageView *view);
ClutterStageView *view,
ClutterFrame *frame);
void clutter_stage_emit_before_paint (ClutterStage *stage,
ClutterStageView *view);
ClutterStageView *view,
ClutterFrame *frame);
void clutter_stage_emit_after_paint (ClutterStage *stage,
ClutterStageView *view);
ClutterStageView *view,
ClutterFrame *frame);
void clutter_stage_emit_after_update (ClutterStage *stage,
ClutterStageView *view);
ClutterStageView *view,
ClutterFrame *frame);
CLUTTER_EXPORT
void _clutter_stage_set_window (ClutterStage *stage,

View File

@ -1230,7 +1230,7 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
begin_frame_timing_measurement (view);
_clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_PRE_PAINT);
clutter_stage_emit_before_update (stage, view);
clutter_stage_emit_before_update (stage, view, frame);
clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage));
clutter_stage_maybe_finish_queue_redraws (stage);
@ -1241,18 +1241,18 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
devices = clutter_stage_find_updated_devices (stage, view);
_clutter_stage_window_prepare_frame (stage_window, view, frame);
clutter_stage_emit_prepare_frame (stage, view);
clutter_stage_emit_prepare_frame (stage, view, frame);
if (clutter_stage_view_has_redraw_clip (view))
{
clutter_stage_emit_before_paint (stage, view);
clutter_stage_emit_before_paint (stage, view, frame);
_clutter_stage_window_redraw_view (stage_window, view, frame);
clutter_frame_clock_record_flip_time (frame_clock,
g_get_monotonic_time ());
clutter_stage_emit_after_paint (stage, view);
clutter_stage_emit_after_paint (stage, view, frame);
if (_clutter_context_get_show_fps ())
end_frame_timing_measurement (view);
@ -1264,7 +1264,7 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
priv->needs_update_devices = FALSE;
_clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_POST_PAINT);
clutter_stage_emit_after_update (stage, view);
clutter_stage_emit_after_update (stage, view, frame);
return clutter_frame_get_result (frame);
}

View File

@ -53,6 +53,7 @@
#include "clutter-enum-types.h"
#include "clutter-event-private.h"
#include "clutter-frame-clock.h"
#include "clutter-frame.h"
#include "clutter-grab.h"
#include "clutter-id-pool.h"
#include "clutter-input-device-private.h"
@ -444,7 +445,8 @@ clutter_stage_do_paint_view (ClutterStage *stage,
void
clutter_stage_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip)
const cairo_region_t *redraw_clip,
ClutterFrame *frame)
{
ClutterStagePrivate *priv = stage->priv;
@ -455,44 +457,49 @@ clutter_stage_paint_view (ClutterStage *stage,
if (g_signal_has_handler_pending (stage, stage_signals[PAINT_VIEW],
0, TRUE))
g_signal_emit (stage, stage_signals[PAINT_VIEW], 0, view, redraw_clip);
g_signal_emit (stage, stage_signals[PAINT_VIEW], 0, view, redraw_clip, frame);
else
CLUTTER_STAGE_GET_CLASS (stage)->paint_view (stage, view, redraw_clip);
CLUTTER_STAGE_GET_CLASS (stage)->paint_view (stage, view, redraw_clip, frame);
}
void
clutter_stage_emit_before_update (ClutterStage *stage,
ClutterStageView *view)
ClutterStageView *view,
ClutterFrame *frame)
{
g_signal_emit (stage, stage_signals[BEFORE_UPDATE], 0, view);
g_signal_emit (stage, stage_signals[BEFORE_UPDATE], 0, view, frame);
}
void
clutter_stage_emit_prepare_frame (ClutterStage *stage,
ClutterStageView *view)
ClutterStageView *view,
ClutterFrame *frame)
{
g_signal_emit (stage, stage_signals[PREPARE_FRAME], 0, view);
g_signal_emit (stage, stage_signals[PREPARE_FRAME], 0, view, frame);
}
void
clutter_stage_emit_before_paint (ClutterStage *stage,
ClutterStageView *view)
ClutterStageView *view,
ClutterFrame *frame)
{
g_signal_emit (stage, stage_signals[BEFORE_PAINT], 0, view);
g_signal_emit (stage, stage_signals[BEFORE_PAINT], 0, view, frame);
}
void
clutter_stage_emit_after_paint (ClutterStage *stage,
ClutterStageView *view)
ClutterStageView *view,
ClutterFrame *frame)
{
g_signal_emit (stage, stage_signals[AFTER_PAINT], 0, view);
g_signal_emit (stage, stage_signals[AFTER_PAINT], 0, view, frame);
}
void
clutter_stage_emit_after_update (ClutterStage *stage,
ClutterStageView *view)
ClutterStageView *view,
ClutterFrame *frame)
{
g_signal_emit (stage, stage_signals[AFTER_UPDATE], 0, view);
g_signal_emit (stage, stage_signals[AFTER_UPDATE], 0, view, frame);
}
static gboolean
@ -1228,7 +1235,8 @@ clutter_stage_finalize (GObject *object)
static void
clutter_stage_real_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip)
const cairo_region_t *redraw_clip,
ClutterFrame *frame)
{
clutter_stage_do_paint_view (stage, view, redraw_clip);
}
@ -1383,6 +1391,7 @@ clutter_stage_class_init (ClutterStageClass *klass)
* ClutterStage::before-update:
* @stage: the #ClutterStage
* @view: a #ClutterStageView
* @frame: a #ClutterFrame
*/
stage_signals[BEFORE_UPDATE] =
g_signal_new (I_("before-update"),
@ -1390,12 +1399,14 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
G_TYPE_NONE, 2,
CLUTTER_TYPE_STAGE_VIEW,
CLUTTER_TYPE_FRAME);
/**
* ClutterStage::prepare-frame:
* @stage: the stage that received the event
* @view: a #ClutterStageView
* @frame: a #ClutterFrame
*
* The signal is emitted after the stage is updated,
* before the stage is painted, even if it will not be painted.
@ -1406,13 +1417,15 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
G_TYPE_NONE, 2,
CLUTTER_TYPE_STAGE_VIEW,
CLUTTER_TYPE_FRAME);
/**
* ClutterStage::before-paint:
* @stage: the stage that received the event
* @view: a #ClutterStageView
* @frame: a #ClutterFrame
*
* The signal is emitted before the stage is painted.
*/
@ -1422,12 +1435,14 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ClutterStageClass, before_paint),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
G_TYPE_NONE, 2,
CLUTTER_TYPE_STAGE_VIEW,
CLUTTER_TYPE_FRAME);
/**
* ClutterStage::after-paint:
* @stage: the stage that received the event
* @view: a #ClutterStageView
* @frame: a #ClutterFrame
*
* The signal is emitted after the stage is painted,
* but before the results are displayed on the screen.0
@ -1438,13 +1453,15 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_SIGNAL_RUN_LAST,
0, /* no corresponding vfunc */
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
G_TYPE_NONE, 2,
CLUTTER_TYPE_STAGE_VIEW,
CLUTTER_TYPE_FRAME);
/**
* ClutterStage::after-update:
* @stage: the #ClutterStage
* @view: a #ClutterStageView
* @frame: a #ClutterFrame
*/
stage_signals[AFTER_UPDATE] =
g_signal_new (I_("after-update"),
@ -1452,14 +1469,16 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
G_TYPE_NONE, 2,
CLUTTER_TYPE_STAGE_VIEW,
CLUTTER_TYPE_FRAME);
/**
* ClutterStage::paint-view:
* @stage: the stage that received the event
* @view: a #ClutterStageView
* @redraw_clip: a #cairo_region_t with the redraw clip
* @frame: a #ClutterFrame
*
* The signal is emitted before a [class@Clutter.StageView] is being
* painted.
@ -1474,9 +1493,10 @@ clutter_stage_class_init (ClutterStageClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ClutterStageClass, paint_view),
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_NONE, 3,
CLUTTER_TYPE_STAGE_VIEW,
CAIRO_GOBJECT_TYPE_REGION);
CAIRO_GOBJECT_TYPE_REGION,
CLUTTER_TYPE_FRAME);
/**
* ClutterStage::presented: (skip)

View File

@ -72,11 +72,13 @@ struct _ClutterStageClass
void (* deactivate) (ClutterStage *stage);
void (* before_paint) (ClutterStage *stage,
ClutterStageView *view);
ClutterStageView *view,
ClutterFrame *frame);
void (* paint_view) (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip);
const cairo_region_t *redraw_clip,
ClutterFrame *frame);
/*< private >*/
/* padding for future expansion */

View File

@ -165,6 +165,7 @@ meta_cursor_renderer_update_stage_overlay (MetaCursorRenderer *renderer,
static void
meta_cursor_renderer_after_paint (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaCursorRenderer *renderer)
{
MetaCursorRendererPrivate *priv =

View File

@ -191,6 +191,7 @@ cursor_changed (MetaCursorTracker *cursor_tracker,
static void
on_prepare_frame (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaScreenCastAreaStreamSrc *area_src)
{
sync_cursor_state (area_src);

View File

@ -287,6 +287,7 @@ cursor_changed (MetaCursorTracker *cursor_tracker,
static void
on_prepare_frame (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaScreenCastMonitorStreamSrc *monitor_src)
{
sync_cursor_state (monitor_src);

View File

@ -146,6 +146,7 @@ cursor_changed (MetaCursorTracker *cursor_tracker,
static void
on_prepare_frame (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaScreenCastVirtualStreamSrc *virtual_src)
{
sync_cursor_state (virtual_src);

View File

@ -396,12 +396,13 @@ scale_offset_and_clamp_region (const cairo_region_t *region,
static void
paint_stage (MetaStageImpl *stage_impl,
ClutterStageView *stage_view,
cairo_region_t *redraw_clip)
cairo_region_t *redraw_clip,
ClutterFrame *frame)
{
ClutterStage *stage = stage_impl->wrapper;
_clutter_stage_maybe_setup_viewport (stage, stage_view);
clutter_stage_paint_view (stage, stage_view, redraw_clip);
clutter_stage_paint_view (stage, stage_view, redraw_clip, frame);
clutter_stage_view_after_paint (stage_view, redraw_clip);
}
@ -607,7 +608,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
cairo_region_t *debug_redraw_clip;
debug_redraw_clip = cairo_region_create_rectangle (&view_rect);
paint_stage (stage_impl, stage_view, debug_redraw_clip);
paint_stage (stage_impl, stage_view, debug_redraw_clip, frame);
cairo_region_destroy (debug_redraw_clip);
}
else if (use_clipped_redraw)
@ -616,7 +617,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
cogl_framebuffer_push_region_clip (fb, fb_clip_region);
paint_stage (stage_impl, stage_view, redraw_clip);
paint_stage (stage_impl, stage_view, redraw_clip, frame);
cogl_framebuffer_pop_clip (fb);
}
@ -624,7 +625,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
{
meta_topic (META_DEBUG_BACKEND, "Unclipped stage paint");
paint_stage (stage_impl, stage_view, redraw_clip);
paint_stage (stage_impl, stage_view, redraw_clip, frame);
}
g_clear_pointer (&redraw_clip, cairo_region_destroy);

View File

@ -209,7 +209,8 @@ notify_watchers_for_mode (MetaStage *stage,
static void
meta_stage_before_paint (ClutterStage *stage,
ClutterStageView *view)
ClutterStageView *view,
ClutterFrame *frame)
{
MetaStage *meta_stage = META_STAGE (stage);
@ -267,12 +268,14 @@ meta_stage_paint (ClutterActor *actor,
static void
meta_stage_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip)
const cairo_region_t *redraw_clip,
ClutterFrame *frame)
{
MetaStage *meta_stage = META_STAGE (stage);
CLUTTER_STAGE_CLASS (meta_stage_parent_class)->paint_view (stage, view,
redraw_clip);
redraw_clip,
frame);
notify_watchers_for_mode (meta_stage, view, NULL,
META_STAGE_WATCH_AFTER_PAINT);

View File

@ -1159,6 +1159,7 @@ meta_compositor_after_paint (MetaCompositor *compositor,
static void
on_before_paint (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaCompositor *compositor)
{
MetaCompositorView *compositor_view;
@ -1174,6 +1175,7 @@ on_before_paint (ClutterStage *stage,
static void
on_after_paint (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaCompositor *compositor)
{
MetaCompositorView *compositor_view;

View File

@ -335,6 +335,7 @@ out:
static void
on_before_update (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaCompositor *compositor)
{
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor);
@ -373,6 +374,7 @@ on_before_update (ClutterStage *stage,
static void
on_after_update (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaCompositor *compositor)
{
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor);

View File

@ -173,6 +173,7 @@ run_repaint_laters (GSList **laters_list)
static void
on_before_update (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaLaters *laters)
{
unsigned int i;

View File

@ -234,6 +234,7 @@ static void
view_painted_cb (ClutterStage *stage,
ClutterStageView *view,
cairo_region_t *redraw_clip,
ClutterFrame *frame,
gpointer data)
{
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);

View File

@ -5,6 +5,7 @@
static void
on_after_update (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
gboolean *was_updated)
{
*was_updated = TRUE;

View File

@ -102,6 +102,7 @@ generate_round_texture (CoglContext *ctx)
static void
on_after_paint (ClutterActor *stage,
ClutterPaintContext *paint_context,
ClutterFrame *frame,
Data *data)
{
CoglFramebuffer *framebuffer =

View File

@ -38,7 +38,8 @@ do_events (ClutterActor *stage)
static void
on_after_paint (ClutterActor *stage,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
gconstpointer *data)
{
do_events (stage);

View File

@ -14,7 +14,8 @@ static int rows, cols;
static void
on_after_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
gconstpointer *data)
{
static GTimer *timer = NULL;

View File

@ -13,7 +13,8 @@
static void
on_after_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
gconstpointer *data)
{
static GTimer *timer = NULL;

View File

@ -29,7 +29,8 @@ clutter_perf_fps_init (void)
}
static void perf_stage_after_paint_cb (ClutterStage *stage,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
gpointer *data);
static gboolean perf_fake_mouse_cb (gpointer stage);
@ -54,7 +55,8 @@ clutter_perf_fps_report (const gchar *id)
static void
perf_stage_after_paint_cb (ClutterStage *stage,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
gpointer *data)
{
if (!testtimer)

View File

@ -16,7 +16,8 @@ static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff };
static void
on_after_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
ClutterStageView *stage_view,
ClutterFrame *frame,
void *state)
{
float saved_viewport[4];

View File

@ -141,7 +141,8 @@ check_paint (TestState *state, int x, int y, int scale)
static void
on_after_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
TestState *state)
{
CoglPipeline *pipeline;

View File

@ -64,10 +64,10 @@ assert_rectangle_color_and_black_border (int x,
assert_region_color (x-10, y+height, width+20, 10, 0x00, 0x00, 0x00, 0xff);
}
static void
on_after_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
ClutterStageView *view,
ClutterFrame *frame,
void *state)
{
float saved_viewport[4];

View File

@ -88,6 +88,7 @@ meta_backend_test_create_color_manager (MetaBackend *backend)
static void
on_after_update (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
gboolean *was_updated)
{
*was_updated = TRUE;

View File

@ -105,6 +105,7 @@ on_effects_completed (ClutterActor *actor,
static void
check_for_pending_effects (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
PendingEffectsData *data)
{
MetaWindow *window;
@ -178,6 +179,7 @@ sync_point (struct wl_client *client,
static void
on_after_paint (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
struct wl_resource *callback)
{
g_signal_handlers_disconnect_by_data (stage, callback);

View File

@ -54,6 +54,7 @@ static MetaContext *test_context;
static void
on_after_update (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
KmsRenderingTest *test)
{
test->number_of_frames_left--;
@ -90,6 +91,7 @@ meta_test_kms_render_basic (void)
static void
on_scanout_before_update (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
KmsRenderingTest *test)
{
test->scanout.n_paints = 0;
@ -99,6 +101,7 @@ on_scanout_before_update (ClutterStage *stage,
static void
on_scanout_before_paint (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
KmsRenderingTest *test)
{
CoglScanout *scanout;
@ -118,6 +121,7 @@ static void
on_scanout_paint_view (ClutterStage *stage,
ClutterStageView *stage_view,
cairo_region_t *region,
ClutterFrame *frame,
KmsRenderingTest *test)
{
test->scanout.n_paints++;

View File

@ -94,6 +94,7 @@ meta_test_stage_views_exist (void)
static void
on_after_paint (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
gboolean *was_painted)
{
*was_painted = TRUE;

View File

@ -126,6 +126,7 @@ subsurface_invalid_xdg_shell_actions (void)
static void
on_after_paint (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
gboolean *was_painted)
{
*was_painted = TRUE;

View File

@ -130,6 +130,7 @@ discard_non_cursor_feedbacks (struct wl_list *feedbacks)
static void
on_after_paint (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaWaylandCompositor *compositor)
{
struct wl_list *feedbacks;

View File

@ -214,6 +214,7 @@ meta_wayland_compositor_update (MetaWaylandCompositor *compositor,
static void
on_after_update (ClutterStage *stage,
ClutterStageView *stage_view,
ClutterFrame *frame,
MetaWaylandCompositor *compositor)
{
GList *l;