| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qstroker.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | class QSubpathForwardIterator | - | ||||||||||||||||||||||||
| 7 | { | - | ||||||||||||||||||||||||
| 8 | public: | - | ||||||||||||||||||||||||
| 9 | QSubpathForwardIterator(const QDataBuffer<QStrokerOps::Element> *path) | - | ||||||||||||||||||||||||
| 10 | : m_path(path), m_pos(0) { } never executed: end of block | 0 | ||||||||||||||||||||||||
| 11 | inline int position() const { return never executed: m_pos;return m_pos;never executed: }return m_pos; | 0 | ||||||||||||||||||||||||
| 12 | inline bool hasNext() const { return never executed: m_pos < m_path->size();return m_pos < m_path->size();never executed: }return m_pos < m_path->size(); | 0 | ||||||||||||||||||||||||
| 13 | inline QStrokerOps::Element next() { ((!(hasNext())) ? qt_assert("hasNext()",__FILE__,57) : qt_noop()); return never executed: m_path->at(m_pos++);return m_path->at(m_pos++);never executed: }return m_path->at(m_pos++); | 0 | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | private: | - | ||||||||||||||||||||||||
| 16 | const QDataBuffer<QStrokerOps::Element> *m_path; | - | ||||||||||||||||||||||||
| 17 | int m_pos; | - | ||||||||||||||||||||||||
| 18 | }; | - | ||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | class QSubpathBackwardIterator | - | ||||||||||||||||||||||||
| 21 | { | - | ||||||||||||||||||||||||
| 22 | public: | - | ||||||||||||||||||||||||
| 23 | QSubpathBackwardIterator(const QDataBuffer<QStrokerOps::Element> *path) | - | ||||||||||||||||||||||||
| 24 | : m_path(path), m_pos(path->size() - 1) { } never executed: end of block | 0 | ||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | inline int position() const { return never executed: m_pos;return m_pos;never executed: }return m_pos; | 0 | ||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | inline bool hasNext() const { return never executed: m_pos >= 0;return m_pos >= 0;never executed: }return m_pos >= 0; | 0 | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | inline QStrokerOps::Element next() | - | ||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | ((!(hasNext())) ? qt_assert("hasNext()",__FILE__,76) : qt_noop()); | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | QStrokerOps::Element ce = m_path->at(m_pos); | - | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | if (m_pos == m_path->size() - 1
| 0 | ||||||||||||||||||||||||
| 37 | --m_pos; | - | ||||||||||||||||||||||||
| 38 | ce.type = QPainterPath::MoveToElement; | - | ||||||||||||||||||||||||
| 39 | return never executed: ce;return ce;never executed: return ce; | 0 | ||||||||||||||||||||||||
| 40 | } | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | const QStrokerOps::Element &pe = m_path->at(m_pos + 1); | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | switch (pe.type) { | - | ||||||||||||||||||||||||
| 45 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||||||||||||||
| 46 | ce.type = QPainterPath::LineToElement; | - | ||||||||||||||||||||||||
| 47 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 48 | case never executed: QPainterPath::CurveToDataElement:case QPainterPath::CurveToDataElement:never executed: case QPainterPath::CurveToDataElement: | 0 | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | if (ce.type == QPainterPath::CurveToElement
| 0 | ||||||||||||||||||||||||
| 51 | ce.type = QPainterPath::CurveToDataElement; | - | ||||||||||||||||||||||||
| 52 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 53 | ce.type = QPainterPath::CurveToElement; | - | ||||||||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 55 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 56 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||||||||||||||
| 57 | ce.type = QPainterPath::CurveToDataElement; | - | ||||||||||||||||||||||||
| 58 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 59 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 60 | QMessageLogger(__FILE__, 104, __PRETTY_FUNCTION__).warning("QSubpathReverseIterator::next: Case %d unhandled", ce.type); | - | ||||||||||||||||||||||||
| 61 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 62 | } | - | ||||||||||||||||||||||||
| 63 | --m_pos; | - | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | return never executed: ce;return ce;never executed: return ce; | 0 | ||||||||||||||||||||||||
| 66 | } | - | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | private: | - | ||||||||||||||||||||||||
| 69 | const QDataBuffer<QStrokerOps::Element> *m_path; | - | ||||||||||||||||||||||||
| 70 | int m_pos; | - | ||||||||||||||||||||||||
| 71 | }; | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | class QSubpathFlatIterator | - | ||||||||||||||||||||||||
| 74 | { | - | ||||||||||||||||||||||||
| 75 | public: | - | ||||||||||||||||||||||||
| 76 | QSubpathFlatIterator(const QDataBuffer<QStrokerOps::Element> *path, qreal threshold) | - | ||||||||||||||||||||||||
| 77 | : m_path(path), m_pos(0), m_curve_index(-1), m_curve_threshold(threshold) { } never executed: end of block | 0 | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | inline bool hasNext() const { return never executed: m_curve_index >= 0 || m_pos < m_path->size();return m_curve_index >= 0 || m_pos < m_path->size();never executed: }return m_curve_index >= 0 || m_pos < m_path->size(); | 0 | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | QStrokerOps::Element next() | - | ||||||||||||||||||||||||
| 82 | { | - | ||||||||||||||||||||||||
| 83 | ((!(hasNext())) ? qt_assert("hasNext()",__FILE__,127) : qt_noop()); | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | if (m_curve_index >= 0
| 0 | ||||||||||||||||||||||||
| 86 | QStrokerOps::Element e = { QPainterPath::LineToElement, | - | ||||||||||||||||||||||||
| 87 | qfixed(m_curve.at(m_curve_index).x()), | - | ||||||||||||||||||||||||
| 88 | qfixed(m_curve.at(m_curve_index).y()) | - | ||||||||||||||||||||||||
| 89 | }; | - | ||||||||||||||||||||||||
| 90 | ++m_curve_index; | - | ||||||||||||||||||||||||
| 91 | if (m_curve_index >= m_curve.size()
| 0 | ||||||||||||||||||||||||
| 92 | m_curve_index = -1; never executed: m_curve_index = -1; | 0 | ||||||||||||||||||||||||
| 93 | return never executed: e;return e;never executed: return e; | 0 | ||||||||||||||||||||||||
| 94 | } | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | QStrokerOps::Element e = m_path->at(m_pos); | - | ||||||||||||||||||||||||
| 97 | if (e.isCurveTo()
| 0 | ||||||||||||||||||||||||
| 98 | ((!(m_pos > 0)) ? qt_assert("m_pos > 0",__FILE__,142) : qt_noop()); | - | ||||||||||||||||||||||||
| 99 | ((!(m_pos < m_path->size())) ? qt_assert("m_pos < m_path->size()",__FILE__,143) : qt_noop()); | - | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | m_curve = QBezier::fromPoints(QPointF(m_path->at(m_pos-1).x, | - | ||||||||||||||||||||||||
| 102 | m_path->at(m_pos-1).y), | - | ||||||||||||||||||||||||
| 103 | QPointF(e.x, | - | ||||||||||||||||||||||||
| 104 | e.y), | - | ||||||||||||||||||||||||
| 105 | QPointF(m_path->at(m_pos+1).x, | - | ||||||||||||||||||||||||
| 106 | m_path->at(m_pos+1).y), | - | ||||||||||||||||||||||||
| 107 | QPointF(m_path->at(m_pos+2).x, | - | ||||||||||||||||||||||||
| 108 | m_path->at(m_pos+2).y)).toPolygon(m_curve_threshold); | - | ||||||||||||||||||||||||
| 109 | m_curve_index = 1; | - | ||||||||||||||||||||||||
| 110 | e.type = QPainterPath::LineToElement; | - | ||||||||||||||||||||||||
| 111 | e.x = m_curve.at(0).x(); | - | ||||||||||||||||||||||||
| 112 | e.y = m_curve.at(0).y(); | - | ||||||||||||||||||||||||
| 113 | m_pos += 2; | - | ||||||||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 115 | ((!(e.isLineTo() || e.isMoveTo())) ? qt_assert("e.isLineTo() || e.isMoveTo()",__FILE__,159) : qt_noop()); | - | ||||||||||||||||||||||||
| 116 | ++m_pos; | - | ||||||||||||||||||||||||
| 117 | return never executed: e;return e;never executed: return e; | 0 | ||||||||||||||||||||||||
| 118 | } | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | private: | - | ||||||||||||||||||||||||
| 121 | const QDataBuffer<QStrokerOps::Element> *m_path; | - | ||||||||||||||||||||||||
| 122 | int m_pos; | - | ||||||||||||||||||||||||
| 123 | QPolygonF m_curve; | - | ||||||||||||||||||||||||
| 124 | int m_curve_index; | - | ||||||||||||||||||||||||
| 125 | qreal m_curve_threshold; | - | ||||||||||||||||||||||||
| 126 | }; | - | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | template <class Iterator> bool qt_stroke_side(Iterator *it, QStroker *stroker, | - | ||||||||||||||||||||||||
| 129 | bool capFirst, QLineF *startTangent); | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | static inline qreal adapted_angle_on_x(const QLineF &line) | - | ||||||||||||||||||||||||
| 136 | { | - | ||||||||||||||||||||||||
| 137 | qreal angle = line.angle(QLineF(0, 0, 1, 0)); | - | ||||||||||||||||||||||||
| 138 | if (line.dy() > 0
| 0 | ||||||||||||||||||||||||
| 139 | angle = 360 - angle; never executed: angle = 360 - angle; | 0 | ||||||||||||||||||||||||
| 140 | return never executed: angle;return angle;never executed: return angle; | 0 | ||||||||||||||||||||||||
| 141 | } | - | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | QStrokerOps::QStrokerOps() | - | ||||||||||||||||||||||||
| 144 | : m_elements(0) | - | ||||||||||||||||||||||||
| 145 | , m_curveThreshold(qfixed(0.25)) | - | ||||||||||||||||||||||||
| 146 | , m_dashThreshold(qfixed(0.25)) | - | ||||||||||||||||||||||||
| 147 | , m_customData(0) | - | ||||||||||||||||||||||||
| 148 | , m_moveTo(0) | - | ||||||||||||||||||||||||
| 149 | , m_lineTo(0) | - | ||||||||||||||||||||||||
| 150 | , m_cubicTo(0) | - | ||||||||||||||||||||||||
| 151 | { | - | ||||||||||||||||||||||||
| 152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | QStrokerOps::~QStrokerOps() | - | ||||||||||||||||||||||||
| 155 | { | - | ||||||||||||||||||||||||
| 156 | } | - | ||||||||||||||||||||||||
| 157 | void QStrokerOps::begin(void *customData) | - | ||||||||||||||||||||||||
| 158 | { | - | ||||||||||||||||||||||||
| 159 | m_customData = customData; | - | ||||||||||||||||||||||||
| 160 | m_elements.reset(); | - | ||||||||||||||||||||||||
| 161 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | void QStrokerOps::end() | - | ||||||||||||||||||||||||
| 169 | { | - | ||||||||||||||||||||||||
| 170 | if (m_elements.size() > 1
| 0 | ||||||||||||||||||||||||
| 171 | processCurrentSubpath(); never executed: processCurrentSubpath(); | 0 | ||||||||||||||||||||||||
| 172 | m_customData = 0; | - | ||||||||||||||||||||||||
| 173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 174 | void QStrokerOps::strokePath(const QPainterPath &path, void *customData, const QTransform &matrix) | - | ||||||||||||||||||||||||
| 175 | { | - | ||||||||||||||||||||||||
| 176 | if (path.isEmpty()
| 0 | ||||||||||||||||||||||||
| 177 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | setCurveThresholdFromTransform(QTransform()); | - | ||||||||||||||||||||||||
| 180 | begin(customData); | - | ||||||||||||||||||||||||
| 181 | int count = path.elementCount(); | - | ||||||||||||||||||||||||
| 182 | if (matrix.isIdentity()
| 0 | ||||||||||||||||||||||||
| 183 | for (int i=0; i<count
| 0 | ||||||||||||||||||||||||
| 184 | const QPainterPath::Element &e = path.elementAt(i); | - | ||||||||||||||||||||||||
| 185 | switch (e.type) { | - | ||||||||||||||||||||||||
| 186 | case never executed: QPainterPath::MoveToElement:case QPainterPath::MoveToElement:never executed: case QPainterPath::MoveToElement: | 0 | ||||||||||||||||||||||||
| 187 | moveTo(qfixed(e.x), qfixed(e.y)); | - | ||||||||||||||||||||||||
| 188 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 189 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||||||||||||||
| 190 | lineTo(qfixed(e.x), qfixed(e.y)); | - | ||||||||||||||||||||||||
| 191 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 192 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||||||||||||||
| 193 | { | - | ||||||||||||||||||||||||
| 194 | const QPainterPath::Element &cp2 = path.elementAt(++i); | - | ||||||||||||||||||||||||
| 195 | const QPainterPath::Element &ep = path.elementAt(++i); | - | ||||||||||||||||||||||||
| 196 | cubicTo(qfixed(e.x), qfixed(e.y), | - | ||||||||||||||||||||||||
| 197 | qfixed(cp2.x), qfixed(cp2.y), | - | ||||||||||||||||||||||||
| 198 | qfixed(ep.x), qfixed(ep.y)); | - | ||||||||||||||||||||||||
| 199 | } | - | ||||||||||||||||||||||||
| 200 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 201 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 202 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 203 | } | - | ||||||||||||||||||||||||
| 204 | } | - | ||||||||||||||||||||||||
| 205 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 206 | for (int i=0; i<count
| 0 | ||||||||||||||||||||||||
| 207 | const QPainterPath::Element &e = path.elementAt(i); | - | ||||||||||||||||||||||||
| 208 | QPointF pt = QPointF(e.x, e.y) * matrix; | - | ||||||||||||||||||||||||
| 209 | switch (e.type) { | - | ||||||||||||||||||||||||
| 210 | case never executed: QPainterPath::MoveToElement:case QPainterPath::MoveToElement:never executed: case QPainterPath::MoveToElement: | 0 | ||||||||||||||||||||||||
| 211 | moveTo(qfixed(pt.x()), qfixed(pt.y())); | - | ||||||||||||||||||||||||
| 212 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 213 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||||||||||||||
| 214 | lineTo(qfixed(pt.x()), qfixed(pt.y())); | - | ||||||||||||||||||||||||
| 215 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 216 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||||||||||||||
| 217 | { | - | ||||||||||||||||||||||||
| 218 | QPointF cp2 = ((QPointF) path.elementAt(++i)) * matrix; | - | ||||||||||||||||||||||||
| 219 | QPointF ep = ((QPointF) path.elementAt(++i)) * matrix; | - | ||||||||||||||||||||||||
| 220 | cubicTo(qfixed(pt.x()), qfixed(pt.y()), | - | ||||||||||||||||||||||||
| 221 | qfixed(cp2.x()), qfixed(cp2.y()), | - | ||||||||||||||||||||||||
| 222 | qfixed(ep.x()), qfixed(ep.y())); | - | ||||||||||||||||||||||||
| 223 | } | - | ||||||||||||||||||||||||
| 224 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 225 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 226 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||
| 228 | } | - | ||||||||||||||||||||||||
| 229 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 230 | end(); | - | ||||||||||||||||||||||||
| 231 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 232 | void QStrokerOps::strokePolygon(const QPointF *points, int pointCount, bool implicit_close, | - | ||||||||||||||||||||||||
| 233 | void *data, const QTransform &matrix) | - | ||||||||||||||||||||||||
| 234 | { | - | ||||||||||||||||||||||||
| 235 | if (!pointCount
| 0 | ||||||||||||||||||||||||
| 236 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | setCurveThresholdFromTransform(QTransform()); | - | ||||||||||||||||||||||||
| 239 | begin(data); | - | ||||||||||||||||||||||||
| 240 | if (matrix.isIdentity()
| 0 | ||||||||||||||||||||||||
| 241 | moveTo(qfixed(points[0].x()), qfixed(points[0].y())); | - | ||||||||||||||||||||||||
| 242 | for (int i=1; i<pointCount
| 0 | ||||||||||||||||||||||||
| 243 | lineTo(qfixed(points[i].x()), never executed: lineTo(qfixed(points[i].x()), qfixed(points[i].y())); | 0 | ||||||||||||||||||||||||
| 244 | qfixed(points[i].y())); never executed: lineTo(qfixed(points[i].x()), qfixed(points[i].y())); | 0 | ||||||||||||||||||||||||
| 245 | if (implicit_close
| 0 | ||||||||||||||||||||||||
| 246 | lineTo(qfixed(points[0].x()), qfixed(points[0].y())); never executed: lineTo(qfixed(points[0].x()), qfixed(points[0].y())); | 0 | ||||||||||||||||||||||||
| 247 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 248 | QPointF start = points[0] * matrix; | - | ||||||||||||||||||||||||
| 249 | moveTo(qfixed(start.x()), qfixed(start.y())); | - | ||||||||||||||||||||||||
| 250 | for (int i=1; i<pointCount
| 0 | ||||||||||||||||||||||||
| 251 | QPointF pt = points[i] * matrix; | - | ||||||||||||||||||||||||
| 252 | lineTo(qfixed(pt.x()), qfixed(pt.y())); | - | ||||||||||||||||||||||||
| 253 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 254 | if (implicit_close
| 0 | ||||||||||||||||||||||||
| 255 | lineTo(qfixed(start.x()), qfixed(start.y())); never executed: lineTo(qfixed(start.x()), qfixed(start.y())); | 0 | ||||||||||||||||||||||||
| 256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 257 | end(); | - | ||||||||||||||||||||||||
| 258 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform &matrix) | - | ||||||||||||||||||||||||
| 266 | { | - | ||||||||||||||||||||||||
| 267 | int count = 0; | - | ||||||||||||||||||||||||
| 268 | QPointF pts[12]; | - | ||||||||||||||||||||||||
| 269 | QPointF start = qt_curves_for_arc(rect, 0, -360, pts, &count); | - | ||||||||||||||||||||||||
| 270 | ((!(count == 12)) ? qt_assert("count == 12",__FILE__,348) : qt_noop()); | - | ||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | if (!matrix.isIdentity()
| 0 | ||||||||||||||||||||||||
| 273 | start = start * matrix; | - | ||||||||||||||||||||||||
| 274 | for (int i=0; i<12
| 0 | ||||||||||||||||||||||||
| 275 | pts[i] = pts[i] * matrix; | - | ||||||||||||||||||||||||
| 276 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 277 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||
| 279 | setCurveThresholdFromTransform(QTransform()); | - | ||||||||||||||||||||||||
| 280 | begin(data); | - | ||||||||||||||||||||||||
| 281 | moveTo(qfixed(start.x()), qfixed(start.y())); | - | ||||||||||||||||||||||||
| 282 | for (int i=0; i<12
| 0 | ||||||||||||||||||||||||
| 283 | cubicTo(qfixed(pts[i].x()), qfixed(pts[i].y()), | - | ||||||||||||||||||||||||
| 284 | qfixed(pts[i+1].x()), qfixed(pts[i+1].y()), | - | ||||||||||||||||||||||||
| 285 | qfixed(pts[i+2].x()), qfixed(pts[i+2].y())); | - | ||||||||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 287 | end(); | - | ||||||||||||||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | QStroker::QStroker() | - | ||||||||||||||||||||||||
| 292 | : m_capStyle(SquareJoin), m_joinStyle(FlatJoin), | - | ||||||||||||||||||||||||
| 293 | m_back1X(0), m_back1Y(0), | - | ||||||||||||||||||||||||
| 294 | m_back2X(0), m_back2Y(0) | - | ||||||||||||||||||||||||
| 295 | { | - | ||||||||||||||||||||||||
| 296 | m_strokeWidth = qfixed(1); | - | ||||||||||||||||||||||||
| 297 | m_miterLimit = qfixed(2); | - | ||||||||||||||||||||||||
| 298 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | QStroker::~QStroker() | - | ||||||||||||||||||||||||
| 301 | { | - | ||||||||||||||||||||||||
| 302 | } | - | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | Qt::PenCapStyle QStroker::capForJoinMode(LineJoinMode mode) | - | ||||||||||||||||||||||||
| 305 | { | - | ||||||||||||||||||||||||
| 306 | if (mode == FlatJoin
never executed: Qt::FlatCap;return Qt::FlatCap;never executed: return Qt::FlatCap; | 0 | ||||||||||||||||||||||||
| 307 | else if (mode == SquareJoin
never executed: Qt::SquareCap;return Qt::SquareCap;never executed: return Qt::SquareCap; | 0 | ||||||||||||||||||||||||
| 308 | else return never executed: Qt::RoundCap;return Qt::RoundCap;never executed: return Qt::RoundCap; | 0 | ||||||||||||||||||||||||
| 309 | } | - | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | QStroker::LineJoinMode QStroker::joinModeForCap(Qt::PenCapStyle style) | - | ||||||||||||||||||||||||
| 312 | { | - | ||||||||||||||||||||||||
| 313 | if (style == Qt::FlatCap
never executed: FlatJoin;return FlatJoin;never executed: return FlatJoin; | 0 | ||||||||||||||||||||||||
| 314 | else if (style == Qt::SquareCap
never executed: SquareJoin;return SquareJoin;never executed: return SquareJoin; | 0 | ||||||||||||||||||||||||
| 315 | else return never executed: RoundCap;return RoundCap;never executed: return RoundCap; | 0 | ||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||
| 318 | Qt::PenJoinStyle QStroker::joinForJoinMode(LineJoinMode mode) | - | ||||||||||||||||||||||||
| 319 | { | - | ||||||||||||||||||||||||
| 320 | if (mode == FlatJoin
never executed: Qt::BevelJoin;return Qt::BevelJoin;never executed: return Qt::BevelJoin; | 0 | ||||||||||||||||||||||||
| 321 | else if (mode == MiterJoin
never executed: Qt::MiterJoin;return Qt::MiterJoin;never executed: return Qt::MiterJoin; | 0 | ||||||||||||||||||||||||
| 322 | else if (mode == SvgMiterJoin
never executed: Qt::SvgMiterJoin;return Qt::SvgMiterJoin;never executed: return Qt::SvgMiterJoin; | 0 | ||||||||||||||||||||||||
| 323 | else return never executed: Qt::RoundJoin;return Qt::RoundJoin;never executed: return Qt::RoundJoin; | 0 | ||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | QStroker::LineJoinMode QStroker::joinModeForJoin(Qt::PenJoinStyle joinStyle) | - | ||||||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||||||||
| 328 | if (joinStyle == Qt::BevelJoin
never executed: FlatJoin;return FlatJoin;never executed: return FlatJoin; | 0 | ||||||||||||||||||||||||
| 329 | else if (joinStyle == Qt::MiterJoin
never executed: MiterJoin;return MiterJoin;never executed: return MiterJoin; | 0 | ||||||||||||||||||||||||
| 330 | else if (joinStyle == Qt::SvgMiterJoin
never executed: SvgMiterJoin;return SvgMiterJoin;never executed: return SvgMiterJoin; | 0 | ||||||||||||||||||||||||
| 331 | else return never executed: RoundJoin;return RoundJoin;never executed: return RoundJoin; | 0 | ||||||||||||||||||||||||
| 332 | } | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | void QStroker::processCurrentSubpath() | - | ||||||||||||||||||||||||
| 340 | { | - | ||||||||||||||||||||||||
| 341 | ((!(!m_elements.isEmpty())) ? qt_assert("!m_elements.isEmpty()",__FILE__,419) : qt_noop()); | - | ||||||||||||||||||||||||
| 342 | ((!(m_elements.first().type == QPainterPath::MoveToElement)) ? qt_assert("m_elements.first().type == QPainterPath::MoveToElement",__FILE__,420) : qt_noop()); | - | ||||||||||||||||||||||||
| 343 | ((!(m_elements.size() > 1)) ? qt_assert("m_elements.size() > 1",__FILE__,421) : qt_noop()); | - | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | QSubpathForwardIterator fwit(&m_elements); | - | ||||||||||||||||||||||||
| 346 | QSubpathBackwardIterator bwit(&m_elements); | - | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | QLineF fwStartTangent, bwStartTangent; | - | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | bool fwclosed = qt_stroke_side(&fwit, this, false, &fwStartTangent); | - | ||||||||||||||||||||||||
| 351 | bool bwclosed = qt_stroke_side(&bwit, this, !fwclosed, &bwStartTangent); | - | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | if (!bwclosed
| 0 | ||||||||||||||||||||||||
| 354 | joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle); never executed: joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle); | 0 | ||||||||||||||||||||||||
| 355 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine, LineJoinMode join) | - | ||||||||||||||||||||||||
| 362 | { | - | ||||||||||||||||||||||||
| 363 | if (qFuzzyCompare(m_back1X, nextLine.x1())
| 0 | ||||||||||||||||||||||||
| 364 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||
| 372 | if (join == FlatJoin
| 0 | ||||||||||||||||||||||||
| 373 | QLineF prevLine(m_back2X, m_back2Y, | - | ||||||||||||||||||||||||
| 374 | m_back1X, m_back1Y); | - | ||||||||||||||||||||||||
| 375 | QPointF isect; | - | ||||||||||||||||||||||||
| 376 | QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); | - | ||||||||||||||||||||||||
| 377 | QLineF shortCut(prevLine.p2(), nextLine.p1()); | - | ||||||||||||||||||||||||
| 378 | qreal angle = shortCut.angleTo(prevLine); | - | ||||||||||||||||||||||||
| 379 | if (type == QLineF::BoundedIntersection
| 0 | ||||||||||||||||||||||||
| 380 | emitLineTo(focal_x, focal_y); | - | ||||||||||||||||||||||||
| 381 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 382 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 383 | } | - | ||||||||||||||||||||||||
| 384 | emitLineTo(qfixed(nextLine.x1()), | - | ||||||||||||||||||||||||
| 385 | qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 388 | QLineF prevLine(m_back2X, m_back2Y, | - | ||||||||||||||||||||||||
| 389 | m_back1X, m_back1Y); | - | ||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | QPointF isect; | - | ||||||||||||||||||||||||
| 392 | QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); | - | ||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | if (join == MiterJoin
| 0 | ||||||||||||||||||||||||
| 395 | qreal appliedMiterLimit = m_strokeWidth * m_miterLimit; | - | ||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | QLineF shortCut(prevLine.p2(), nextLine.p1()); | - | ||||||||||||||||||||||||
| 399 | qreal angle = shortCut.angleTo(prevLine); | - | ||||||||||||||||||||||||
| 400 | if (type == QLineF::BoundedIntersection
| 0 | ||||||||||||||||||||||||
| 401 | emitLineTo(focal_x, focal_y); | - | ||||||||||||||||||||||||
| 402 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 403 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 404 | } | - | ||||||||||||||||||||||||
| 405 | QLineF miterLine(QPointF(m_back1X, | - | ||||||||||||||||||||||||
| 406 | m_back1Y), isect); | - | ||||||||||||||||||||||||
| 407 | if (type == QLineF::NoIntersection
| 0 | ||||||||||||||||||||||||
| 408 | QLineF l1(prevLine); | - | ||||||||||||||||||||||||
| 409 | l1.setLength(appliedMiterLimit); | - | ||||||||||||||||||||||||
| 410 | l1.translate(prevLine.dx(), prevLine.dy()); | - | ||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||
| 412 | QLineF l2(nextLine); | - | ||||||||||||||||||||||||
| 413 | l2.setLength(appliedMiterLimit); | - | ||||||||||||||||||||||||
| 414 | l2.translate(-l2.dx(), -l2.dy()); | - | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | emitLineTo(qfixed(l1.x2()), qfixed(l1.y2())); | - | ||||||||||||||||||||||||
| 417 | emitLineTo(qfixed(l2.x1()), qfixed(l2.y1())); | - | ||||||||||||||||||||||||
| 418 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 419 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 420 | emitLineTo(qfixed(isect.x()), qfixed(isect.y())); | - | ||||||||||||||||||||||||
| 421 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 422 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | } else if (join == SquareJoin
| 0 | ||||||||||||||||||||||||
| 425 | qfixed offset = m_strokeWidth / 2; | - | ||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | QLineF l1(prevLine); | - | ||||||||||||||||||||||||
| 428 | l1.translate(l1.dx(), l1.dy()); | - | ||||||||||||||||||||||||
| 429 | l1.setLength(offset); | - | ||||||||||||||||||||||||
| 430 | QLineF l2(nextLine.p2(), nextLine.p1()); | - | ||||||||||||||||||||||||
| 431 | l2.translate(l2.dx(), l2.dy()); | - | ||||||||||||||||||||||||
| 432 | l2.setLength(offset); | - | ||||||||||||||||||||||||
| 433 | emitLineTo(qfixed(l1.x2()), qfixed(l1.y2())); | - | ||||||||||||||||||||||||
| 434 | emitLineTo(qfixed(l2.x2()), qfixed(l2.y2())); | - | ||||||||||||||||||||||||
| 435 | emitLineTo(qfixed(l2.x1()), qfixed(l2.y1())); | - | ||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | } never executed: else if (join == RoundJoinend of block
| 0 | ||||||||||||||||||||||||
| 438 | qfixed offset = m_strokeWidth / 2; | - | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | QLineF shortCut(prevLine.p2(), nextLine.p1()); | - | ||||||||||||||||||||||||
| 441 | qreal angle = shortCut.angleTo(prevLine); | - | ||||||||||||||||||||||||
| 442 | if (type == QLineF::BoundedIntersection
| 0 | ||||||||||||||||||||||||
| 443 | emitLineTo(focal_x, focal_y); | - | ||||||||||||||||||||||||
| 444 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 445 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 446 | } | - | ||||||||||||||||||||||||
| 447 | qreal l1_on_x = adapted_angle_on_x(prevLine); | - | ||||||||||||||||||||||||
| 448 | qreal l2_on_x = adapted_angle_on_x(nextLine); | - | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | qreal sweepLength = qAbs(l2_on_x - l1_on_x); | - | ||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | int point_count; | - | ||||||||||||||||||||||||
| 453 | QPointF curves[15]; | - | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | QPointF curve_start = | - | ||||||||||||||||||||||||
| 456 | qt_curves_for_arc(QRectF(focal_x - offset, | - | ||||||||||||||||||||||||
| 457 | focal_y - offset, | - | ||||||||||||||||||||||||
| 458 | offset * 2, | - | ||||||||||||||||||||||||
| 459 | offset * 2), | - | ||||||||||||||||||||||||
| 460 | l1_on_x + 90, -sweepLength, | - | ||||||||||||||||||||||||
| 461 | curves, &point_count); | - | ||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | (void)curve_start;; | - | ||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||
| 467 | for (int i=0; i<point_count
| 0 | ||||||||||||||||||||||||
| 468 | emitCubicTo(qfixed(curves[i].x()), | - | ||||||||||||||||||||||||
| 469 | qfixed(curves[i].y()), | - | ||||||||||||||||||||||||
| 470 | qfixed(curves[i+1].x()), | - | ||||||||||||||||||||||||
| 471 | qfixed(curves[i+1].y()), | - | ||||||||||||||||||||||||
| 472 | qfixed(curves[i+2].x()), | - | ||||||||||||||||||||||||
| 473 | qfixed(curves[i+2].y())); | - | ||||||||||||||||||||||||
| 474 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | } never executed: else if (join == RoundCapend of block
| 0 | ||||||||||||||||||||||||
| 482 | qfixed offset = m_strokeWidth / 2; | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | QLineF l1 = prevLine; | - | ||||||||||||||||||||||||
| 486 | l1.translate(l1.dx(), l1.dy()); | - | ||||||||||||||||||||||||
| 487 | l1.setLength(0.5522847498 * offset); | - | ||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||
| 490 | QLineF l2(focal_x, focal_y, | - | ||||||||||||||||||||||||
| 491 | prevLine.x2(), prevLine.y2()); | - | ||||||||||||||||||||||||
| 492 | l2.translate(-l2.dy(), l2.dx()); | - | ||||||||||||||||||||||||
| 493 | l2.setLength(0.5522847498 * offset); | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | emitCubicTo(qfixed(l1.x2()), | - | ||||||||||||||||||||||||
| 496 | qfixed(l1.y2()), | - | ||||||||||||||||||||||||
| 497 | qfixed(l2.x2()), | - | ||||||||||||||||||||||||
| 498 | qfixed(l2.y2()), | - | ||||||||||||||||||||||||
| 499 | qfixed(l2.x1()), | - | ||||||||||||||||||||||||
| 500 | qfixed(l2.y1())); | - | ||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | l2 = QLineF(l2.x1(), l2.y1(), l2.x1()-l2.dx(), l2.y1()-l2.dy()); | - | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | l1.translate(nextLine.x1() - l1.x1(), nextLine.y1() - l1.y1()); | - | ||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||
| 508 | emitCubicTo(qfixed(l2.x2()), | - | ||||||||||||||||||||||||
| 509 | qfixed(l2.y2()), | - | ||||||||||||||||||||||||
| 510 | qfixed(l1.x2()), | - | ||||||||||||||||||||||||
| 511 | qfixed(l1.y2()), | - | ||||||||||||||||||||||||
| 512 | qfixed(l1.x1()), | - | ||||||||||||||||||||||||
| 513 | qfixed(l1.y1())); | - | ||||||||||||||||||||||||
| 514 | } never executed: else if (join == SvgMiterJoinend of block
| 0 | ||||||||||||||||||||||||
| 515 | QLineF shortCut(prevLine.p2(), nextLine.p1()); | - | ||||||||||||||||||||||||
| 516 | qreal angle = shortCut.angleTo(prevLine); | - | ||||||||||||||||||||||||
| 517 | if (type == QLineF::BoundedIntersection
| 0 | ||||||||||||||||||||||||
| 518 | emitLineTo(focal_x, focal_y); | - | ||||||||||||||||||||||||
| 519 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 520 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 521 | } | - | ||||||||||||||||||||||||
| 522 | QLineF miterLine(QPointF(focal_x, | - | ||||||||||||||||||||||||
| 523 | focal_y), isect); | - | ||||||||||||||||||||||||
| 524 | if (type == QLineF::NoIntersection
| 0 | ||||||||||||||||||||||||
| 525 | emitLineTo(qfixed(nextLine.x1()), | - | ||||||||||||||||||||||||
| 526 | qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 527 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 528 | emitLineTo(qfixed(isect.x()), qfixed(isect.y())); | - | ||||||||||||||||||||||||
| 529 | emitLineTo(qfixed(nextLine.x1()), qfixed(nextLine.y1())); | - | ||||||||||||||||||||||||
| 530 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 531 | } else { | - | ||||||||||||||||||||||||
| 532 | ((!(!"QStroker::joinPoints(), bad join style...")) ? qt_assert("!\"QStroker::joinPoints(), bad join style...\"",__FILE__,619) : qt_noop()); | - | ||||||||||||||||||||||||
| 533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 534 | } | - | ||||||||||||||||||||||||
| 535 | } | - | ||||||||||||||||||||||||
| 536 | template <class Iterator> bool qt_stroke_side(Iterator *it, | - | ||||||||||||||||||||||||
| 537 | QStroker *stroker, | - | ||||||||||||||||||||||||
| 538 | bool capFirst, | - | ||||||||||||||||||||||||
| 539 | QLineF *startTangent) | - | ||||||||||||||||||||||||
| 540 | { | - | ||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||
| 542 | const int MAX_OFFSET = 16; | - | ||||||||||||||||||||||||
| 543 | QBezier offsetCurves[MAX_OFFSET]; | - | ||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | ((!(it->hasNext())) ? qt_assert("it->hasNext()",__FILE__,641) : qt_noop()); | - | ||||||||||||||||||||||||
| 546 | QStrokerOps::Element first_element = it->next(); | - | ||||||||||||||||||||||||
| 547 | ((!(first_element.isMoveTo())) ? qt_assert("first_element.isMoveTo()",__FILE__,643) : qt_noop()); | - | ||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||
| 549 | qfixed2d start = first_element; | - | ||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | - | |||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||
| 557 | qfixed2d prev = start; | - | ||||||||||||||||||||||||
| 558 | - | |||||||||||||||||||||||||
| 559 | bool first = true; | - | ||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | qfixed offset = stroker->strokeWidth() / 2; | - | ||||||||||||||||||||||||
| 562 | - | |||||||||||||||||||||||||
| 563 | while (it->hasNext()
| 0 | ||||||||||||||||||||||||
| 564 | QStrokerOps::Element e = it->next(); | - | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||
| 567 | if (e.isLineTo()
| 0 | ||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||
| 571 | QLineF line(prev.x, prev.y, | - | ||||||||||||||||||||||||
| 572 | e.x, e.y); | - | ||||||||||||||||||||||||
| 573 | if (line.p1() != line.p2()
| 0 | ||||||||||||||||||||||||
| 574 | QLineF normal = line.normalVector(); | - | ||||||||||||||||||||||||
| 575 | normal.setLength(offset); | - | ||||||||||||||||||||||||
| 576 | line.translate(normal.dx(), normal.dy()); | - | ||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||
| 579 | if (first
| 0 | ||||||||||||||||||||||||
| 580 | if (capFirst
| 0 | ||||||||||||||||||||||||
| 581 | stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode()); never executed: stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode()); | 0 | ||||||||||||||||||||||||
| 582 | else | - | ||||||||||||||||||||||||
| 583 | stroker->emitMoveTo(qfixed(line.x1()), qfixed(line.y1())); never executed: stroker->emitMoveTo(qfixed(line.x1()), qfixed(line.y1())); | 0 | ||||||||||||||||||||||||
| 584 | *startTangent = line; | - | ||||||||||||||||||||||||
| 585 | first = false; | - | ||||||||||||||||||||||||
| 586 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 587 | stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode()); | - | ||||||||||||||||||||||||
| 588 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | stroker->emitLineTo(qfixed(line.x2()), | - | ||||||||||||||||||||||||
| 592 | qfixed(line.y2())); | - | ||||||||||||||||||||||||
| 593 | prev = e; | - | ||||||||||||||||||||||||
| 594 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 595 | - | |||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | } never executed: else if (e.isCurveTo()end of block
| 0 | ||||||||||||||||||||||||
| 598 | QStrokerOps::Element cp2 = it->next(); | - | ||||||||||||||||||||||||
| 599 | QStrokerOps::Element ep = it->next(); | - | ||||||||||||||||||||||||
| 600 | - | |||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | - | |||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||
| 606 | - | |||||||||||||||||||||||||
| 607 | QBezier bezier = | - | ||||||||||||||||||||||||
| 608 | QBezier::fromPoints(QPointF(prev.x, prev.y), | - | ||||||||||||||||||||||||
| 609 | QPointF(e.x, e.y), | - | ||||||||||||||||||||||||
| 610 | QPointF(cp2.x, cp2.y), | - | ||||||||||||||||||||||||
| 611 | QPointF(ep.x, ep.y)); | - | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | int count = bezier.shifted(offsetCurves, | - | ||||||||||||||||||||||||
| 614 | MAX_OFFSET, | - | ||||||||||||||||||||||||
| 615 | offset, | - | ||||||||||||||||||||||||
| 616 | stroker->curveThreshold()); | - | ||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | if (count
| 0 | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | QLineF tangent = bezier.startTangent(); | - | ||||||||||||||||||||||||
| 621 | tangent.translate(offsetCurves[0].pt1() - bezier.pt1()); | - | ||||||||||||||||||||||||
| 622 | if (first
| 0 | ||||||||||||||||||||||||
| 623 | QPointF pt = offsetCurves[0].pt1(); | - | ||||||||||||||||||||||||
| 624 | if (capFirst
| 0 | ||||||||||||||||||||||||
| 625 | stroker->joinPoints(prev.x, prev.y, | - | ||||||||||||||||||||||||
| 626 | tangent, | - | ||||||||||||||||||||||||
| 627 | stroker->capStyleMode()); | - | ||||||||||||||||||||||||
| 628 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 629 | stroker->emitMoveTo(qfixed(pt.x()), | - | ||||||||||||||||||||||||
| 630 | qfixed(pt.y())); | - | ||||||||||||||||||||||||
| 631 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 632 | *startTangent = tangent; | - | ||||||||||||||||||||||||
| 633 | first = false; | - | ||||||||||||||||||||||||
| 634 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 635 | stroker->joinPoints(prev.x, prev.y, | - | ||||||||||||||||||||||||
| 636 | tangent, | - | ||||||||||||||||||||||||
| 637 | stroker->joinStyleMode()); | - | ||||||||||||||||||||||||
| 638 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | - | |||||||||||||||||||||||||
| 641 | for (int i=0; i<count
| 0 | ||||||||||||||||||||||||
| 642 | QPointF cp1 = offsetCurves[i].pt2(); | - | ||||||||||||||||||||||||
| 643 | QPointF cp2 = offsetCurves[i].pt3(); | - | ||||||||||||||||||||||||
| 644 | QPointF ep = offsetCurves[i].pt4(); | - | ||||||||||||||||||||||||
| 645 | stroker->emitCubicTo(qfixed(cp1.x()), qfixed(cp1.y()), | - | ||||||||||||||||||||||||
| 646 | qfixed(cp2.x()), qfixed(cp2.y()), | - | ||||||||||||||||||||||||
| 647 | qfixed(ep.x()), qfixed(ep.y())); | - | ||||||||||||||||||||||||
| 648 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 649 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||
| 651 | prev = ep; | - | ||||||||||||||||||||||||
| 652 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 653 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 654 | - | |||||||||||||||||||||||||
| 655 | if (start == prev
| 0 | ||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||
| 661 | if (!first
| 0 | ||||||||||||||||||||||||
| 662 | stroker->joinPoints(prev.x, prev.y, *startTangent, stroker->joinStyleMode()); never executed: stroker->joinPoints(prev.x, prev.y, *startTangent, stroker->joinStyleMode()); | 0 | ||||||||||||||||||||||||
| 663 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 664 | } else { | - | ||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||
| 668 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 669 | } | - | ||||||||||||||||||||||||
| 670 | } | - | ||||||||||||||||||||||||
| 671 | qreal qt_t_for_arc_angle(qreal angle) | - | ||||||||||||||||||||||||
| 672 | { | - | ||||||||||||||||||||||||
| 673 | if (qFuzzyIsNull(angle)
| 0 | ||||||||||||||||||||||||
| 674 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 675 | - | |||||||||||||||||||||||||
| 676 | if (qFuzzyCompare(angle, qreal(90))
| 0 | ||||||||||||||||||||||||
| 677 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||
| 679 | qreal radians = qDegreesToRadians(angle); | - | ||||||||||||||||||||||||
| 680 | qreal cosAngle = qCos(radians); | - | ||||||||||||||||||||||||
| 681 | qreal sinAngle = qSin(radians); | - | ||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||
| 684 | qreal tc = angle / 90; | - | ||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | tc -= ((((2-3*0.5522847498) * tc + 3*(0.5522847498 -1)) * tc) * tc + 1 - cosAngle) | - | ||||||||||||||||||||||||
| 688 | / (((6-9*0.5522847498) * tc + 6*(0.5522847498 -1)) * tc); | - | ||||||||||||||||||||||||
| 689 | tc -= ((((2-3*0.5522847498) * tc + 3*(0.5522847498 -1)) * tc) * tc + 1 - cosAngle) | - | ||||||||||||||||||||||||
| 690 | / (((6-9*0.5522847498) * tc + 6*(0.5522847498 -1)) * tc); | - | ||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | qreal ts = tc; | - | ||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||
| 696 | ts -= ((((3*0.5522847498 -2) * ts - 6*0.5522847498 + 3) * ts + 3*0.5522847498) * ts - sinAngle) | - | ||||||||||||||||||||||||
| 697 | / (((9*0.5522847498 -6) * ts + 12*0.5522847498 - 6) * ts + 3*0.5522847498); | - | ||||||||||||||||||||||||
| 698 | ts -= ((((3*0.5522847498 -2) * ts - 6*0.5522847498 + 3) * ts + 3*0.5522847498) * ts - sinAngle) | - | ||||||||||||||||||||||||
| 699 | / (((9*0.5522847498 -6) * ts + 12*0.5522847498 - 6) * ts + 3*0.5522847498); | - | ||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | qreal t = 0.5 * (tc + ts); | - | ||||||||||||||||||||||||
| 704 | return never executed: t;return t;never executed: return t; | 0 | ||||||||||||||||||||||||
| 705 | } | - | ||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | __attribute__((visibility("default"))) void qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length, | - | ||||||||||||||||||||||||
| 708 | QPointF* startPoint, QPointF *endPoint); | - | ||||||||||||||||||||||||
| 709 | QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, | - | ||||||||||||||||||||||||
| 710 | QPointF *curves, int *point_count) | - | ||||||||||||||||||||||||
| 711 | { | - | ||||||||||||||||||||||||
| 712 | ((!(point_count)) ? qt_assert("point_count",__FILE__,856) : qt_noop()); | - | ||||||||||||||||||||||||
| 713 | ((!(curves)) ? qt_assert("curves",__FILE__,857) : qt_noop()); | - | ||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||
| 715 | *point_count = 0; | - | ||||||||||||||||||||||||
| 716 | if (qt_is_nan(rect.x())
| 0 | ||||||||||||||||||||||||
| 717 | || qt_is_nan(startAngle)
| 0 | ||||||||||||||||||||||||
| 718 | QMessageLogger(__FILE__, 862, __PRETTY_FUNCTION__).warning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined"); | - | ||||||||||||||||||||||||
| 719 | return never executed: QPointF();return QPointF();never executed: return QPointF(); | 0 | ||||||||||||||||||||||||
| 720 | } | - | ||||||||||||||||||||||||
| 721 | - | |||||||||||||||||||||||||
| 722 | if (rect.isNull()
| 0 | ||||||||||||||||||||||||
| 723 | return never executed: QPointF();return QPointF();never executed: return QPointF(); | 0 | ||||||||||||||||||||||||
| 724 | } | - | ||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||
| 726 | qreal x = rect.x(); | - | ||||||||||||||||||||||||
| 727 | qreal y = rect.y(); | - | ||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | qreal w = rect.width(); | - | ||||||||||||||||||||||||
| 730 | qreal w2 = rect.width() / 2; | - | ||||||||||||||||||||||||
| 731 | qreal w2k = w2 * 0.5522847498; | - | ||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | qreal h = rect.height(); | - | ||||||||||||||||||||||||
| 734 | qreal h2 = rect.height() / 2; | - | ||||||||||||||||||||||||
| 735 | qreal h2k = h2 * 0.5522847498; | - | ||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||
| 737 | QPointF points[16] = | - | ||||||||||||||||||||||||
| 738 | { | - | ||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | QPointF(x + w, y + h2), | - | ||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | QPointF(x + w, y + h2 + h2k), | - | ||||||||||||||||||||||||
| 744 | QPointF(x + w2 + w2k, y + h), | - | ||||||||||||||||||||||||
| 745 | QPointF(x + w2, y + h), | - | ||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | - | |||||||||||||||||||||||||
| 748 | QPointF(x + w2 - w2k, y + h), | - | ||||||||||||||||||||||||
| 749 | QPointF(x, y + h2 + h2k), | - | ||||||||||||||||||||||||
| 750 | QPointF(x, y + h2), | - | ||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | QPointF(x, y + h2 - h2k), | - | ||||||||||||||||||||||||
| 754 | QPointF(x + w2 - w2k, y), | - | ||||||||||||||||||||||||
| 755 | QPointF(x + w2, y), | - | ||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | QPointF(x + w2 + w2k, y), | - | ||||||||||||||||||||||||
| 759 | QPointF(x + w, y + h2 - h2k), | - | ||||||||||||||||||||||||
| 760 | QPointF(x + w, y + h2) | - | ||||||||||||||||||||||||
| 761 | }; | - | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | if (sweepLength > 360
never executed: sweepLength = 360; | 0 | ||||||||||||||||||||||||
| 764 | else if (sweepLength < -360
never executed: sweepLength = -360; | 0 | ||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||
| 766 | - | |||||||||||||||||||||||||
| 767 | if (startAngle == 0.0
| 0 | ||||||||||||||||||||||||
| 768 | if (sweepLength == 360.0
| 0 | ||||||||||||||||||||||||
| 769 | for (int i = 11; i >= 0
| 0 | ||||||||||||||||||||||||
| 770 | curves[(*point_count)++] = points[i]; never executed: curves[(*point_count)++] = points[i]; | 0 | ||||||||||||||||||||||||
| 771 | return never executed: points[12];return points[12];never executed: return points[12]; | 0 | ||||||||||||||||||||||||
| 772 | } else if (sweepLength == -360.0
| 0 | ||||||||||||||||||||||||
| 773 | for (int i = 1; i <= 12
| 0 | ||||||||||||||||||||||||
| 774 | curves[(*point_count)++] = points[i]; never executed: curves[(*point_count)++] = points[i]; | 0 | ||||||||||||||||||||||||
| 775 | return never executed: points[0];return points[0];never executed: return points[0]; | 0 | ||||||||||||||||||||||||
| 776 | } | - | ||||||||||||||||||||||||
| 777 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | int startSegment = int(qFloor(startAngle / 90)); | - | ||||||||||||||||||||||||
| 780 | int endSegment = int(qFloor((startAngle + sweepLength) / 90)); | - | ||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | qreal startT = (startAngle - startSegment * 90) / 90; | - | ||||||||||||||||||||||||
| 783 | qreal endT = (startAngle + sweepLength - endSegment * 90) / 90; | - | ||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||
| 785 | int delta = sweepLength > 0
| 0 | ||||||||||||||||||||||||
| 786 | if (delta < 0
| 0 | ||||||||||||||||||||||||
| 787 | startT = 1 - startT; | - | ||||||||||||||||||||||||
| 788 | endT = 1 - endT; | - | ||||||||||||||||||||||||
| 789 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||
| 792 | if (qFuzzyIsNull(startT - qreal(1))
| 0 | ||||||||||||||||||||||||
| 793 | startT = 0; | - | ||||||||||||||||||||||||
| 794 | startSegment += delta; | - | ||||||||||||||||||||||||
| 795 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | if (qFuzzyIsNull(endT)
| 0 | ||||||||||||||||||||||||
| 799 | endT = 1; | - | ||||||||||||||||||||||||
| 800 | endSegment -= delta; | - | ||||||||||||||||||||||||
| 801 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 802 | - | |||||||||||||||||||||||||
| 803 | startT = qt_t_for_arc_angle(startT * 90); | - | ||||||||||||||||||||||||
| 804 | endT = qt_t_for_arc_angle(endT * 90); | - | ||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | const bool splitAtStart = !qFuzzyIsNull(startT); | - | ||||||||||||||||||||||||
| 807 | const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1)); | - | ||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | const int end = endSegment + delta; | - | ||||||||||||||||||||||||
| 810 | - | |||||||||||||||||||||||||
| 811 | - | |||||||||||||||||||||||||
| 812 | if (startSegment == end
| 0 | ||||||||||||||||||||||||
| 813 | const int quadrant = 3 - ((startSegment % 4) + 4) % 4; | - | ||||||||||||||||||||||||
| 814 | const int j = 3 * quadrant; | - | ||||||||||||||||||||||||
| 815 | return never executed: delta > 0 ? points[j + 3] : points[j];return delta > 0 ? points[j + 3] : points[j];never executed: return delta > 0 ? points[j + 3] : points[j]; | 0 | ||||||||||||||||||||||||
| 816 | } | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | QPointF startPoint, endPoint; | - | ||||||||||||||||||||||||
| 819 | qt_find_ellipse_coords(rect, startAngle, sweepLength, &startPoint, &endPoint); | - | ||||||||||||||||||||||||
| 820 | - | |||||||||||||||||||||||||
| 821 | for (int i = startSegment; i != end
| 0 | ||||||||||||||||||||||||
| 822 | const int quadrant = 3 - ((i % 4) + 4) % 4; | - | ||||||||||||||||||||||||
| 823 | const int j = 3 * quadrant; | - | ||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | QBezier b; | - | ||||||||||||||||||||||||
| 826 | if (delta > 0
| 0 | ||||||||||||||||||||||||
| 827 | b = QBezier::fromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]); never executed: b = QBezier::fromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]); | 0 | ||||||||||||||||||||||||
| 828 | else | - | ||||||||||||||||||||||||
| 829 | b = QBezier::fromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]); never executed: b = QBezier::fromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]); | 0 | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | if (startSegment == endSegment
| 0 | ||||||||||||||||||||||||
| 833 | return never executed: startPoint;return startPoint;never executed: return startPoint; | 0 | ||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||
| 835 | if (i == startSegment
| 0 | ||||||||||||||||||||||||
| 836 | if (i == endSegment
| 0 | ||||||||||||||||||||||||
| 837 | b = b.bezierOnInterval(startT, endT); never executed: b = b.bezierOnInterval(startT, endT); | 0 | ||||||||||||||||||||||||
| 838 | else if (splitAtStart
| 0 | ||||||||||||||||||||||||
| 839 | b = b.bezierOnInterval(startT, 1); never executed: b = b.bezierOnInterval(startT, 1); | 0 | ||||||||||||||||||||||||
| 840 | } never executed: else if (i == endSegmentend of block
| 0 | ||||||||||||||||||||||||
| 841 | b = b.bezierOnInterval(0, endT); | - | ||||||||||||||||||||||||
| 842 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 843 | - | |||||||||||||||||||||||||
| 844 | - | |||||||||||||||||||||||||
| 845 | curves[(*point_count)++] = b.pt2(); | - | ||||||||||||||||||||||||
| 846 | curves[(*point_count)++] = b.pt3(); | - | ||||||||||||||||||||||||
| 847 | curves[(*point_count)++] = b.pt4(); | - | ||||||||||||||||||||||||
| 848 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||
| 850 | ((!(*point_count > 0)) ? qt_assert("*point_count > 0",__FILE__,994) : qt_noop()); | - | ||||||||||||||||||||||||
| 851 | curves[*(point_count)-1] = endPoint; | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | return never executed: startPoint;return startPoint;never executed: return startPoint; | 0 | ||||||||||||||||||||||||
| 854 | } | - | ||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||
| 857 | static inline void qdashstroker_moveTo(qfixed x, qfixed y, void *data) { | - | ||||||||||||||||||||||||
| 858 | ((QStroker *) data)->moveTo(x, y); | - | ||||||||||||||||||||||||
| 859 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||
| 861 | static inline void qdashstroker_lineTo(qfixed x, qfixed y, void *data) { | - | ||||||||||||||||||||||||
| 862 | ((QStroker *) data)->lineTo(x, y); | - | ||||||||||||||||||||||||
| 863 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | static inline void qdashstroker_cubicTo(qfixed, qfixed, qfixed, qfixed, qfixed, qfixed, void *) { | - | ||||||||||||||||||||||||
| 866 | ((!(0)) ? qt_assert("0",__FILE__,1010) : qt_noop()); | - | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 869 | - | |||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | QDashStroker::QDashStroker(QStroker *stroker) | - | ||||||||||||||||||||||||
| 875 | : m_stroker(stroker), m_dashOffset(0), m_stroke_width(1), m_miter_limit(1) | - | ||||||||||||||||||||||||
| 876 | { | - | ||||||||||||||||||||||||
| 877 | if (m_stroker
| 0 | ||||||||||||||||||||||||
| 878 | setMoveToHook(qdashstroker_moveTo); | - | ||||||||||||||||||||||||
| 879 | setLineToHook(qdashstroker_lineTo); | - | ||||||||||||||||||||||||
| 880 | setCubicToHook(qdashstroker_cubicTo); | - | ||||||||||||||||||||||||
| 881 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 882 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | QDashStroker::~QDashStroker() | - | ||||||||||||||||||||||||
| 885 | { | - | ||||||||||||||||||||||||
| 886 | } | - | ||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | QVector<qfixed> QDashStroker::patternForStyle(Qt::PenStyle style) | - | ||||||||||||||||||||||||
| 889 | { | - | ||||||||||||||||||||||||
| 890 | const qfixed space = 2; | - | ||||||||||||||||||||||||
| 891 | const qfixed dot = 1; | - | ||||||||||||||||||||||||
| 892 | const qfixed dash = 4; | - | ||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | QVector<qfixed> pattern; | - | ||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | switch (style) { | - | ||||||||||||||||||||||||
| 897 | case never executed: Qt::DashLine:case Qt::DashLine:never executed: case Qt::DashLine: | 0 | ||||||||||||||||||||||||
| 898 | pattern << dash << space; | - | ||||||||||||||||||||||||
| 899 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 900 | case never executed: Qt::DotLine:case Qt::DotLine:never executed: case Qt::DotLine: | 0 | ||||||||||||||||||||||||
| 901 | pattern << dot << space; | - | ||||||||||||||||||||||||
| 902 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 903 | case never executed: Qt::DashDotLine:case Qt::DashDotLine:never executed: case Qt::DashDotLine: | 0 | ||||||||||||||||||||||||
| 904 | pattern << dash << space << dot << space; | - | ||||||||||||||||||||||||
| 905 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 906 | case never executed: Qt::DashDotDotLine:case Qt::DashDotDotLine:never executed: case Qt::DashDotDotLine: | 0 | ||||||||||||||||||||||||
| 907 | pattern << dash << space << dot << space << dot << space; | - | ||||||||||||||||||||||||
| 908 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 909 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 910 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 911 | } | - | ||||||||||||||||||||||||
| 912 | - | |||||||||||||||||||||||||
| 913 | return never executed: pattern;return pattern;never executed: return pattern; | 0 | ||||||||||||||||||||||||
| 914 | } | - | ||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||
| 916 | static inline bool lineRectIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) | - | ||||||||||||||||||||||||
| 917 | { | - | ||||||||||||||||||||||||
| 918 | return never executed: ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x)return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y));never executed: return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); | 0 | ||||||||||||||||||||||||
| 919 | && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); never executed: return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); | 0 | ||||||||||||||||||||||||
| 920 | } | - | ||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||
| 922 | - | |||||||||||||||||||||||||
| 923 | static bool lineIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) | - | ||||||||||||||||||||||||
| 924 | { | - | ||||||||||||||||||||||||
| 925 | if (!lineRectIntersectsRect(p1, p2, tl, br)
| 0 | ||||||||||||||||||||||||
| 926 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 927 | if (p1.x == p2.x
| 0 | ||||||||||||||||||||||||
| 928 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 929 | - | |||||||||||||||||||||||||
| 930 | if (p1.y > p2.y
| 0 | ||||||||||||||||||||||||
| 931 | qSwap(p1, p2); never executed: qSwap(p1, p2); | 0 | ||||||||||||||||||||||||
| 932 | qfixed2d u; | - | ||||||||||||||||||||||||
| 933 | qfixed2d v; | - | ||||||||||||||||||||||||
| 934 | qfixed2d w = {p2.x - p1.x, p2.y - p1.y}; | - | ||||||||||||||||||||||||
| 935 | if (p1.x < p2.x
| 0 | ||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | u.x = tl.x - p1.x; u.y = br.y - p1.y; | - | ||||||||||||||||||||||||
| 938 | v.x = br.x - p1.x; v.y = tl.y - p1.y; | - | ||||||||||||||||||||||||
| 939 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||
| 941 | u.x = tl.x - p1.x; u.y = tl.y - p1.y; | - | ||||||||||||||||||||||||
| 942 | v.x = br.x - p1.x; v.y = br.y - p1.y; | - | ||||||||||||||||||||||||
| 943 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 944 | qreal val1 = u.x * w.y - u.y * w.x; | - | ||||||||||||||||||||||||
| 945 | qreal val2 = v.x * w.y - v.y * w.x; | - | ||||||||||||||||||||||||
| 946 | return never executed: (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0);return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0);never executed: return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0); | 0 | ||||||||||||||||||||||||
| 947 | - | |||||||||||||||||||||||||
| 948 | } | - | ||||||||||||||||||||||||
| 949 | - | |||||||||||||||||||||||||
| 950 | void QDashStroker::processCurrentSubpath() | - | ||||||||||||||||||||||||
| 951 | { | - | ||||||||||||||||||||||||
| 952 | int dashCount = qMin(m_dashPattern.size(), 32); | - | ||||||||||||||||||||||||
| 953 | qfixed dashes[32]; | - | ||||||||||||||||||||||||
| 954 | - | |||||||||||||||||||||||||
| 955 | if (m_stroker
| 0 | ||||||||||||||||||||||||
| 956 | m_customData = m_stroker; | - | ||||||||||||||||||||||||
| 957 | m_stroke_width = m_stroker->strokeWidth(); | - | ||||||||||||||||||||||||
| 958 | m_miter_limit = m_stroker->miterLimit(); | - | ||||||||||||||||||||||||
| 959 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||
| 961 | qreal longestLength = 0; | - | ||||||||||||||||||||||||
| 962 | qreal sumLength = 0; | - | ||||||||||||||||||||||||
| 963 | for (int i=0; i<dashCount
| 0 | ||||||||||||||||||||||||
| 964 | dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke_width; | - | ||||||||||||||||||||||||
| 965 | sumLength += dashes[i]; | - | ||||||||||||||||||||||||
| 966 | if (dashes[i] > longestLength
| 0 | ||||||||||||||||||||||||
| 967 | longestLength = dashes[i]; never executed: longestLength = dashes[i]; | 0 | ||||||||||||||||||||||||
| 968 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 969 | - | |||||||||||||||||||||||||
| 970 | if (qFuzzyIsNull(sumLength)
| 0 | ||||||||||||||||||||||||
| 971 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | qreal invSumLength = qreal(1) / sumLength; | - | ||||||||||||||||||||||||
| 974 | - | |||||||||||||||||||||||||
| 975 | ((!(dashCount > 0)) ? qt_assert("dashCount > 0",__FILE__,1127) : qt_noop()); | - | ||||||||||||||||||||||||
| 976 | - | |||||||||||||||||||||||||
| 977 | dashCount = dashCount & -2; | - | ||||||||||||||||||||||||
| 978 | - | |||||||||||||||||||||||||
| 979 | int idash = 0; | - | ||||||||||||||||||||||||
| 980 | qreal pos = 0; | - | ||||||||||||||||||||||||
| 981 | qreal elen = 0; | - | ||||||||||||||||||||||||
| 982 | qreal doffset = m_dashOffset * m_stroke_width; | - | ||||||||||||||||||||||||
| 983 | - | |||||||||||||||||||||||||
| 984 | - | |||||||||||||||||||||||||
| 985 | doffset -= qFloor(doffset * invSumLength) * sumLength; | - | ||||||||||||||||||||||||
| 986 | - | |||||||||||||||||||||||||
| 987 | while (doffset >= dashes[idash]
| 0 | ||||||||||||||||||||||||
| 988 | doffset -= dashes[idash]; | - | ||||||||||||||||||||||||
| 989 | if (++
| 0 | ||||||||||||||||||||||||
| 990 | idash = 0; never executed: idash = 0; | 0 | ||||||||||||||||||||||||
| 991 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||
| 993 | qreal estart = 0; | - | ||||||||||||||||||||||||
| 994 | qreal estop = 0; | - | ||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||
| 996 | QLineF cline; | - | ||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||
| 998 | QPainterPath dashPath; | - | ||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | QSubpathFlatIterator it(&m_elements, m_dashThreshold); | - | ||||||||||||||||||||||||
| 1001 | qfixed2d prev = it.next(); | - | ||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||
| 1003 | bool clipping = !m_clip_rect.isEmpty(); | - | ||||||||||||||||||||||||
| 1004 | qfixed2d move_to_pos = prev; | - | ||||||||||||||||||||||||
| 1005 | qfixed2d line_to_pos; | - | ||||||||||||||||||||||||
| 1006 | - | |||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | qfixed padding = qfixed(qMax(m_stroke_width, m_miter_limit) * longestLength); | - | ||||||||||||||||||||||||
| 1009 | qfixed2d clip_tl = { qfixed(m_clip_rect.left()) - padding, | - | ||||||||||||||||||||||||
| 1010 | qfixed(m_clip_rect.top()) - padding }; | - | ||||||||||||||||||||||||
| 1011 | qfixed2d clip_br = { qfixed(m_clip_rect.right()) + padding , | - | ||||||||||||||||||||||||
| 1012 | qfixed(m_clip_rect.bottom()) + padding }; | - | ||||||||||||||||||||||||
| 1013 | - | |||||||||||||||||||||||||
| 1014 | bool hasMoveTo = false; | - | ||||||||||||||||||||||||
| 1015 | while (it.hasNext()
| 0 | ||||||||||||||||||||||||
| 1016 | QStrokerOps::Element e = it.next(); | - | ||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||
| 1018 | ((!(e.isLineTo())) ? qt_assert("e.isLineTo()",__FILE__,1170) : qt_noop()); | - | ||||||||||||||||||||||||
| 1019 | cline = QLineF(prev.x, | - | ||||||||||||||||||||||||
| 1020 | prev.y, | - | ||||||||||||||||||||||||
| 1021 | e.x, | - | ||||||||||||||||||||||||
| 1022 | e.y); | - | ||||||||||||||||||||||||
| 1023 | elen = cline.length(); | - | ||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||
| 1025 | estop = estart + elen; | - | ||||||||||||||||||||||||
| 1026 | - | |||||||||||||||||||||||||
| 1027 | bool done = pos >= estop; | - | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | if (clipping
| 0 | ||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||
| 1031 | if (!lineIntersectsRect(prev, e, clip_tl, clip_br)
| 0 | ||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | elen -= qFloor(elen * invSumLength) * sumLength; | - | ||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | while (!done
| 0 | ||||||||||||||||||||||||
| 1036 | qreal dpos = pos + dashes[idash] - doffset - estart; | - | ||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | ((!(dpos >= 0)) ? qt_assert("dpos >= 0",__FILE__,1190) : qt_noop()); | - | ||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||
| 1040 | if (dpos > elen
| 0 | ||||||||||||||||||||||||
| 1041 | doffset = dashes[idash] - (dpos - elen); | - | ||||||||||||||||||||||||
| 1042 | pos = estop; | - | ||||||||||||||||||||||||
| 1043 | done = true; | - | ||||||||||||||||||||||||
| 1044 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1045 | pos = dpos + estart; | - | ||||||||||||||||||||||||
| 1046 | done = pos >= estop; | - | ||||||||||||||||||||||||
| 1047 | if (++
| 0 | ||||||||||||||||||||||||
| 1048 | idash = 0; never executed: idash = 0; | 0 | ||||||||||||||||||||||||
| 1049 | doffset = 0; | - | ||||||||||||||||||||||||
| 1050 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||||||||
| 1052 | hasMoveTo = false; | - | ||||||||||||||||||||||||
| 1053 | move_to_pos = e; | - | ||||||||||||||||||||||||
| 1054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1055 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||
| 1057 | - | |||||||||||||||||||||||||
| 1058 | while (!done
| 0 | ||||||||||||||||||||||||
| 1059 | QPointF p2; | - | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | bool has_offset = doffset > 0; | - | ||||||||||||||||||||||||
| 1062 | bool evenDash = (idash & 1) == 0; | - | ||||||||||||||||||||||||
| 1063 | qreal dpos = pos + dashes[idash] - doffset - estart; | - | ||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||
| 1065 | ((!(dpos >= 0)) ? qt_assert("dpos >= 0",__FILE__,1217) : qt_noop()); | - | ||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||
| 1067 | if (dpos > elen
| 0 | ||||||||||||||||||||||||
| 1068 | doffset = dashes[idash] - (dpos - elen); | - | ||||||||||||||||||||||||
| 1069 | pos = estop; | - | ||||||||||||||||||||||||
| 1070 | done = true; | - | ||||||||||||||||||||||||
| 1071 | p2 = cline.p2(); | - | ||||||||||||||||||||||||
| 1072 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1073 | p2 = cline.pointAt(dpos/elen); | - | ||||||||||||||||||||||||
| 1074 | pos = dpos + estart; | - | ||||||||||||||||||||||||
| 1075 | done = pos >= estop; | - | ||||||||||||||||||||||||
| 1076 | if (++
| 0 | ||||||||||||||||||||||||
| 1077 | idash = 0; never executed: idash = 0; | 0 | ||||||||||||||||||||||||
| 1078 | doffset = 0; | - | ||||||||||||||||||||||||
| 1079 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | if (evenDash
| 0 | ||||||||||||||||||||||||
| 1082 | line_to_pos.x = qfixed(p2.x()); | - | ||||||||||||||||||||||||
| 1083 | line_to_pos.y = qfixed(p2.y()); | - | ||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||
| 1085 | if (!clipping
| 0 | ||||||||||||||||||||||||
| 1086 | || lineRectIntersectsRect(move_to_pos, line_to_pos, clip_tl, clip_br)
| 0 | ||||||||||||||||||||||||
| 1087 | { | - | ||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||
| 1089 | - | |||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||
| 1091 | - | |||||||||||||||||||||||||
| 1092 | if (!has_offset
| 0 | ||||||||||||||||||||||||
| 1093 | emitMoveTo(move_to_pos.x, move_to_pos.y); | - | ||||||||||||||||||||||||
| 1094 | hasMoveTo = true; | - | ||||||||||||||||||||||||
| 1095 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||
| 1097 | emitLineTo(line_to_pos.x, line_to_pos.y); | - | ||||||||||||||||||||||||
| 1098 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1099 | hasMoveTo = false; | - | ||||||||||||||||||||||||
| 1100 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1101 | move_to_pos = line_to_pos; | - | ||||||||||||||||||||||||
| 1102 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1103 | move_to_pos.x = qfixed(p2.x()); | - | ||||||||||||||||||||||||
| 1104 | move_to_pos.y = qfixed(p2.y()); | - | ||||||||||||||||||||||||
| 1105 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1106 | } | - | ||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||
| 1109 | estart = estop; | - | ||||||||||||||||||||||||
| 1110 | prev = e; | - | ||||||||||||||||||||||||
| 1111 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1112 | - | |||||||||||||||||||||||||
| 1113 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |