[cairo] How cairo_pattern_set_matrix() works?

Owen Taylor otaylor at redhat.com
Fri Mar 18 10:53:13 PST 2005


Silenio Quarti wrote:
> Owen Taylor <otaylor at redhat.com> wrote on 03/18/2005 01:15:14 PM:
> 
> 
>>Silenio Quarti wrote:
>>
>>>What cairo_pattern_set_matrix() should do? Should it affect every
>>>individual cell or the whole pattern coordinate system? It seems also
>>>that the matrix have the inverse effect. If the matrix scaling portion
>>>is 0.5, it actually enlarges the image, instead of reducing it.
>>>
>>>For example, in the code below I was expecting 4 surfaces/pixmaps
>>>of reduced size (30x30) to be drawn completely (one in which corner of 
> 
> the
> 
>>>rectangle (50,50, 60,60)), but instead the output is partial enlarged
>>>images.
>>>
>>>Is this the expected behavior?
>>
>>The matrix for a pattern defines a mapping from user space to pattern
>>space. So, if we set a scale on the pattern matrix of 0.5, that means
>>that for every unit we move in user space, we move 0.5 units in pattern
>>space ... that is, enlargement.
> 
> 
> Ok, that makes sense. So if I change the matrix as follow:
> 
> cairo_matrix_translate(matrix, -50, -50);
> cairo_matrix_scale(matrix, 2, 2);
> 
> shouldn't I get 4 reduced images one in which corner
> of the rectangle (50,50,60,60)? With snapshot 0.4.0,
> the output is only one image in the top/left corner of the
> rectangle. The problem is that only one quarter of the
> rectangle is filled. It seems that the pattern cell 
> was not affected.

This is a known bug in the RENDER implementation in the X server.
Try with the PNG backend. (We probably need to trigger a software
fallback in this case...)

One of the cairo-demo/cairo_snippets test cases shows this bug.

Regards,
						Owen





More information about the cairo mailing list