aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/surface.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-10-31 23:20:54 -0400
committerMatthew Hoops2011-10-31 23:20:54 -0400
commit0d6dbfa2cbaa568464a18071484ab411cddba4f9 (patch)
tree2d9e112094a5d72bc39d0e6c7a8696a873fcbcea /engines/pegasus/surface.cpp
parent74d08a1543b9200f22e609576bdc5c97cdd7e8ed (diff)
downloadscummvm-rg350-0d6dbfa2cbaa568464a18071484ab411cddba4f9.tar.gz
scummvm-rg350-0d6dbfa2cbaa568464a18071484ab411cddba4f9.tar.bz2
scummvm-rg350-0d6dbfa2cbaa568464a18071484ab411cddba4f9.zip
PEGASUS: Add ability to draw masked surfaces
Diffstat (limited to 'engines/pegasus/surface.cpp')
-rwxr-xr-xengines/pegasus/surface.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 2bf989588e..f0c97d60ea 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -205,6 +205,37 @@ void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Co
}
}
+void Surface::copyToCurrentPortMasked(const Common::Rect &srcRect, const Common::Rect &dstRect, const Surface *mask) const {
+ Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
+ byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
+ byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
+
+ int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
+
+ for (int y = 0; y < srcRect.height(); y++) {
+ byte *maskSrc = (byte *)mask->getSurface()->getBasePtr(0, y);
+
+ for (int x = 0; x < srcRect.width(); x++) {
+ if (g_system->getScreenFormat().bytesPerPixel == 2) {
+ uint16 color = READ_UINT16(maskSrc);
+ if (!isTransparent(color))
+ memcpy(dst, src, 2);
+ } else if (g_system->getScreenFormat().bytesPerPixel == 4) {
+ uint32 color = READ_UINT32(maskSrc);
+ if (!isTransparent(color))
+ memcpy(dst, src, 4);
+ }
+
+ src += g_system->getScreenFormat().bytesPerPixel;
+ maskSrc += g_system->getScreenFormat().bytesPerPixel;
+ dst += g_system->getScreenFormat().bytesPerPixel;
+ }
+
+ src += _surface->pitch - lineSize;
+ dst += screen->pitch - lineSize;
+ }
+}
+
void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
// pixel all the way up.