Avoid drawing twice if relayout queues a draw
authorOwen W. Taylor <otaylor@redhat.com>
Thu, 12 Mar 2009 19:33:36 +0000 (15:33 -0400)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 13 Mar 2009 15:20:50 +0000 (15:20 +0000)
It's reasonably normal for a relayout of the stage to cause the stage
to be queued for drawing; for this reason we should do the relayout before
we clear stage->update_idle. (But want to clear update_idle() before actually
doing the redraw to handle the corner case where the draw queues another
redraw.)

clutter/clutter-stage.c

index 925c3b8..98172cb 100644 (file)
@@ -356,6 +356,13 @@ redraw_update_idle (gpointer user_data)
   ClutterStage *stage = user_data;
   ClutterStagePrivate *priv = stage->priv;
 
+  /* clutter_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 size.
+   */
+  _clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage));
+
   if (priv->update_idle)
     {
       g_source_remove (priv->update_idle);