Graphics Environment: 11.2 Windowing and Clipping: Clipping

Up: GEOS SDK TechDocs| Up | Prev: 11.1 Palettes | Next: 11.3 Signalling Updates
GrSetClipPath(), GrSetClipRect(), GrGetClipRegion(), GrTestRectInMask(), GrSetWinClipRect(), GrGetMaskBounds(), GrGetMaskBoundsDWord(), GrGetWinBounds(), GrGetWinBoundsDWord()

The graphics system provides some routines which allow geodes to work together with the windowing system to control clipping. A window's clipping region, you will recall, is that area of the window that must be redrawn. It corresponds to that area of the graphics space which is visible inside the window and not obscured by another window. The area outside the clipping region is supposed to be that area that doesn't need to be redrawn. Geodes which are certain that part of their graphics space doesn't need to be (or shouldn't be) redrawn can restrict their clipping region to exclude this portion.

Restricting the clipping region can lead to quicker redraws, since the graphics system doesn't have as much to redraw. Arcade games in which most of the action only takes place in one or two areas of the display can restrict their clipping region to speed redraws in the smaller, active areas. Also, the clip region can be used as a sort of stencil.

The clip region is defined by a path which describes the boundaries of the region. A window typically begins with a rectangular clip region. If it is partially obscured by other windows, this rectangle will have "bites" taken out of it. This is done using normal path routines used for combining paths. The clipping path of a newly obscured window is determined by computing its old clipping path with that of the obscuring window.

Since any number of paths may be combined, it is a simple matter for the graphics system to combine a window's clipping path with a geode's path chosen to restrict the clipping region. Thus the geode can define its restricted clipping area without knowing anything about the window's present status.

GrSetClipPath() sets the geode-defined path to use when restricting the window's clip path. GrSetClipRect() is an optimization of GrSetClipPath() to handle the most common case in which the new path element is a rectangle.

GrGetClipRegion() returns the Region data structure corresponding to the current clip path. GrGetMaskBounds() and GrGetMaskBoundsDWord() return the bounds of the current clipping path.To find out whether there is a clip path at all, just call GrTestPath() and pass GPT_CLIP.

GrTestRectInMask() determines whether a rectangular area lies fully, partially, or not at all within the clipping area. This routine is useful for optimizing redraws.

GrSetWinClipRect() and GrSetWinClipPath() set the clipping path associated with the window; you should never have occasion to use it. GrGetWinBounds() and GrGetWinBoundsDWord() return the bounds of the window clipping path. To find out whether there is a window clipping path at all, call GrTestPath() and pass GPT_WIN_CLIP.


Up: GEOS SDK TechDocs| Up | Prev: 11.1 Palettes | Next: 11.3 Signalling Updates