[Scummvm-git-logs] scummvm branch-2-0 -> 1eb14345160ff9c7edc0f284d36afaa4f597ce1d

tsoliman tarek at bashasoliman.com
Mon Jan 15 22:49:20 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:
1eb1434516 GRAPHICS: Fix rounding error when using non-integral scaling


Commit: 1eb14345160ff9c7edc0f284d36afaa4f597ce1d
    https://github.com/scummvm/scummvm/commit/1eb14345160ff9c7edc0f284d36afaa4f597ce1d
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2018-01-15T15:47:15-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!

(cherry picked from commit f285e384da6efb992bfc705c32eba44cf3255564)

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