aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp147
-rw-r--r--engines/wintermute/graphics/transparent_surface.h6
2 files changed, 90 insertions, 63 deletions
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index e8628ef6a6..5fe0d13766 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -84,20 +84,23 @@ void BlenderAdditive::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *o
if (ina == 0) {
return;
} else {
- if (*cb != 255)
+ if (*cb != 255) {
*outb = MIN(*outb + ((inb * (*cb) * ina) >> 16), 255);
- else
+ } else {
*outb = MIN(*outb + (inb * ina >> 8), 255);
+ }
- if (*cg != 255)
+ if (*cg != 255) {
*outg = MIN(*outg + ((ing * (*cg) * ina) >> 16), 255);
- else
+ } else {
*outg = MIN(*outg + (ing * ina >> 8), 255);
+ }
- if (*cr != 255)
+ if (*cr != 255) {
*outr = MIN(*outr + ((inr * (*cr) * ina) >> 16), 255);
- else
+ } else {
*outr = MIN(*outr + (inr * ina >> 8), 255);
+ }
}
}
@@ -120,20 +123,23 @@ void BlenderSubtractive::blendPixel(byte ina, byte inr, byte ing, byte inb, byte
if (ina == 0) {
return;
} else {
- if (*cb != 255)
+ if (*cb != 255) {
*outb = MAX(*outb - ((inb * (*cb) * (*outb) * ina) >> 24), 0);
- else
+ } else {
*outb = MAX(*outb - (inb * (*outb) * ina >> 16), 0);
+ }
- if (*cg != 255)
+ if (*cg != 255) {
*outg = MAX(*outg - ((ing * (*cg) * (*outg) * ina) >> 24), 0);
- else
+ } else {
*outg = MAX(*outg - (ing * (*outg) * ina >> 16), 0);
+ }
- if (*cr != 255)
- *outr = MAX(*outr - ((inr * (*cr) * (*outr) * ina) >> 24), 0);
- else
+ if (*cr != 255) {
+ *outr = MAX(*outr - ((inr * (*cr) * (*outr) * ina) >> 24), 0);
+ } else {
*outr = MAX(*outr - (inr * (*outr) * ina >> 16), 0);
+ }
}
}
@@ -152,20 +158,23 @@ void BlenderNormal::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *out
if (ina == 0) {
return;
} else if (ina == 255) {
- if (*cb != 255)
+ if (*cb != 255) {
*outb = (inb * (*cb)) >> 8;
- else
+ } else {
*outb = inb;
+ }
- if (*cr != 255)
+ if (*cr != 255) {
*outr = (inr * (*cr)) >> 8;
- else
+ } else {
*outr = inr;
+ }
- if (*cg != 255)
+ if (*cg != 255) {
*outg = (ing * (*cg)) >> 8;
- else
+ } else {
*outg = ing;
+ }
*outa = ina;
@@ -178,26 +187,29 @@ void BlenderNormal::blendPixel(byte ina, byte inr, byte ing, byte inb, byte *out
*outr = (*outr * (255 - ina) >> 8);
*outg = (*outg * (255 - ina) >> 8);
- if (*cb == 0)
+ if (*cb == 0) {
*outb = *outb;
- else if (*cb != 255)
+ } else if (*cb != 255) {
*outb = *outb + (inb * ina * (*cb) >> 16);
- else
+ } else {
*outb = *outb + (inb * ina >> 8);
+ }
- if (*cr == 0)
+ if (*cr == 0) {
*outr = *outr;
- else if (*cr != 255)
+ } else if (*cr != 255) {
*outr = *outr + (inr * ina * (*cr) >> 16);
- else
+ } else {
*outr = *outr + (inr * ina >> 8);
+ }
- if (*cg == 0)
+ if (*cg == 0) {
*outg = *outg;
- else if (*cg != 255)
+ } else if (*cg != 255) {
*outg = *outg + (ing * ina * (*cg) >> 16);
- else
+ } else {
*outg = *outg + (ing * ina >> 8);
+ }
return;
}
@@ -375,10 +387,10 @@ void doBlit(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, in
byte *outb = &out[TransparentSurface::kBIndex];
b.blendPixel(in[TransparentSurface::kAIndex],
- in[TransparentSurface::kRIndex],
- in[TransparentSurface::kGIndex],
- in[TransparentSurface::kBIndex],
- outa, outr, outg, outb);
+ in[TransparentSurface::kRIndex],
+ in[TransparentSurface::kGIndex],
+ in[TransparentSurface::kBIndex],
+ outa, outr, outg, outb);
in += inStep;
out += 4;
@@ -404,10 +416,10 @@ void doBlit(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, in
byte *outb = &out[TransparentSurface::kBIndex];
b.blendPixel(in[TransparentSurface::kAIndex],
- in[TransparentSurface::kRIndex],
- in[TransparentSurface::kGIndex],
- in[TransparentSurface::kBIndex],
- outa, outr, outg, outb, &ca, &cr, &cg, &cb);
+ in[TransparentSurface::kRIndex],
+ in[TransparentSurface::kGIndex],
+ in[TransparentSurface::kBIndex],
+ outa, outr, outg, outb, &ca, &cr, &cg, &cb);
in += inStep;
out += 4;
}
@@ -427,8 +439,9 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
// Check if we need to draw anything at all
int ca = (color >> 24) & 0xff;
- if (ca == 0)
+ if (ca == 0) {
return retSize;
+ }
// Create an encapsulating surface for the data
TransparentSurface srcImage(*this, false);
@@ -456,17 +469,19 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
srcImage.h = pPartRect->height();
debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping,
- pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height);
+ pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height);
} else {
debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, 0, 0,
- srcImage.w, srcImage.h, color, width, height);
+ srcImage.w, srcImage.h, color, width, height);
}
- if (width == -1)
+ if (width == -1) {
width = srcImage.w;
- if (height == -1)
+ }
+ if (height == -1) {
height = srcImage.h;
+ }
#ifdef SCALING_TESTING
// Hardcode scaling to 66% to test scaling
@@ -516,7 +531,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
yp = img->h - 1;
}
- byte *ino= (byte *)img->getBasePtr(xp, yp);
+ byte *ino = (byte *)img->getBasePtr(xp, yp);
byte *outo = (byte *)target.getBasePtr(posX, posY);
if (color == 0xFFFFFFFF && blendMode == BLEND_NORMAL && _alphaMode == ALPHA_OPAQUE) {
@@ -649,8 +664,9 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
target->create((uint16)dstW, (uint16)dstH, this->format);
- if (transform._zoom.x == 0 || transform._zoom.y == 0)
+ if (transform._zoom.x == 0 || transform._zoom.y == 0) {
return target;
+ }
uint32 invAngle = 360 - (transform._angle % 360);
float invCos = cos(invAngle * M_PI / 180.0);
@@ -684,8 +700,12 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
for (int x = 0; x < dstW; x++) {
int dx = (sdx >> 16);
int dy = (sdy >> 16);
- if (flipx) dx = sw - dx;
- if (flipy) dy = sh - dy;
+ if (flipx) {
+ dx = sw - dx;
+ }
+ if (flipy) {
+ dy = sh - dy;
+ }
#ifdef ENABLE_BILINEAR
if ((dx > -1) && (dy > -1) && (dx < sw) && (dy < sh)) {
@@ -694,7 +714,7 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
c00 = *sp;
sp += 1;
c01 = *sp;
- sp += (this->pitch/4);
+ sp += (this->pitch / 4);
c11 = *sp;
sp -= 1;
c10 = *sp;
@@ -764,8 +784,8 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
bool flipx = false, flipy = false; // TODO: See mirroring comment in RenderTicket ctor
- int *sax = new int[dstW+1];
- int *say = new int[dstH+1];
+ int *sax = new int[dstW + 1];
+ int *say = new int[dstH + 1];
assert(sax && say);
/*
@@ -808,14 +828,16 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
}
}
- const tColorRGBA *sp = (const tColorRGBA *) getBasePtr(0,0);
- tColorRGBA *dp = (tColorRGBA *) target->getBasePtr(0,0);
+ const tColorRGBA *sp = (const tColorRGBA *) getBasePtr(0, 0);
+ tColorRGBA *dp = (tColorRGBA *) target->getBasePtr(0, 0);
int spixelgap = srcW;
- if (flipx)
+ if (flipx) {
sp += spixelw;
- if (flipy)
+ }
+ if (flipy) {
sp += spixelgap * spixelh;
+ }
csay = say;
for (int y = 0; y < dstH; y++) {
@@ -835,10 +857,11 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
c01 = sp;
c10 = sp;
if (cy < spixelh) {
- if (flipy)
+ if (flipy) {
c10 -= spixelgap;
- else
+ } else {
c10 += spixelgap;
+ }
}
c11 = c10;
if (cx < spixelw) {
@@ -874,10 +897,11 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
int *salastx = csax;
csax++;
int sstepx = (*csax >> 16) - (*salastx >> 16);
- if (flipx)
+ if (flipx) {
sp -= sstepx;
- else
+ } else {
sp += sstepx;
+ }
/*
* Advance destination pointer x
@@ -891,10 +915,11 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
csay++;
int sstepy = (*csay >> 16) - (*salasty >> 16);
sstepy *= spixelgap;
- if (flipy)
+ if (flipy) {
sp = csp - sstepy;
- else
+ } else {
sp = csp + sstepy;
+ }
}
delete[] sax;
@@ -903,14 +928,16 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
#else
int *scaleCacheX = new int[dstW];
- for (int x = 0; x < dstW; x++)
+ for (int x = 0; x < dstW; x++) {
scaleCacheX[x] = (x * srcW) / dstW;
+ }
for (int y = 0; y < dstH; y++) {
uint32 *destP = (uint32 *)target->getBasePtr(0, y);
const uint32 *srcP = (const uint32 *)getBasePtr(0, (y * srcH) / dstH);
- for (int x = 0; x < dstW; x++)
+ for (int x = 0; x < dstW; x++) {
*destP++ = srcP[scaleCacheX[x]];
+ }
}
delete[] scaleCacheX;
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index 7f6b1ac865..4ad9bf07eb 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -74,17 +74,17 @@ struct TransparentSurface : public Graphics::Surface {
ALPHA_FULL = 2
};
- #ifdef SCUMM_LITTLE_ENDIAN
+#ifdef SCUMM_LITTLE_ENDIAN
static const int kAIndex = 0;
static const int kBIndex = 1;
static const int kGIndex = 2;
static const int kRIndex = 3;
- #else
+#else
static const int kAIndex = 3;
static const int kBIndex = 2;
static const int kGIndex = 1;
static const int kRIndex = 0;
- #endif
+#endif
static const int kBShift = 8;//img->format.bShift;
static const int kGShift = 16;//img->format.gShift;