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

Side by Side Diff: Source/core/svg/SVGPathSegListBuilder.cpp

Issue 1037463002: Rework the SVGPathConsumer interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase; FIXME -> TODO. Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGPathSegListBuilder.h ('k') | Source/core/svg/SVGPathStringBuilder.h » ('j') | 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) 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "core/svg/SVGPathSegLinetoVerticalRel.h" 45 #include "core/svg/SVGPathSegLinetoVerticalRel.h"
46 #include "core/svg/SVGPathSegMovetoAbs.h" 46 #include "core/svg/SVGPathSegMovetoAbs.h"
47 #include "core/svg/SVGPathSegMovetoRel.h" 47 #include "core/svg/SVGPathSegMovetoRel.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 SVGPathSegListBuilder::SVGPathSegListBuilder(SVGPathElement* pathElement, PassRe fPtrWillBeRawPtr<SVGPathSegList> pathSegList) 51 SVGPathSegListBuilder::SVGPathSegListBuilder(SVGPathElement* pathElement, PassRe fPtrWillBeRawPtr<SVGPathSegList> pathSegList)
52 : m_pathElement(pathElement) 52 : m_pathElement(pathElement)
53 , m_pathSegList(pathSegList) 53 , m_pathSegList(pathSegList)
54 { 54 {
55 ASSERT(m_pathElement);
56 ASSERT(m_pathSegList);
55 } 57 }
56 58
57 DEFINE_TRACE(SVGPathSegListBuilder) 59 DEFINE_TRACE(SVGPathSegListBuilder)
58 { 60 {
59 visitor->trace(m_pathElement); 61 visitor->trace(m_pathElement);
60 visitor->trace(m_pathSegList); 62 visitor->trace(m_pathSegList);
61 SVGPathConsumer::trace(visitor); 63 SVGPathConsumer::trace(visitor);
62 } 64 }
63 65
64 void SVGPathSegListBuilder::moveTo(const FloatPoint& targetPoint, PathCoordinate Mode mode) 66 void SVGPathSegListBuilder::emitSegment(const PathSegmentData& segment)
65 { 67 {
66 ASSERT(m_pathElement); 68 RefPtrWillBeRawPtr<SVGPathSeg> newPathSegment;
67 ASSERT(m_pathSegList); 69 switch (segment.command) {
68 if (mode == AbsoluteCoordinates) 70 case PathSegMoveToRel:
69 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegMovetoAbs::create(m _pathElement, targetPoint.x(), targetPoint.y())); 71 newPathSegment = SVGPathSegMovetoRel::create(m_pathElement, segment.targ etPoint.x(), segment.targetPoint.y());
70 else 72 break;
71 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegMovetoRel::create(m _pathElement, targetPoint.x(), targetPoint.y())); 73 case PathSegMoveToAbs:
72 } 74 newPathSegment = SVGPathSegMovetoAbs::create(m_pathElement, segment.targ etPoint.x(), segment.targetPoint.y());
73 75 break;
74 void SVGPathSegListBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinate Mode mode) 76 case PathSegLineToRel:
75 { 77 newPathSegment = SVGPathSegLinetoRel::create(m_pathElement, segment.targ etPoint.x(), segment.targetPoint.y());
76 ASSERT(m_pathElement); 78 break;
77 ASSERT(m_pathSegList); 79 case PathSegLineToAbs:
78 if (mode == AbsoluteCoordinates) 80 newPathSegment = SVGPathSegLinetoAbs::create(m_pathElement, segment.targ etPoint.x(), segment.targetPoint.y());
79 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoAbs::create(m _pathElement, targetPoint.x(), targetPoint.y())); 81 break;
80 else 82 case PathSegLineToHorizontalRel:
81 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoRel::create(m _pathElement, targetPoint.x(), targetPoint.y())); 83 newPathSegment = SVGPathSegLinetoHorizontalRel::create(m_pathElement, se gment.targetPoint.x());
82 } 84 break;
83 85 case PathSegLineToHorizontalAbs:
84 void SVGPathSegListBuilder::lineToHorizontal(float x, PathCoordinateMode mode) 86 newPathSegment = SVGPathSegLinetoHorizontalAbs::create(m_pathElement, se gment.targetPoint.x());
85 { 87 break;
86 ASSERT(m_pathElement); 88 case PathSegLineToVerticalRel:
87 ASSERT(m_pathSegList); 89 newPathSegment = SVGPathSegLinetoVerticalRel::create(m_pathElement, segm ent.targetPoint.y());
88 if (mode == AbsoluteCoordinates) 90 break;
89 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoHorizontalAbs ::create(m_pathElement, x)); 91 case PathSegLineToVerticalAbs:
90 else 92 newPathSegment = SVGPathSegLinetoVerticalAbs::create(m_pathElement, segm ent.targetPoint.y());
91 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoHorizontalRel ::create(m_pathElement, x)); 93 break;
92 } 94 case PathSegClosePath:
93 95 newPathSegment = SVGPathSegClosePath::create(m_pathElement);
94 void SVGPathSegListBuilder::lineToVertical(float y, PathCoordinateMode mode) 96 break;
95 { 97 case PathSegCurveToCubicRel:
96 ASSERT(m_pathElement); 98 newPathSegment = SVGPathSegCurvetoCubicRel::create(m_pathElement, segmen t.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.point1.y (), segment.point2.x(), segment.point2.y());
97 ASSERT(m_pathSegList); 99 break;
98 if (mode == AbsoluteCoordinates) 100 case PathSegCurveToCubicAbs:
99 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoVerticalAbs:: create(m_pathElement, y)); 101 newPathSegment = SVGPathSegCurvetoCubicAbs::create(m_pathElement, segmen t.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.point1.y (), segment.point2.x(), segment.point2.y());
100 else 102 break;
101 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegLinetoVerticalRel:: create(m_pathElement, y)); 103 case PathSegCurveToCubicSmoothRel:
102 } 104 newPathSegment = SVGPathSegCurvetoCubicSmoothRel::create(m_pathElement, segment.targetPoint.x(), segment.targetPoint.y(), segment.point2.x(), segment.po int2.y());
103 105 break;
104 void SVGPathSegListBuilder::curveToCubic(const FloatPoint& point1, const FloatPo int& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) 106 case PathSegCurveToCubicSmoothAbs:
105 { 107 newPathSegment = SVGPathSegCurvetoCubicSmoothAbs::create(m_pathElement, segment.targetPoint.x(), segment.targetPoint.y(), segment.point2.x(), segment.po int2.y());
106 ASSERT(m_pathElement); 108 break;
107 ASSERT(m_pathSegList); 109 case PathSegCurveToQuadraticRel:
108 if (mode == AbsoluteCoordinates) 110 newPathSegment = SVGPathSegCurvetoQuadraticRel::create(m_pathElement, se gment.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.poin t1.y());
109 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicAbs::cr eate(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), po int2.x(), point2.y())); 111 break;
110 else 112 case PathSegCurveToQuadraticAbs:
111 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicRel::cr eate(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), po int2.x(), point2.y())); 113 newPathSegment = SVGPathSegCurvetoQuadraticAbs::create(m_pathElement, se gment.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.poin t1.y());
112 } 114 break;
113 115 case PathSegCurveToQuadraticSmoothRel:
114 void SVGPathSegListBuilder::curveToCubicSmooth(const FloatPoint& point2, const F loatPoint& targetPoint, PathCoordinateMode mode) 116 newPathSegment = SVGPathSegCurvetoQuadraticSmoothRel::create(m_pathEleme nt, segment.targetPoint.x(), segment.targetPoint.y());
115 { 117 break;
116 ASSERT(m_pathElement); 118 case PathSegCurveToQuadraticSmoothAbs:
117 ASSERT(m_pathSegList); 119 newPathSegment = SVGPathSegCurvetoQuadraticSmoothAbs::create(m_pathEleme nt, segment.targetPoint.x(), segment.targetPoint.y());
118 if (mode == AbsoluteCoordinates) 120 break;
119 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicSmoothA bs::create(m_pathElement, targetPoint.x(), targetPoint.y(), point2.x(), point2.y ())); 121 case PathSegArcRel:
120 else 122 newPathSegment = SVGPathSegArcRel::create(m_pathElement, segment.targetP oint.x(), segment.targetPoint.y(), segment.arcRadii().x(), segment.arcRadii().y( ), segment.arcAngle(), segment.arcLarge, segment.arcSweep);
121 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoCubicSmoothR el::create(m_pathElement, targetPoint.x(), targetPoint.y(), point2.x(), point2.y ())); 123 break;
122 } 124 case PathSegArcAbs:
123 125 newPathSegment = SVGPathSegArcAbs::create(m_pathElement, segment.targetP oint.x(), segment.targetPoint.y(), segment.arcRadii().x(), segment.arcRadii().y( ), segment.arcAngle(), segment.arcLarge, segment.arcSweep);
124 void SVGPathSegListBuilder::curveToQuadratic(const FloatPoint& point1, const Flo atPoint& targetPoint, PathCoordinateMode mode) 126 break;
125 { 127 default:
126 ASSERT(m_pathElement); 128 ASSERT_NOT_REACHED();
127 ASSERT(m_pathSegList); 129 }
128 if (mode == AbsoluteCoordinates) 130 m_pathSegList->appendWithoutByteStreamSync(newPathSegment);
129 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticAbs ::create(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y() ));
130 else
131 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticRel ::create(m_pathElement, targetPoint.x(), targetPoint.y(), point1.x(), point1.y() ));
132 }
133
134 void SVGPathSegListBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint , PathCoordinateMode mode)
135 {
136 ASSERT(m_pathElement);
137 ASSERT(m_pathSegList);
138 if (mode == AbsoluteCoordinates)
139 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticSmo othAbs::create(m_pathElement, targetPoint.x(), targetPoint.y()));
140 else
141 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegCurvetoQuadraticSmo othRel::create(m_pathElement, targetPoint.x(), targetPoint.y()));
142 }
143
144 void SVGPathSegListBuilder::arcTo(float r1, float r2, float angle, bool largeArc Flag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode)
145 {
146 ASSERT(m_pathElement);
147 ASSERT(m_pathSegList);
148 if (mode == AbsoluteCoordinates)
149 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegArcAbs::create(m_pa thElement, targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepF lag));
150 else
151 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegArcRel::create(m_pa thElement, targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepF lag));
152 }
153
154 void SVGPathSegListBuilder::closePath()
155 {
156 ASSERT(m_pathElement);
157 ASSERT(m_pathSegList);
158 m_pathSegList->appendWithoutByteStreamSync(SVGPathSegClosePath::create(m_pat hElement));
159 } 131 }
160 132
161 } 133 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPathSegListBuilder.h ('k') | Source/core/svg/SVGPathStringBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698