Pixman

Soeren Sandmann sandmann at daimi.au.dk
Wed Aug 8 09:28:36 PDT 2007


Lukas Hejtmanek <xhejtman at ics.muni.cz> writes:

> Hello,
> 
> I took a look at pixman_blt_mmx code and I'm a bit confused:
> 
> 1  } else if (src_bpp == 32) {
> 2  src_stride = src_stride * sizeof (uint32_t) / 4;
> 3  dst_stride = dst_stride * sizeof (uint32_t) / 4;
> 4  src_bytes = (uint8_t *)(((uint32_t *)src_bits) + src_stride * (src_y) + (src_x));
> 5  dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + dst_stride * (dst_y) + (dst_x));
> 6  byte_width = 4 * width;
> 7  src_stride *= 4;
> 8  dst_stride *= 4;
> 9  } else {
> 
> what are the lines 2 and 3 used for?
> 
> according to lines 4 and 5, it seems that {src,dst}_stride should be 
> width * bpp / 8 and src_x should be also multiplied by bpp / 8.
> But on the line 7 and 8 it seems that {src,dst}_stride get multiplied by bpp/8
> again. Or am I something missing?

Initially, the stride is given in "number of uint32_t's". Lines 2 and
3 converts this to "number of pixels", which is a no-op since the
pixels are 32 bit deep here.

Then in line 7 and 8 the strides are converted to "number of bytes"
which is what the loop uses. The 16 bit version of the code may be
easier to understand since the first conversion is not a no-op there.

Previously there used to be an FbBits type which in theory could be
typedef'ed to other than uint32_t, so the code would have read:

        - convert from "number of FbBits" to "number of 32 bit pixels"
        - convert from "number of 32 bit pixels" to "number of bytes".

It may be worthwhile reinstating the FbBits type, although the code
was known to be broken if that type was ever anything but uint32_t.



Soren 



More information about the xorg mailing list