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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Oct 6 23:41:20 CEST 2009


Revision: 44721
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44721&view=rev
Author:   thebluegr
Date:     2009-10-06 21:41:20 +0000 (Tue, 06 Oct 2009)

Log Message:
-----------
Reverted the priority line drawing code in the current GUI (with some cleanup) to use the FreeSCI line drawing code, which was removed in #44692. Apparently, Sierra's implementation of the Bresenham line drawing algorithm was a bit different than ours, which resulted in problems with flood fill

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

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-10-06 21:23:24 UTC (rev 44720)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-10-06 21:41:20 UTC (rev 44721)
@@ -59,13 +59,6 @@
 	memcpy(p + (y * drv->_screen->_width * drv->getMode()->scaleFactor + x), &col, 1);
 }
 
-static void drawProcPriority(int x, int y, int c, void *data) {
-	GfxDriver *drv = (GfxDriver *)data;
-	byte *p = drv->_screen->_priorityScreen;
-	uint8 col = c;
-	memcpy(p + (y * drv->_screen->_width + x), &col, 1);
-}
-
 void GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t color,
 						gfx_line_mode_t line_mode, gfx_line_style_t line_style) {
 	uint32 scolor = color.visual.getParentIndex();
@@ -87,7 +80,7 @@
 				Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, scolor, drawProc, this);
 
 				if (color.mask & GFX_MASK_PRIORITY) {
-					Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, color.priority, drawProcPriority, this);
+					gfx_draw_line_buffer(_screen->_priorityScreen, 1, 1, nstart, nend, color.priority);
 				}
 			}
 		}

Modified: scummvm/trunk/engines/sci/gfx/gfx_support.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_support.cpp	2009-10-06 21:23:24 UTC (rev 44720)
+++ scummvm/trunk/engines/sci/gfx/gfx_support.cpp	2009-10-06 21:41:20 UTC (rev 44721)
@@ -34,15 +34,49 @@
 
 namespace Sci {
 
-static void drawProc(int x, int y, int c, void *data) {
-	gfx_pixmap_t *pxm = (gfx_pixmap_t *)data;
-	byte *p = pxm->index_data;
-	uint8 col = c;
-	memcpy(p + (y * pxm->index_width + x), &col, 1);
-}
+#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \
+                  linearend, nonlinearstart, linearmod, nonlinearmod) \
+	incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \
+	incrNE <<= 1; \
+	deltanonlinear <<= 1; \
+	incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear);  \
+	d = nonlinearstart - 1;  \
+	while (linearvar != (linearend)) { \
+		memcpy(buffer + linewidth * (starty) + (startx), &color, pixelwidth); \
+		linearvar += linearmod; \
+		if ((d += incrE) < 0) { \
+			d += incrNE; \
+			nonlinearvar += nonlinearmod; \
+		}; \
+	}; \
+	memcpy(buffer + linewidth * (starty) + (startx), &color, pixelwidth);
 
+
+// Sierra's Bresenham line drawing
+// WARNING: Do not just blindly replace this with Graphics::drawLine(), as it seems to create issues with flood fill
+void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, Common::Point start, Common::Point end, unsigned int color) {
+	int incrE, incrNE, d;
+	int dx = ABS(end.x - start.x);
+	int dy = ABS(end.y - start.y);
+#ifdef SCUMM_BIG_ENDIAN
+	color = SWAP_BYTES_32(color);
+#endif
+
+	if (dx > dy) {
+		int sign1 = (end.x < start.x) ? -1 : 1;
+		int sign2 = (end.y < start.y) ? -1 : 1;
+		LINEMACRO(start.x, start.y, dx, dy, start.x, start.y, end.x, dx, sign1 * pixelwidth, sign2);
+	} else { // dx <= dy
+		int sign1 = (end.y < start.y) ? -1 : 1;
+		int sign2 = (end.x < start.x) ? -1 : 1;
+		LINEMACRO(start.x, start.y, dy, dx, start.y, start.x, end.y, dy, sign1, sign2 * pixelwidth);
+	}
+ }
+ 
+#undef LINEMACRO
+
 void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color) {
-	Graphics::drawLine(start.x, start.y, end.x, end.y, color, drawProc, pxm);
+	gfx_draw_line_buffer(pxm->index_data, pxm->index_width, 1, start, end, color);
 }
 
 void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) {

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-10-06 21:23:24 UTC (rev 44720)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-10-06 21:41:20 UTC (rev 44721)
@@ -144,6 +144,9 @@
 void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start,
 	Common::Point end, int color);
 
+void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, 
+	Common::Point start, Common::Point end, unsigned int color);
+
 /**
  * Draws a filled rectangular area to a pixmap's index buffer
  *


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