OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const AffineTransform& RenderSVGResourceMarker::localToParentTransform() const | 87 const AffineTransform& RenderSVGResourceMarker::localToParentTransform() const |
88 { | 88 { |
89 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi
ewport.y()) * viewportTransform(); | 89 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi
ewport.y()) * viewportTransform(); |
90 return m_localToParentTransform; | 90 return m_localToParentTransform; |
91 // If this class were ever given a localTransform(), then the above would re
ad: | 91 // If this class were ever given a localTransform(), then the above would re
ad: |
92 // return viewportTranslation * localTransform() * viewportTransform(); | 92 // return viewportTranslation * localTransform() * viewportTransform(); |
93 } | 93 } |
94 | 94 |
95 FloatPoint RenderSVGResourceMarker::referencePoint() const | 95 FloatPoint RenderSVGResourceMarker::referencePoint() const |
96 { | 96 { |
97 SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); | 97 SVGMarkerElement* marker = toSVGMarkerElement(node()); |
98 ASSERT(marker); | 98 ASSERT(marker); |
99 | 99 |
100 SVGLengthContext lengthContext(marker); | 100 SVGLengthContext lengthContext(marker); |
101 return FloatPoint(marker->refXCurrentValue().value(lengthContext), marker->r
efYCurrentValue().value(lengthContext)); | 101 return FloatPoint(marker->refXCurrentValue().value(lengthContext), marker->r
efYCurrentValue().value(lengthContext)); |
102 } | 102 } |
103 | 103 |
104 float RenderSVGResourceMarker::angle() const | 104 float RenderSVGResourceMarker::angle() const |
105 { | 105 { |
106 SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); | 106 SVGMarkerElement* marker = toSVGMarkerElement(node()); |
107 ASSERT(marker); | 107 ASSERT(marker); |
108 | 108 |
109 float angle = -1; | 109 float angle = -1; |
110 if (marker->orientTypeCurrentValue() == SVGMarkerOrientAngle) | 110 if (marker->orientTypeCurrentValue() == SVGMarkerOrientAngle) |
111 angle = marker->orientAngleCurrentValue().value(); | 111 angle = marker->orientAngleCurrentValue().value(); |
112 | 112 |
113 return angle; | 113 return angle; |
114 } | 114 } |
115 | 115 |
116 AffineTransform RenderSVGResourceMarker::markerTransformation(const FloatPoint&
origin, float autoAngle, float strokeWidth) const | 116 AffineTransform RenderSVGResourceMarker::markerTransformation(const FloatPoint&
origin, float autoAngle, float strokeWidth) const |
117 { | 117 { |
118 SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); | 118 SVGMarkerElement* marker = toSVGMarkerElement(node()); |
119 ASSERT(marker); | 119 ASSERT(marker); |
120 | 120 |
121 float markerAngle = angle(); | 121 float markerAngle = angle(); |
122 bool useStrokeWidth = marker->markerUnitsCurrentValue() == SVGMarkerUnitsStr
okeWidth; | 122 bool useStrokeWidth = marker->markerUnitsCurrentValue() == SVGMarkerUnitsStr
okeWidth; |
123 | 123 |
124 AffineTransform transform; | 124 AffineTransform transform; |
125 transform.translate(origin.x(), origin.y()); | 125 transform.translate(origin.x(), origin.y()); |
126 transform.rotate(markerAngle == -1 ? autoAngle : markerAngle); | 126 transform.rotate(markerAngle == -1 ? autoAngle : markerAngle); |
127 transform = markerContentTransformation(transform, referencePoint(), useStro
keWidth ? strokeWidth : -1); | 127 transform = markerContentTransformation(transform, referencePoint(), useStro
keWidth ? strokeWidth : -1); |
128 return transform; | 128 return transform; |
(...skipping 21 matching lines...) Expand all Loading... |
150 AffineTransform transformation = contentTransformation; | 150 AffineTransform transformation = contentTransformation; |
151 if (strokeWidth != -1) | 151 if (strokeWidth != -1) |
152 transformation.scaleNonUniform(strokeWidth, strokeWidth); | 152 transformation.scaleNonUniform(strokeWidth, strokeWidth); |
153 | 153 |
154 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); | 154 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); |
155 return transformation; | 155 return transformation; |
156 } | 156 } |
157 | 157 |
158 AffineTransform RenderSVGResourceMarker::viewportTransform() const | 158 AffineTransform RenderSVGResourceMarker::viewportTransform() const |
159 { | 159 { |
160 SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); | 160 SVGMarkerElement* marker = toSVGMarkerElement(node()); |
161 ASSERT(marker); | 161 ASSERT(marker); |
162 | 162 |
163 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height(
)); | 163 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height(
)); |
164 } | 164 } |
165 | 165 |
166 void RenderSVGResourceMarker::calcViewport() | 166 void RenderSVGResourceMarker::calcViewport() |
167 { | 167 { |
168 if (!selfNeedsLayout()) | 168 if (!selfNeedsLayout()) |
169 return; | 169 return; |
170 | 170 |
171 SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node()); | 171 SVGMarkerElement* marker = toSVGMarkerElement(node()); |
172 ASSERT(marker); | 172 ASSERT(marker); |
173 | 173 |
174 SVGLengthContext lengthContext(marker); | 174 SVGLengthContext lengthContext(marker); |
175 float w = marker->markerWidthCurrentValue().value(lengthContext); | 175 float w = marker->markerWidthCurrentValue().value(lengthContext); |
176 float h = marker->markerHeightCurrentValue().value(lengthContext); | 176 float h = marker->markerHeightCurrentValue().value(lengthContext); |
177 m_viewport = FloatRect(0, 0, w, h); | 177 m_viewport = FloatRect(0, 0, w, h); |
178 } | 178 } |
179 | 179 |
180 } | 180 } |
OLD | NEW |