[cairo] bug in backend to device transformation

Behdad Esfahbod behdad at behdad.org
Wed Sep 12 14:44:06 PDT 2007

On Wed, 2007-09-12 at 13:44 -0400, Jonathan Gramain wrote:
> Hello everyone
> I think I've found a bug in cairo-gstate.c, concerning the matrix
> transformation in the method _cairo_gstate_backend_to_user_rectangle,
> here is the current code :
>    cairo_matrix_t matrix_inverse; 
>     cairo_matrix_multiply (&matrix_inverse, &gstate->ctm_inverse,
>                            &gstate->target->device_transform_inverse);
>     _cairo_matrix_transform_bounding_box (&matrix_inverse, 
>                                           x1, y1, x2, y2, is_tight);
> Shouldn't we first apply the device inverse transform before applying
> the CTM inverse? I'm doing some work on a canvas based on libpapyrus,
> and I encountered a problem when I tried to draw on a GdkWindow (using
> gdk_cairo_create) embedded in a GtkScrolledWindow, and at the same
> time applying rotations and scaling on the CTM : the scrolled window
> moves the GdkWindow, thus the device transform is a translation on
> this window, and so the clipping region was not right, and eventually
> went outside of the visible region. 

You are absolutely correct.  Thanks for tracking your problem down!
I have committed the fix now.

> Hope this helps.
> Jonathan Gramain

Have fun with cairo!


"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the cairo mailing list