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

Unified Diff: Source/WebCore/rendering/svg/SVGMarkerData.h

Issue 10447082: Merge 117971 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/rendering/svg/RenderSVGShape.cpp ('k') | Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/svg/SVGMarkerData.h
===================================================================
--- Source/WebCore/rendering/svg/SVGMarkerData.h (revision 118879)
+++ Source/WebCore/rendering/svg/SVGMarkerData.h (working copy)
@@ -29,25 +29,58 @@
class RenderSVGResourceMarker;
+enum SVGMarkerType {
+ StartMarker,
+ MidMarker,
+ EndMarker
+};
+
+struct MarkerPosition {
+ MarkerPosition(SVGMarkerType useType, const FloatPoint& useOrigin, float useAngle)
+ : type(useType)
+ , origin(useOrigin)
+ , angle(useAngle)
+ {
+ }
+
+ SVGMarkerType type;
+ FloatPoint origin;
+ float angle;
+};
+
class SVGMarkerData {
public:
- enum Type {
- Unknown = 0,
- Start,
- Mid,
- End
- };
+ SVGMarkerData(Vector<MarkerPosition>& positions)
+ : m_positions(positions)
+ , m_elementIndex(0)
+ {
+ }
- SVGMarkerData(const Type& type = Unknown, RenderSVGResourceMarker* marker = 0)
- : m_type(type)
- , m_marker(marker)
+ static void updateFromPathElement(void* info, const PathElement* element)
{
+ SVGMarkerData* markerData = static_cast<SVGMarkerData*>(info);
+
+ // First update the outslope for the previous element.
+ markerData->updateOutslope(element->points[0]);
+
+ // Record the marker for the previous element.
+ if (markerData->m_elementIndex > 0) {
+ SVGMarkerType markerType = markerData->m_elementIndex == 1 ? StartMarker : MidMarker;
+ markerData->m_positions.append(MarkerPosition(markerType, markerData->m_origin, markerData->currentAngle(markerType)));
+ }
+
+ // Update our marker data for this element.
+ markerData->updateMarkerDataForPathElement(element);
+ ++markerData->m_elementIndex;
}
- FloatPoint origin() const { return m_origin; }
- RenderSVGResourceMarker* marker() const { return m_marker; }
+ void pathIsDone()
+ {
+ m_positions.append(MarkerPosition(EndMarker, m_origin, currentAngle(EndMarker)));
+ }
- float currentAngle() const
+private:
+ float currentAngle(SVGMarkerType type) const
{
FloatSize inslopeChange = m_inslopePoints[1] - m_inslopePoints[0];
FloatSize outslopeChange = m_outslopePoints[1] - m_outslopePoints[0];
@@ -55,31 +88,19 @@
double inslope = rad2deg(atan2(inslopeChange.height(), inslopeChange.width()));
double outslope = rad2deg(atan2(outslopeChange.height(), outslopeChange.width()));
- double angle = 0;
- switch (m_type) {
- case Start:
- angle = outslope;
- break;
- case Mid:
- angle = (inslope + outslope) / 2;
- break;
- case End:
- angle = inslope;
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
+ switch (type) {
+ case StartMarker:
+ return narrowPrecisionToFloat(outslope);
+ case MidMarker:
+ return narrowPrecisionToFloat((inslope + outslope) / 2);
+ case EndMarker:
+ return narrowPrecisionToFloat(inslope);
}
- return narrowPrecisionToFloat(angle);
+ ASSERT_NOT_REACHED();
+ return 0;
}
- void updateTypeAndMarker(const Type& type, RenderSVGResourceMarker* marker)
- {
- m_type = type;
- m_marker = marker;
- }
-
void updateOutslope(const FloatPoint& point)
{
m_outslopePoints[0] = m_origin;
@@ -113,15 +134,14 @@
}
}
-private:
void updateInslope(const FloatPoint& point)
{
m_inslopePoints[0] = m_origin;
m_inslopePoints[1] = point;
}
- Type m_type;
- RenderSVGResourceMarker* m_marker;
+ Vector<MarkerPosition>& m_positions;
+ unsigned m_elementIndex;
FloatPoint m_origin;
FloatPoint m_subpathStart;
FloatPoint m_inslopePoints[2];
« no previous file with comments | « Source/WebCore/rendering/svg/RenderSVGShape.cpp ('k') | Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698