SDL: fix -prescale 0.153 regression. [R. Belmont]

This commit is contained in:
R. Belmont 2014-06-12 03:11:37 +00:00
parent ab1a0b37b6
commit ead56f4d3c

View File

@ -2284,7 +2284,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
// copyline_palette16 // copyline_palette16
//============================================================ //============================================================
INLINE void copyline_palette16(UINT32 *dst, const UINT16 *src, int width, const rgb_t *palette, int xborderpix) INLINE void copyline_palette16(UINT32 *dst, const UINT16 *src, int width, const rgb_t *palette, int xborderpix, int xprescale)
{ {
int x; int x;
@ -2292,7 +2292,11 @@ INLINE void copyline_palette16(UINT32 *dst, const UINT16 *src, int width, const
if (xborderpix) if (xborderpix)
*dst++ = 0xff000000 | palette[*src]; *dst++ = 0xff000000 | palette[*src];
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
*dst++ = 0xff000000 | palette[*src++]; {
int srcpix = *src++;
for (int x2 = 0; x2 < xprescale; x2++)
*dst++ = 0xff000000 | palette[srcpix];
}
if (xborderpix) if (xborderpix)
*dst++ = 0xff000000 | palette[*--src]; *dst++ = 0xff000000 | palette[*--src];
} }
@ -2303,7 +2307,7 @@ INLINE void copyline_palette16(UINT32 *dst, const UINT16 *src, int width, const
// copyline_palettea16 // copyline_palettea16
//============================================================ //============================================================
INLINE void copyline_palettea16(UINT32 *dst, const UINT16 *src, int width, const rgb_t *palette, int xborderpix) INLINE void copyline_palettea16(UINT32 *dst, const UINT16 *src, int width, const rgb_t *palette, int xborderpix, int xprescale)
{ {
int x; int x;
@ -2311,7 +2315,11 @@ INLINE void copyline_palettea16(UINT32 *dst, const UINT16 *src, int width, const
if (xborderpix) if (xborderpix)
*dst++ = palette[*src]; *dst++ = palette[*src];
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
*dst++ = palette[*src++]; {
int srcpix = *src++;
for (int x2 = 0; x2 < xprescale; x2++)
*dst++ = palette[srcpix];
}
if (xborderpix) if (xborderpix)
*dst++ = palette[*--src]; *dst++ = palette[*--src];
} }
@ -2322,7 +2330,7 @@ INLINE void copyline_palettea16(UINT32 *dst, const UINT16 *src, int width, const
// copyline_rgb32 // copyline_rgb32
//============================================================ //============================================================
INLINE void copyline_rgb32(UINT32 *dst, const UINT32 *src, int width, const rgb_t *palette, int xborderpix) INLINE void copyline_rgb32(UINT32 *dst, const UINT32 *src, int width, const rgb_t *palette, int xborderpix, int xprescale)
{ {
int x; int x;
@ -2339,8 +2347,11 @@ INLINE void copyline_rgb32(UINT32 *dst, const UINT32 *src, int width, const rgb_
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
rgb_t srcpix = *src++; rgb_t srcpix = *src++;
for (int x2 = 0; x2 < xprescale; x2++)
{
*dst++ = 0xff000000 | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()]; *dst++ = 0xff000000 | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()];
} }
}
if (xborderpix) if (xborderpix)
{ {
rgb_t srcpix = *--src; rgb_t srcpix = *--src;
@ -2354,7 +2365,14 @@ INLINE void copyline_rgb32(UINT32 *dst, const UINT32 *src, int width, const rgb_
if (xborderpix) if (xborderpix)
*dst++ = 0xff000000 | *src; *dst++ = 0xff000000 | *src;
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
*dst++ = 0xff000000 | *src++; {
rgb_t srcpix = *src++;
for (int x2 = 0; x2 < xprescale; x2++)
{
*dst++ = 0xff000000 | srcpix;
}
}
if (xborderpix) if (xborderpix)
*dst++ = 0xff000000 | *--src; *dst++ = 0xff000000 | *--src;
} }
@ -2364,7 +2382,7 @@ INLINE void copyline_rgb32(UINT32 *dst, const UINT32 *src, int width, const rgb_
// copyline_argb32 // copyline_argb32
//============================================================ //============================================================
INLINE void copyline_argb32(UINT32 *dst, const UINT32 *src, int width, const rgb_t *palette, int xborderpix) INLINE void copyline_argb32(UINT32 *dst, const UINT32 *src, int width, const rgb_t *palette, int xborderpix, int xprescale)
{ {
int x; int x;
@ -2381,6 +2399,7 @@ INLINE void copyline_argb32(UINT32 *dst, const UINT32 *src, int width, const rgb
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
rgb_t srcpix = *src++; rgb_t srcpix = *src++;
for (int x2 = 0; x2 < xprescale; x2++)
*dst++ = (srcpix & 0xff000000) | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()]; *dst++ = (srcpix & 0xff000000) | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()];
} }
if (xborderpix) if (xborderpix)
@ -2396,7 +2415,11 @@ INLINE void copyline_argb32(UINT32 *dst, const UINT32 *src, int width, const rgb
if (xborderpix) if (xborderpix)
*dst++ = *src; *dst++ = *src;
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
*dst++ = *src++; {
rgb_t srcpix = *src++;
for (int x2 = 0; x2 < xprescale; x2++)
*dst++ = srcpix;
}
if (xborderpix) if (xborderpix)
*dst++ = *--src; *dst++ = *--src;
} }
@ -2447,7 +2470,7 @@ INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr)
// copyline_yuy16_to_argb // copyline_yuy16_to_argb
//============================================================ //============================================================
INLINE void copyline_yuy16_to_argb(UINT32 *dst, const UINT16 *src, int width, const rgb_t *palette, int xborderpix) INLINE void copyline_yuy16_to_argb(UINT32 *dst, const UINT16 *src, int width, const rgb_t *palette, int xborderpix, int xprescale)
{ {
int x; int x;
@ -2472,9 +2495,12 @@ INLINE void copyline_yuy16_to_argb(UINT32 *dst, const UINT16 *src, int width, co
UINT16 srcpix1 = *src++; UINT16 srcpix1 = *src++;
UINT8 cb = srcpix0 & 0xff; UINT8 cb = srcpix0 & 0xff;
UINT8 cr = srcpix1 & 0xff; UINT8 cr = srcpix1 & 0xff;
for (int x2 = 0; x2 < xprescale/2; x2++)
{
*dst++ = ycc_to_rgb(palette[0x000 + (srcpix0 >> 8)], cb, cr); *dst++ = ycc_to_rgb(palette[0x000 + (srcpix0 >> 8)], cb, cr);
*dst++ = ycc_to_rgb(palette[0x000 + (srcpix1 >> 8)], cb, cr); *dst++ = ycc_to_rgb(palette[0x000 + (srcpix1 >> 8)], cb, cr);
} }
}
if (xborderpix) if (xborderpix)
{ {
UINT16 srcpix1 = *--src; UINT16 srcpix1 = *--src;
@ -2504,9 +2530,12 @@ INLINE void copyline_yuy16_to_argb(UINT32 *dst, const UINT16 *src, int width, co
UINT16 srcpix1 = *src++; UINT16 srcpix1 = *src++;
UINT8 cb = srcpix0 & 0xff; UINT8 cb = srcpix0 & 0xff;
UINT8 cr = srcpix1 & 0xff; UINT8 cr = srcpix1 & 0xff;
for (int x2 = 0; x2 < xprescale/2; x2++)
{
*dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr); *dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr);
*dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr); *dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr);
} }
}
if (xborderpix) if (xborderpix)
{ {
UINT16 srcpix1 = *--src; UINT16 srcpix1 = *--src;
@ -2551,33 +2580,35 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou
// when nescesarry copy (and convert) the data // when nescesarry copy (and convert) the data
if (!texture->nocopy) if (!texture->nocopy)
{ {
int y; int y, y2;
UINT8 *dst; UINT8 *dst;
for (y = 0; y < texsource->height; y++) for (y = 0; y < texsource->height; y++)
{ {
dst = (UINT8 *)(texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth); for (y2 = 0; y2 < texture->yprescale; y2++)
{
dst = (UINT8 *)(texture->data + (y * texture->yprescale + texture->borderpix + y2) * texture->rawwidth);
switch (PRIMFLAG_GET_TEXFORMAT(flags)) switch (PRIMFLAG_GET_TEXFORMAT(flags))
{ {
case TEXFORMAT_PALETTE16: case TEXFORMAT_PALETTE16:
copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix); copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_PALETTEA16: case TEXFORMAT_PALETTEA16:
copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix); copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_RGB32: case TEXFORMAT_RGB32:
copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix); copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_ARGB32: case TEXFORMAT_ARGB32:
copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix); copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
break; break;
case TEXFORMAT_YUY16: case TEXFORMAT_YUY16:
copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix); copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
break; break;
default: default:
@ -2586,6 +2617,7 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou
} }
} }
} }
}
// always fill non-wrapping textures with an extra pixel on the bottom // always fill non-wrapping textures with an extra pixel on the bottom
if (texture->borderpix) if (texture->borderpix)