Bug 637852. Part 2: Add BaseRect::ScaleInverseRoundOut API. r=joe
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 23 Jun 2011 00:11:27 +1200
changeset 71517 c9dd59391c7d104e4d9faa863b3cbf655f562a41
parent 71516 7853e5cf72f7700cfe63e4c9e25315800e2fb52d
child 71518 b53df216be6181b6488332f66fa0954a29c019a8
push id20559
push usereakhgari@mozilla.com
push dateWed, 22 Jun 2011 19:51:00 +0000
treeherdermozilla-central@cd95d565c4d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs637852
milestone7.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 637852. Part 2: Add BaseRect::ScaleInverseRoundOut API. r=joe
gfx/src/BaseRect.h
--- a/gfx/src/BaseRect.h
+++ b/gfx/src/BaseRect.h
@@ -300,16 +300,26 @@ struct BaseRect {
   {
     T right = static_cast<T>(NS_ceil(double(XMost()) * aXScale));
     T bottom = static_cast<T>(NS_ceil(double(YMost()) * aYScale));
     x = static_cast<T>(NS_floor(double(x) * aXScale));
     y = static_cast<T>(NS_floor(double(y) * aYScale));
     width = right - x;
     height = bottom - y;
   }
+  void ScaleInverseRoundOut(double aScale) { ScaleInverseRoundOut(aScale, aScale); }
+  void ScaleInverseRoundOut(double aXScale, double aYScale)
+  {
+    T right = static_cast<T>(ceil(double(XMost()) / aXScale));
+    T bottom = static_cast<T>(ceil(double(YMost()) / aYScale));
+    x = static_cast<T>(floor(double(x) / aXScale));
+    y = static_cast<T>(floor(double(y) / aYScale));
+    width = right - x;
+    height = bottom - y;
+  }
 
 private:
   // Do not use the default operator== or operator!= !
   // Use IsEqualEdges or IsEqualInterior explicitly.
   bool operator==(const Sub& aRect) const { return false; }
   bool operator!=(const Sub& aRect) const { return false; }
 };