[cairo] On recovery from errors in cairo

Bill Spitzak spitzak at d2.com
Fri Sep 22 13:12:40 PDT 2006

I agree that this should NOT be any kind of error. Degenerate 
0-determinant transforms MUST be supported in Cairo. If you are worried 
about the inverse transform, have cairo_device_to_user() return a bad 
status and set the results to Infinity, but don't make a permanent 
error, and certainly allow all other drawing to work.

Having written some Illustrator-type software, I know for a fact that it 
is *EXTREMELY* PAINFUL for the higher-level software to avoid such 
transforms, as I used a backend that was similar. Changing the backend 
to handle the degenerate transform (a tiny change to the hit-detect 
code) made the whole program much simpler by removing all the stuff 
tracking if the transform was degenerate. For this reason I am convinced 
that degenerate transforms must be supported at the lowest level.

I have not hit this in Cairo because I am completely unable to use 
cairo's transforms due to them changing the line width. However I'm sure 
our software would hit this error within seconds if it actually used the 
Cairo transforms.

Note that if changes are made so that the pen and font are not affected 
by the current transform, or if hairline mode is supported, doing a 
stroke or text drawing in a degenerate transform will still draw something.

Behdad Esfahbod wrote:

> This very specific one has caught me bad.  In my case, it was
> cairo_scale (cr, 0, 0).  I argue that this shouldn't put the context in
> an error state:
>   cairo_save (cr);
>   cairo_scale (cr, 0, 0);
>   cairo_restore (cr);
> but it currently does.

More information about the cairo mailing list