Check out the new USENIX Web site. next up previous
Next: Delayed Updates Up: Architecture of the Canvas Previous: Behavior of Items

Delayed Update/Redraw Model

One of the goals of the canvas is to eliminate flicker when drawing items. Flicker is caused when an area is repainted multiple times with different colors; for example, a stack of colored rectangles would flicker if it were painted directly to the screen, one rectangle after another.

The canvas solves this problem by using a special form of double-buffering. When an area of the canvas needs to be repainted, the following actions take place:

  1. The canvas creates a temporary, offscreen pixmap with the same size as the area that needs to be repainted.

  2. If an item's bounding box intersects the area that needs to be repainted, the canvas asks the item to paint itself to the pixmap created in (1). The canvas thus walks the tree of items in the normal Z-order.

  3. The canvas does a bitblt of the pixmap to the screen and destroys the pixmap.

The visual effect is that the whole area is painted simultaneously, eliminating all flicker.

This process actually takes place during the idle loop of the application. Repainting the canvas in the idle loop means that at that point all interaction between the application and canvas items is finished, i.e. the application literally has nothing else to do, so it is appropriate to flush all pending redraws.



Subsections
next up previous
Next: Delayed Updates Up: Architecture of the Canvas Previous: Behavior of Items
Federico Mena Quintero
2000-05-08