Quartz does not handle window invalidation and repainting. That’s the job of whatever window system is in use—Cocoa or Carbon. Quartz is exactly like QuickDraw in this regard. QuickDraw doesn’t know anything about invalidation and update regions; that’s always been handled by the Window Manager.
To eliminate unnecessary drawing in your application, you can follow one of two approaches— draw the changed areas only, or intersect the changed areas with the context’s clipping area before drawing the window. If the changed area is a complex shape, it may be sufficient to clip using a bounding box that encloses the shape instead of trying to construct a path that represents the shape.
Carbon applications need to use windows in compositing mode, and then, instead of drawing into the window content area, draw into views. An application can invalidate all or part of a view using functions such as
HIViewSetNeedsDisplay, which marks a view as needing to be completely redrawn, or completely valid.
HIViewSetNeedsDisplayInRect, which marks a rectangle contained in a view as needing to be redrawn, or valid. The rectangle that you pass to the function is intersected with the visible portion of the view.
HIViewSetNeedsDisplayInShape, which marks a portion of a view as either needing to be redrawn or valid. The shape that you pass to the function is intersected with the visible portion of the view.
When the application draws in the Quartz context obtained from the Carbon even kEventControlDraw, the clipping area is already configured to eliminate unnecessary drawing. For more information, see Upgrading to the Mac OS X HIToolbox, HIView Programming Guide, and HIView Reference.
Last updated: 2006-09-05