[Scummvm-cvs-logs] SF.net SVN: scummvm: [21794] scummvm/trunk/gui/ThemeNew.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Apr 11 09:07:03 CEST 2006


Revision: 21794
Author:   lordhoto
Date:     2006-04-11 09:05:59 -0700 (Tue, 11 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21794&view=rev

Log Message:
-----------
Checks if something is drawn out of the screen in drawSurfaceMasked (fixes crashes with --force-1x-overlay)

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeNew.cpp
Modified: scummvm/trunk/gui/ThemeNew.cpp
===================================================================
--- scummvm/trunk/gui/ThemeNew.cpp	2006-04-11 15:45:21 UTC (rev 21793)
+++ scummvm/trunk/gui/ThemeNew.cpp	2006-04-11 16:05:59 UTC (rev 21794)
@@ -1187,6 +1187,8 @@
 
 	const OverlayColor transparency = _colors[kColorTransparency];
 	int drawWidth = (r.width() < surf->w) ? r.width() : surf->w;
+	if (r.left + drawWidth > _screen.w)
+		drawWidth = _screen.w - r.left;
 
 	int srcAdd = 0;
 	if (upDown) {
@@ -1197,14 +1199,22 @@
 		srcAdd = surf->w;
 	}
 
+	int h = r.height();
+	if (r.top + h > _screen.h)
+		h = _screen.h - r.top;
+
 	while (dst < _screen.pixels) {
 		dst += _screen.w;
 		src += srcAdd;
+		--h;
 	}
 
+	if (h <= 0)
+		return;
+
 	if (alpha >= 256) {
 		if (leftRight) {
-			for (int i = 0; i < r.height(); ++i) {
+			for (int i = 0; i < h; ++i) {
 				OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor);
 				for (int x = 0; x < drawWidth; ++x) {
 					if (src[drawWidth-x-1] != transparency)
@@ -1214,7 +1224,7 @@
 				src += srcAdd;
 			}
 		} else {
-			for (int i = 0; i < r.height(); ++i) {
+			for (int i = 0; i < h; ++i) {
 				OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor);
 				for (int x = 0; x < drawWidth; ++x) {
 					if (src[x] != transparency)
@@ -1226,7 +1236,7 @@
 		}
 	} else {
 		if (leftRight) {
-			for (int i = 0; i < r.height(); ++i) {
+			for (int i = 0; i < h; ++i) {
 				OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor);
 				for (int x = 0; x < drawWidth; ++x) {
 					if (src[drawWidth-x-1] != transparency)
@@ -1236,7 +1246,7 @@
 				src += srcAdd;
 			}
 		} else {
-			for (int i = 0; i < r.height(); ++i) {
+			for (int i = 0; i < h; ++i) {
 				OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor);
 				for (int x = 0; x < drawWidth; ++x) {
 					if (src[x] != transparency)


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