| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 SVGMarkerType type; | 43 SVGMarkerType type; |
| 44 FloatPoint origin; | 44 FloatPoint origin; |
| 45 float angle; | 45 float angle; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 class SVGMarkerData { | 48 class SVGMarkerData { |
| 49 public: | 49 public: |
| 50 SVGMarkerData(Vector<MarkerPosition>& positions) | 50 SVGMarkerData(Vector<MarkerPosition>& positions, bool autoStartReverse) |
| 51 : m_positions(positions) | 51 : m_positions(positions) |
| 52 , m_elementIndex(0) | 52 , m_elementIndex(0) |
| 53 , m_autoStartReverse(autoStartReverse) |
| 53 { | 54 { |
| 54 } | 55 } |
| 55 | 56 |
| 56 static void updateFromPathElement(void* info, const PathElement* element) | 57 static void updateFromPathElement(void* info, const PathElement* element) |
| 57 { | 58 { |
| 58 SVGMarkerData* markerData = static_cast<SVGMarkerData*>(info); | 59 SVGMarkerData* markerData = static_cast<SVGMarkerData*>(info); |
| 59 | 60 |
| 60 // First update the outslope for the previous element. | 61 // First update the outslope for the previous element. |
| 61 markerData->updateOutslope(element->points[0]); | 62 markerData->updateOutslope(element->points[0]); |
| 62 | 63 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 { | 82 { |
| 82 // For details of this calculation, see: http://www.w3.org/TR/SVG/single
-page.html#painting-MarkerElement | 83 // For details of this calculation, see: http://www.w3.org/TR/SVG/single
-page.html#painting-MarkerElement |
| 83 FloatPoint inSlope(m_inslopePoints[1] - m_inslopePoints[0]); | 84 FloatPoint inSlope(m_inslopePoints[1] - m_inslopePoints[0]); |
| 84 FloatPoint outSlope(m_outslopePoints[1] - m_outslopePoints[0]); | 85 FloatPoint outSlope(m_outslopePoints[1] - m_outslopePoints[0]); |
| 85 | 86 |
| 86 double inAngle = rad2deg(inSlope.slopeAngleRadians()); | 87 double inAngle = rad2deg(inSlope.slopeAngleRadians()); |
| 87 double outAngle = rad2deg(outSlope.slopeAngleRadians()); | 88 double outAngle = rad2deg(outSlope.slopeAngleRadians()); |
| 88 | 89 |
| 89 switch (type) { | 90 switch (type) { |
| 90 case StartMarker: | 91 case StartMarker: |
| 92 if (m_autoStartReverse) |
| 93 outAngle += 180; |
| 91 return narrowPrecisionToFloat(outAngle); | 94 return narrowPrecisionToFloat(outAngle); |
| 92 case MidMarker: | 95 case MidMarker: |
| 93 // WK193015: Prevent bugs due to angles being non-continuous. | 96 // WK193015: Prevent bugs due to angles being non-continuous. |
| 94 if (fabs(inAngle - outAngle) > 180) | 97 if (fabs(inAngle - outAngle) > 180) |
| 95 inAngle += 360; | 98 inAngle += 360; |
| 96 return narrowPrecisionToFloat((inAngle + outAngle) / 2); | 99 return narrowPrecisionToFloat((inAngle + outAngle) / 2); |
| 97 case EndMarker: | 100 case EndMarker: |
| 98 return narrowPrecisionToFloat(inAngle); | 101 return narrowPrecisionToFloat(inAngle); |
| 99 } | 102 } |
| 100 | 103 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 m_inslopePoints[0] = m_origin; | 143 m_inslopePoints[0] = m_origin; |
| 141 m_inslopePoints[1] = point; | 144 m_inslopePoints[1] = point; |
| 142 } | 145 } |
| 143 | 146 |
| 144 Vector<MarkerPosition>& m_positions; | 147 Vector<MarkerPosition>& m_positions; |
| 145 unsigned m_elementIndex; | 148 unsigned m_elementIndex; |
| 146 FloatPoint m_origin; | 149 FloatPoint m_origin; |
| 147 FloatPoint m_subpathStart; | 150 FloatPoint m_subpathStart; |
| 148 FloatPoint m_inslopePoints[2]; | 151 FloatPoint m_inslopePoints[2]; |
| 149 FloatPoint m_outslopePoints[2]; | 152 FloatPoint m_outslopePoints[2]; |
| 153 bool m_autoStartReverse; |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 } | 156 } |
| 153 | 157 |
| 154 #endif // SVGMarkerData_h | 158 #endif // SVGMarkerData_h |
| OLD | NEW |