Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1534)

Unified Diff: Source/platform/graphics/Path.cpp

Issue 1144353005: [SVG] Lower stroke hit testing resolution. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: +2 mac expectations Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/Path.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Path.cpp
diff --git a/Source/platform/graphics/Path.cpp b/Source/platform/graphics/Path.cpp
index 89875f5d836a73bd56e9c3fa0a5086af87b81c8b..f2b42c23e9be3c5fce307af558631488768c2dbd 100644
--- a/Source/platform/graphics/Path.cpp
+++ b/Source/platform/graphics/Path.cpp
@@ -71,14 +71,25 @@ bool Path::contains(const FloatPoint& point, WindRule rule) const
return SkPathContainsPoint(m_path, point, static_cast<SkPath::FillType>(rule));
}
-bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const
+// FIXME: this method ignores the CTM and may yield inaccurate results for large scales.
+SkPath Path::strokePath(const StrokeData& strokeData) const
{
SkPaint paint;
strokeData.setupPaint(&paint);
+
+ // Skia stroke resolution scale. This is multiplied by 4 internally
+ // (i.e. 1.0 corresponds to 1/4 pixel res).
+ static const SkScalar kResScale = 0.3f;
+
SkPath strokePath;
- paint.getFillPath(m_path, &strokePath);
+ paint.getFillPath(m_path, &strokePath, nullptr, kResScale);
+
+ return strokePath;
+}
- return SkPathContainsPoint(strokePath, point, SkPath::kWinding_FillType);
+bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const
+{
+ return SkPathContainsPoint(strokePath(strokeData), point, SkPath::kWinding_FillType);
}
FloatRect Path::boundingRect() const
@@ -88,12 +99,7 @@ FloatRect Path::boundingRect() const
FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const
{
- SkPaint paint;
- strokeData.setupPaint(&paint);
- SkPath boundingPath;
- paint.getFillPath(m_path, &boundingPath);
-
- return boundingPath.getBounds();
+ return strokePath(strokeData).getBounds();
}
static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int count)
« no previous file with comments | « Source/platform/graphics/Path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698