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

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: Make canvas-ellipse-360-winding.html for virtual/gpu pass. Created 7 years, 3 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
« no previous file with comments | « Source/core/platform/graphics/Path.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 sweepDegrees += s360; 311 sweepDegrees += s360;
312 312
313 m_path.arcTo(oval, startDegrees, sweepDegrees, false); 313 m_path.arcTo(oval, startDegrees, sweepDegrees, false);
314 } 314 }
315 315
316 void Path::addRect(const FloatRect& rect) 316 void Path::addRect(const FloatRect& rect)
317 { 317 {
318 m_path.addRect(rect); 318 m_path.addRect(rect);
319 } 319 }
320 320
321 void Path::addEllipse(const FloatPoint& p, float radiusX, float radiusY, float r otation, float startAngle, float endAngle, bool anticlockwise)
322 {
323 // Optimize the common case of an entire ellipse.
324 SkScalar twoPiScalar = WebCoreFloatToSkScalar(2 * piFloat);
325 SkScalar endAngleScalar = WebCoreFloatToSkScalar(endAngle);
326 if (!rotation && !startAngle && SkScalarNearlyEqual(twoPiScalar, SkScalarAbs (endAngleScalar))) {
327 FloatRect boundingRect(p - FloatSize(radiusX, radiusY), FloatSize(2 * ra diusX, 2 * radiusY));
328 if (anticlockwise && SkScalarNearlyEqual(twoPiScalar, -endAngleScalar)) {
329 m_path.addOval(boundingRect, SkPath::kCCW_Direction);
330 return;
331 }
332 if (!anticlockwise && SkScalarNearlyEqual(twoPiScalar, endAngleScalar)) {
333 m_path.addOval(boundingRect);
334 return;
335 }
336 }
337
338 // Add an arc after the relevant transform.
339 AffineTransform ellipseTransform = AffineTransform::translation(p.x(), p.y() ).rotate(rad2deg(rotation)).scale(radiusX, radiusY);
340 ASSERT(ellipseTransform.isInvertible());
341 AffineTransform inverseEllipseTransform = ellipseTransform.inverse();
342 transform(inverseEllipseTransform);
343 addArc(FloatPoint::zero(), 1 /* unit circle */, startAngle, endAngle, anticl ockwise);
344 transform(ellipseTransform);
345 }
346
321 void Path::addEllipse(const FloatRect& rect) 347 void Path::addEllipse(const FloatRect& rect)
322 { 348 {
323 m_path.addOval(rect); 349 m_path.addOval(rect);
324 } 350 }
325 351
326 void Path::addRoundedRect(const RoundedRect& r) 352 void Path::addRoundedRect(const RoundedRect& r)
327 { 353 {
328 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii( ).bottomLeft(), r.radii().bottomRight()); 354 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii( ).bottomLeft(), r.radii().bottomRight());
329 } 355 }
330 356
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 { 440 {
415 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s ize.height())); 441 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s ize.height()));
416 } 442 }
417 443
418 bool Path::unionPath(const Path& other) 444 bool Path::unionPath(const Path& other)
419 { 445 {
420 return Op(m_path, other.m_path, kUnion_PathOp, &m_path); 446 return Op(m_path, other.m_path, kUnion_PathOp, &m_path);
421 } 447 }
422 448
423 } 449 }
OLDNEW
« 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