From 7f03398faa3f1a275b454fd6cddba426bd94e169 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 17 Aug 2007 06:40:12 +0000 Subject: [PATCH] More work in progress, still doesn't compile... --- src/video/SDL_blit.c | 45 +- src/video/SDL_blit.h | 5 + src/video/SDL_blit_auto.c | 10472 ++++++++++++++++++------------------ src/video/SDL_blit_auto.h | 2 +- src/video/sdlgenblit.pl | 10 +- 5 files changed, 5268 insertions(+), 5266 deletions(-) diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index bf89c5ada..86b26e2ea 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -24,6 +24,7 @@ #include "SDL_video.h" #include "SDL_sysvideo.h" #include "SDL_blit.h" +#include "SDL_blit_auto.h" #include "SDL_blit_copy.h" #include "SDL_RLEaccel_c.h" #include "SDL_pixels_c.h" @@ -61,19 +62,20 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, /* Set up source and destination buffer pointers, and BLIT! */ if (okay && srcrect->w && srcrect->h) { + SDL_BlitFunc RunBlit; SDL_BlitInfo *info = &src->map->info; /* Set up the blit information */ info->src = (Uint8 *) src->pixels + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * info->src_fmt->BytesPerPixel; - info.src_w = srcrect->w; - info.src_h = srcrect->h; - info.dst = (Uint8 *) dst->pixels + + info->src_w = srcrect->w; + info->src_h = srcrect->h; + info->dst = (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel; - info.dst_w = dstrect->w; - info.dst_h = dstrect->h; + info->dst_w = dstrect->w; + info->dst_h = dstrect->h; RunBlit = (SDL_BlitFunc) src->map->data; /* Run the actual software blit */ @@ -117,7 +119,7 @@ SDL_UseAltivecPrefetch() #endif /* __MACOSX__ */ static SDL_BlitFunc -SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntry * entries) +SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries) { int i; static Uint32 features = 0xffffffff; @@ -154,7 +156,7 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntr } } - for (i = 0; entries[i].blit; ++i) { + for (i = 0; entries[i].func; ++i) { if (src_format != entries[i].src_format) { continue; } @@ -177,44 +179,43 @@ int SDL_CalculateBlit(SDL_Surface * surface) { SDL_BlitFunc blit = NULL; - int blit_index; + SDL_Surface *dst = surface->map->dst; + Uint32 src_format; + Uint32 dst_format; /* Clean everything out to start */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { SDL_UnRLESurface(surface, 1); } surface->map->blit = NULL; + surface->map->info.src_fmt = surface->format; + surface->map->info.src_pitch = surface->pitch; + surface->map->info.dst_fmt = dst->format; + surface->map->info.dst_pitch = dst->pitch; - /* Get the blit function index, based on surface mode */ - /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */ - blit_index = 0; - blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0; - if (surface->flags & SDL_SRCALPHA - && ((surface->map->cmod >> 24) != SDL_ALPHA_OPAQUE - || surface->format->Amask)) { - blit_index |= 2; - } + src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask); + dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask); /* Check for special "identity" case -- copy blit */ - if (surface->map->identity && blit_index == 0) { + if (surface->map->identity && !surface->map->info.flags) { /* Handle overlapping blits on the same surface */ - if (surface == surface->map->dst) { + if (surface == dst) { blit = SDL_BlitCopyOverlap; } else { blit = SDL_BlitCopy; } } else { if (surface->format->BitsPerPixel < 8) { - blit = SDL_CalculateBlit0(surface, blit_index); + blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable0); } else { switch (surface->format->BytesPerPixel) { case 1: - blit = SDL_CalculateBlit1(surface, blit_index); + blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable1); break; case 2: case 3: case 4: - blit = SDL_CalculateBlitN(surface, blit_index); + blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTableN); break; } } diff --git a/src/video/SDL_blit.h b/src/video/SDL_blit.h index d43f68299..e6cd41464 100644 --- a/src/video/SDL_blit.h +++ b/src/video/SDL_blit.h @@ -101,6 +101,11 @@ typedef struct SDL_BlitMap /* Functions found in SDL_blit.c */ extern int SDL_CalculateBlit(SDL_Surface * surface); +/* Blit function tables in SDL_blit_*.c */ +extern SDL_BlitFuncEntry SDL_BlitFuncTable0[]; +extern SDL_BlitFuncEntry SDL_BlitFuncTable1[]; +extern SDL_BlitFuncEntry SDL_BlitFuncTableN[]; + /* * Useful macros for blitting routines */ diff --git a/src/video/SDL_blit_auto.c b/src/video/SDL_blit_auto.c index b555d9928..ea1ac8e09 100644 --- a/src/video/SDL_blit_auto.c +++ b/src/video/SDL_blit_auto.c @@ -28,7 +28,5241 @@ #include "SDL_blit.h" #include "SDL_blit_auto.h" -static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = { +static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + *dst = *src; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + *dst = *src; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + R = (R * modulateR) / 255; + G = (G * modulateG) / 255; + B = (B * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + A = (A * modulateA) / 255; + } + pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + int srcy, srcx; + int posy, posx; + int incy, incx; + + srcy = 0; + posy = 0; + incy = (info->src_h << 16) / info->dst_h; + incx = (info->src_w << 16) / info->dst_w; + + while (info->dst_h--) { + Uint32 *src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + srcx = -1; + posx = 0x10000L; + while (posy >= 0x10000L) { + ++srcy; + posy -= 0x10000L; + } + while (n--) { + if (posx >= 0x10000L) { + while (posx >= 0x10000L) { + ++srcx; + posx -= 0x10000L; + } + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + } + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + /* This goes away if we ever use premultiplied alpha */ + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { + case SDL_COPY_MASK: + if (srcA) { + dstR = srcR; + dstG = srcG; + dstB = srcB; + } + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + } + dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale }, @@ -116,5242 +5350,6 @@ static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = { { 0, 0, 0, 0, NULL } }; -SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable; - -void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - *dst = *src; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - *dst = *src; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - pixel = *src; - B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 pixel; - Uint32 R, G, B, A; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - pixel = *src; - B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; - if (flags & SDL_COPY_MODULATE_COLOR) { - R = (R * modulateR) / 255; - G = (G * modulateG) / 255; - B = (B * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - A = (A * modulateA) / 255; - } - pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; - *dst = pixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - - while (info->dst_h--) { - Uint32 *src = (Uint32 *)info->src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - while (n--) { - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - ++src; - ++dst; - } - info->src += info->src_pitch; - info->dst += info->dst_pitch; - } -} - -void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) -{ - const int flags = info->flags; - const Uint32 modulateR = info->r; - const Uint32 modulateG = info->g; - const Uint32 modulateB = info->b; - const Uint32 modulateA = info->a; - Uint32 srcpixel; - Uint32 srcR, srcG, srcB, srcA; - Uint32 dstpixel; - Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - int posy, posx; - int incy, incx; - - srcy = 0; - posy = 0; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; - - while (info->dst_h--) { - Uint32 *src; - Uint32 *dst = (Uint32 *)info->dst; - int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } - while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } - srcpixel = *src; - srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; - dstpixel = *dst; - dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; - if (flags & SDL_COPY_MODULATE_COLOR) { - srcR = (srcR * modulateR) / 255; - srcG = (srcG * modulateG) / 255; - srcB = (srcB * modulateB) / 255; - } - if (flags & SDL_COPY_MODULATE_ALPHA) { - srcA = (srcA * modulateA) / 255; - } - if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { - /* This goes away if we ever use premultiplied alpha */ - if (srcA < 255) { - srcR = (srcR * srcA) / 255; - srcG = (srcG * srcA) / 255; - srcB = (srcB * srcA) / 255; - } - } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; - case SDL_COPY_BLEND: - dstR = srcR + ((255 - srcA) * dstR) / 255; - dstG = srcG + ((255 - srcA) * dstG) / 255; - dstB = srcB + ((255 - srcA) * dstB) / 255; - break; - case SDL_COPY_ADD: - dstR = srcR + dstR; if (dstR > 255) dstR = 255; - dstG = srcG + dstG; if (dstG > 255) dstG = 255; - dstB = srcB + dstB; if (dstB > 255) dstB = 255; - break; - case SDL_COPY_MOD: - dstR = (srcR * dstR) / 255; - dstG = (srcG * dstG) / 255; - dstB = (srcB * dstB) / 255; - break; - } - dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; - *dst = dstpixel; - posx += incx; - ++dst; - } - posy += incy; - info->dst += info->dst_pitch; - } -} - /* *INDENT-ON* */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_blit_auto.h b/src/video/SDL_blit_auto.h index 39f3ac32e..85ed6f0cb 100644 --- a/src/video/SDL_blit_auto.h +++ b/src/video/SDL_blit_auto.h @@ -24,7 +24,7 @@ /* *INDENT-OFF* */ -extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable; +extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[]; /* *INDENT-ON* */ diff --git a/src/video/sdlgenblit.pl b/src/video/sdlgenblit.pl index c291e9b2a..0341785b1 100755 --- a/src/video/sdlgenblit.pl +++ b/src/video/sdlgenblit.pl @@ -123,7 +123,7 @@ __EOF__ sub output_copydefs { print FILE <<__EOF__; -extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable; +extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[]; __EOF__ } @@ -275,7 +275,7 @@ sub output_copyfunc my $blend = shift; my $scale = shift; - output_copyfuncname("void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); + output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); print FILE <<__EOF__; { const int flags = info->flags; @@ -384,7 +384,7 @@ __EOF__ sub output_copyfunctable { print FILE <<__EOF__; -static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = { +static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { __EOF__ for (my $i = 0; $i <= $#src_formats; ++$i) { my $src = $src_formats[$i]; @@ -436,8 +436,6 @@ __EOF__ { 0, 0, 0, 0, NULL } }; -SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable; - __EOF__ } @@ -469,10 +467,10 @@ close_file("SDL_blit_auto.h"); open_file("SDL_blit_auto.c"); output_copyinc(); -output_copyfunctable(); for (my $i = 0; $i <= $#src_formats; ++$i) { for (my $j = 0; $j <= $#dst_formats; ++$j) { output_copyfunc_c($src_formats[$i], $dst_formats[$j]); } } +output_copyfunctable(); close_file("SDL_blit_auto.c");