[Scummvm-cvs-logs] SF.net SVN: scummvm:[54972] scummvm/trunk/engines/mohawk/graphics.cpp
tdhs at users.sourceforge.net
tdhs at users.sourceforge.net
Mon Dec 20 05:29:54 CET 2010
Revision: 54972
http://scummvm.svn.sourceforge.net/scummvm/?rev=54972&view=rev
Author: tdhs
Date: 2010-12-20 04:29:53 +0000 (Mon, 20 Dec 2010)
Log Message:
-----------
MOHAWK: Fixed Valgrind Error in Myst When Selecting 0 in Imager Code (Myst Card 4709)
Reworked MystGraphics::copyImageSectionToScreen() :
Added clipping of width and height within src surface dimensions.
Improved function readability.
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/graphics.cpp
Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp 2010-12-20 02:25:17 UTC (rev 54971)
+++ scummvm/trunk/engines/mohawk/graphics.cpp 2010-12-20 04:29:53 UTC (rev 54972)
@@ -350,10 +350,6 @@
}
void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest) {
- // Clip the destination rect to the screen
- if (dest.right > _vm->_system->getWidth() || dest.bottom > _vm->_system->getHeight())
- dest.debugPrint(4, "Clipping destination rect to the screen:");
-
Graphics::Surface *surface = findImage(image)->getSurface();
// Make sure the image is bottom aligned in the dest rect
@@ -367,20 +363,30 @@
top += dest.height() - _viewport.height();
}
+ // Clip the destination rect to the screen
+ if (dest.right > _vm->_system->getWidth() || dest.bottom > _vm->_system->getHeight())
+ dest.debugPrint(4, "Clipping destination rect to the screen");
dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
- debug(3, "Image Blit:");
- debug(3, "src.x: %d", src.left);
- debug(3, "src.y: %d", src.top);
- debug(3, "dest.x: %d", dest.left);
- debug(3, "dest.y: %d", dest.top);
- debug(3, "width: %d", src.width());
- debug(3, "height: %d", src.height());
-
uint16 width = MIN<int>(surface->w, dest.width());
uint16 height = MIN<int>(surface->h, dest.height());
+ // Clamp Width and Height to within src surface dimensions
+ if (src.left + width > surface->w)
+ width = surface->w - src.left;
+ if (src.top + height > surface->h)
+ height = surface->h - src.top;
+
+ debug(3, "MystGraphics::copyImageSectionToScreen()");
+ debug(3, "\tImage: %d", image);
+ debug(3, "\tsrc.left: %d", src.left);
+ debug(3, "\tsrc.top: %d", src.top);
+ debug(3, "\tdest.left: %d", dest.left);
+ debug(3, "\tdest.top: %d", dest.top);
+ debug(3, "\twidth: %d", width);
+ debug(3, "\theight: %d", height);
+
_vm->_system->copyRectToScreen((byte *)surface->getBasePtr(src.left, top), surface->pitch, dest.left, dest.top, width, height);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list