Bug 804559 - Use correct rounding code instead of rolling our own. r=jrmuizel
authorJoe Drew <joe@drew.ca>
Mon, 03 Dec 2012 18:02:11 -0500
changeset 114855 8c174a108843d242359020eb552ad52b88f9f533
parent 114854 305129d04cd1f6362e1e29b127c202ac768a9145
child 114856 cab6183755bbdcb0274c056ad60e517ae89d9f75
push id23947
push useremorley@mozilla.com
push dateTue, 04 Dec 2012 14:54:11 +0000
treeherdermozilla-central@0035f77045bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs804559
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 804559 - Use correct rounding code instead of rolling our own. r=jrmuizel Drew's First Law of Programming: If you write your own rounding code, you will be wrong 100% of the time.
image/src/RasterImage.cpp
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -155,18 +155,20 @@ struct ScaleRequest
     , done(false)
     , stopped(false)
   {
     MOZ_ASSERT(!aSrcFrame->GetIsPaletted());
     MOZ_ASSERT(aScale.width > 0 && aScale.height > 0);
 
     weakImage = aImage->asWeakPtr();
     srcRect = aSrcFrame->GetRect();
-    dstSize.width = NSToIntRoundUp(srcRect.width * scale.width);
-    dstSize.height = NSToIntRoundUp(srcRect.height * scale.height);
+
+    nsIntRect dstRect = srcRect;
+    dstRect.ScaleRoundOut(scale.width, scale.height);
+    dstSize = dstRect.Size();
   }
 
   // This can only be called on the main thread.
   bool GetSurfaces(imgFrame* srcFrame)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     nsRefPtr<RasterImage> image = weakImage.get();