[Scummvm-cvs-logs] CVS: scummvm/saga gfx.cpp,1.33,1.34 gfx.h,1.16,1.17

Max Horn fingolfin at users.sourceforge.net
Thu Nov 25 15:53:08 CET 2004


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

Modified Files:
	gfx.cpp gfx.h 
Log Message:
Make use of new graphic primitives (untested, I don't have saga -- please don't kill if this breaks, it should be trivial for you to fix it :-)

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- gfx.cpp	24 Nov 2004 00:14:01 -0000	1.33
+++ gfx.cpp	25 Nov 2004 23:51:52 -0000	1.34
@@ -355,49 +355,25 @@
 
 // Fills a rectangle in the surface ds from point 'p1' to point 'p2' using
 // the specified color.
-int drawRect(SURFACE *ds, Rect *dst_rect, int color) {
-	byte *write_p;
-
-	int w;
-	int h;
-	int row;
-	int left, top, right, bottom;
+int drawRect(SURFACE *ds, const Rect *dst_rect, int color) {
+	Rect r(ds->w, ds->h);
 
 	if (dst_rect != NULL) {
-		dst_rect->clip(ds->w, ds->h);
-
-		left = dst_rect->left;
-		top = dst_rect->top;
-		right = dst_rect->right;
-		bottom = dst_rect->bottom;
+		r = *dst_rect;
+		r.clip(ds->w, ds->h);
 
-		if ((left >= right) || (top >= bottom)) {
+		if (!r.isValidRect()) {
 			// Empty or negative region
 			return FAILURE;
 		}
-	} else {
-		left = 0;
-		top = 0;
-		right = ds->w;
-		bottom = ds->h;
-	}
-
-	w = right - left;
-	h = bottom - top;
-
-	write_p = (byte *)ds->pixels + (ds->pitch * top) + left;
-
-	for (row = 0; row < h; row++) {
-		memset(write_p, color, w);
-		write_p += ds->pitch;
 	}
+	
+	ds->fillRect(r, color);
 
 	return SUCCESS;
 }
 
 int drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color) {
-	int left, top, right, bottom;
-
 	int min_x;
 	int max_x;
 	int min_y;
@@ -410,29 +386,7 @@
 
 	assert((ds != NULL) && (p1 != NULL) && (p2 != NULL));
 
-	left = p1->x;
-	top = p1->y;
-	right = p2->x;
-	bottom = p2->y;
-
-	min_x = MIN(left, right);
-	min_y = MIN(top, bottom);
-	max_x = MAX(left, right);
-	max_y = MAX(top, bottom);
-
-	n_p1.x = min_x;
-	n_p1.y = min_y;
-	n_p2.x = max_x;
-	n_p2.y = min_y;
-	n_p3.x = max_x;
-	n_p3.y = max_y;
-	n_p4.x = min_x;
-	n_p4.y = max_y;
-
-	drawLine(ds, &n_p1, &n_p2, color);
-	drawLine(ds, &n_p2, &n_p3, color);
-	drawLine(ds, &n_p3, &n_p4, color);
-	drawLine(ds, &n_p4, &n_p1, color);
+	ds->frameRect(Common::Rect(min_x, min_y, max_x+1, max_y+1), color);
 
 	return SUCCESS;
 }

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- gfx.h	24 Nov 2004 00:14:02 -0000	1.16
+++ gfx.h	25 Nov 2004 23:51:52 -0000	1.17
@@ -87,7 +87,7 @@
 int bufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src,
 	int src_w, int src_h, Rect *src_rect, Point *dst_pt);
 int getClipInfo(CLIPINFO *clipinfo);
-int drawRect(SURFACE *ds, Rect *dst_rect, int color);
+int drawRect(SURFACE *ds, const Rect *dst_rect, int color);
 int drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color);
 int drawPolyLine(SURFACE *ds, const Point *pts, int pt_ct, int draw_color);
 int clipLine(SURFACE *ds, const Point *src_p1, const Point *src_p2, Point *dst_p1, Point *dst_p2);





More information about the Scummvm-git-logs mailing list