[Scummvm-cvs-logs] SF.net SVN: scummvm:[54707] scummvm/trunk/engines/mohawk

fuzzie at users.sourceforge.net fuzzie at users.sourceforge.net
Wed Dec 1 19:21:17 CET 2010


Revision: 54707
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54707&view=rev
Author:   fuzzie
Date:     2010-12-01 18:21:17 +0000 (Wed, 01 Dec 2010)

Log Message:
-----------
MOHAWK: add LBGraphics::copyImageSectionToScreen

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/graphics.cpp
    scummvm/trunk/engines/mohawk/graphics.h

Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-01 17:56:36 UTC (rev 54706)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-01 18:21:17 UTC (rev 54707)
@@ -790,29 +790,41 @@
 
 void LBGraphics::copyImageToScreen(uint16 image, bool useOffsets, int left, int top) {
 	MohawkSurface *mhkSurface = findImage(image);
+	Graphics::Surface *surface = mhkSurface->getSurface();
 
 	if (useOffsets) {
 		left -= mhkSurface->getOffsetX();
 		top -= mhkSurface->getOffsetY();
 	}
 
+	Common::Rect srcRect(0, 0, surface->w, surface->h);
+	Common::Rect dstRect(left, top, left + surface->w, top + surface->h);
+	copyImageSectionToScreen(image, srcRect, dstRect);
+}
+
+void LBGraphics::copyImageSectionToScreen(uint16 image, Common::Rect srcRect, Common::Rect dstRect) {
+	MohawkSurface *mhkSurface = findImage(image);
+
 	uint16 startX = 0;
 	uint16 startY = 0;
 
+	assert(srcRect.isValidRect() && dstRect.isValidRect());
+	assert(srcRect.left >= 0 && srcRect.top >= 0);
+
 	// TODO: clip rect
-	if (left < 0) {
-		startX -= left;
-		left = 0;
+	if (dstRect.left < 0) {
+		startX -= dstRect.left;
+		dstRect.left = 0;
 	}
 
-	if (top < 0) {
-		startY -= top;
-		top = 0;
+	if (dstRect.top < 0) {
+		startY -= dstRect.top;
+		dstRect.top = 0;
 	}
 
-	if (left >= _vm->_system->getWidth())
+	if (dstRect.left >= _vm->_system->getWidth())
 		return;
-	if (top >= _vm->_system->getHeight())
+	if (dstRect.top >= _vm->_system->getHeight())
 		return;
 
 	Graphics::Surface *surface = mhkSurface->getSurface();
@@ -821,16 +833,25 @@
 	if (startY >= surface->h)
 		return;
 
-	uint16 width = MIN<int>(surface->w - startX, _vm->_system->getWidth() - left);
-	uint16 height = MIN<int>(surface->h - startY, _vm->_system->getHeight() - top);
+	if (srcRect.left > surface->w)
+		return;
+	if (srcRect.top > surface->h)
+		return;
+	if (srcRect.right > surface->w)
+		srcRect.right = surface->w;
+	if (srcRect.bottom > surface->h)
+		srcRect.bottom = surface->h;
 
-	byte *surf = (byte *)surface->getBasePtr(0, startY);
+	uint16 width = MIN<int>(srcRect.right - srcRect.left - startX, _vm->_system->getWidth() - dstRect.left);
+	uint16 height = MIN<int>(srcRect.bottom - srcRect.top - startY, _vm->_system->getHeight() - dstRect.top);
+
+	byte *surf = (byte *)surface->getBasePtr(0, srcRect.top + startY);
 	Graphics::Surface *screen = _vm->_system->lockScreen();
 
 	// image and screen are always 8bpp for LB
 	for (uint16 y = 0; y < height; y++) {
-		byte *dest = (byte *)screen->getBasePtr(left, top + y);
-		byte *src = surf + startX;
+		byte *dest = (byte *)screen->getBasePtr(dstRect.left, dstRect.top + y);
+		byte *src = surf + srcRect.left + startX;
 		// blit, with 0 being transparent
 		for (uint16 x = 0; x < width; x++) {
 			if (*src)

Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h	2010-12-01 17:56:36 UTC (rev 54706)
+++ scummvm/trunk/engines/mohawk/graphics.h	2010-12-01 18:21:17 UTC (rev 54707)
@@ -207,6 +207,7 @@
 
 	void preloadImage(uint16 image);
 	void copyImageToScreen(uint16 image, bool useOffsets = false, int left = 0, int top = 0);
+	void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
 	void setPalette(uint16 id);
 	bool imageIsTransparentAt(uint16 image, bool useOffsets, int x, int y);
 


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