p3/regal — pull request #51 by adhoc-bobcat (2013-03-04 19:20:11+00:00)
Title: Cleanups and fixes to PixelConversions

Fixes:
* Color conversion of 5551, 565, 4444 textures. Blue and Red were swapped.
* Luminance alpha textures. Both components were mapped to the same 8 bits out of the 16 bit value.

I had the bad luck of testing this change originally with a brightly
colored abstract block game, and I didn't noticed that the red and
blue channels were swapped. I tracked it down to a confusion on my
part about the order of the packed components in each integer, and how
it worked for bit-packed and non-bit-packed forms.

This quick fix is to just swap around masks for the Red and Blue
components for the packed-pixel types (such as
GL_UNSIGNED_SHORT_5_6_5), and adjust the corresponding tests to go
along with it.

This looks inconsistent with the surrounding declarations, as the
bit-packed forms say that red (or at least the first component) is in
the highest bits, while the non-bit-packed forms seem to say that red
is in the lowest bits. Both however are correct due to the way the
values are read out of memory.

I spent an extra day trying to make this consistent, and also
properly handle endian swapping. However I got bogged down in the
clean up, and I ran out of time to do it for now. I left some comments
around it in the code, and I'll keep my work in progress patch, but I
won't have time in the near future to do anything on it.

Along the way, I also noticed that the intensity-alpha format
specification was using the first byte for both values, instead of
using the second byte for alpha as it was supposed to.

Cleanups:

* I removed some dead declarations that I left behind before submitting.
I had meant to take them out, and missed them.

* I added some comments to document the RegalPixelConversions header.

* Removed a TODO comment around using memcpy when dealing with
conversions of to/from the intermediate
format. There is an opportunity to use a memcpy for some formats,
but for the format I called out it may not be possible (depends on
endian).