diff options
author | Tarek Soliman | 2018-01-12 22:43:00 -0600 |
---|---|---|
committer | Tarek Soliman | 2018-01-12 22:43:00 -0600 |
commit | f285e384da6efb992bfc705c32eba44cf3255564 (patch) | |
tree | bded177e0e627e63750af6ed031ecf35da356943 /backends/graphics | |
parent | 531467581f6ce923fda54eb8bf24cae28739b5ce (diff) | |
download | scummvm-rg350-f285e384da6efb992bfc705c32eba44cf3255564.tar.gz scummvm-rg350-f285e384da6efb992bfc705c32eba44cf3255564.tar.bz2 scummvm-rg350-f285e384da6efb992bfc705c32eba44cf3255564.zip |
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!
Diffstat (limited to 'backends/graphics')
-rw-r--r-- | backends/graphics/windowed.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h index 1d4958c9d6..5f89d2d233 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); } /** |