diff options
author | Sven Hesse | 2010-09-30 13:03:51 +0000 |
---|---|---|
committer | Sven Hesse | 2010-09-30 13:03:51 +0000 |
commit | 89f946ba3edde6cf1fa3b9d0eddd56aecfaee394 (patch) | |
tree | e246d935973056821bde8a20053d6818ac9c8f40 | |
parent | 3ab8bf16a27f34ed865edd7c028d0dff90448622 (diff) | |
download | scummvm-rg350-89f946ba3edde6cf1fa3b9d0eddd56aecfaee394.tar.gz scummvm-rg350-89f946ba3edde6cf1fa3b9d0eddd56aecfaee394.tar.bz2 scummvm-rg350-89f946ba3edde6cf1fa3b9d0eddd56aecfaee394.zip |
GOB: Transparency support for 16bit surfaces
svn-id: r52950
-rw-r--r-- | engines/gob/surface.cpp | 42 | ||||
-rw-r--r-- | engines/gob/surface.h | 12 |
2 files changed, 30 insertions, 24 deletions
diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp index e3a84feccd..dc3e92f200 100644 --- a/engines/gob/surface.cpp +++ b/engines/gob/surface.cpp @@ -259,7 +259,7 @@ bool Surface::clipBlitRect(int16 &left, int16 &top, int16 &right, int16 &bottom, } void Surface::blit(const Surface &from, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, int16 transp) { + int16 x, int16 y, int32 transp) { // Color depths have to fit assert(_bpp == from._bpp); @@ -276,20 +276,24 @@ void Surface::blit(const Surface &from, int16 left, int16 top, int16 right, int1 // Nothing to do return; - // Pointers to the blit destination and source start points - byte *dst = getData(x , y); - const byte *src = from.getData(left, top); - - if ((left == 0) && (_width == from._width) && (_width == width) && ((_bpp != 1) || (transp < 0))) { + if ((left == 0) && (_width == from._width) && (_width == width) && (transp == -1)) { // If these conditions are met, we can directly use memcpy + // Pointers to the blit destination and source start points + byte *dst = getData(x , y); + const byte *src = from.getData(left, top); + memcpy(dst, src, width * height * _bpp); return; } - if ((_bpp != 1) || (transp < 0)) { + if (transp == -1) { // We don't have to look for transparency => we can use memcpy line-wise + // Pointers to the blit destination and source start points + byte *dst = getData(x , y); + const byte *src = from.getData(left, top); + while (height-- > 0) { memcpy(dst, src, width * _bpp); @@ -300,33 +304,35 @@ void Surface::blit(const Surface &from, int16 left, int16 top, int16 right, int1 return; } - assert(_bpp == 1); - // Otherwise, we have to copy by pixel + // Pointers to the blit destination and source start points + Pixel dst = get(x , y); + ConstPixel src = from.get(left, top); + while (height-- > 0) { - byte *dstRow = dst; - const byte *srcRow = src; + Pixel dstRow = dst; + ConstPixel srcRow = src; for (uint16 i = 0; i < width; i++, dstRow++, srcRow++) - if (*srcRow != transp) - *dstRow = *srcRow; + if (srcRow.get() != ((uint32) transp)) + dstRow.set(srcRow.get()); dst += _width; src += from._width; } } -void Surface::blit(const Surface &from, int16 x, int16 y, int16 transp) { +void Surface::blit(const Surface &from, int16 x, int16 y, int32 transp) { blit(from, 0, 0, from._width - 1, from._height - 1, x, y, transp); } -void Surface::blit(const Surface &from, int16 transp) { +void Surface::blit(const Surface &from, int32 transp) { blit(from, 0, 0, from._width - 1, from._height - 1, 0, 0, transp); } void Surface::blitScaled(const Surface &from, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, Common::Rational scale, int16 transp) { + int16 x, int16 y, Common::Rational scale, int32 transp) { if (scale == 1) { // Yeah, "scaled" @@ -390,11 +396,11 @@ void Surface::blitScaled(const Surface &from, int16 left, int16 top, int16 right } -void Surface::blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int16 transp) { +void Surface::blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int32 transp) { blitScaled(from, 0, 0, from._width - 1, from._height - 1, x, y, scale, transp); } -void Surface::blitScaled(const Surface &from, Common::Rational scale, int16 transp) { +void Surface::blitScaled(const Surface &from, Common::Rational scale, int32 transp) { blitScaled(from, 0, 0, from._width - 1, from._height - 1, 0, 0, scale, transp); } diff --git a/engines/gob/surface.h b/engines/gob/surface.h index 625462e2b7..9a26dbc79b 100644 --- a/engines/gob/surface.h +++ b/engines/gob/surface.h @@ -93,14 +93,14 @@ public: ConstPixel get(uint16 x = 0, uint16 y = 0) const; void blit(const Surface &from, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, int16 transp = -1); - void blit(const Surface &from, int16 x, int16 y, int16 transp = -1); - void blit(const Surface &from, int16 transp = -1); + int16 x, int16 y, int32 transp = -1); + void blit(const Surface &from, int16 x, int16 y, int32 transp = -1); + void blit(const Surface &from, int32 transp = -1); void blitScaled(const Surface &from, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, Common::Rational scale, int16 transp = -1); - void blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int16 transp = -1); - void blitScaled(const Surface &from, Common::Rational scale, int16 transp = -1); + int16 x, int16 y, Common::Rational scale, int32 transp = -1); + void blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int32 transp = -1); + void blitScaled(const Surface &from, Common::Rational scale, int32 transp = -1); void fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color); void fill(uint32 color); |