[Scummvm-cvs-logs] SF.net SVN: scummvm:[44248] scummvm/trunk/engines/sci/gfx

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Sep 22 10:57:45 CEST 2009


Revision: 44248
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44248&view=rev
Author:   thebluegr
Date:     2009-09-22 08:57:45 +0000 (Tue, 22 Sep 2009)

Log Message:
-----------
Simplified the code which creates the mouse cursor

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
    scummvm/trunk/engines/sci/gfx/gfx_driver.h

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-09-22 06:58:17 UTC (rev 44247)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-09-22 08:57:45 UTC (rev 44248)
@@ -211,57 +211,43 @@
 
 // Mouse pointer operations
 
-// Scale cursor and map its colors to the global palette
-byte *GfxDriver::createCursor(gfx_pixmap_t *pointer) {
-	int linewidth = pointer->width;
-	int lines = pointer->height;
-	byte *data = new byte[linewidth*lines];
-	byte *linebase = data, *pos;
-	byte *src = pointer->index_data;
+void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
+	if (!pointer || !hotspot) {
+		CursorMan.showMouse(false);
+		return;
+	}
 
+	// Scale cursor and map its colors to the global palette
+	byte *cursorData = new byte[pointer->width * pointer->height];
+
 	for (int yc = 0; yc < pointer->index_height; yc++) {
-		pos = linebase;
+		byte *linebase = &cursorData[yc * (pointer->width * _mode->scaleFactor)];
 
 		for (int xc = 0; xc < pointer->index_width; xc++) {
-			byte color = *src;
+			byte color = pointer->index_data[yc * pointer->index_width + xc];
 			// FIXME: The palette size check is a workaround for cursors using non-palette colour GFX_CURSOR_TRANSPARENT
 			// Note that some cursors don't have a palette in SQ5
 			if (pointer->palette && color < pointer->palette->size())
 				color = pointer->palette->getColor(color).parent_index;
-			for (int scalectr = 0; scalectr < _mode->scaleFactor; scalectr++) {
-				*pos++ = color;
-			}
-			src++;
+			memset(&linebase[xc], color, _mode->scaleFactor);
 		}
+
+		// Scale vertically
 		for (int scalectr = 1; scalectr < _mode->scaleFactor; scalectr++)
-			memcpy(linebase + linewidth * scalectr, linebase, linewidth);
-		linebase += linewidth * _mode->scaleFactor;
+			memcpy(&linebase[pointer->width * scalectr], linebase, pointer->width);
 	}
-	return data;
-}
 
+	// FIXME: The palette size check is a workaround for cursors using non-palette color GFX_CURSOR_TRANSPARENT
+	// Note that some cursors don't have a palette (e.g. in SQ5 and QFG3)
+	byte color_key = pointer->color_key;
+	if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && (pointer->palette && (uint)pointer->color_key < pointer->palette->size()))
+		color_key = pointer->palette->getColor(pointer->color_key).parent_index;
 
-void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
-	if ((pointer == NULL) || (hotspot == NULL)) {
-		CursorMan.showMouse(false);
-	} else {
-		byte *cursorData = createCursor(pointer);
+	CursorMan.replaceCursor(cursorData, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
+	CursorMan.showMouse(true);
 
-		// FIXME: The palette size check is a workaround for cursors using non-palette color GFX_CURSOR_TRANSPARENT
-		// Note that some cursors don't have a palette (e.g. in SQ5 and QFG3)
-		byte color_key = GFX_CURSOR_TRANSPARENT;
-		if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && (pointer->palette && (unsigned int)pointer->color_key < pointer->palette->size()))
-			color_key = pointer->palette->getColor(pointer->color_key).parent_index;
-		// Some cursors don't have a palette, so we set the color key directly
-		if (!pointer->palette)
-			color_key = pointer->color_key;
-
-		CursorMan.replaceCursor(cursorData, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
-		CursorMan.showMouse(true);
-
-		delete[] cursorData;
-		cursorData = 0;
-	}
+	delete[] cursorData;
+	cursorData = 0;
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-09-22 06:58:17 UTC (rev 44247)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-09-22 08:57:45 UTC (rev 44248)
@@ -229,8 +229,6 @@
 	byte *getVisual0() { return _visual[0]; }
 
 private:
-	byte *createCursor(gfx_pixmap_t *pointer);
-
 	gfx_pixmap_t *_priority[2];
 	byte *_visual[2];
 	gfx_mode_t *_mode; /**< Currently active mode, NULL if no mode is active */


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