Bug 1185636 - Part 2 - Add some utility methods to Point and Size. r=jmuizelaar
authorLee Salzman <lsalzman@mozilla.com>
Mon, 20 Jul 2015 14:53:24 -0400
changeset 287517 dfe577ec4e569e36f4f79d9c9c731ab9d717c093
parent 287516 ee7df762c1950867b6ff57be5dac80266c33882f
child 287518 09b212388126c4b24042f8a10502ff505f4558d2
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs1185636
milestone42.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 1185636 - Part 2 - Add some utility methods to Point and Size. r=jmuizelaar
gfx/2d/BasePoint.h
gfx/2d/BaseSize.h
--- a/gfx/2d/BasePoint.h
+++ b/gfx/2d/BasePoint.h
@@ -64,16 +64,20 @@ struct BasePoint {
   Sub operator/(T aScale) const {
     return Sub(x / aScale, y / aScale);
   }
 
   Sub operator-() const {
     return Sub(-x, -y);
   }
 
+  T DotProduct(const Sub& aPoint) const {
+      return x * aPoint.x + y * aPoint.y;
+  }
+
   T Length() const {
     return hypot(x, y);
   }
 
   // Round() is *not* rounding to nearest integer if the values are negative.
   // They are always rounding as floor(n + 0.5).
   // See https://bugzilla.mozilla.org/show_bug.cgi?id=410748#c14
   Sub& Round() {
--- a/gfx/2d/BaseSize.h
+++ b/gfx/2d/BaseSize.h
@@ -25,16 +25,20 @@ struct BaseSize {
   MOZ_CONSTEXPR BaseSize(T aWidth, T aHeight) : width(aWidth), height(aHeight) {}
 
   void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; }
 
   bool IsEmpty() const {
     return width == 0 || height == 0;
   }
 
+  bool IsSquare() const {
+    return width == height;
+  }
+
   // Note that '=' isn't defined so we'll get the
   // compiler generated default assignment operator
 
   bool operator==(const Sub& aSize) const {
     return width == aSize.width && height == aSize.height;
   }
   bool operator!=(const Sub& aSize) const {
     return width != aSize.width || height != aSize.height;