Avoid triple buffering
Because drawing occurs in the window back buffer and not directly on the screen, most of the motivation for doing your own double buffering is no longer present. In the past, it was sometimes necessary to composite your drawing into an offscreen
Simplify dirty region updates
In order for QuickDraw to know which parts of the window back buffer to flush to the screen, every call to QuickDraw needs to record the region it dirties. When a drawing sequence consists of a number of small items contained within a well-known larger area, it is usually best to dirty the whole region at once rather than having every QuickDraw routine incrementally add to the dirty region. This way, you short-circuit the dirty region updating code inside each QuickDraw routine.
Assuming all the small QuickDraw operations are enclosed in a bigger rectangular region (
Setting the dirty region to a large rectangular region accomplishes two goals. First, it makes sure that the dirty region is rectangular, which greatly simplifies any subsequent region operations. Second, the large region encompasses all of the regions dirtied by the individual QuickDraw drawing calls, thus turning their dirty region updates into trivial intersection checks of the regions' bounding rectangles.
This technique is particularly handy for speeding up the drawing of complex vector graphics.
Short-circuit QuickDraw's implicit LockPortBits
On Mac OS X, your window's back buffer is shared between your application and the window server. In order for your application to access the back buffer contents, the window server must be locked out temporarily. Because QuickDraw primitives are typically not bracketed by any sort of begin/end sequence, each QuickDraw routine needs to make sure the port bits are locked by implicitly calling
Luckily, calls to
This ensures that the port bits are locked only once for the entire sequence of QuickDraw calls and the nested implicit
Don't flush to the screen more often than necessary
For most applications, there is no need to flush more than 30 frames per second to obtain smooth animation. Flushing more often only results in additional CPU overhead and may end up slowing down the desired animation.
To control when flushing occurs you want to use a time-based strategy aimed at providing 30 fps:
Mac OS X introduced some new performance characteristics for QuickDraw drawing, but the information presented here will help developers eliminate their graphics performance bottlenecks.
Contact ADC | ADC Site Map | ADC Advanced Search
|For information about Apple Products, please visit Apple.com.|
Contact Apple | Privacy Notice
Copyright © 2002 Apple Computer, Inc. All rights reserved.