mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-25 15:05:34 +00:00
Made the RLE code (semi) readable again
This commit is contained in:
parent
b4deeeba05
commit
a8955f2640
|
@ -119,7 +119,7 @@
|
|||
int i; \
|
||||
Uint32 *src = (Uint32 *)(from); \
|
||||
Uint32 *dst = (Uint32 *)(to); \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
for (i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
Uint32 s1 = s & 0xff00ff; \
|
||||
|
@ -130,7 +130,7 @@
|
|||
d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
|
||||
*dst++ = d1 | d; \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* For 16bpp pixels we can go a step further: put the middle component
|
||||
|
@ -180,16 +180,16 @@
|
|||
int i; \
|
||||
Uint8 *src = from; \
|
||||
Uint8 *dst = to; \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
for (i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s, d; \
|
||||
unsigned rs, gs, bs, rd, gd, bd; \
|
||||
switch(bpp) { \
|
||||
switch (bpp) { \
|
||||
case 2: \
|
||||
s = *(Uint16 *)src; \
|
||||
d = *(Uint16 *)dst; \
|
||||
break; \
|
||||
case 3: \
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
s = (src[0] << 16) | (src[1] << 8) | src[2]; \
|
||||
d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \
|
||||
} else { \
|
||||
|
@ -208,12 +208,12 @@
|
|||
gd += (gs - gd) * alpha >> 8; \
|
||||
bd += (bs - bd) * alpha >> 8; \
|
||||
PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \
|
||||
switch(bpp) { \
|
||||
switch (bpp) { \
|
||||
case 2: \
|
||||
*(Uint16 *)dst = (Uint16)d; \
|
||||
break; \
|
||||
case 3: \
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
dst[0] = (Uint8)(d >> 16); \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d); \
|
||||
|
@ -273,17 +273,17 @@
|
|||
unsigned n = (length); \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
if(((uintptr_t)src ^ (uintptr_t)dst) & 3) { \
|
||||
if (((uintptr_t)src ^ (uintptr_t)dst) & 3) { \
|
||||
/* source and destination not in phase, blit one by one */ \
|
||||
while(n--) \
|
||||
while (n--) \
|
||||
BLEND16_50(dst, src, mask); \
|
||||
} else { \
|
||||
if((uintptr_t)src & 3) { \
|
||||
if ((uintptr_t)src & 3) { \
|
||||
/* first odd pixel */ \
|
||||
BLEND16_50(dst, src, mask); \
|
||||
n--; \
|
||||
} \
|
||||
for(; n > 1; n -= 2) { \
|
||||
for (; n > 1; n -= 2) { \
|
||||
Uint32 s = *(Uint32 *)src; \
|
||||
Uint32 d = *(Uint32 *)dst; \
|
||||
*(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) \
|
||||
|
@ -292,7 +292,7 @@
|
|||
src += 2; \
|
||||
dst += 2; \
|
||||
} \
|
||||
if(n) \
|
||||
if (n) \
|
||||
BLEND16_50(dst, src, mask); /* last odd pixel */ \
|
||||
} \
|
||||
} while(0)
|
||||
|
@ -305,28 +305,28 @@
|
|||
|
||||
#define CHOOSE_BLIT(blitter, alpha, fmt) \
|
||||
do { \
|
||||
if(alpha == 255) { \
|
||||
switch(fmt->BytesPerPixel) { \
|
||||
if (alpha == 255) { \
|
||||
switch (fmt->BytesPerPixel) { \
|
||||
case 1: blitter(1, Uint8, OPAQUE_BLIT); break; \
|
||||
case 2: blitter(2, Uint8, OPAQUE_BLIT); break; \
|
||||
case 3: blitter(3, Uint8, OPAQUE_BLIT); break; \
|
||||
case 4: blitter(4, Uint16, OPAQUE_BLIT); break; \
|
||||
} \
|
||||
} else { \
|
||||
switch(fmt->BytesPerPixel) { \
|
||||
switch (fmt->BytesPerPixel) { \
|
||||
case 1: \
|
||||
/* No 8bpp alpha blitting */ \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
switch(fmt->Rmask | fmt->Gmask | fmt->Bmask) { \
|
||||
switch (fmt->Rmask | fmt->Gmask | fmt->Bmask) { \
|
||||
case 0xffff: \
|
||||
if(fmt->Gmask == 0x07e0 \
|
||||
if (fmt->Gmask == 0x07e0 \
|
||||
|| fmt->Rmask == 0x07e0 \
|
||||
|| fmt->Bmask == 0x07e0) { \
|
||||
if(alpha == 128) \
|
||||
if (alpha == 128) { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_565_50); \
|
||||
else { \
|
||||
} else { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_565); \
|
||||
} \
|
||||
} else \
|
||||
|
@ -334,17 +334,18 @@
|
|||
break; \
|
||||
\
|
||||
case 0x7fff: \
|
||||
if(fmt->Gmask == 0x03e0 \
|
||||
if (fmt->Gmask == 0x03e0 \
|
||||
|| fmt->Rmask == 0x03e0 \
|
||||
|| fmt->Bmask == 0x03e0) { \
|
||||
if(alpha == 128) \
|
||||
if (alpha == 128) { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_555_50); \
|
||||
else { \
|
||||
} else { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_555); \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
/* fallthrough */ \
|
||||
} else \
|
||||
goto general16; \
|
||||
break; \
|
||||
\
|
||||
default: \
|
||||
general16: \
|
||||
|
@ -357,13 +358,14 @@
|
|||
break; \
|
||||
\
|
||||
case 4: \
|
||||
if((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \
|
||||
if ((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \
|
||||
&& (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 \
|
||||
|| fmt->Bmask == 0xff00)) { \
|
||||
if(alpha == 128) \
|
||||
if (alpha == 128) { \
|
||||
blitter(4, Uint16, ALPHA_BLIT32_888_50); \
|
||||
else \
|
||||
} else { \
|
||||
blitter(4, Uint16, ALPHA_BLIT32_888); \
|
||||
} \
|
||||
} else \
|
||||
blitter(4, Uint16, ALPHA_BLIT_ANY); \
|
||||
break; \
|
||||
|
@ -388,25 +390,25 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
|
|||
int left = srcrect->x; \
|
||||
int right = left + srcrect->w; \
|
||||
dstbuf -= left * bpp; \
|
||||
for(;;) { \
|
||||
for (;;) { \
|
||||
int run; \
|
||||
ofs += *(Type *)srcbuf; \
|
||||
run = ((Type *)srcbuf)[1]; \
|
||||
srcbuf += 2 * sizeof(Type); \
|
||||
if(run) { \
|
||||
if (run) { \
|
||||
/* clip to left and right borders */ \
|
||||
if(ofs < right) { \
|
||||
if (ofs < right) { \
|
||||
int start = 0; \
|
||||
int len = run; \
|
||||
int startcol; \
|
||||
if(left - ofs > 0) { \
|
||||
if (left - ofs > 0) { \
|
||||
start = left - ofs; \
|
||||
len -= start; \
|
||||
if(len <= 0) \
|
||||
if (len <= 0) \
|
||||
goto nocopy ## bpp ## do_blit; \
|
||||
} \
|
||||
startcol = ofs + start; \
|
||||
if(len > right - startcol) \
|
||||
if (len > right - startcol) \
|
||||
len = right - startcol; \
|
||||
do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \
|
||||
len, bpp, alpha); \
|
||||
|
@ -414,12 +416,13 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
|
|||
nocopy ## bpp ## do_blit: \
|
||||
srcbuf += run * bpp; \
|
||||
ofs += run; \
|
||||
} else if(!ofs) \
|
||||
} else if (!ofs) \
|
||||
break; \
|
||||
if(ofs == w) { \
|
||||
\
|
||||
if (ofs == w) { \
|
||||
ofs = 0; \
|
||||
dstbuf += surf_dst->pitch; \
|
||||
if(!--linecount) \
|
||||
if (!--linecount) \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
|
|
Loading…
Reference in a new issue