From 5d1600d6036941885a6ad2a4372f35678696d549 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 8 Sep 2010 11:32:29 +0100 Subject: [PATCH] stage: only update viewport when allocation changes In clutter_stage_allocate at the end we were always querying the latest allocation set and using the geometry to assert the viewport and then kicking a full redraw. These only need to be done when the allocation really changes, so we now read the previous allocation at the start of the function and compare at the end. This was stopping clipped redraws from being used in a lot of cases. --- clutter/clutter-stage.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index f813c4006..34e60c445 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -232,6 +232,7 @@ clutter_stage_allocate (ClutterActor *self, ClutterAllocationFlags flags) { ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv; + ClutterGeometry prev_geom; ClutterGeometry geom = { 0, }; gboolean origin_changed; gint width, height; @@ -241,6 +242,8 @@ clutter_stage_allocate (ClutterActor *self, if (priv->impl == NULL) return; + clutter_actor_get_allocation_geometry (self, &prev_geom); + width = clutter_actor_box_get_width (box); height = clutter_actor_box_get_height (box); _clutter_stage_window_get_geometry (priv->impl, &geom); @@ -321,13 +324,16 @@ clutter_stage_allocate (ClutterActor *self, } clutter_actor_get_allocation_geometry (self, &geom); - _clutter_stage_set_viewport (CLUTTER_STAGE (self), - 0, 0, geom.width, geom.height); + if (geom.width != prev_geom.width || geom.height != prev_geom.height) + { + _clutter_stage_set_viewport (CLUTTER_STAGE (self), + 0, 0, geom.width, geom.height); - /* Note: we don't assume that set_viewport will queue a full redraw - * since it may bail-out early if something preemptively set the - * viewport before the stage was really allocated its new size. */ - queue_full_redraw (CLUTTER_STAGE (self)); + /* Note: we don't assume that set_viewport will queue a full redraw + * since it may bail-out early if something preemptively set the + * viewport before the stage was really allocated its new size. */ + queue_full_redraw (CLUTTER_STAGE (self)); + } } /* This provides a common point of entry for painting the scenegraph