Commit 6e0116fa by Nicolas Capens

Support different component orders for decoding RGB565.

Bug 21635916 Change-Id: I1216a96d17228e53155aaaf24d43365afb5cead7 Reviewed-on: https://swiftshader-review.googlesource.com/3392Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 303d2407
...@@ -182,15 +182,29 @@ namespace ...@@ -182,15 +182,29 @@ namespace
void LoadImageRow<RGB565>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width, sw::Format internalFormat) void LoadImageRow<RGB565>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width, sw::Format internalFormat)
{ {
const unsigned short *source565 = reinterpret_cast<const unsigned short*>(source); const unsigned short *source565 = reinterpret_cast<const unsigned short*>(source);
unsigned char *dest565 = dest + xoffset * 4; unsigned char *destB = dest + xoffset * 4;
if(internalFormat == sw::FORMAT_X8R8G8B8 || internalFormat == sw::FORMAT_A8R8G8B8)
{
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
unsigned short rgba = source565[x]; unsigned short rgba = source565[x];
dest565[4 * x + 0] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2); destB[4 * x + 0] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2);
dest565[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9); destB[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9);
dest565[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13); destB[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
dest565[4 * x + 3] = 0xFF; destB[4 * x + 3] = 0xFF;
}
}
else // internalFormat == sw::FORMAT_X8B8G8R8 || internalFormat == sw::FORMAT_A8B8G8R8
{
for(int x = 0; x < width; x++)
{
unsigned short rgba = source565[x];
destB[4 * x + 0] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
destB[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9);
destB[4 * x + 2] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2);
destB[4 * x + 3] = 0xFF;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment