[cairo] clipmask of multiple rects in different angles

Theo Veenker theoveenker at gmail.com
Wed Jul 20 21:46:48 UTC 2016

On 20/07/16 22:28, Enrico Weigelt, metux IT consult wrote:
> On 20.07.2016 21:15, Theo Veenker wrote:
>> Not an answer to your question, but if you just take the bounding box
>> of the modified element and use that as a clip mask and clear and
>> redraw everything that is in or partly in the box you can get very
>> good performance in my experience.
> I'm meanwhile clipping to only the regions to be redrawn. Doesn't seem
> to get faster (xcb), but even slower (drm).
> Maybe the damage tracking itself is slowing it down ... I'll now try to
> cache the matrices.

Are you also saving the bounding boxes of your graphic objects? I 
suppose it is not efficient if you need recalculate the bbox (by drawing 
onto a dummy surface) before each redraw.

What also helps *a lot* is drawing only once every vertical retrace. In 
my setup all graphic objects have a current and a new state (this means 
every attribute such as x or y, color etc. is doubled). Let's say we're 
not using a back-buffer then a graphics expose will cause a redraw using 
the current state of the objects. And only at vertical retrace the 
drawing is updated to refrect the new state. In this aproach you can 
change the state of objects as often as you want with nearly zero CPU 
load. Only at retrace when changes are drawn you will have load. So if 
you're the only process drawing you'll have almost a full video frame to 
do the job; that should be plenty of time.

> By the way: is there a way to create a region and subsequently add new
> boxes to it, without going via a context ?

Personally I don't use the cairo region type. I just create my own array 
of integer rectangles (do floor on x, and y; ceil on w and h) from which 
the clip mask is then created.


More information about the cairo mailing list