Fixed bug 2014 - Hardcoded srcA value in SDL_Blit_auto.c functions

Sylvain Becker 2019-10-24 18:07:30 +02:00
parent 59352cea8b
commit 8081f11773
2 changed files with 186 additions and 253 deletions

View File

@ -69,7 +69,7 @@ static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -79,22 +79,14 @@ static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -121,7 +113,7 @@ static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -152,22 +144,14 @@ static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
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;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -281,7 +265,8 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -291,7 +276,7 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -299,9 +284,6 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
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) {
@ -345,7 +327,8 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -376,7 +359,7 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -384,9 +367,6 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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) {
@ -469,7 +449,7 @@ static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -479,22 +459,14 @@ static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -521,7 +493,7 @@ static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -552,22 +524,14 @@ static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
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;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -681,7 +645,8 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -691,7 +656,7 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -699,9 +664,6 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
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) {
@ -745,7 +707,8 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -776,7 +739,7 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -784,9 +747,6 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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) {
@ -825,7 +785,8 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
{
Uint32 pixel;
Uint32 R, G, B, A;
const Uint32 A = 0xFF;
Uint32 R, G, B;
int srcy, srcx;
int posy, posx;
int incy, incx;
@ -854,7 +815,7 @@ static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
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;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
posx += incx;
@ -869,7 +830,7 @@ static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
@ -879,23 +840,15 @@ static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
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 = (Uint8)(dstpixel >> 24);
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstA = srcA + ((255 - srcA) * dstA) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = 0xFF;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -922,7 +875,7 @@ static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
@ -953,23 +906,15 @@ static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
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;
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 = (Uint8)(dstpixel >> 24);
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstA = srcA + ((255 - srcA) * dstA) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = 0xFF;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -1000,7 +945,8 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 pixel;
Uint32 R, G, B, A;
const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 R, G, B;
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
@ -1008,15 +954,12 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
pixel = *src;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
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)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
++src;
@ -1035,7 +978,8 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 pixel;
Uint32 R, G, B, A;
const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 R, G, B;
int srcy, srcx;
int posy, posx;
int incy, incx;
@ -1064,15 +1008,12 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
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;
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)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
posx += incx;
@ -1091,7 +1032,8 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
@ -1101,7 +1043,7 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
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 = (Uint8)(dstpixel >> 24);
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -1109,9 +1051,6 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
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) {
@ -1156,7 +1095,8 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
@ -1187,7 +1127,7 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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;
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 = (Uint8)(dstpixel >> 24);
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -1195,9 +1135,6 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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) {
@ -1281,7 +1218,7 @@ static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -1291,22 +1228,14 @@ static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -1333,7 +1262,7 @@ static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -1364,22 +1293,14 @@ static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
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;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -1493,7 +1414,8 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -1503,7 +1425,7 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -1511,9 +1433,6 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
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) {
@ -1557,7 +1476,8 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -1588,7 +1508,7 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -1596,9 +1516,6 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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) {
@ -1676,7 +1593,7 @@ static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -1686,22 +1603,14 @@ static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -1728,7 +1637,7 @@ static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -1759,22 +1668,14 @@ static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
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;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -1888,7 +1789,8 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
@ -1898,7 +1800,7 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -1906,9 +1808,6 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
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) {
@ -1952,7 +1851,8 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB;
int srcy, srcx;
@ -1983,7 +1883,7 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -1991,9 +1891,6 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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) {
@ -2032,7 +1929,8 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info)
{
Uint32 pixel;
Uint32 R, G, B, A;
const Uint32 A = 0xFF;
Uint32 R, G, B;
int srcy, srcx;
int posy, posx;
int incy, incx;
@ -2061,7 +1959,7 @@ static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info)
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;
B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
posx += incx;
@ -2076,7 +1974,7 @@ static void SDL_Blit_BGR888_ARGB8888_Blend(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
@ -2086,23 +1984,15 @@ static void SDL_Blit_BGR888_ARGB8888_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
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 = (Uint8)(dstpixel >> 24);
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstA = srcA + ((255 - srcA) * dstA) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = 0xFF;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -2129,7 +2019,7 @@ static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
{
const int flags = info->flags;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
@ -2160,23 +2050,15 @@ static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
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;
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 = (Uint8)(dstpixel >> 24);
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_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
dstA = srcA + ((255 - srcA) * dstA) / 255;
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = 0xFF;
break;
case SDL_COPY_ADD:
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
@ -2207,7 +2089,8 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 pixel;
Uint32 R, G, B, A;
const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 R, G, B;
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
@ -2215,15 +2098,12 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
pixel = *src;
B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
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)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
++src;
@ -2242,7 +2122,8 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 pixel;
Uint32 R, G, B, A;
const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 R, G, B;
int srcy, srcx;
int posy, posx;
int incy, incx;
@ -2271,15 +2152,12 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
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;
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)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
posx += incx;
@ -2298,7 +2176,8 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
@ -2308,7 +2187,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
int n = info->dst_w;
while (n--) {
srcpixel = *src;
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
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 = (Uint8)(dstpixel >> 24);
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -2316,9 +2195,6 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
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) {
@ -2363,7 +2239,8 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
@ -2394,7 +2271,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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;
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 = (Uint8)(dstpixel >> 24);
if (flags & SDL_COPY_MODULATE_COLOR) {
@ -2402,9 +2279,6 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
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) {

View File

@ -68,8 +68,8 @@ my %get_rgba_string_ignore_alpha = (
);
my %get_rgba_string = (
"RGB888" => $get_rgba_string_ignore_alpha{"RGB888"} . " _A = 0xFF;",
"BGR888" => $get_rgba_string_ignore_alpha{"BGR888"} . " _A = 0xFF;",
"RGB888" => $get_rgba_string_ignore_alpha{"RGB888"},
"BGR888" => $get_rgba_string_ignore_alpha{"BGR888"},
"ARGB8888" => $get_rgba_string_ignore_alpha{"ARGB8888"} . " _A = (Uint8)(_pixel >> 24);",
"RGBA8888" => $get_rgba_string_ignore_alpha{"RGBA8888"} . " _A = (Uint8)_pixel;",
"ABGR8888" => $get_rgba_string_ignore_alpha{"ABGR8888"} . " _A = (Uint8)(_pixel >> 24);",
@ -212,6 +212,8 @@ sub output_copycore
my $dst = shift;
my $modulate = shift;
my $blend = shift;
my $is_modulateA_done = shift;
my $A_is_const_FF = shift;
my $s = "";
my $d = "";
@ -243,7 +245,7 @@ __EOF__
${s}B = (${s}B * modulateB) / 255;
}
__EOF__
if (not $ignore_dst_alpha) {
if (!$ignore_dst_alpha && !$is_modulateA_done) {
print FILE <<__EOF__;
if (flags & SDL_COPY_MODULATE_ALPHA) {
${s}A = (${s}A * modulateA) / 255;
@ -252,7 +254,8 @@ __EOF__
}
}
if ( $blend ) {
print FILE <<__EOF__;
if (!$A_is_const_FF) {
print FILE <<__EOF__;
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
/* This goes away if we ever use premultiplied alpha */
if (${s}A < 255) {
@ -261,17 +264,35 @@ __EOF__
${s}B = (${s}B * ${s}A) / 255;
}
}
__EOF__
}
print FILE <<__EOF__;
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_BLEND:
__EOF__
if ($A_is_const_FF) {
print FILE <<__EOF__;
${d}R = ${s}R;
${d}G = ${s}G;
${d}B = ${s}B;
__EOF__
} else {
print FILE <<__EOF__;
${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255;
${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255;
${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255;
__EOF__
}
if ( $dst_has_alpha ) {
print FILE <<__EOF__;
if ($A_is_const_FF) {
print FILE <<__EOF__;
${d}A = 0xFF;
__EOF__
} else {
print FILE <<__EOF__;
${d}A = ${s}A + ((255 - ${s}A) * ${d}A) / 255;
__EOF__
}
}
print FILE <<__EOF__;
@ -306,6 +327,11 @@ sub output_copyfunc
my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
my $ignore_dst_alpha = !$dst_has_alpha && !$blend;
my $src_has_alpha = ($src =~ /A/) ? 1 : 0;
my $is_modulateA_done = 0;
my $A_is_const_FF = 0;
output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
print FILE <<__EOF__;
@ -331,7 +357,25 @@ __EOF__
if ( $blend ) {
print FILE <<__EOF__;
Uint32 srcpixel;
__EOF__
if (!$ignore_dst_alpha && !$src_has_alpha) {
if ($modulate){
$is_modulateA_done = 1;
print FILE <<__EOF__;
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
__EOF__
} else {
$A_is_const_FF = 1;
}
print FILE <<__EOF__;
Uint32 srcR, srcG, srcB;
__EOF__
} else {
print FILE <<__EOF__;
Uint32 srcR, srcG, srcB, srcA;
__EOF__
}
print FILE <<__EOF__;
Uint32 dstpixel;
__EOF__
if ($dst_has_alpha) {
@ -347,7 +391,22 @@ __EOF__
print FILE <<__EOF__;
Uint32 pixel;
__EOF__
if (!$ignore_dst_alpha) {
if (!$ignore_dst_alpha && !$src_has_alpha) {
if ($modulate){
$is_modulateA_done = 1;
print FILE <<__EOF__;
const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
__EOF__
} else {
$A_is_const_FF = 1;
print FILE <<__EOF__;
const Uint32 A = 0xFF;
__EOF__
}
print FILE <<__EOF__;
Uint32 R, G, B;
__EOF__
} elsif (!$ignore_dst_alpha) {
print FILE <<__EOF__;
Uint32 R, G, B, A;
__EOF__
@ -392,7 +451,7 @@ __EOF__
print FILE <<__EOF__;
}
__EOF__
output_copycore($src, $dst, $modulate, $blend);
output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF);
print FILE <<__EOF__;
posx += incx;
++dst;
@ -410,7 +469,7 @@ __EOF__
int n = info->dst_w;
while (n--) {
__EOF__
output_copycore($src, $dst, $modulate, $blend);
output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF);
print FILE <<__EOF__;
++src;
++dst;