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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Oct 6 17:20:33 CEST 2009


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

Log Message:
-----------
Removed the Bresenham line drawing code in the SCI new GUI, and replaced it with Graphics::drawLine()

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui_gfx.cpp
    scummvm/trunk/engines/sci/gui/gui_gfx.h

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-06 14:37:25 UTC (rev 44696)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-06 15:20:33 UTC (rev 44697)
@@ -25,6 +25,7 @@
 
 #include "common/timer.h"
 #include "common/util.h"
+#include "graphics/primitives.h"
 
 #include "sci/sci.h"
 #include "sci/engine/state.h"
@@ -842,6 +843,19 @@
 	}
 }
 
+// Data passed to drawProc()
+struct LineData {
+	byte drawMask;
+	byte prio;
+	byte control;
+	SciGuiScreen *screen;
+};
+
+static void drawProc(int x, int y, int c, void *data) {
+	LineData *lineData = (LineData *)data;
+	lineData->screen->putPixel(x, y, lineData->drawMask, (byte)c, lineData->prio, lineData->control);
+}
+
 void SciGuiGfx::Draw_Line(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control) {
 	//set_drawing_flag
 	byte flag = _screen->getDrawingMask(color, prio, control);
@@ -853,72 +867,16 @@
 	right += _curPort->left;
 	top += _curPort->top;
 	bottom += _curPort->top;
-	// horizontal line
-	if (top == bottom) {
-		Draw_Horiz(left, right, top, flag, color, prio, control);
-		return;
-	}
-	// vertical line
-	if (left == right) {
-		Draw_Vert(top, bottom, left, flag, color, prio, control);
-		return;
-	}
-	// sloped line - draw with Bresenham algorithm
-	int dy = bottom - top;
-	int dx = right - left;
-	int stepy = dy < 0 ? -1 : 1;
-	int stepx = dx < 0 ? -1 : 1;
-	dy = ABS(dy) << 1;
-	dx = ABS(dx) << 1;
 
-	// setting the 1st and last pixel
-	_screen->putPixel(left, top, flag, color, prio, control);
-	_screen->putPixel(right, bottom, flag, color, prio, control);
-	// drawing the line
-	if (dx > dy) // going horizontal
-	{
-		int fraction = dy - (dx >> 1);
-		while (left != right) {
-			if (fraction >= 0) {
-				top += stepy;
-				fraction -= dx;
-			}
-			left += stepx;
-			fraction += dy;
-			_screen->putPixel(left, top, flag, color, prio, control);
-		}
-	} else // going vertical
-	{
-		int fraction = dx - (dy >> 1);
-		while (top != bottom) {
-			if (fraction >= 0) {
-				left += stepx;
-				fraction -= dy;
-			}
-			top += stepy;
-			fraction += dx;
-			_screen->putPixel(left, top, flag, color, prio, control);
-		}
-	}
-	//g_sci->eventMgr->waitUntil(5);
-	//ShowBits(&_rThePort->rect,6);
-}
+	LineData lineData;
+	lineData.drawMask = flag;
+	lineData.prio = prio;
+	lineData.control = control;
+	lineData.screen = _screen;
 
-void SciGuiGfx::Draw_Horiz(int16 left, int16 right, int16 top, byte flag, byte color, byte prio, byte control) {
-	if (right < left)
-		SWAP(right, left);
-	for (int i = left; i <= right; i++)
-		_screen->putPixel(i, top, flag, color, prio, control);
+	Graphics::drawLine(left, top, right, bottom, color, drawProc, &lineData);
 }
 
-//--------------------------------
-void SciGuiGfx::Draw_Vert(int16 top, int16 bottom, int16 left, byte flag, byte color, byte prio, byte control) {
-	if (top > bottom)
-		SWAP(top, bottom);
-	for (int i = top; i <= bottom; i++)
-		_screen->putPixel(left, i, flag, color, prio, control);
-}
-
 // Bitmap for drawing sierra circles
 const byte pattern_Circles[8][15] = {
 	{ 0x01 },

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-06 14:37:25 UTC (rev 44696)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-06 15:20:33 UTC (rev 44697)
@@ -103,8 +103,6 @@
 	void RestoreBits(GuiMemoryHandle memoryHandle);
 
 	void Draw_Line(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control);
-	void Draw_Horiz(int16 left, int16 right, int16 top, byte flag, byte color, byte prio, byte control);
-	void Draw_Vert(int16 top, int16 bottom, int16 left, byte flag, byte color, byte prio, byte control);
 	void Draw_Box(Common::Rect box, byte color, byte prio, byte control);
 	void Draw_TexturedBox(Common::Rect box, byte color, byte prio, byte control, byte texture);
 	void Draw_Circle(Common::Rect box, byte size, byte color, byte prio, byte control);


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