Revert "Merge pull request #7361 from hrydgard/color-conv-centralize"

This reverts commit f1b57dabf5, reversing
changes made to 41001637ce.
This commit is contained in:
Henrik Rydgard 2015-01-22 19:53:32 +01:00
parent 07933cad42
commit cae58cafee
33 changed files with 1195 additions and 476 deletions

View file

@ -31,7 +31,6 @@
#include "Core/System.h"
#include "Core/Reporting.h"
#include "Core/HLE/sceDisplay.h"
#include "Common/ColorConv.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUState.h"
@ -97,6 +96,22 @@ static const char color_vs[] =
" gl_Position = a_position;\n"
"}\n";
inline u16 RGBA8888toRGB565(u32 px) {
return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800);
}
inline u16 RGBA8888toRGBA4444(u32 px) {
return ((px >> 4) & 0x000F) | ((px >> 8) & 0x00F0) | ((px >> 12) & 0x0F00) | ((px >> 16) & 0xF000);
}
inline u16 BGRA8888toRGB565(u32 px) {
return ((px >> 19) & 0x001F) | ((px >> 5) & 0x07E0) | ((px << 8) & 0xF800);
}
inline u16 BGRA8888toRGBA4444(u32 px) {
return ((px >> 20) & 0x000F) | ((px >> 8) & 0x00F0) | ((px << 4) & 0x0F00) | ((px >> 16) & 0xF000);
}
void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format);
void CenterRect(float *x, float *y, float *w, float *h,
@ -406,7 +421,14 @@ void FramebufferManager::MakePixelTexture(const u8 *srcPixels, GEBufferFormat sr
{
const u16 *src = (const u16 *)srcPixels + srcStride * y;
u8 *dst = convBuf_ + 4 * width * y;
ConvertRGB565ToRGBA888F((u32 *)dst, src, width);
for (int x = 0; x < width; x++)
{
u16 col = src[x];
dst[x * 4] = Convert5To8((col) & 0x1f);
dst[x * 4 + 1] = Convert6To8((col >> 5) & 0x3f);
dst[x * 4 + 2] = Convert5To8((col >> 11) & 0x1f);
dst[x * 4 + 3] = 255;
}
}
break;
@ -414,7 +436,14 @@ void FramebufferManager::MakePixelTexture(const u8 *srcPixels, GEBufferFormat sr
{
const u16 *src = (const u16 *)srcPixels + srcStride * y;
u8 *dst = convBuf_ + 4 * width * y;
ConvertRGBA5551ToRGBA8888((u32 *)dst, src, width);
for (int x = 0; x < width; x++)
{
u16 col = src[x];
dst[x * 4] = Convert5To8((col) & 0x1f);
dst[x * 4 + 1] = Convert5To8((col >> 5) & 0x1f);
dst[x * 4 + 2] = Convert5To8((col >> 10) & 0x1f);
dst[x * 4 + 3] = (col >> 15) ? 255 : 0;
}
}
break;
@ -422,7 +451,14 @@ void FramebufferManager::MakePixelTexture(const u8 *srcPixels, GEBufferFormat sr
{
const u16 *src = (const u16 *)srcPixels + srcStride * y;
u8 *dst = convBuf_ + 4 * width * y;
ConvertRGBA4444ToRGBA8888((u32 *)dst, src, width);
for (int x = 0; x < width; x++)
{
u16 col = src[x];
dst[x * 4] = Convert4To8((col >> 8) & 0xf);
dst[x * 4 + 1] = Convert4To8((col >> 4) & 0xf);
dst[x * 4 + 2] = Convert4To8(col & 0xf);
dst[x * 4 + 3] = Convert4To8(col >> 12);
}
}
break;
@ -1325,6 +1361,7 @@ void FramebufferManager::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int
void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format) {
// Must skip stride in the cases below. Some games pack data into the cracks, like MotoGP.
const u32 *src32 = (const u32 *)src;
if (format == GE_FORMAT_8888) {
u32 *dst32 = (u32 *)dst;
if (src == dst) {
@ -1350,13 +1387,17 @@ void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u
case GE_FORMAT_565: // BGR 565
if (UseBGRA8888()) {
for (u32 y = 0; y < height; ++y) {
ConvertBGRA8888ToRGB565(dst16, src32, width);
for (u32 x = 0; x < width; ++x) {
dst16[x] = BGRA8888toRGB565(src32[x]);
}
src32 += srcStride;
dst16 += dstStride;
}
} else {
for (u32 y = 0; y < height; ++y) {
ConvertRGBA8888ToRGB565(dst16, src32, width);
for (u32 x = 0; x < width; ++x) {
dst16[x] = RGBA8888toRGB565(src32[x]);
}
src32 += srcStride;
dst16 += dstStride;
}
@ -1380,13 +1421,17 @@ void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u
case GE_FORMAT_4444: // ABGR 4444
if (UseBGRA8888()) {
for (u32 y = 0; y < height; ++y) {
ConvertBGRA8888ToRGBA4444(dst16, src32, width);
for (u32 x = 0; x < width; ++x) {
dst16[x] = BGRA8888toRGBA4444(src32[x]);
}
src32 += srcStride;
dst16 += dstStride;
}
} else {
for (u32 y = 0; y < height; ++y) {
ConvertRGBA8888ToRGBA4444(dst16, src32, width);
for (u32 x = 0; x < width; ++x) {
dst16[x] = RGBA8888toRGBA4444(src32[x]);
}
src32 += srcStride;
dst16 += dstStride;
}