[cairo] Zero matrix transformation

Jeff Muizelaar jeff at infidigm.net
Wed Mar 19 06:24:55 PDT 2008


On Wed, Mar 19, 2008 at 12:22:10PM +0000, Daniel Kraft wrote:
> Hi,
> 
> I just set-up git cairo and pixman and was playing around a bit with it. 
>   On the GSoC ideas page there's one item:
> 
> Fix cairo so that a degenerate matrix draws nothing rather than 
> triggering an error state. That is: cairo_scale (cr, 0, 0); should not 
> cause an error, (though maybe it shouldn't actually draw nothing for 
> painting an infinite source pattern---compute the average color for a 
> surface-based source pattern perhaps?).
> 
> I tried to reproduce this, but for me (using the hello-program from the 
> FAQ with this scale-statement added) this seems to work.  Using numbers 
> between 0 and 1, the writing becomes smaller as I would expect; for 
> using 0, nothing is drawn, as the item states as desired behaviour.
> 
> Did I understand something wrong, did my test not trigger the error for 
> some reason, is this already done...?  I'd like to start working on 
> cairo a bit to make experiences, and this looked not too hard.  If you 
> have any other suggestions, I'd be happy to hear from you!

In your example, if you call cairo_status(cr) after the call to
cairo_scale(cr, 0, 0) you should get CAIRO_STATUS_INVALID_MATRIX.
Alternatively, you can try changing the scale back to 1, 1 with
cairo_set_matrix after setting it to 0, 0 and you should not be able to
draw anything.

The desired behaviour is that nothing be drawn only when the matrix is
degenerate. If it becomes well-formed drawing should work as normal
instead of the cairo context remaining in an error state.

-Jeff


More information about the cairo mailing list