[cairo] Clipping

Tim Teulings rael at edge.ping.de
Sun Aug 21 14:15:37 PDT 2005


A question regarding clipping. My GUI library (that I'm in process of
writing a Cairo backend for) has a stack based clipping model.

Each stack entry consists of
* a number of rectangles that define regions that have drawn
* a number of rectangles to have to be explicitely left out when drawn

The first case is required for refreshing. I add a number of to be
refreshed rectangles which sum builds the to be redrawn area.

The second case is necessary where a parent control wants to draw its
background but want to leave out the ares its child controls. In this
case I have a bounding retangle that defines the drawing area and
several small rectangles that "bite out" some parts.

The invidual entries in my stack itself should be subtractive.

I have difficulties in assigning the correct OPERATORs for the above
operations and thus need to ask for your help :-)

When I start defining a clip stack entry I call
cairo_rectangle to add the initial rectangle

But what is the correct OPERATOR for expanding the "to be drawn" area
and which OPERATOR is correct for cutting out rectangles out of the "to
be drawn" area?

When I'm finished which my rectangles I call

Is this in priciple correct? What is the required alignment if I draw to
 windows and I do not want some apha bending of my clipping rectangles
(of course I call cairo_restore later to cleanup the stack :-))?

If I'm bulding a stack of clipping areas by calling repeately cairo_save
and cairo clip does this result in intersection of the areas or other
correlation or are the areas independent?

Are there known performance penalties regarding clipping? Something I
should be aware of?


More information about the cairo mailing list