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

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: Match addEllipse impl to addArc style. Add 4 more layout tests. Created 7 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
Index: Source/core/platform/graphics/Path.cpp
diff --git a/Source/core/platform/graphics/Path.cpp b/Source/core/platform/graphics/Path.cpp
index f70126594af34acf02f8ae71ceb686aa18ca0440..8b05e64c86cf1ca92bfec6b710cb838c28f98b72 100644
--- a/Source/core/platform/graphics/Path.cpp
+++ b/Source/core/platform/graphics/Path.cpp
@@ -305,6 +305,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))) {
Stephen White 2013/07/09 13:58:08 If we're doing an approximate comparison for the e
dshwang 2013/07/09 14:42:05 I made it with intention. Let me explain. First o
+ 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);
« Source/core/html/canvas/CanvasPathMethods.cpp ('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