diff options
author | Einar Johan Trøan Sømåen | 2013-08-20 18:00:17 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2013-08-20 18:00:17 +0200 |
commit | ea19c4162d24d6bf32246671aa5fab285ca7ad39 (patch) | |
tree | c68e7abd03d4e95c95d10eed3696bce9150ba03e /engines/wintermute/graphics/transparent_surface.cpp | |
parent | e824ebaa44a2b6c97fd98e404588e72f520e53a7 (diff) | |
download | scummvm-rg350-ea19c4162d24d6bf32246671aa5fab285ca7ad39.tar.gz scummvm-rg350-ea19c4162d24d6bf32246671aa5fab285ca7ad39.tar.bz2 scummvm-rg350-ea19c4162d24d6bf32246671aa5fab285ca7ad39.zip |
WINTERMUTE: Add binary alpha-blitting.
For now, no RLE, or anything, but the infrastructure for it
is put in place here.
Diffstat (limited to 'engines/wintermute/graphics/transparent_surface.cpp')
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 9539b68c85..249d30f7d9 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -140,9 +140,9 @@ void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int } #endif -TransparentSurface::TransparentSurface() : Surface(), _enableAlphaBlit(true) {} +TransparentSurface::TransparentSurface() : Surface(), _alphaMode(ALPHA_FULL) {} -TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface(), _enableAlphaBlit(true) { +TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface(), _alphaMode(ALPHA_FULL) { if (copyData) { copyFrom(surf); } else { @@ -179,6 +179,37 @@ void doBlitOpaque(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pit } } +void doBlitBinary(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { + byte *in, *out; + +#ifdef SCUMM_LITTLE_ENDIAN + const int aIndex = 0; +#else + const int aIndex = 3; +#endif + const int aShift = 0;//img->format.aShift; + + for (uint32 i = 0; i < height; i++) { + out = outo; + in = ino; + for (uint32 j = 0; j < width; j++) { + uint32 pix = *(uint32 *)in; + int a = (pix >> aShift) & 0xff; + in += inStep; + + if (a == 0) { // Full transparency + out += 4; + } else { // Full opacity (Any value not exactly 0 is Opaque here) + *(uint32 *)out = pix; + out[aIndex] = 0xFF; + out += 4; + } + } + outo += pitch; + ino += inoStep; + } +} + void doBlitAlpha(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { byte *in, *out; @@ -388,9 +419,11 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p const int rShiftTarget = 24;//target.format.rShift; if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { - if (_enableAlphaBlit) { + if (_alphaMode == ALPHA_FULL) { doBlitAlpha(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); - } else { + } else if (_alphaMode == ALPHA_BINARY) { + doBlitBinary(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + } else if (_alphaMode == ALPHA_OPAQUE) { doBlitOpaque(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); } } else { |