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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Feb 27 18:10:41 CET 2007


Revision: 25898
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25898&view=rev
Author:   lordhoto
Date:     2007-02-27 09:10:40 -0800 (Tue, 27 Feb 2007)

Log Message:
-----------
fix for gradient calculation

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeModern.cpp

Modified: scummvm/trunk/gui/ThemeModern.cpp
===================================================================
--- scummvm/trunk/gui/ThemeModern.cpp	2007-02-27 14:44:27 UTC (rev 25897)
+++ scummvm/trunk/gui/ThemeModern.cpp	2007-02-27 17:10:40 UTC (rev 25898)
@@ -813,13 +813,16 @@
 
 void ThemeModern::colorFade(const Common::Rect &r, OverlayColor start, OverlayColor end, uint factor) {
 	OverlayColor *ptr = (OverlayColor*)_screen.getBasePtr(r.left, r.top);
-	int h = r.height();
-	while (h--) {
-		OverlayColor col = calcGradient(start, end, r.height()-h, r.height(), factor);
-		for (int i = 0; i < r.width(); ++i) {
-			ptr[i] = col;
+	const int h = r.height();
+	const int w = r.width();
+	const int lastRow = r.height() - 1;
+	const int ptrAdd = _screen.w - r.width();
+	for (int l = 0; l < h; ++l) { 
+		OverlayColor col = calcGradient(start, end, l, lastRow, factor);
+		for (int i = 0; i < w; ++i) {
+			*ptr++ = col;
 		}
-		ptr += _screen.w;
+		ptr += ptrAdd;
 	}
 }
 
@@ -867,8 +870,8 @@
 			usedHeight = specialHeight;
 		}
 
-		OverlayColor startCol = calcGradient(start, end, yPos-r.top, r.height(), factor);
-		OverlayColor endCol = calcGradient(start, end, yPos-r.top+usedHeight, r.height(), factor);
+		OverlayColor startCol = calcGradient(start, end, yPos-r.top, r.height()-1, factor);
+		OverlayColor endCol = calcGradient(start, end, yPos-r.top+usedHeight, r.height()-1, factor);
 
 		for (int i = 0; i < partsW; ++i) {
 			// calculate the correct drawing width
@@ -1088,21 +1091,26 @@
 	if (h <= 0)
 		return;
 
-#define NO_EFFECT(x, y) (src[x] & rowColor)
-#define ALPHA_EFFECT(x, y) (getColorAlpha(src[x] & rowColor, dst[y], alpha))
-#define DARKEN_EFFECT(x, y) (calcDimColor(src[x] & rowColor))
+#define NO_EFFECT(x) ((x) & rowColor)
+#define ALPHA_EFFECT(x) (getColorAlpha((x) & rowColor, *dst, alpha))
+#define DARKEN_EFFECT(x) (calcDimColor((x) & rowColor))
 
 #define LEFT_RIGHT_OFFSET(x) (drawWidth-x-1)
 #define NORMAL_OFFSET(x) (x)
 
 #define blitSurface(a, b) \
+		const int dstAdd = _screen.w - drawWidth; \
+		const int lastRow = r.height() - 1; \
 		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[a(x)] != transparency) \
-					dst[x] = b(a(x), x); \
+			OverlayColor rowColor = calcGradient(start, end, i, lastRow, factor); \
+			for (int x = 0; x < drawWidth; ++x, ++dst) { \
+				OverlayColor col = src[a(x)]; \
+				if (col != transparency) { \
+					col = b(col); \
+					*dst = col; \
+				} \
 			} \
-			dst += _screen.w; \
+			dst += dstAdd; \
 			src += srcAdd; \
 		}
 	if (alpha >= 256) {


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