[Scummvm-cvs-logs] CVS: scummvm/graphics font.cpp,1.2,1.3

Max Horn fingolfin at users.sourceforge.net
Fri Nov 26 16:56:17 CET 2004


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

Modified Files:
	font.cpp 
Log Message:
do clipping

Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/font.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- font.cpp	15 Aug 2004 14:05:28 -0000	1.2
+++ font.cpp	27 Nov 2004 00:55:26 -0000	1.3
@@ -36,9 +36,9 @@
 	return desc.width[chr - desc.firstchar];
 }
 
-void NewFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const {
+void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const {
 	assert(dst != 0);
-	byte *ptr = (byte *)dst->pixels + x * dst->bytesPerPixel + y * dst->pitch;
+	byte *ptr = (byte *)dst->getBasePtr(tx, ty);
 
 	assert(desc.bits != 0 && desc.maxwidth <= 16);
 	assert(dst->bytesPerPixel == 1 || dst->bytesPerPixel == 2);
@@ -54,19 +54,22 @@
 	chr -= desc.firstchar;
 	const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.height));
 
-	for (y = 0; y < desc.height; y++) {
+	for (int y = 0; y < desc.height; y++, ptr += dst->pitch) {
 		const bitmap_t buffer = *tmp++;
 		bitmap_t mask = 0x8000;
-		for (x = 0; x < w; x++) {
+		if (ty + y < 0 || ty + y >= dst->h)
+			continue;
+		
+		for (int x = 0; x < w; x++, mask >>= 1) {
+			if (tx + x < 0 || tx + x >= dst->w)
+				continue;
 			if ((buffer & mask) != 0) {
 				if (dst->bytesPerPixel == 1)
 					ptr[x] = color;
 				else if (dst->bytesPerPixel == 2)
 					((uint16 *)ptr)[x] = color;
 			}
-			mask >>= 1;
 		}
-		ptr += dst->pitch;
 	}
 }
 





More information about the Scummvm-git-logs mailing list