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.
This commit is contained in:
Robert Bragg 2010-09-08 11:32:29 +01:00
parent 1e7f22db3b
commit 5d1600d603

View File

@ -232,6 +232,7 @@ clutter_stage_allocate (ClutterActor *self,
ClutterAllocationFlags flags) ClutterAllocationFlags flags)
{ {
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv; ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
ClutterGeometry prev_geom;
ClutterGeometry geom = { 0, }; ClutterGeometry geom = { 0, };
gboolean origin_changed; gboolean origin_changed;
gint width, height; gint width, height;
@ -241,6 +242,8 @@ clutter_stage_allocate (ClutterActor *self,
if (priv->impl == NULL) if (priv->impl == NULL)
return; return;
clutter_actor_get_allocation_geometry (self, &prev_geom);
width = clutter_actor_box_get_width (box); width = clutter_actor_box_get_width (box);
height = clutter_actor_box_get_height (box); height = clutter_actor_box_get_height (box);
_clutter_stage_window_get_geometry (priv->impl, &geom); _clutter_stage_window_get_geometry (priv->impl, &geom);
@ -321,6 +324,8 @@ clutter_stage_allocate (ClutterActor *self,
} }
clutter_actor_get_allocation_geometry (self, &geom); clutter_actor_get_allocation_geometry (self, &geom);
if (geom.width != prev_geom.width || geom.height != prev_geom.height)
{
_clutter_stage_set_viewport (CLUTTER_STAGE (self), _clutter_stage_set_viewport (CLUTTER_STAGE (self),
0, 0, geom.width, geom.height); 0, 0, geom.width, geom.height);
@ -328,6 +333,7 @@ clutter_stage_allocate (ClutterActor *self,
* since it may bail-out early if something preemptively set the * since it may bail-out early if something preemptively set the
* viewport before the stage was really allocated its new size. */ * viewport before the stage was really allocated its new size. */
queue_full_redraw (CLUTTER_STAGE (self)); queue_full_redraw (CLUTTER_STAGE (self));
}
} }
/* This provides a common point of entry for painting the scenegraph /* This provides a common point of entry for painting the scenegraph