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

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

Issue 14298022: Add support for new canvas ellipse method. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 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
Index: Source/core/platform/graphics/Path.cpp
diff --git a/Source/core/platform/graphics/Path.cpp b/Source/core/platform/graphics/Path.cpp
index 57479a3b747535e0324b7ff1123f0a12c21f830a..03c87c28e4b49e48e34321ec05c8f856c3bf397c 100644
--- a/Source/core/platform/graphics/Path.cpp
+++ b/Source/core/platform/graphics/Path.cpp
@@ -359,6 +359,28 @@ void Path::addRect(const FloatRect& rect)
ensureSkPath()->addRect(rect);
}
+void Path::addEllipse(const FloatPoint& p, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise)
+{
+ if (!radiusX || !radiusY || startAngle == endAngle) {
+ // The ellipse is empty but we still need to draw the connecting line to start point.
+ FloatPoint p1(p.x() + radiusX * cosf(startAngle + rotation), p.y() + radiusY * sinf(startAngle + rotation));
+ if (!hasCurrentPoint())
+ moveTo(p1);
+ else if (p1 != currentPoint())
+ addLineTo(p1);
+ return;
+ }
+
+ // Add an arc after the relevant transform.
+ AffineTransform ellipseTransform = AffineTransform().rotate(rad2deg(rotation)).scale(radiusX, radiusY);
+ ASSERT(ellipseTransform.isInvertible());
+ AffineTransform inverseEllipseTransform = ellipseTransform.inverse();
+ transform(inverseEllipseTransform);
+ float unitCircleRadius = 1.;
+ addArc(inverseEllipseTransform.mapPoint(p), unitCircleRadius, startAngle, endAngle, anticlockwise);
+ transform(ellipseTransform);
+}
+
void Path::addEllipse(const FloatRect& rect)
{
ensureSkPath()->addOval(rect);
« Source/core/html/canvas/CanvasRenderingContext2D.idl ('K') | « Source/core/platform/graphics/Path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698