Bug 831529 - Stop using SkPath::contains for now since it doesn't match the canvas spec. r=jrmuizel
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 08 Feb 2013 10:54:59 +1300
changeset 131099 10ad0aba662434d3c2e80f705c6399691c2d8574
parent 131098 c1a747d02e87265dc9b57b2d005fb5338bcaeba3
child 131100 135831bd21278fb78937906955d6d1cac51dfb8a
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs831529
milestone21.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 831529 - Stop using SkPath::contains for now since it doesn't match the canvas spec. r=jrmuizel
gfx/2d/PathSkia.cpp
--- a/gfx/2d/PathSkia.cpp
+++ b/gfx/2d/PathSkia.cpp
@@ -131,18 +131,25 @@ PathSkia::ContainsPoint(const Point &aPo
 
   Rect bounds = GetBounds(aTransform);
 
   if (aPoint.x < bounds.x || aPoint.y < bounds.y ||
       aPoint.x > bounds.XMost() || aPoint.y > bounds.YMost()) {
     return false;
   }
 
-  return mPath.contains(SkFloatToScalar(transformed.x),
-                        SkFloatToScalar(transformed.y));
+  SkRegion pointRect;
+  pointRect.setRect(int32_t(SkFloatToScalar(transformed.x - 1)),
+                    int32_t(SkFloatToScalar(transformed.y - 1)),
+                    int32_t(SkFloatToScalar(transformed.x + 1)),
+                    int32_t(SkFloatToScalar(transformed.y + 1)));
+
+  SkRegion pathRegion;
+  
+  return pathRegion.setPath(mPath, pointRect);
 }
 
 static Rect SkRectToRect(const SkRect& aBounds)
 {
   return Rect(SkScalarToFloat(aBounds.fLeft),
               SkScalarToFloat(aBounds.fTop),
               SkScalarToFloat(aBounds.fRight - aBounds.fLeft),
               SkScalarToFloat(aBounds.fBottom - aBounds.fTop));
@@ -165,18 +172,25 @@ PathSkia::StrokeContainsPoint(const Stro
 
   Rect bounds = aTransform.TransformBounds(SkRectToRect(strokePath.getBounds()));
 
   if (aPoint.x < bounds.x || aPoint.y < bounds.y ||
       aPoint.x > bounds.XMost() || aPoint.y > bounds.YMost()) {
     return false;
   }
 
-  return strokePath.contains(SkFloatToScalar(transformed.x),
-                             SkFloatToScalar(transformed.y));
+  SkRegion pointRect;
+  pointRect.setRect(int32_t(SkFloatToScalar(transformed.x - 1)),
+                    int32_t(SkFloatToScalar(transformed.y - 1)),
+                    int32_t(SkFloatToScalar(transformed.x + 1)),
+                    int32_t(SkFloatToScalar(transformed.y + 1)));
+
+  SkRegion pathRegion;
+  
+  return pathRegion.setPath(strokePath, pointRect);
 }
 
 Rect
 PathSkia::GetBounds(const Matrix &aTransform) const
 {
   Rect bounds = SkRectToRect(mPath.getBounds());
   return aTransform.TransformBounds(bounds);
 }