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

fuzzie at users.sourceforge.net fuzzie at users.sourceforge.net
Sat Dec 25 20:52:54 CET 2010


Revision: 55038
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55038&view=rev
Author:   fuzzie
Date:     2010-12-25 19:52:54 +0000 (Sat, 25 Dec 2010)

Log Message:
-----------
MOHAWK: Add subimage drawing/caching code

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-25 19:52:24 UTC (rev 55037)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-25 19:52:54 UTC (rev 55038)
@@ -101,8 +101,14 @@
 void GraphicsManager::clearCache() {
 	for (Common::HashMap<uint16, MohawkSurface*>::iterator it = _cache.begin(); it != _cache.end(); it++)
 		delete it->_value;
+	for (Common::HashMap<uint16, Common::Array<MohawkSurface*> >::iterator it = _subImageCache.begin(); it != _subImageCache.end(); it++) {
+		Common::Array<MohawkSurface *> &array = it->_value;
+		for (uint i = 0; i < array.size(); i++)
+			delete array[i];
+	}
 
 	_cache.clear();
+	_subImageCache.clear();
 }
 
 MohawkSurface *GraphicsManager::findImage(uint16 id) {
@@ -117,6 +123,10 @@
 	return _cache[id];
 }
 
+Common::Array<MohawkSurface *> GraphicsManager::decodeImages(uint16 id) {
+	error("decodeImages not implemented for this game");
+}
+
 void GraphicsManager::preloadImage(uint16 image) {
 	findImage(image);
 }
@@ -150,6 +160,22 @@
 }
 
 void GraphicsManager::copyAnimImageSectionToScreen(uint16 image, Common::Rect srcRect, Common::Rect dstRect) {
+	copyAnimImageSectionToScreen(findImage(image), srcRect, dstRect);
+}
+
+void GraphicsManager::copyAnimSubImageToScreen(uint16 image, uint16 subimage, int left, int top) {
+	if (!_subImageCache.contains(image))
+		_subImageCache[image] = decodeImages(image);
+	Common::Array<MohawkSurface *> &images = _subImageCache[image];
+
+	Graphics::Surface *surface = images[subimage]->getSurface();
+
+	Common::Rect srcRect(0, 0, surface->w, surface->h);
+	Common::Rect dstRect(left, top, left + surface->w, top + surface->h);
+	copyAnimImageSectionToScreen(images[subimage], srcRect, dstRect);
+}
+
+void GraphicsManager::copyAnimImageSectionToScreen(MohawkSurface *image, Common::Rect srcRect, Common::Rect dstRect) {
 	uint16 startX = 0;
 	uint16 startY = 0;
 
@@ -172,7 +198,7 @@
 	if (dstRect.top >= getVM()->_system->getHeight())
 		return;
 
-	Graphics::Surface *surface = findImage(image)->getSurface();
+	Graphics::Surface *surface = image->getSurface();
 	if (startX >= surface->w)
 		return;
 	if (startY >= surface->h)

Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h	2010-12-25 19:52:24 UTC (rev 55037)
+++ scummvm/trunk/engines/mohawk/graphics.h	2010-12-25 19:52:54 UTC (rev 55038)
@@ -88,20 +88,25 @@
 	virtual void setPalette(uint16 id);
 	void copyAnimImageToScreen(uint16 image, int left = 0, int top = 0);
 	void copyAnimImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
+	void copyAnimSubImageToScreen(uint16 image, uint16 subimage, int left = 0, int top = 0);
 
 protected:
+	void copyAnimImageSectionToScreen(MohawkSurface *image, Common::Rect src, Common::Rect dest);
+
 	// findImage will search the cache to find the image.
 	// If not found, it will call decodeImage to get a new one.
 	MohawkSurface *findImage(uint16 id);
 
 	// decodeImage will always return a new image.
 	virtual MohawkSurface *decodeImage(uint16 id) = 0;
+	virtual Common::Array<MohawkSurface *> decodeImages(uint16 id);
 
 	virtual MohawkEngine *getVM() = 0;
 
 private:
 	// An image cache that stores images until clearCache() is called
 	Common::HashMap<uint16, MohawkSurface*> _cache;
+	Common::HashMap<uint16, Common::Array<MohawkSurface*> > _subImageCache;
 };
 
 class MystGraphics : public GraphicsManager {


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