Render transformation matrix

Damien Ciabrini Damien.Ciabrini at sophia.inria.fr
Wed Jan 26 08:01:28 PST 2005


Owen,
Thanks for your quick answer

> On Wed, 2005-01-26 at 14:35 +0100, Damien Ciabrini wrote:
> 
> 
>>I'm trying to add support for the Render transformation matrix for the 
>>Kdrive mga driver, and I'd like to know if I understood the problem 
>>correctly.
>>
>>In a user program, I want to composite a Picture with a certain zoom 
>>factor. I do it with the following piece of code:
>>
>>  XRenderSetPictureTransform(dpy,icon_pic,&xform);
>>  // XRenderSetPictureFilter(dpy,icon_pic,FilterBilinear, 0, 0);
>>  XRenderComposite(dpy,composite_op,icon_pic, 0, back_buffer_pic,
>>                   0, 0, 0, 0, zoomed_x[i],zoomed_y[i],
>>		  zoomed_size[i],zoomed_size[i]);
>>and this is my transformation matrix:
>>   XTransform xform = {{
>>	{ 1.0f, 0.0f, 0.0f },
>>	{ 0.0f, 1.0f, 0.0f },
>>	{ 0.0f, 0.0f, 2.0f }
>>   }};
>>I assume it would give the same result with the following matrix:
>>   XTransform xform = {{
>>	{ 2.0f, 0.0f, 0.0f },
>>	{ 0.0f, 2.0f, 0.0f },
>>	{ 0.0f, 0.0f, 1.0f }
>>   }};
> 
> 
> Are you actually passing in floating point values, or is the
> above just a shorthand? (the code above will give you matrices that 
> are off by a factor of 65536.. you need to use XDoubleToFixed)
>
Ok, stupid me... I though it was XDoubleToFloat :)

> But in any case, the two matrices aren't equivalent ... I'm pretty
> sure that the code just ignores the 3rd line of the transform,
> since the code isn't really dealing with homogeneous coordinates,
> but if it wasn't, then the first matrix applied to [1,0,1] would
> give [1,0,2] which is equivalent to [0.5,0,1]. The second 
> gives [2,0,1].
Thanks for the clarification.

> 
> So, this may not be your question, but if I wanted to zoom a picture
> by a factor of s, I'd use the matrix
> 
>  DoubleToFixed(1/s), 0,                  0
>  0,                  DoubleToFixed(1/s), 0
>  0,                  0,                  1
> 
> It's 1/s since the matrix transforms from destination coordinates to
> source coordinates.
> 
> Regards,
> 						Owen
> 
thank you so much ! It works like a charm :)

[FYI, my test program was a simple X11 clone of a well known dock 
application. Maybe I should post it on this ML. In addition to 
rendercheck, It could serve as a means to test/profile gfx drivers...?]



More information about the xorg mailing list