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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
3 * 2006 Rob Buis <buis@kde.org> 3 * 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2013 Google Inc. All rights reserved. 5 * Copyright (C) 2013 Google Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 sweepDegrees += s360; 298 sweepDegrees += s360;
299 299
300 m_path.arcTo(oval, startDegrees, sweepDegrees, false); 300 m_path.arcTo(oval, startDegrees, sweepDegrees, false);
301 } 301 }
302 302
303 void Path::addRect(const FloatRect& rect) 303 void Path::addRect(const FloatRect& rect)
304 { 304 {
305 m_path.addRect(rect); 305 m_path.addRect(rect);
306 } 306 }
307 307
308 void Path::addEllipse(const FloatPoint& p, float radiusX, float radiusY, float r otation, float startAngle, float endAngle, bool anticlockwise)
309 {
310 // Optimize the common case of an entire ellipse.
311 SkScalar twoPiScalar = WebCoreFloatToSkScalar(2 * piFloat);
312 SkScalar endAngleScalar = WebCoreFloatToSkScalar(endAngle);
313 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
314 FloatRect boundingRect(p - FloatSize(radiusX, radiusY), FloatSize(2 * ra diusX, 2 * radiusY));
315 if (anticlockwise && SkScalarNearlyEqual(twoPiScalar, -endAngleScalar)) {
316 m_path.addOval(boundingRect, SkPath::kCCW_Direction);
317 return;
318 }
319 if (!anticlockwise && SkScalarNearlyEqual(twoPiScalar, endAngleScalar)) {
320 m_path.addOval(boundingRect);
321 return;
322 }
323 }
324
325 // Add an arc after the relevant transform.
326 AffineTransform ellipseTransform = AffineTransform::translation(p.x(), p.y() ).rotate(rad2deg(rotation)).scale(radiusX, radiusY);
327 ASSERT(ellipseTransform.isInvertible());
328 AffineTransform inverseEllipseTransform = ellipseTransform.inverse();
329 transform(inverseEllipseTransform);
330 addArc(FloatPoint::zero(), 1 /* unit circle */, startAngle, endAngle, anticl ockwise);
331 transform(ellipseTransform);
332 }
333
308 void Path::addEllipse(const FloatRect& rect) 334 void Path::addEllipse(const FloatRect& rect)
309 { 335 {
310 m_path.addOval(rect); 336 m_path.addOval(rect);
311 } 337 }
312 338
313 void Path::addRoundedRect(const RoundedRect& r) 339 void Path::addRoundedRect(const RoundedRect& r)
314 { 340 {
315 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii( ).bottomLeft(), r.radii().bottomRight()); 341 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii( ).bottomLeft(), r.radii().bottomRight());
316 } 342 }
317 343
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 427
402 closeSubpath(); 428 closeSubpath();
403 } 429 }
404 430
405 void Path::translate(const FloatSize& size) 431 void Path::translate(const FloatSize& size)
406 { 432 {
407 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s ize.height())); 433 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s ize.height()));
408 } 434 }
409 435
410 } 436 }
OLDNEW
« 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