[Scummvm-cvs-logs] CVS: scummvm/graphics surface.cpp,1.5,1.6 surface.h,1.6,1.7

Max Horn fingolfin at users.sourceforge.net
Sun May 8 05:35:40 CEST 2005


Update of /cvsroot/scummvm/scummvm/graphics
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1533

Modified Files:
	surface.cpp surface.h 
Log Message:
Patch #1193795 (Adding drawLine() to Surface)

Index: surface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/surface.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- surface.cpp	2 May 2005 18:00:05 -0000	1.5
+++ surface.cpp	8 May 2005 12:33:55 -0000	1.6
@@ -20,10 +20,32 @@
 
 #include "common/stdafx.h"
 #include "common/util.h"
+#include "graphics/primitives.h"
 #include "graphics/surface.h"
 
 namespace Graphics {
 
+static void plotPoint1(int x, int y, int color, void *data) {
+	Surface *s = (Surface *)data;
+	byte *ptr = (byte *)s->getBasePtr(x, y);
+	*ptr = (byte)color;
+}
+
+static void plotPoint2(int x, int y, int color, void *data) {
+	Surface *s = (Surface *)data;
+	uint16 *ptr = (uint16 *)s->getBasePtr(x, y);
+	*ptr = (uint16)color;
+}
+
+void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {
+	if (bytesPerPixel == 1)
+		Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint1, this);
+	else if (bytesPerPixel == 2)
+		Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint2, this);
+	else
+		error("Surface::drawLine: bytesPerPixel must be 1 or 2");
+}
+
 void Surface::hLine(int x, int y, int x2, uint32 color) {
 	// Clipping
 	if (y < 0 || y >= h)

Index: surface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/surface.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- surface.h	2 May 2005 18:00:05 -0000	1.6
+++ surface.h	8 May 2005 12:33:55 -0000	1.7
@@ -46,7 +46,8 @@
 	inline void *getBasePtr(int x, int y) {
 		return static_cast<void *>(static_cast<byte *>(pixels) + y * pitch + x * bytesPerPixel);
 	}
-	
+
+	void drawLine(int x0, int y0, int x1, int y1, uint32 color);
 	void hLine(int x, int y, int x2, uint32 color);
 	void vLine(int x, int y, int y2, uint32 color);
 	void fillRect(const Common::Rect &r, uint32 color);





More information about the Scummvm-git-logs mailing list