From 6fe22ac8505da2c9a0b7eb97c3a6ea5f3edea95c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 5 Jun 2009 17:55:24 +0100 Subject: [PATCH] [repaint] Run the repaint functions in clutter_redraw() The clutter_redraw() function is used by libraries embedding Clutter inside another toolkit, instead of queueing a redraw on the embedded stage. This means that clutter_redraw() should perform the same sequence of actions done by the redraw idle callback. --- clutter/clutter-main.c | 34 +++++++++++++++++++++++++++------- clutter/clutter-private.h | 3 +++ clutter/clutter-stage.c | 4 ++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 055d7d6b0..d15ff0470 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -174,14 +174,8 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage) } } -/** - * clutter_redraw: - * - * Forces a redraw of the entire stage. Applications should never use this - * function, but queue a redraw using clutter_actor_queue_redraw(). - */ void -clutter_redraw (ClutterStage *stage) +_clutter_do_redraw (ClutterStage *stage) { ClutterMainContext *ctx; ClutterMasterClock *master_clock; @@ -235,6 +229,32 @@ clutter_redraw (ClutterStage *stage) CLUTTER_TIMESTAMP (SCHEDULER, "Redraw finish for stage:%p", stage); } +/** + * clutter_redraw: + * + * Forces a redraw of the entire stage. Applications should never use this + * function, but queue a redraw using clutter_actor_queue_redraw(). + * + * This function should only be used by libraries integrating Clutter from + * within another toolkit. + */ +void +clutter_redraw (ClutterStage *stage) +{ + ClutterMasterClock *master_clock; + + /* we need to do this because the clutter_redraw() might be called by + * clutter-gtk, and this will not cause the master clock to advance nor + * the repaint functions to be run + */ + master_clock = _clutter_master_clock_get_default (); + _clutter_master_clock_advance (master_clock); + + _clutter_run_repaint_functions (); + + _clutter_do_redraw (stage); +} + /** * clutter_set_motion_events_enabled: * @enable: %TRUE to enable per-actor motion events diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 6b62cee48..c384323d1 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -211,6 +211,9 @@ ClutterActor *_clutter_do_pick (ClutterStage *stage, gint y, ClutterPickMode mode); +/* the actual redraw */ +void _clutter_do_redraw (ClutterStage *stage); + guint _clutter_pixel_to_id (guchar pixel[4]); void _clutter_id_to_color (guint id, ClutterColor *col); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 75cfc47a4..3ee13481d 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -417,7 +417,7 @@ redraw_update_idle (gpointer user_data) CLUTTER_NOTE (PAINT, "Repaint functions"); _clutter_run_repaint_functions (); - /* clutter_redraw() will also call maybe_relayout(), but since a relayout + /* clutter_do_redraw() will also call maybe_relayout(), but since a relayout * can queue a redraw, we want to do the relayout before we clear the * update_idle to avoid painting the stage twice. Calling maybe_relayout() * twice in a row is cheap because of caching of requested and allocated @@ -427,7 +427,7 @@ redraw_update_idle (gpointer user_data) /* redrawing will advance the master clock */ CLUTTER_NOTE (PAINT, "redrawing via idle for stage[%p]", stage); - clutter_redraw (stage); + _clutter_do_redraw (stage); /* reset the guard, so that new redraws are possible */ priv->update_idle = 0;