aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/surface.cpp
diff options
context:
space:
mode:
authorSven Hesse2010-09-30 13:03:51 +0000
committerSven Hesse2010-09-30 13:03:51 +0000
commit89f946ba3edde6cf1fa3b9d0eddd56aecfaee394 (patch)
treee246d935973056821bde8a20053d6818ac9c8f40 /engines/gob/surface.cpp
parent3ab8bf16a27f34ed865edd7c028d0dff90448622 (diff)
downloadscummvm-rg350-89f946ba3edde6cf1fa3b9d0eddd56aecfaee394.tar.gz
scummvm-rg350-89f946ba3edde6cf1fa3b9d0eddd56aecfaee394.tar.bz2
scummvm-rg350-89f946ba3edde6cf1fa3b9d0eddd56aecfaee394.zip
GOB: Transparency support for 16bit surfaces
svn-id: r52950
Diffstat (limited to 'engines/gob/surface.cpp')
-rw-r--r--engines/gob/surface.cpp42
1 files changed, 24 insertions, 18 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);
}