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

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

Issue 2168133002: Compute exact bounds for SVGPathElement::getBBox() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: empty subpath workaround Created 4 years, 5 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 | « third_party/WebKit/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: third_party/WebKit/Source/platform/graphics/Path.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Path.cpp b/third_party/WebKit/Source/platform/graphics/Path.cpp
index 2fd75f846eb85a9d762f0115ee9bc2a8ea9b0e00..b163fa41326e1d38a190eb148ccd8e41bef2638c 100644
--- a/third_party/WebKit/Source/platform/graphics/Path.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Path.cpp
@@ -115,14 +115,31 @@ bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData)
return strokePath(strokeData).contains(WebCoreFloatToSkScalar(point.x()), WebCoreFloatToSkScalar(point.y()));
}
-FloatRect Path::boundingRect() const
+namespace {
+
+FloatRect pathBounds(const SkPath& path, Path::BoundsType boundsType)
+{
+ SkRect bounds;
+ if (boundsType == Path::BoundsType::Conservative
+ || !TightBounds(path, &bounds)
+ || bounds.isEmpty()) // workaround for https://bugs.chromium.org/p/skia/issues/detail?id=5555
+ return path.getBounds();
+
+ DCHECK(boundsType == Path::BoundsType::Exact);
fs 2016/07/21 19:21:40 (DCHECK_EQ? Or maybe that doesn't for enum class,
f(malita) 2016/07/22 18:40:01 Done.
+ return bounds;
+}
+
+} // anonymous ns
+
+// TODO(fmalita): evaluate returning exact bounds in all cases.
+FloatRect Path::boundingRect(BoundsType boundsType) const
{
- return m_path.getBounds();
+ return pathBounds(m_path, boundsType);
}
-FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const
+FloatRect Path::strokeBoundingRect(const StrokeData& strokeData, BoundsType boundsType) const
{
- return strokePath(strokeData).getBounds();
+ return pathBounds(strokePath(strokeData), boundsType);
}
static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int count)
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698