|
@@ -75,13 +75,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -136,13 +142,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -270,14 +282,13 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -286,7 +297,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -297,15 +320,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -358,14 +385,13 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -374,7 +400,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -385,15 +423,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -457,13 +499,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -518,13 +566,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -652,14 +706,13 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -668,7 +721,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -679,15 +744,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
@@ -740,14 +809,13 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -756,7 +824,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -767,15 +847,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
@@ -838,14 +922,21 @@ static void SDL_Blit_XRGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
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);
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
dstA = 0xFF;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -900,14 +991,21 @@ static void SDL_Blit_XRGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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);
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
dstA = 0xFF;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1039,14 +1137,13 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -1057,7 +1154,22 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1068,15 +1180,19 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -1129,14 +1245,13 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -1147,7 +1262,22 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1158,15 +1288,19 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -1179,9 +1313,10 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
+ const Uint32 A = 0xFF;
|
|
|
Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
@@ -1202,8 +1337,8 @@ static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1213,13 +1348,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -1227,16 +1362,24 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1252,7 +1395,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -1262,13 +1405,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -1288,16 +1431,24 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1313,7 +1464,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1323,13 +1474,15 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_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;
|
|
|
+ const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
Uint32 R, G, B;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
@@ -1338,13 +1491,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -1354,13 +1507,15 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_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;
|
|
|
+ const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
@@ -1381,13 +1536,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1397,7 +1552,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -1408,7 +1563,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
Uint32 srcR, srcG, srcB;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -1416,23 +1571,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_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;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -1440,8 +1594,25 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1452,18 +1623,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -1473,7 +1648,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -1484,7 +1659,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
Uint32 srcR, srcG, srcB;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -1504,23 +1679,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -1528,8 +1702,25 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1540,18 +1731,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1561,8 +1756,10 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -1581,7 +1778,10 @@ static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
while (n--) {
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
- *dst = *src;
|
|
|
+ pixel = *src;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
|
}
|
|
@@ -1590,7 +1790,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -1606,14 +1806,20 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1629,7 +1835,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -1639,7 +1845,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -1667,14 +1873,20 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
dstR = srcR;
|
|
|
dstG = srcG;
|
|
|
dstB = srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1690,7 +1902,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1700,7 +1912,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -1721,7 +1933,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -1731,7 +1943,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -1764,7 +1976,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1774,7 +1986,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -1795,21 +2007,20 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -1818,29 +2029,2802 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
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:
|
|
|
- MULT_DIV_255(srcR, dstR, dstR);
|
|
|
- MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XRGB8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ 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) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ 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_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ const Uint32 modulateR = info->r;
|
|
|
+ const Uint32 modulateG = info->g;
|
|
|
+ const Uint32 modulateB = info->b;
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XBGR8888_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;
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XBGR8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_XBGR8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ 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) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ Uint32 pixel;
|
|
|
+ const Uint32 A = 0xFF;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ 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;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ 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);
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_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;
|
|
|
+ const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 R, G, B;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_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;
|
|
|
+ const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ 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;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ARGB8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ 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) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ Uint32 pixel;
|
|
|
+ const Uint32 A = 0xFF;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ pixel |= (A << 24);
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ 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;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ dstR = srcR;
|
|
|
+ dstG = srcG;
|
|
|
+ dstB = srcB;
|
|
|
+ dstA = 0xFF;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_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;
|
|
|
+ const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 R, G, B;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_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;
|
|
|
+ const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ 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;
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_XBGR8888_ABGR8888_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;
|
|
|
+ const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
+ Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ pixel &= 0xFFFFFF;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+
|
|
|
+ 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 = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ const Uint32 modulateR = info->r;
|
|
|
+ const Uint32 modulateG = info->g;
|
|
|
+ const Uint32 modulateB = info->b;
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_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;
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_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;
|
|
|
+
|
|
|
+ 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 = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XRGB8888_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;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+
|
|
|
+ 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 = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ const Uint32 modulateR = info->r;
|
|
|
+ const Uint32 modulateG = info->g;
|
|
|
+ const Uint32 modulateB = info->b;
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_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;
|
|
|
+ Uint32 pixel;
|
|
|
+ Uint32 R, G, B;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_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;
|
|
|
+
|
|
|
+ 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 = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_XBGR8888_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;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ 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_ARGB8888_ARGB8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+{
|
|
|
+ const int flags = info->flags;
|
|
|
+ Uint32 srcpixel;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
+ Uint32 dstpixel;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ srcpixel = *src;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
+ MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ break;
|
|
|
+ case SDL_COPY_MUL:
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ *dst = dstpixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_ARGB8888_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 = (Uint8)(pixel >> 24);
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ ++src;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ info->src += info->src_pitch;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_ARGB8888_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;
|
|
|
+ Uint64 srcy, srcx;
|
|
|
+ Uint64 posy, posx;
|
|
|
+ Uint64 incy, incx;
|
|
|
+
|
|
|
+ incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
|
|
+ incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
|
|
+ posy = incy / 2;
|
|
|
+
|
|
|
+ while (info->dst_h--) {
|
|
|
+ Uint32 *src = 0;
|
|
|
+ Uint32 *dst = (Uint32 *)info->dst;
|
|
|
+ int n = info->dst_w;
|
|
|
+ posx = incx / 2;
|
|
|
+
|
|
|
+ srcy = posy >> 16;
|
|
|
+ while (n--) {
|
|
|
+ srcx = posx >> 16;
|
|
|
+ src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
+ pixel = *src;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(R, modulateR, R);
|
|
|
+ MULT_DIV_255(G, modulateG, G);
|
|
|
+ MULT_DIV_255(B, modulateB, B);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ *dst = pixel;
|
|
|
+ posx += incx;
|
|
|
+ ++dst;
|
|
|
+ }
|
|
|
+ posy += incy;
|
|
|
+ info->dst += info->dst_pitch;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void SDL_Blit_ARGB8888_ARGB8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ dstpixel = *dst;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
+ MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
+ MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
+ MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
+ }
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
+ case SDL_COPY_BLEND:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
+ 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:
|
|
|
+ MULT_DIV_255(srcR, dstR, dstR);
|
|
|
+ MULT_DIV_255(srcG, dstG, dstG);
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -1850,7 +4834,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -1858,10 +4842,9 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
const Uint32 modulateB = info->b;
|
|
|
const Uint32 modulateA = info->a;
|
|
|
Uint32 srcpixel;
|
|
|
- const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
- Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -1881,23 +4864,25 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -1905,8 +4890,25 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -1917,18 +4919,22 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1938,11 +4944,10 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
- const Uint32 A = 0xFF;
|
|
|
- Uint32 R, G, B;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -1962,8 +4967,8 @@ static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -1973,11 +4978,11 @@ static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
- Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
@@ -1987,17 +4992,43 @@ static void SDL_Blit_XBGR8888_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;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
- dstR = srcR;
|
|
|
- dstG = srcG;
|
|
|
- dstB = srcB;
|
|
|
- dstA = 0xFF;
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2008,12 +5039,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(srcR, dstR, dstR);
|
|
|
- MULT_DIV_255(srcG, dstG, dstG);
|
|
|
- MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -2023,11 +5064,11 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
- Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
@@ -2049,17 +5090,43 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
+ if (srcA < 255) {
|
|
|
+ MULT_DIV_255(srcR, srcA, srcR);
|
|
|
+ MULT_DIV_255(srcG, srcA, srcG);
|
|
|
+ MULT_DIV_255(srcB, srcA, srcB);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
- dstR = srcR;
|
|
|
- dstG = srcG;
|
|
|
- dstB = srcB;
|
|
|
- dstA = 0xFF;
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2070,12 +5137,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(srcR, dstR, dstR);
|
|
|
- MULT_DIV_255(srcG, dstG, dstG);
|
|
|
- MULT_DIV_255(srcB, dstB, dstB);
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -2085,7 +5162,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2093,8 +5170,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
const Uint32 modulateB = info->b;
|
|
|
const Uint32 modulateA = info->a;
|
|
|
Uint32 pixel;
|
|
|
- const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
- Uint32 R, G, B;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -2102,13 +5178,16 @@ static void SDL_Blit_XBGR8888_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;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -2118,7 +5197,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2126,8 +5205,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
const Uint32 modulateB = info->b;
|
|
|
const Uint32 modulateA = info->a;
|
|
|
Uint32 pixel;
|
|
|
- const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
- Uint32 R, G, B;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -2147,13 +5225,16 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -2163,7 +5244,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2171,8 +5252,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
const Uint32 modulateB = info->b;
|
|
|
const Uint32 modulateA = info->a;
|
|
|
Uint32 srcpixel;
|
|
|
- const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
- Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
@@ -2182,23 +5262,25 @@ static void SDL_Blit_XBGR8888_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;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2209,7 +5291,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2220,18 +5317,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -2241,7 +5342,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2249,8 +5350,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
const Uint32 modulateB = info->b;
|
|
|
const Uint32 modulateA = info->a;
|
|
|
Uint32 srcpixel;
|
|
|
- const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
|
|
- Uint32 srcR, srcG, srcB;
|
|
|
+ Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
@@ -2272,23 +5372,25 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
|
|
|
+ srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
|
MULT_DIV_255(srcB, modulateB, srcB);
|
|
|
}
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
+ }
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2299,7 +5401,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2310,18 +5427,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -2331,7 +5452,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
Uint64 srcy, srcx;
|
|
@@ -2353,7 +5474,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- pixel &= 0xFFFFFF;
|
|
|
+ pixel >>= 8;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -2363,7 +5484,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -2377,18 +5498,17 @@ static void SDL_Blit_ARGB8888_XRGB8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2397,7 +5517,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2408,15 +5540,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -2429,7 +5565,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -2455,18 +5591,17 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2475,7 +5610,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2486,15 +5633,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -2507,7 +5658,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2522,7 +5673,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
@@ -2538,7 +5689,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2565,7 +5716,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
@@ -2581,7 +5732,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2599,7 +5750,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
@@ -2611,14 +5762,13 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2627,7 +5777,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2638,15 +5800,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -2659,7 +5825,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2689,7 +5855,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
@@ -2701,14 +5867,13 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2717,7 +5882,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2728,15 +5905,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -2749,7 +5930,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
Uint32 R, G, B;
|
|
@@ -2772,7 +5953,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
pixel = (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
@@ -2783,7 +5964,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -2797,18 +5978,17 @@ static void SDL_Blit_ARGB8888_XBGR8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2817,7 +5997,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2828,15 +6020,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
@@ -2849,7 +6045,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -2875,18 +6071,17 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -2895,7 +6090,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -2906,15 +6113,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
@@ -2927,7 +6138,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2942,7 +6153,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
@@ -2958,7 +6169,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -2985,7 +6196,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
@@ -3001,7 +6212,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3019,7 +6230,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
@@ -3031,14 +6242,13 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3047,7 +6257,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3058,15 +6280,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
@@ -3079,7 +6305,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3109,7 +6335,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
@@ -3121,14 +6347,13 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3137,7 +6362,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3148,15 +6385,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
@@ -3169,8 +6410,9 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
+ Uint32 pixel;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -3189,7 +6431,9 @@ static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
while (n--) {
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
- *dst = *src;
|
|
|
+ pixel = *src;
|
|
|
+ pixel = (pixel >> 8) | (pixel << 24);
|
|
|
+ *dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
|
}
|
|
@@ -3198,7 +6442,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -3212,18 +6456,17 @@ static void SDL_Blit_ARGB8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3234,7 +6477,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3245,15 +6503,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -3266,7 +6528,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -3292,18 +6554,17 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3314,7 +6575,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3325,15 +6601,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -3346,7 +6626,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3362,7 +6642,7 @@ static void SDL_Blit_ARGB8888_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 = (Uint8)(pixel >> 24);
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
@@ -3381,7 +6661,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3409,7 +6689,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
@@ -3428,7 +6708,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3446,7 +6726,7 @@ static void SDL_Blit_ARGB8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
@@ -3458,14 +6738,13 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3476,7 +6755,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3487,15 +6781,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -3508,7 +6806,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3538,7 +6836,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
@@ -3550,14 +6848,13 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3568,7 +6865,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3579,15 +6891,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
@@ -3600,9 +6916,10 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -3622,7 +6939,8 @@ static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- pixel >>= 8;
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -3632,13 +6950,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -3648,16 +6966,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3665,8 +6982,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3677,18 +7011,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -3698,13 +7036,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -3726,16 +7064,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3743,8 +7080,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3755,18 +7109,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -3776,14 +7134,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -3791,13 +7150,16 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -3807,14 +7169,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -3834,13 +7197,16 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
+ R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -3850,7 +7216,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3860,7 +7226,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -3870,7 +7236,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -3880,14 +7246,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3895,8 +7260,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3907,18 +7289,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -3928,7 +7314,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -3938,7 +7324,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -3960,7 +7346,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -3970,14 +7356,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -3985,8 +7370,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -3997,18 +7399,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4018,7 +7424,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
Uint32 R, G, B;
|
|
@@ -4041,8 +7447,8 @@ static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4052,7 +7458,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -4066,18 +7472,17 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4086,7 +7491,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4097,18 +7514,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4118,7 +7539,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -4144,18 +7565,17 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
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;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4164,7 +7584,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4175,18 +7607,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4196,7 +7632,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -4211,13 +7647,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4227,7 +7663,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -4254,13 +7690,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4270,7 +7706,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -4288,9 +7724,9 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -4300,14 +7736,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4316,7 +7751,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4327,18 +7774,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4348,7 +7799,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -4378,9 +7829,9 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
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;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -4390,14 +7841,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4406,7 +7856,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4417,18 +7879,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4438,7 +7904,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
Uint64 srcy, srcx;
|
|
@@ -4460,7 +7926,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- pixel = (pixel >> 8) | (pixel << 24);
|
|
|
+ pixel &= 0xFFFFFF;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4470,13 +7936,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -4484,18 +7950,17 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4503,10 +7968,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4517,18 +7992,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4538,13 +8017,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -4564,18 +8043,17 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
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;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4583,10 +8061,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4597,18 +8085,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4618,15 +8110,14 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_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;
|
|
|
+ Uint32 R, G, B;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -4634,16 +8125,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
- MULT_DIV_255(A, modulateA, A);
|
|
|
- }
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4653,15 +8141,14 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_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;
|
|
|
+ Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -4681,16 +8168,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
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;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
- MULT_DIV_255(A, modulateA, A);
|
|
|
- }
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4700,7 +8184,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -4710,7 +8194,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -4718,9 +8202,9 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
srcpixel = *src;
|
|
|
- srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -4730,14 +8214,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4745,10 +8228,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4759,18 +8252,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4780,7 +8277,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -4790,7 +8287,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -4810,9 +8307,9 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
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;
|
|
|
+ srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -4822,14 +8319,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4837,10 +8333,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4851,18 +8357,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4872,10 +8382,10 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
- Uint32 R, G, B;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -4895,8 +8405,8 @@ static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -4906,13 +8416,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -4922,16 +8432,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -4939,8 +8448,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -4951,18 +8477,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -4972,13 +8502,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5000,16 +8530,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5017,8 +8546,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5029,18 +8575,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5050,14 +8600,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5065,13 +8616,16 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5081,14 +8635,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5108,13 +8663,16 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5124,7 +8682,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -5134,7 +8692,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5144,7 +8702,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -5154,14 +8712,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5169,8 +8726,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5181,18 +8755,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5202,7 +8780,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -5212,7 +8790,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5234,7 +8812,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -5244,14 +8822,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5259,8 +8836,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5271,18 +8865,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5292,9 +8890,8 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
- Uint32 pixel;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5313,9 +8910,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
while (n--) {
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
- pixel = *src;
|
|
|
- pixel &= 0xFFFFFF;
|
|
|
- *dst = pixel;
|
|
|
+ *dst = *src;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
|
}
|
|
@@ -5324,13 +8919,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5340,16 +8935,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5357,8 +8951,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5369,18 +8980,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5390,13 +9005,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5418,16 +9033,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5435,8 +9049,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5447,18 +9078,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5468,14 +9103,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5483,13 +9119,16 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5499,14 +9138,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5526,13 +9166,16 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
|
|
+ B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5542,7 +9185,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -5552,7 +9195,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5562,7 +9205,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -5572,14 +9215,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5587,8 +9229,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5599,18 +9258,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5620,7 +9283,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -5630,7 +9293,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5652,7 +9315,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcpixel = *src;
|
|
|
srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
dstpixel = *dst;
|
|
|
- dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -5662,14 +9325,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5677,8 +9339,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5689,18 +9368,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5710,10 +9393,10 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
- Uint32 R, G, B, A;
|
|
|
+ Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5733,8 +9416,8 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5744,13 +9427,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5758,18 +9441,17 @@ static void SDL_Blit_ABGR8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5777,10 +9459,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5791,18 +9483,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5812,13 +9508,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5838,18 +9534,17 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -5857,10 +9552,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -5871,18 +9576,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5892,15 +9601,14 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_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;
|
|
|
+ Uint32 R, G, B;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5908,16 +9616,13 @@ static void SDL_Blit_ABGR8888_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 = (Uint8)(pixel >> 24);
|
|
|
+ B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
- MULT_DIV_255(A, modulateA, A);
|
|
|
- }
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -5927,15 +9632,14 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_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;
|
|
|
+ Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -5955,16 +9659,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
|
|
|
+ B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
- MULT_DIV_255(A, modulateA, A);
|
|
|
- }
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -5974,7 +9675,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -5984,7 +9685,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -5992,9 +9693,9 @@ static void SDL_Blit_ABGR8888_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 = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -6004,14 +9705,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6019,10 +9719,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6033,18 +9743,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6054,7 +9768,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6064,7 +9778,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB, dstA;
|
|
|
+ Uint32 dstR, dstG, dstB;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -6084,9 +9798,9 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
srcpixel = *src;
|
|
|
- srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
|
|
|
+ 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 = (Uint8)(dstpixel >> 24);
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -6096,14 +9810,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6111,10 +9824,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
- MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
- dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6125,18 +9848,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6146,10 +9873,9 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
- Uint32 R, G, B;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -6169,8 +9895,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ pixel >>= 8;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6180,7 +9905,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -6196,16 +9921,15 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6214,7 +9938,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6225,18 +9961,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6246,7 +9986,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -6274,16 +10014,15 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6292,7 +10031,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6303,18 +10054,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6324,7 +10079,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6345,7 +10100,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6355,7 +10110,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6388,7 +10143,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6398,7 +10153,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6418,7 +10173,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -6428,14 +10183,13 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6444,7 +10198,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6455,18 +10221,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6476,7 +10246,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6508,7 +10278,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -6518,14 +10288,13 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6534,7 +10303,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6545,18 +10326,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6566,9 +10351,10 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -6588,7 +10374,8 @@ static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- pixel >>= 8;
|
|
|
+ B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6598,13 +10385,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -6614,16 +10401,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6631,8 +10417,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6643,18 +10446,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6664,13 +10471,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -6692,16 +10499,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ 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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6709,8 +10515,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6721,18 +10544,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6742,14 +10569,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -6757,13 +10585,16 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
int n = info->dst_w;
|
|
|
while (n--) {
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
|
|
+ B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6773,14 +10604,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_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;
|
|
|
+ Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -6800,13 +10632,16 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
|
|
pixel = *src;
|
|
|
- B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
|
|
+ B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(R, modulateR, R);
|
|
|
MULT_DIV_255(G, modulateG, G);
|
|
|
MULT_DIV_255(B, modulateB, B);
|
|
|
}
|
|
|
- pixel = (B << 16) | (G << 8) | R;
|
|
|
+ if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
+ MULT_DIV_255(A, modulateA, A);
|
|
|
+ }
|
|
|
+ pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6816,7 +10651,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6826,7 +10661,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
|
|
|
while (info->dst_h--) {
|
|
|
Uint32 *src = (Uint32 *)info->src;
|
|
@@ -6836,7 +10671,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -6846,14 +10681,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6861,8 +10695,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6873,18 +10724,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -6894,7 +10749,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -6904,7 +10759,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
Uint32 srcpixel;
|
|
|
Uint32 srcR, srcG, srcB, srcA;
|
|
|
Uint32 dstpixel;
|
|
|
- Uint32 dstR, dstG, dstB;
|
|
|
+ Uint32 dstR, dstG, dstB, dstA;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -6926,7 +10781,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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;
|
|
|
+ dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -6936,14 +10791,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -6951,8 +10805,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
dstG += srcG;
|
|
|
MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
dstB += srcB;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -6963,18 +10834,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstB << 16) | (dstG << 8) | dstR;
|
|
|
+ dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -6984,10 +10859,9 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
Uint32 pixel;
|
|
|
- Uint32 R, G, B, A;
|
|
|
Uint64 srcy, srcx;
|
|
|
Uint64 posy, posx;
|
|
|
Uint64 incy, incx;
|
|
@@ -7007,8 +10881,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
srcx = posx >> 16;
|
|
|
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 = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (pixel >> 8) | (pixel << 24);
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -7018,7 +10891,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -7034,16 +10907,15 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
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 = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -7054,7 +10926,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -7065,18 +10952,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -7086,7 +10977,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
Uint32 srcpixel;
|
|
@@ -7114,16 +11005,15 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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 = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (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) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -7134,7 +11024,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -7145,18 +11050,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -7166,7 +11075,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -7191,7 +11100,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
MULT_DIV_255(A, modulateA, A);
|
|
|
}
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -7201,7 +11110,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -7238,7 +11147,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
if (flags & SDL_COPY_MODULATE_ALPHA) {
|
|
|
MULT_DIV_255(A, modulateA, A);
|
|
|
}
|
|
|
- pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
|
|
+ pixel = (A << 24) | (B << 16) | (G << 8) | R;
|
|
|
*dst = pixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -7248,7 +11157,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -7268,7 +11177,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
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 = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -7278,14 +11187,13 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -7296,7 +11204,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -7307,18 +11230,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
++src;
|
|
|
++dst;
|
|
@@ -7328,7 +11255,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
{
|
|
|
const int flags = info->flags;
|
|
|
const Uint32 modulateR = info->r;
|
|
@@ -7360,7 +11287,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
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 = (Uint8)(dstpixel >> 24);
|
|
|
+ dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
|
|
|
if (flags & SDL_COPY_MODULATE_COLOR) {
|
|
|
MULT_DIV_255(srcR, modulateR, srcR);
|
|
|
MULT_DIV_255(srcG, modulateG, srcG);
|
|
@@ -7370,14 +11297,13 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcA, modulateA, srcA);
|
|
|
}
|
|
|
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
|
|
|
- /* This goes away if we ever use premultiplied alpha */
|
|
|
if (srcA < 255) {
|
|
|
MULT_DIV_255(srcR, srcA, srcR);
|
|
|
MULT_DIV_255(srcG, srcA, srcG);
|
|
|
MULT_DIV_255(srcB, srcA, srcB);
|
|
|
}
|
|
|
}
|
|
|
- switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
|
|
|
+ switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
|
|
|
case SDL_COPY_BLEND:
|
|
|
MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
dstR += srcR;
|
|
@@ -7388,7 +11314,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
dstA += srcA;
|
|
|
break;
|
|
|
+ case SDL_COPY_BLEND_PREMULTIPLIED:
|
|
|
+ MULT_DIV_255((255 - srcA), dstR, dstR);
|
|
|
+ dstR += srcR;
|
|
|
+ if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstG, dstG);
|
|
|
+ dstG += srcG;
|
|
|
+ if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstB, dstB);
|
|
|
+ dstB += srcB;
|
|
|
+ if (dstB > 255) dstB = 255;
|
|
|
+ MULT_DIV_255((255 - srcA), dstA, dstA);
|
|
|
+ dstA += srcA;
|
|
|
+ if (dstA > 255) dstA = 255;
|
|
|
+ break;
|
|
|
case SDL_COPY_ADD:
|
|
|
+ case SDL_COPY_ADD_PREMULTIPLIED:
|
|
|
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
|
|
|
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
|
|
|
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
|
|
@@ -7399,18 +11340,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
MULT_DIV_255(srcB, dstB, dstB);
|
|
|
break;
|
|
|
case SDL_COPY_MUL:
|
|
|
- MULT_DIV_255(dstR, (255 - srcA), dstR);
|
|
|
- dstR += (srcR * dstR);
|
|
|
- if (dstR > 255) dstR = 255;
|
|
|
- MULT_DIV_255(dstB, (255 - srcA), dstB);
|
|
|
- dstB += (srcB * dstB);
|
|
|
- if (dstB > 255) dstB = 255;
|
|
|
- MULT_DIV_255(dstG, (255 - srcA), dstG);
|
|
|
- dstG += (srcG * dstG);
|
|
|
- if (dstG > 255) dstG = 255;
|
|
|
+ {
|
|
|
+ Uint32 tmp1, tmp2;
|
|
|
+
|
|
|
+ MULT_DIV_255(srcR, dstR, tmp1);
|
|
|
+ MULT_DIV_255(dstR, (255 - srcA), tmp2);
|
|
|
+ dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
|
|
|
+ MULT_DIV_255(srcG, dstG, tmp1);
|
|
|
+ MULT_DIV_255(dstG, (255 - srcA), tmp2);
|
|
|
+ dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
|
|
|
+ MULT_DIV_255(srcB, dstB, tmp1);
|
|
|
+ MULT_DIV_255(dstB, (255 - srcA), tmp2);
|
|
|
+ dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
|
|
|
+ dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
|
|
|
*dst = dstpixel;
|
|
|
posx += incx;
|
|
|
++dst;
|
|
@@ -7422,131 +11367,173 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
|
|
|
|
|
SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
|
|
|
{ SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
|
|
|
- { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend },
|
|
|
+ { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale },
|
|
|
{ 0, 0, 0, 0, NULL }
|
|
|
};
|
|
|
|