mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
stage: Move stage redraw logic into clutter-stage.c
The _clutter_do_redraw() function should really be moved inside ClutterStage, since all it does is calling private stage and backend functions. This also allows us to change a long-standing issue with a global fps counter for all stages, instead of a\ per-stage one.
This commit is contained in:
parent
89a0d514b4
commit
92ddaa9c13
@ -227,54 +227,6 @@ clutter_get_accessibility_enabled (void)
|
||||
return cally_get_cally_initialized ();
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_do_redraw (ClutterStage *stage)
|
||||
{
|
||||
static GTimer *timer = NULL;
|
||||
static guint timer_n_frames = 0;
|
||||
ClutterMainContext *ctx;
|
||||
|
||||
ctx = _clutter_context_get_default ();
|
||||
|
||||
_clutter_stage_set_pick_buffer_valid (stage, FALSE, -1);
|
||||
_clutter_stage_reset_picks_per_frame_counter (stage);
|
||||
|
||||
_clutter_backend_ensure_context (ctx->backend, stage);
|
||||
|
||||
/* Setup FPS count - not currently across *all* stages rather than per */
|
||||
if (G_UNLIKELY (clutter_get_show_fps ()))
|
||||
{
|
||||
if (!timer)
|
||||
timer = g_timer_new ();
|
||||
}
|
||||
|
||||
/* The code below can't go in stage paint as base actor_paint
|
||||
* will get called before it (and break picking, etc)
|
||||
*/
|
||||
_clutter_stage_maybe_setup_viewport (stage);
|
||||
|
||||
/* Call through to the actual backend to do the painting down from
|
||||
* the stage. It will likely need to swap buffers, vblank sync etc
|
||||
* which will be windowing system dependent
|
||||
*/
|
||||
_clutter_backend_redraw (ctx->backend, stage);
|
||||
|
||||
/* Complete FPS info */
|
||||
if (G_UNLIKELY (clutter_get_show_fps ()))
|
||||
{
|
||||
timer_n_frames++;
|
||||
|
||||
if (g_timer_elapsed (timer, NULL) >= 1.0)
|
||||
{
|
||||
g_print ("*** FPS: %i ***\n", timer_n_frames);
|
||||
timer_n_frames = 0;
|
||||
g_timer_start (timer);
|
||||
}
|
||||
}
|
||||
|
||||
CLUTTER_TIMESTAMP (SCHEDULER, "Redraw finish for stage:%p", stage);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_redraw:
|
||||
*
|
||||
|
@ -210,9 +210,6 @@ 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,
|
||||
|
@ -137,6 +137,9 @@ struct _ClutterStagePrivate
|
||||
|
||||
GHashTable *devices;
|
||||
|
||||
GTimer *fps_timer;
|
||||
gint32 timer_n_frames;
|
||||
|
||||
guint relayout_pending : 1;
|
||||
guint redraw_pending : 1;
|
||||
guint is_fullscreen : 1;
|
||||
@ -798,6 +801,52 @@ _clutter_stage_maybe_relayout (ClutterActor *actor)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_do_redraw (ClutterStage *stage)
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
ClutterActor *actor = CLUTTER_ACTOR (stage);
|
||||
ClutterStagePrivate *priv = stage->priv;
|
||||
|
||||
CLUTTER_TIMESTAMP (SCHEDULER, "Redraw started for %s[%p]",
|
||||
_clutter_actor_get_debug_name (actor),
|
||||
stage);
|
||||
|
||||
_clutter_stage_set_pick_buffer_valid (stage, FALSE, -1);
|
||||
_clutter_stage_reset_picks_per_frame_counter (stage);
|
||||
|
||||
_clutter_backend_ensure_context (backend, stage);
|
||||
|
||||
if (clutter_get_show_fps ())
|
||||
{
|
||||
if (priv->fps_timer == NULL)
|
||||
priv->fps_timer = g_timer_new ();
|
||||
}
|
||||
|
||||
_clutter_stage_maybe_setup_viewport (stage);
|
||||
|
||||
_clutter_backend_redraw (backend, stage);
|
||||
|
||||
if (clutter_get_show_fps ())
|
||||
{
|
||||
priv->timer_n_frames += 1;
|
||||
|
||||
if (g_timer_elapsed (priv->fps_timer, NULL) >= 1.0)
|
||||
{
|
||||
g_print ("*** FPS for %s: %i ***\n",
|
||||
_clutter_actor_get_debug_name (actor),
|
||||
priv->timer_n_frames);
|
||||
|
||||
priv->timer_n_frames = 0;
|
||||
g_timer_start (priv->fps_timer);
|
||||
}
|
||||
}
|
||||
|
||||
CLUTTER_TIMESTAMP (SCHEDULER, "Redraw finished for %s[%p]",
|
||||
_clutter_actor_get_debug_name (actor),
|
||||
stage);
|
||||
}
|
||||
|
||||
/**
|
||||
* _clutter_stage_do_update:
|
||||
* @stage: A #ClutterStage
|
||||
@ -829,8 +878,7 @@ _clutter_stage_do_update (ClutterStage *stage)
|
||||
|
||||
_clutter_stage_maybe_finish_queue_redraws (stage);
|
||||
|
||||
CLUTTER_NOTE (PAINT, "redrawing via idle for stage[%p]", stage);
|
||||
_clutter_do_redraw (stage);
|
||||
clutter_stage_do_redraw (stage);
|
||||
|
||||
/* reset the guard, so that new redraws are possible */
|
||||
priv->redraw_pending = FALSE;
|
||||
@ -1199,6 +1247,9 @@ clutter_stage_finalize (GObject *object)
|
||||
|
||||
g_hash_table_destroy (priv->devices);
|
||||
|
||||
if (priv->fps_timer != NULL)
|
||||
g_timer_destroy (priv->fps_timer);
|
||||
|
||||
G_OBJECT_CLASS (clutter_stage_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -30,17 +30,22 @@ on_button_press (ClutterActor *actor,
|
||||
ClutterActor *new_stage;
|
||||
ClutterActor *label, *tex;
|
||||
gint width, height;
|
||||
gchar *stage_label, *win_title;
|
||||
ClutterTimeline *timeline;
|
||||
ClutterAlpha *alpha;
|
||||
gchar *stage_label, *stage_name;
|
||||
ClutterTimeline *timeline;
|
||||
ClutterAlpha *alpha;
|
||||
ClutterBehaviour *r_behave;
|
||||
|
||||
new_stage = clutter_stage_new ();
|
||||
if (new_stage == NULL)
|
||||
return FALSE;
|
||||
|
||||
clutter_stage_set_color (CLUTTER_STAGE (new_stage), CLUTTER_COLOR_DarkScarletRed);
|
||||
stage_name = g_strdup_printf ("Stage [%d]", ++n_stages);
|
||||
|
||||
clutter_stage_set_title (CLUTTER_STAGE (new_stage), stage_name);
|
||||
clutter_stage_set_color (CLUTTER_STAGE (new_stage),
|
||||
CLUTTER_COLOR_DarkScarletRed);
|
||||
clutter_actor_set_size (new_stage, 320, 240);
|
||||
clutter_actor_set_name (new_stage, stage_name);
|
||||
|
||||
g_signal_connect (new_stage, "destroy", G_CALLBACK (on_destroy), NULL);
|
||||
|
||||
@ -58,7 +63,7 @@ on_button_press (ClutterActor *actor,
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (new_stage), tex);
|
||||
|
||||
stage_label = g_strdup_printf ("<b>Stage: %d</b>", ++n_stages);
|
||||
stage_label = g_strconcat ("<b>", stage_name, "</b>", NULL);
|
||||
label = clutter_text_new_with_text ("Mono 12", stage_label);
|
||||
|
||||
clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White);
|
||||
@ -78,9 +83,6 @@ on_button_press (ClutterActor *actor,
|
||||
NULL);
|
||||
*/
|
||||
|
||||
win_title = g_strdup_printf ("Stage:%p", new_stage);
|
||||
clutter_stage_set_title (CLUTTER_STAGE(new_stage), win_title);
|
||||
|
||||
timeline = clutter_timeline_new (2000);
|
||||
clutter_timeline_set_loop (timeline, TRUE);
|
||||
|
||||
@ -102,6 +104,8 @@ on_button_press (ClutterActor *actor,
|
||||
|
||||
stages = g_list_prepend (stages, new_stage);
|
||||
|
||||
g_free (stage_name);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -111,11 +115,13 @@ test_multistage_main (int argc, char *argv[])
|
||||
ClutterActor *stage_default;
|
||||
ClutterActor *label;
|
||||
gint width, height;
|
||||
gchar *win_title;
|
||||
|
||||
clutter_init (&argc, &argv);
|
||||
|
||||
stage_default = clutter_stage_get_default ();
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage_default), "Default Stage");
|
||||
clutter_actor_set_name (stage_default, "Default Stage");
|
||||
|
||||
g_signal_connect (stage_default, "button-press-event",
|
||||
G_CALLBACK (on_button_press),
|
||||
NULL);
|
||||
@ -131,9 +137,6 @@ test_multistage_main (int argc, char *argv[])
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage_default), label);
|
||||
clutter_actor_show (label);
|
||||
|
||||
win_title = g_strdup_printf ("Stage:%p", stage_default);
|
||||
clutter_stage_set_title (CLUTTER_STAGE(stage_default), win_title);
|
||||
|
||||
clutter_actor_show (stage_default);
|
||||
|
||||
clutter_main ();
|
||||
|
Loading…
Reference in New Issue
Block a user