2009-02-19 Dimitri Glazkov <dglazkov@chromium.org>
[WebKit-https.git] / WebCore / platform / graphics / skia / PathSkia.cpp
index 06a791ace6b175acca0453147976adeb4197d647..2700da8895bbebd9bf989c092527a191c89bec10 100644 (file)
@@ -174,7 +174,6 @@ void Path::apply(void* info, PathApplierFunction function) const
 {
     SkPath::Iter iter(*m_path, false);
     SkPoint pts[4];
-
     PathElement pathElement;
     FloatPoint pathPoints[3];
 
@@ -275,7 +274,7 @@ static FloatRect boundingBoxForCurrentStroke(const GraphicsContext* context)
     SkPaint paint;
     context->platformContext()->setupPaintForStroking(&paint, 0, 0);
     SkPath boundingPath;
-    paint.getFillPath(*context->platformContext()->currentPath(), &boundingPath);
+    paint.getFillPath(context->platformContext()->currentPathInLocalCoordinates(), &boundingPath);
     SkRect r;
     boundingPath.computeBounds(&r, SkPath::kExact_BoundsType);
     return r;
@@ -296,4 +295,22 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
     return r;
 }
 
+bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
+{
+    ASSERT(applier);
+    GraphicsContext* scratch = scratchContext();
+    scratch->save();
+
+    applier->strokeStyle(scratch);
+
+    SkPaint paint;
+    scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
+    SkPath strokePath;
+    paint.getFillPath(*platformPath(), &strokePath);
+    bool contains = SkPathContainsPoint(&strokePath, point,
+                                        SkPath::kWinding_FillType);
+
+    scratch->restore();
+    return contains;
+}
 } // namespace WebCore