wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)

Chris Robinson chris.kcat at
Wed Jul 23 12:18:57 CDT 2008

On Wednesday 23 July 2008 09:10:02 am Stefan Dösinger wrote:
> The patch looks reasonably, just one small thing: There is a count_bits
> function implemented in utils.c, which as far as I can see does the same as
> getMaskSize. Can you check if you can reuse it?

Maybe it would be better if the table was changed to have a bit offset and a 
mask size, instead of the actual mask. All the bits for any given component 
are always continuous, and things would be easier to handle with the offset 
and size (eg. the float formats could get a proper mask; not that they could 
be converted in this way, though). So for a generic converter, you can 
basically get:

outcolor = (((incolor>>infmt->r_offset)&((1<<infmt->r_size)-1)) * 
outfmt->r_size / infmt->r_size) << outfmt->r_offset;
outcolor |= (((incolor>>infmt->g_offset)&((1<<infmt->g_size)-1)) * 
outfmt->g_size / infmt->g_size) << outfmt->g_offset;
outcolor |= (((incolor>>infmt->b_offset)&((1<<infmt->b_size)-1)) * 
outfmt->b_size / infmt->b_size) << outfmt->b_offset;
outcolor |= (((incolor>>infmt->a_offset)&((1<<infmt->a_size)-1)) * 
outfmt->a_size / infmt->a_size) << outfmt->a_offset;

For any non-mixed unsigned integer type.

More information about the wine-devel mailing list