Foramt cleanup on gl-rgb.c

This commit is contained in:
Josh Pearson 2015-09-09 11:45:09 -07:00
parent 3df4244bc2
commit dd765f80d6
3 changed files with 44 additions and 44 deletions

View File

@ -119,41 +119,41 @@ uint16 __glKosAverageBiPixelARGB4444(uint16 p1, uint16 p2) {
//===================================================================================================//
//== Colorspace Conversion ==//
static uint16 _glConvPixelRGBAU32(uint8 r, uint8 g, uint8 b, uint8 a) {
static uint16 _glKosConvPixelRGBAU32(uint8 r, uint8 g, uint8 b, uint8 a) {
return (uint16)((a & RGB4_MAX) << ARGB4444_ALPHA_SHIFT) |
((r & RGB4_MAX) << ARGB4444_RED_SHIFT) |
((g & RGB4_MAX) << ARGB4444_GREEN_SHIFT) |
((b & RGB4_MAX));
}
static uint16 _glConvPixelRGBU24(uint8 r, uint8 g, uint8 b) {
static uint16 _glKosConvPixelRGBU24(uint8 r, uint8 g, uint8 b) {
return (uint16)((r & RGB5_MAX) << RGB565_RED_SHIFT) |
((g & RGB6_MAX) << RGB565_GREEN_SHIFT) |
((b & RGB5_MAX));
}
static void _glConvPixelsRGBF(int w, int h, float *src, uint16 *dst) {
static void _glKosConvPixelsRGBF(int w, int h, float *src, uint16 *dst) {
int i;
for(i = 0; i < w * h; i++) {
dst[i] = _glConvPixelRGBU24((uint8)(src[i * 3 + 0] * RGB5_MAX),
(uint8)(src[i * 3 + 1] * RGB6_MAX),
(uint8)(src[i * 3 + 2] * RGB5_MAX));
dst[i] = _glKosConvPixelRGBU24((uint8)(src[i * 3 + 0] * RGB5_MAX),
(uint8)(src[i * 3 + 1] * RGB6_MAX),
(uint8)(src[i * 3 + 2] * RGB5_MAX));
}
}
static void _glConvPixelsRGBAF(int w, int h, float *src, uint16 *dst) {
static void _glKosConvPixelsRGBAF(int w, int h, float *src, uint16 *dst) {
int i;
for(i = 0; i < w * h; i++) {
dst[i] = _glConvPixelRGBAU32((uint8)(src[i * 4 + 0] * RGB4_MAX),
(uint8)(src[i * 4 + 1] * RGB4_MAX),
(uint8)(src[i * 4 + 2] * RGB4_MAX),
(uint8)(src[i * 4 + 3] * RGB4_MAX));
dst[i] = _glKosConvPixelRGBAU32((uint8)(src[i * 4 + 0] * RGB4_MAX),
(uint8)(src[i * 4 + 1] * RGB4_MAX),
(uint8)(src[i * 4 + 2] * RGB4_MAX),
(uint8)(src[i * 4 + 3] * RGB4_MAX));
}
}
static void _glConvPixelsRGBU24(int w, int h, uint8 *src, uint16 *dst) {
static void _glKosConvPixelsRGBU24(int w, int h, uint8 *src, uint16 *dst) {
unsigned char r, g, b;
int i;
@ -162,11 +162,11 @@ static void _glConvPixelsRGBU24(int w, int h, uint8 *src, uint16 *dst) {
g = (src[i * 3 + 1] * RGB6_MAX) / RGB8_MAX;
b = (src[i * 3 + 2] * RGB5_MAX) / RGB8_MAX;
dst[i] = _glConvPixelRGBU24(r, g, b);
dst[i] = _glKosConvPixelRGBU24(r, g, b);
}
}
static void _glConvPixelsRGBAU32(int w, int h, uint8 *src, uint16 *dst) {
static void _glKosConvPixelsRGBAU32(int w, int h, uint8 *src, uint16 *dst) {
unsigned char r, g, b, a;
int i;
@ -176,11 +176,11 @@ static void _glConvPixelsRGBAU32(int w, int h, uint8 *src, uint16 *dst) {
b = (src[i * 4 + 2] * RGB4_MAX) / RGB8_MAX;
a = (src[i * 4 + 3] * RGB4_MAX) / RGB8_MAX;
dst[i] = _glConvPixelRGBAU32(r, g, b, a);
dst[i] = _glKosConvPixelRGBAU32(r, g, b, a);
}
}
static void _glConvPixelsRGBS24(int w, int h, int8 *src, uint16 *dst) {
static void _glKosConvPixelsRGBS24(int w, int h, int8 *src, uint16 *dst) {
unsigned char r, g, b;
int i;
@ -189,11 +189,11 @@ static void _glConvPixelsRGBS24(int w, int h, int8 *src, uint16 *dst) {
g = ((src[i * 3 + 1] + S8_NEG_OFT) * RGB6_MAX) / RGB8_MAX;
b = ((src[i * 3 + 2] + S8_NEG_OFT) * RGB5_MAX) / RGB8_MAX;
dst[i] = _glConvPixelRGBU24(r, g, b);
dst[i] = _glKosConvPixelRGBU24(r, g, b);
}
}
static void _glConvPixelsRGBAS32(int w, int h, int8 *src, uint16 *dst) {
static void _glKosConvPixelsRGBAS32(int w, int h, int8 *src, uint16 *dst) {
unsigned char r, g, b, a;
int i;
@ -203,11 +203,11 @@ static void _glConvPixelsRGBAS32(int w, int h, int8 *src, uint16 *dst) {
b = ((src[i * 4 + 2] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX;
a = ((src[i * 4 + 3] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX;
dst[i] = _glConvPixelRGBAU32(r, g, b, a);
dst[i] = _glKosConvPixelRGBAU32(r, g, b, a);
}
}
static void _glConvPixelsRGBS48(int w, int h, int16 *src, uint16 *dst) {
static void _glKosConvPixelsRGBS48(int w, int h, int16 *src, uint16 *dst) {
unsigned char r, g, b;
int i;
@ -216,11 +216,11 @@ static void _glConvPixelsRGBS48(int w, int h, int16 *src, uint16 *dst) {
g = ((src[i * 3 + 1] + S16_NEG_OFT) * RGB6_MAX) / RGB16_MAX;
b = ((src[i * 3 + 2] + S16_NEG_OFT) * RGB5_MAX) / RGB16_MAX;
dst[i] = _glConvPixelRGBU24(r, g, b);
dst[i] = _glKosConvPixelRGBU24(r, g, b);
}
}
static void _glConvPixelsRGBAS64(int w, int h, int16 *src, uint16 *dst) {
static void _glKosConvPixelsRGBAS64(int w, int h, int16 *src, uint16 *dst) {
unsigned char r, g, b, a;
int i;
@ -230,11 +230,11 @@ static void _glConvPixelsRGBAS64(int w, int h, int16 *src, uint16 *dst) {
b = ((src[i * 4 + 2] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX;
a = ((src[i * 4 + 3] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX;
dst[i] = _glConvPixelRGBAU32(r, g, b, a);
dst[i] = _glKosConvPixelRGBAU32(r, g, b, a);
}
}
static void _glConvPixelsRGBU48(int w, int h, uint16 *src, uint16 *dst) {
static void _glKosConvPixelsRGBU48(int w, int h, uint16 *src, uint16 *dst) {
unsigned char r, g, b;
int i;
@ -243,11 +243,11 @@ static void _glConvPixelsRGBU48(int w, int h, uint16 *src, uint16 *dst) {
g = ((src[i * 3 + 1]) * RGB6_MAX) / RGB16_MAX;
b = ((src[i * 3 + 2]) * RGB5_MAX) / RGB16_MAX;
dst[i] = _glConvPixelRGBU24(r, g, b);
dst[i] = _glKosConvPixelRGBU24(r, g, b);
}
}
static void _glConvPixelsRGBAU64(int w, int h, uint16 *src, uint16 *dst) {
static void _glKosConvPixelsRGBAU64(int w, int h, uint16 *src, uint16 *dst) {
unsigned char r, g, b, a;
int i;
@ -257,54 +257,54 @@ static void _glConvPixelsRGBAU64(int w, int h, uint16 *src, uint16 *dst) {
b = (src[i * 4 + 2] * RGB4_MAX) / RGB16_MAX;
a = (src[i * 4 + 3] * RGB4_MAX) / RGB16_MAX;
dst[i] = _glConvPixelRGBAU32(r, g, b, a);
dst[i] = _glKosConvPixelRGBAU32(r, g, b, a);
}
}
void _glPixelConvertRGB(int format, int w, int h, void *src, uint16 *dst) {
void _glKosPixelConvertRGB(int format, int w, int h, void *src, uint16 *dst) {
switch(format) {
case GL_BYTE:
_glConvPixelsRGBS24(w, h, (int8 *)src, dst);
_glKosConvPixelsRGBS24(w, h, (int8 *)src, dst);
break;
case GL_UNSIGNED_BYTE:
_glConvPixelsRGBU24(w, h, (uint8 *)src, dst);
_glKosConvPixelsRGBU24(w, h, (uint8 *)src, dst);
break;
case GL_SHORT:
_glConvPixelsRGBS48(w, h, (int16 *)src, dst);
_glKosConvPixelsRGBS48(w, h, (int16 *)src, dst);
break;
case GL_UNSIGNED_SHORT:
_glConvPixelsRGBU48(w, h, (uint16 *)src, dst);
_glKosConvPixelsRGBU48(w, h, (uint16 *)src, dst);
break;
case GL_FLOAT:
_glConvPixelsRGBF(w, h, (float *)src, dst);
_glKosConvPixelsRGBF(w, h, (float *)src, dst);
break;
}
}
void _glPixelConvertRGBA(int format, int w, int h, void *src, uint16 *dst) {
void _glKosPixelConvertRGBA(int format, int w, int h, void *src, uint16 *dst) {
switch(format) {
case GL_BYTE:
_glConvPixelsRGBAS32(w, h, (int8 *)src, dst);
_glKosConvPixelsRGBAS32(w, h, (int8 *)src, dst);
break;
case GL_UNSIGNED_BYTE:
_glConvPixelsRGBAU32(w, h, (uint8 *)src, dst);
_glKosConvPixelsRGBAU32(w, h, (uint8 *)src, dst);
break;
case GL_SHORT:
_glConvPixelsRGBAS64(w, h, (int16 *)src, dst);
_glKosConvPixelsRGBAS64(w, h, (int16 *)src, dst);
break;
case GL_UNSIGNED_SHORT:
_glConvPixelsRGBAU64(w, h, (uint16 *)src, dst);
_glKosConvPixelsRGBAU64(w, h, (uint16 *)src, dst);
break;
case GL_FLOAT:
_glConvPixelsRGBAF(w, h, (float *)src, dst);
_glKosConvPixelsRGBAF(w, h, (float *)src, dst);
break;
}
}

View File

@ -62,9 +62,9 @@ typedef GLfloat GLrgba4f[4];
#define ARGB_PACK_ARGBF(a,r,g,b) (((a*0xFF) << 24) | ((r*0xFF) << 16) | ((g*0xFF)<<8) | (b*0xFF))
#define S8_NEG_OFT 128 // Absolute Value of Minimum 8bit Signed Range //
#define S16_NEG_OFT 32768 // Absolute Value of Minimum bit Signed Range //
#define S16_NEG_OFT 32768 // Absolute Value of Minimum 16bit Signed Range //
void _glPixelConvertRGB(int format, int w, int h, void *src, uint16 *dst);
void _glPixelConvertRGBA(int format, int w, int h, void *src, uint16 *dst);
void _glKosPixelConvertRGB(int format, int w, int h, void *src, uint16 *dst);
void _glKosPixelConvertRGBA(int format, int w, int h, void *src, uint16 *dst);
#endif

View File

@ -273,13 +273,13 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
switch(internalFormat) {
case GL_RGB:
_glPixelConvertRGB(type, width, height, (void *)data, tex);
_glKosPixelConvertRGB(type, width, height, (void *)data, tex);
GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->color = (PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED);
sq_cpy(GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data, tex, bytes);
break;
case GL_RGBA:
_glPixelConvertRGBA(type, width, height, (void *)data, tex);
_glKosPixelConvertRGBA(type, width, height, (void *)data, tex);
GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->color = (PVR_TXRFMT_ARGB4444 | PVR_TXRFMT_NONTWIDDLED);
sq_cpy(GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data, tex, bytes);
break;