[Scummvm-git-logs] scummvm master -> f285e384da6efb992bfc705c32eba44cf3255564

tsoliman tarek at bashasoliman.com
Sat Jan 13 05:43:32 CET 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f285e384da GRAPHICS: Fix rounding error when using non-integral scaling


Commit: f285e384da6efb992bfc705c32eba44cf3255564
    https://github.com/scummvm/scummvm/commit/f285e384da6efb992bfc705c32eba44cf3255564
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2018-01-12T22:43:00-06:00

Commit Message:
GRAPHICS: Fix rounding error when using non-integral scaling

When a non-integral scaling was being used, x and/or y cursor position would be
one less than what it should be.

Fixes Trac#10401

Thanks snover!

Changed paths:
    backends/graphics/windowed.h


diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h
index 1d4958c..5f89d2d 100644
--- a/backends/graphics/windowed.h
+++ b/backends/graphics/windowed.h
@@ -94,8 +94,8 @@ protected:
 			error("convertVirtualToWindow called without a valid draw rect");
 		}
 
-		return Common::Point(targetX + x * targetWidth / sourceWidth,
-							 targetY + y * targetHeight / sourceHeight);
+		return Common::Point(targetX + (x * targetWidth + sourceWidth / 2) / sourceWidth,
+		                     targetY + (y * targetHeight + sourceHeight / 2) / sourceHeight);
 	}
 
 	/**
@@ -120,8 +120,8 @@ protected:
 		x = CLIP<int>(x, sourceX, sourceMaxX);
 		y = CLIP<int>(y, sourceY, sourceMaxY);
 
-		return Common::Point(((x - sourceX) * targetWidth) / sourceWidth,
-							 ((y - sourceY) * targetHeight) / sourceHeight);
+		return Common::Point(((x - sourceX) * targetWidth + sourceWidth / 2) / sourceWidth,
+		                     ((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight);
 	}
 
 	/**





More information about the Scummvm-git-logs mailing list