| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2002, 2003 The Karbon Developers | 2 * Copyright (C) 2002, 2003 The Karbon Developers |
| 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
| 4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> | 4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> |
| 5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "core/svg/SVGPathSource.h" | 27 #include "core/svg/SVGPathSource.h" |
| 28 #include "platform/transforms/AffineTransform.h" | 28 #include "platform/transforms/AffineTransform.h" |
| 29 #include "wtf/MathExtras.h" | 29 #include "wtf/MathExtras.h" |
| 30 | 30 |
| 31 static const float gOneOverThree = 1 / 3.f; | 31 static const float gOneOverThree = 1 / 3.f; |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 SVGPathParser::SVGPathParser() | 35 SVGPathParser::SVGPathParser() |
| 36 : m_consumer(0) | 36 : m_source(nullptr) |
| 37 , m_consumer(nullptr) |
| 37 { | 38 { |
| 38 } | 39 } |
| 39 | 40 |
| 41 void SVGPathParser::trace(Visitor* visitor) |
| 42 { |
| 43 visitor->trace(m_source); |
| 44 visitor->trace(m_consumer); |
| 45 } |
| 46 |
| 40 void SVGPathParser::parseClosePathSegment() | 47 void SVGPathParser::parseClosePathSegment() |
| 41 { | 48 { |
| 42 // Reset m_currentPoint for the next path. | 49 // Reset m_currentPoint for the next path. |
| 43 if (m_pathParsingMode == NormalizedParsing) | 50 if (m_pathParsingMode == NormalizedParsing) |
| 44 m_currentPoint = m_subPathPoint; | 51 m_currentPoint = m_subPathPoint; |
| 45 m_closePath = true; | 52 m_closePath = true; |
| 46 m_consumer->closePath(); | 53 m_consumer->closePath(); |
| 47 } | 54 } |
| 48 | 55 |
| 49 bool SVGPathParser::parseMoveToSegment() | 56 bool SVGPathParser::parseMoveToSegment() |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 402 |
| 396 return false; | 403 return false; |
| 397 } | 404 } |
| 398 | 405 |
| 399 void SVGPathParser::cleanup() | 406 void SVGPathParser::cleanup() |
| 400 { | 407 { |
| 401 ASSERT(m_source); | 408 ASSERT(m_source); |
| 402 ASSERT(m_consumer); | 409 ASSERT(m_consumer); |
| 403 | 410 |
| 404 m_consumer->cleanup(); | 411 m_consumer->cleanup(); |
| 405 m_source = 0; | 412 m_source = nullptr; |
| 406 m_consumer = 0; | 413 m_consumer = nullptr; |
| 407 } | 414 } |
| 408 | 415 |
| 409 // This works by converting the SVG arc to "simple" beziers. | 416 // This works by converting the SVG arc to "simple" beziers. |
| 410 // Partly adapted from Niko's code in kdelibs/kdecore/svgicons. | 417 // Partly adapted from Niko's code in kdelibs/kdecore/svgicons. |
| 411 // See also SVG implementation notes: http://www.w3.org/TR/SVG/implnote.html#Arc
ConversionEndpointToCenter | 418 // See also SVG implementation notes: http://www.w3.org/TR/SVG/implnote.html#Arc
ConversionEndpointToCenter |
| 412 bool SVGPathParser::decomposeArcToCubic(float angle, float rx, float ry, FloatPo
int& point1, FloatPoint& point2, bool largeArcFlag, bool sweepFlag) | 419 bool SVGPathParser::decomposeArcToCubic(float angle, float rx, float ry, FloatPo
int& point1, FloatPoint& point2, bool largeArcFlag, bool sweepFlag) |
| 413 { | 420 { |
| 414 FloatSize midPointDistance = point1 - point2; | 421 FloatSize midPointDistance = point1 - point2; |
| 415 midPointDistance.scale(0.5f); | 422 midPointDistance.scale(0.5f); |
| 416 | 423 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 point2 = targetPoint; | 493 point2 = targetPoint; |
| 487 point2.move(t * sinEndTheta, -t * cosEndTheta); | 494 point2.move(t * sinEndTheta, -t * cosEndTheta); |
| 488 | 495 |
| 489 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform
.mapPoint(point2), | 496 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform
.mapPoint(point2), |
| 490 pointTransform.mapPoint(targetPoint), AbsoluteC
oordinates); | 497 pointTransform.mapPoint(targetPoint), AbsoluteC
oordinates); |
| 491 } | 498 } |
| 492 return true; | 499 return true; |
| 493 } | 500 } |
| 494 | 501 |
| 495 } | 502 } |
| OLD | NEW |