[Scummvm-cvs-logs] CVS: scummvm/gui newgui.cpp,1.89,1.90

Max Horn fingolfin at users.sourceforge.net
Fri Nov 26 16:59:22 CET 2004


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

Modified Files:
	newgui.cpp 
Log Message:
do clipping

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- newgui.cpp	25 Nov 2004 23:34:50 -0000	1.89
+++ newgui.cpp	27 Nov 2004 00:55:48 -0000	1.90
@@ -279,6 +279,12 @@
 #ifdef NEWGUI_256
 	fillRect(x, y, w, h, color);
 #else
+	Common::Rect rect(x, y, x + w, y + h);
+	rect.clip(_screen.w, _screen.h);
+	
+	if (!rect.isValidRect())
+		return;
+
 	int r, g, b;
 	uint8 ar, ag, ab;
 	_system->colorToRGB(color, ar, ag, ab);
@@ -286,8 +292,10 @@
 	g = ag * level;
 	b = ab * level;
 
-	OverlayColor *ptr = getBasePtr(x, y);
+	OverlayColor *ptr = getBasePtr(rect.left, rect.top);
 
+	h = rect.height();
+	w = rect.width();
 	while (h--) {
 		for (int i = 0; i < w; i++) {
 			_system->colorToRGB(ptr[i], ar, ag, ab);
@@ -309,11 +317,17 @@
 }
 
 void NewGui::addDirtyRect(int x, int y, int w, int h) {
+	Common::Rect rect(x, y, x + w, y + h);
+	rect.clip(_screen.w, _screen.h);
+	
+	if (!rect.isValidRect())
+		return;
+
 	// For now we don't keep yet another list of dirty rects but simply
 	// blit the affected area directly to the overlay. At least for our current
 	// GUI/widget/dialog code that is just fine.
-	OverlayColor *buf = getBasePtr(x, y);
-	_system->copyRectToOverlay(buf, _screenPitch, x, y, w, h);
+	OverlayColor *buf = getBasePtr(rect.left, rect.top);
+	_system->copyRectToOverlay(buf, _screenPitch, rect.left, rect.top, rect.width(), rect.height());
 }
 
 void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) {
@@ -337,17 +351,19 @@
 //
 // Draw an 8x8 bitmap at location (x,y)
 //
-void NewGui::drawBitmap(uint32 *bitmap, int x, int y, OverlayColor color, int h) {
-	OverlayColor *ptr = getBasePtr(x, y);
+void NewGui::drawBitmap(uint32 *bitmap, int tx, int ty, OverlayColor color, int h) {
+	OverlayColor *ptr = getBasePtr(tx, ty);
 
-	for (y = 0; y < h; y++) {
+	for (int y = 0; y < h; y++, ptr += _screenPitch) {
 		uint32 mask = 0xF0000000;
-		for (x = 0; x < 8; x++) {
+		if (ty + y < 0 || ty + y >= _screen.h)
+			continue;
+		for (int x = 0; x < 8; x++, mask >>= 4) {
+			if (tx + x < 0 || tx + x >= _screen.w)
+				continue;
 			if (bitmap[y] & mask)
 				ptr[x] = color;
-			mask >>= 4;
 		}
-		ptr += _screenPitch;
 	}
 }
 





More information about the Scummvm-git-logs mailing list