OLD | NEW |
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 sweepDegrees += s360; | 352 sweepDegrees += s360; |
353 | 353 |
354 m_path->arcTo(oval, startDegrees, sweepDegrees, false); | 354 m_path->arcTo(oval, startDegrees, sweepDegrees, false); |
355 } | 355 } |
356 | 356 |
357 void Path::addRect(const FloatRect& rect) | 357 void Path::addRect(const FloatRect& rect) |
358 { | 358 { |
359 ensureSkPath()->addRect(rect); | 359 ensureSkPath()->addRect(rect); |
360 } | 360 } |
361 | 361 |
| 362 void Path::addEllipse(const FloatPoint& p, float radiusX, float radiusY, float r
otation, float startAngle, float endAngle, bool anticlockwise) |
| 363 { |
| 364 if (!radiusX || !radiusY || startAngle == endAngle) { |
| 365 // The ellipse is empty but we still need to draw the connecting line to
start point. |
| 366 FloatPoint p1(p.x() + radiusX * cosf(startAngle + rotation), p.y() + rad
iusY * sinf(startAngle + rotation)); |
| 367 if (!hasCurrentPoint()) |
| 368 moveTo(p1); |
| 369 else if (p1 != currentPoint()) |
| 370 addLineTo(p1); |
| 371 return; |
| 372 } |
| 373 |
| 374 // Add an arc after the relevant transform. |
| 375 AffineTransform ellipseTransform = AffineTransform().rotate(rad2deg(rotation
)).scale(radiusX, radiusY); |
| 376 ASSERT(ellipseTransform.isInvertible()); |
| 377 AffineTransform inverseEllipseTransform = ellipseTransform.inverse(); |
| 378 transform(inverseEllipseTransform); |
| 379 float unitCircleRadius = 1.; |
| 380 addArc(inverseEllipseTransform.mapPoint(p), unitCircleRadius, startAngle, en
dAngle, anticlockwise); |
| 381 transform(ellipseTransform); |
| 382 } |
| 383 |
362 void Path::addEllipse(const FloatRect& rect) | 384 void Path::addEllipse(const FloatRect& rect) |
363 { | 385 { |
364 ensureSkPath()->addOval(rect); | 386 ensureSkPath()->addOval(rect); |
365 } | 387 } |
366 | 388 |
367 void Path::addRoundedRect(const RoundedRect& r) | 389 void Path::addRoundedRect(const RoundedRect& r) |
368 { | 390 { |
369 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii(
).bottomLeft(), r.radii().bottomRight()); | 391 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii(
).bottomLeft(), r.radii().bottomRight()); |
370 } | 392 } |
371 | 393 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 477 |
456 closeSubpath(); | 478 closeSubpath(); |
457 } | 479 } |
458 | 480 |
459 void Path::translate(const FloatSize& size) | 481 void Path::translate(const FloatSize& size) |
460 { | 482 { |
461 ensureSkPath()->offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToS
kScalar(size.height())); | 483 ensureSkPath()->offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToS
kScalar(size.height())); |
462 } | 484 } |
463 | 485 |
464 } | 486 } |
OLD | NEW |