[cairo] Locking the source matrix

Carl Worth cworth at redhat.com
Mon Aug 1 14:18:23 PDT 2005


On Mon, 01 Aug 2005 15:55:48 -0400, Owen Taylor wrote:
> Here's a patch that (as discussed) sets things up so that the CTM at the
> time of cairo_set_source() or cairo_set_source_surface() is the one that
> is used for the device->pattern matrix, instead of the CTM at the time
> of drawing.

Thanks.

> It's pretty self-evident. There is some reorganization of 
> _cairo_clip_and_composite_trapezoids() to avoid the ugliness of the code
> using the passed in 'src' in conjunction with 
> gstate->source_ctm_inverse.

The implementation looks pretty good. The cleanup to the
clip_and_composite arguments is nice. I don't love use of "copy" in
the name of _cairo_gstate_copy_transformed_pattern and its friends,
(since I keep reading it as if it's doing some copy of the gstate),
but I won't put up a stink about that since I don't have a good
suggestion for a better name, and the bad suggestion I have is really
bad:

	_cairo_gstate_pattern_init_copy_transformed

which gets even worse when one tries to name the "source" and "mask"
variants. These are just static functions, so I guess I don't care
that much about the names anyway.

> Index: test/source-surface-scale-paint.c
> ===================================================================
> RCS file: /cvs/cairo/cairo/test/source-surface-scale-paint.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 source-surface-scale-paint.c
> --- test/source-surface-scale-paint.c	6 May 2005 20:23:41 -0000	1.2
> +++ test/source-surface-scale-paint.c	1 Aug 2005 20:05:21 -0000
> @@ -46,9 +46,10 @@ draw (cairo_t *cr, int width, int height
>      surface = cairo_image_surface_create_for_data ((unsigned char *) data,
>  					      CAIRO_FORMAT_ARGB32, 4, 4, 16);
>  
> -    cairo_set_source_surface (cr, surface, 2, 2);
> -    cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
>      cairo_scale (cr, 2, 2);
> +    cairo_set_source_surface (cr, surface, 1, 1);
> +    cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
> +    cairo_identity_matrix (cr);
>      cairo_paint (cr);

Changing the test to match the reference image was a nice try, but it
won't do it here. The new version of the test above is now equivalent
to what we're testing in scale-source-surface-paint.

What we need instead is a test that sets a source, then changes the
CTM, demonstrating that the original CTM was locked for the source. I
think the original test code should do that, so we'll just need to
verify that the result is correct. (And perhaps tweak the test to make
a more pleasing result---eg. change the size so that the result is
centered).

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050801/394db4ec/attachment.pgp


More information about the cairo mailing list