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

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: Make canvas-ellipse-360-winding.html for virtual/gpu pass. Created 7 years, 4 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/core/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/core/platform/graphics/Path.cpp
diff --git a/Source/core/platform/graphics/Path.cpp b/Source/core/platform/graphics/Path.cpp
index bb66e31a991bccca391548fa4a3ec8457386968a..04e3045b20a8c572fac75cfc46150a81b794de21 100644
--- a/Source/core/platform/graphics/Path.cpp
+++ b/Source/core/platform/graphics/Path.cpp
@@ -318,6 +318,32 @@ void Path::addRect(const FloatRect& rect)
m_path.addRect(rect);
}
+void Path::addEllipse(const FloatPoint& p, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise)
+{
+ // Optimize the common case of an entire ellipse.
+ SkScalar twoPiScalar = WebCoreFloatToSkScalar(2 * piFloat);
+ SkScalar endAngleScalar = WebCoreFloatToSkScalar(endAngle);
+ if (!rotation && !startAngle && SkScalarNearlyEqual(twoPiScalar, SkScalarAbs(endAngleScalar))) {
+ FloatRect boundingRect(p - FloatSize(radiusX, radiusY), FloatSize(2 * radiusX, 2 * radiusY));
+ if (anticlockwise && SkScalarNearlyEqual(twoPiScalar, -endAngleScalar)) {
+ m_path.addOval(boundingRect, SkPath::kCCW_Direction);
+ return;
+ }
+ if (!anticlockwise && SkScalarNearlyEqual(twoPiScalar, endAngleScalar)) {
+ m_path.addOval(boundingRect);
+ return;
+ }
+ }
+
+ // Add an arc after the relevant transform.
+ AffineTransform ellipseTransform = AffineTransform::translation(p.x(), p.y()).rotate(rad2deg(rotation)).scale(radiusX, radiusY);
+ ASSERT(ellipseTransform.isInvertible());
+ AffineTransform inverseEllipseTransform = ellipseTransform.inverse();
+ transform(inverseEllipseTransform);
+ addArc(FloatPoint::zero(), 1 /* unit circle */, startAngle, endAngle, anticlockwise);
+ transform(ellipseTransform);
+}
+
void Path::addEllipse(const FloatRect& rect)
{
m_path.addOval(rect);
« no previous file with comments | « Source/core/platform/graphics/Path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698