| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qoutlinemapper.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | - | |||||||||||||
| 12 | static const QRectF boundingRect(const QPointF *points, int pointCount) | - | ||||||||||||
| 13 | { | - | ||||||||||||
| 14 | const QPointF *e = points; | - | ||||||||||||
| 15 | const QPointF *last = points + pointCount; | - | ||||||||||||
| 16 | qreal minx, maxx, miny, maxy; | - | ||||||||||||
| 17 | minx = maxx = e->x(); | - | ||||||||||||
| 18 | miny = maxy = e->y(); | - | ||||||||||||
| 19 | while (++
| 0 | ||||||||||||
| 20 | if (e->x() < minx
| 0 | ||||||||||||
| 21 | minx = e->x(); never executed: minx = e->x(); | 0 | ||||||||||||
| 22 | else if (e->x() > maxx
| 0 | ||||||||||||
| 23 | maxx = e->x(); never executed: maxx = e->x(); | 0 | ||||||||||||
| 24 | if (e->y() < miny
| 0 | ||||||||||||
| 25 | miny = e->y(); never executed: miny = e->y(); | 0 | ||||||||||||
| 26 | else if (e->y() > maxy
| 0 | ||||||||||||
| 27 | maxy = e->y(); never executed: maxy = e->y(); | 0 | ||||||||||||
| 28 | } never executed: end of block | 0 | ||||||||||||
| 29 | return never executed: QRectF(QPointF(minx, miny), QPointF(maxx, maxy));return QRectF(QPointF(minx, miny), QPointF(maxx, maxy));never executed: return QRectF(QPointF(minx, miny), QPointF(maxx, maxy)); | 0 | ||||||||||||
| 30 | } | - | ||||||||||||
| 31 | - | |||||||||||||
| 32 | void QOutlineMapper::curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep) { | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | - | |||||||||||||
| 37 | QBezier bezier = QBezier::fromPoints(m_elements.last(), cp1, cp2, ep); | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | bool outsideClip = false; | - | ||||||||||||
| 40 | - | |||||||||||||
| 41 | if (!QRectF(m_clip_rect).contains(m_transform.map(ep))
| 0 | ||||||||||||
| 42 | QRectF potentialCurveArea = m_transform.mapRect(bezier.bounds()); | - | ||||||||||||
| 43 | outsideClip = !potentialCurveArea.intersects(m_clip_rect); | - | ||||||||||||
| 44 | } never executed: end of block | 0 | ||||||||||||
| 45 | if (outsideClip
| 0 | ||||||||||||
| 46 | - | |||||||||||||
| 47 | - | |||||||||||||
| 48 | lineTo(ep); | - | ||||||||||||
| 49 | } never executed: else {end of block | 0 | ||||||||||||
| 50 | bezier.addToPolygon(m_elements, m_curve_threshold); | - | ||||||||||||
| 51 | m_element_types.reserve(m_elements.size()); | - | ||||||||||||
| 52 | for (int i = m_elements.size() - m_element_types.size(); i
| 0 | ||||||||||||
| 53 | m_element_types << QPainterPath::LineToElement; never executed: m_element_types << QPainterPath::LineToElement; | 0 | ||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||
| 55 | ((!(m_elements.size() == m_element_types.size())) ? qt_assert("m_elements.size() == m_element_types.size()",__FILE__,98) : qt_noop()); | - | ||||||||||||
| 56 | } never executed: end of block | 0 | ||||||||||||
| 57 | - | |||||||||||||
| 58 | - | |||||||||||||
| 59 | QT_FT_Outline *QOutlineMapper::convertPath(const QPainterPath &path) | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 | ((!(!path.isEmpty())) ? qt_assert("!path.isEmpty()",__FILE__,104) : qt_noop()); | - | ||||||||||||
| 62 | int elmCount = path.elementCount(); | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | beginOutline(path.fillRule()); | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | for (int index=0; index<elmCount
| 0 | ||||||||||||
| 69 | const QPainterPath::Element &elm = path.elementAt(index); | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | switch (elm.type) { | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | case never executed: QPainterPath::MoveToElement:case QPainterPath::MoveToElement:never executed: case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 74 | if (index == elmCount - 1
| 0 | ||||||||||||
| 75 | continue; never executed: continue; | 0 | ||||||||||||
| 76 | moveTo(elm); | - | ||||||||||||
| 77 | break; never executed: break; | 0 | ||||||||||||
| 78 | - | |||||||||||||
| 79 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||
| 80 | lineTo(elm); | - | ||||||||||||
| 81 | break; never executed: break; | 0 | ||||||||||||
| 82 | - | |||||||||||||
| 83 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 84 | curveTo(elm, path.elementAt(index + 1), path.elementAt(index + 2)); | - | ||||||||||||
| 85 | index += 2; | - | ||||||||||||
| 86 | break; never executed: break; | 0 | ||||||||||||
| 87 | - | |||||||||||||
| 88 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 89 | break; never executed: break; | 0 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | endOutline(); | - | ||||||||||||
| 94 | return never executed: outline();return outline();never executed: return outline(); | 0 | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | QT_FT_Outline *QOutlineMapper::convertPath(const QVectorPath &path) | - | ||||||||||||
| 98 | { | - | ||||||||||||
| 99 | int count = path.elementCount(); | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | - | |||||||||||||
| 102 | - | |||||||||||||
| 103 | - | |||||||||||||
| 104 | beginOutline(path.hasWindingFill() ? Qt::WindingFill : Qt::OddEvenFill); | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | if (path.elements()
| 0 | ||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | const QPainterPath::ElementType *elements = path.elements(); | - | ||||||||||||
| 110 | const QPointF *points = reinterpret_cast<const QPointF *>(path.points()); | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | for (int index = 0; index < count
| 0 | ||||||||||||
| 113 | switch (elements[index]) { | - | ||||||||||||
| 114 | case never executed: QPainterPath::MoveToElement:case QPainterPath::MoveToElement:never executed: case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 115 | if (index == count - 1
| 0 | ||||||||||||
| 116 | continue; never executed: continue; | 0 | ||||||||||||
| 117 | moveTo(points[index]); | - | ||||||||||||
| 118 | break; never executed: break; | 0 | ||||||||||||
| 119 | - | |||||||||||||
| 120 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||
| 121 | lineTo(points[index]); | - | ||||||||||||
| 122 | break; never executed: break; | 0 | ||||||||||||
| 123 | - | |||||||||||||
| 124 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 125 | curveTo(points[index], points[index+1], points[index+2]); | - | ||||||||||||
| 126 | index += 2; | - | ||||||||||||
| 127 | break; never executed: break; | 0 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 130 | break; never executed: break; | 0 | ||||||||||||
| 131 | } | - | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | } never executed: else {end of block | 0 | ||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | m_elements.resize(count); | - | ||||||||||||
| 138 | if (count
| 0 | ||||||||||||
| 139 | memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); never executed: memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); | 0 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | m_element_types.resize(0); | - | ||||||||||||
| 142 | } never executed: end of block | 0 | ||||||||||||
| 143 | - | |||||||||||||
| 144 | endOutline(); | - | ||||||||||||
| 145 | return never executed: outline();return outline();never executed: return outline(); | 0 | ||||||||||||
| 146 | } | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | - | |||||||||||||
| 149 | void QOutlineMapper::endOutline() | - | ||||||||||||
| 150 | { | - | ||||||||||||
| 151 | closeSubpath(); | - | ||||||||||||
| 152 | - | |||||||||||||
| 153 | if (m_elements.isEmpty()
| 0 | ||||||||||||
| 154 | memset(&m_outline, 0, sizeof(m_outline)); | - | ||||||||||||
| 155 | return; never executed: return; | 0 | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | QPointF *elements = m_elements.data(); | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | - | |||||||||||||
| 161 | if (m_transform.isIdentity()
| 0 | ||||||||||||
| 162 | - | |||||||||||||
| 163 | } never executed: else if (m_transform.type() < QTransform::TxProjectend of block
| 0 | ||||||||||||
| 164 | for (int i = 0; i < m_elements.size()
| 0 | ||||||||||||
| 165 | elements[i] = m_transform.map(elements[i]); never executed: elements[i] = m_transform.map(elements[i]); | 0 | ||||||||||||
| 166 | } never executed: else {end of block | 0 | ||||||||||||
| 167 | const QVectorPath vp((qreal *)elements, m_elements.size(), | - | ||||||||||||
| 168 | m_element_types.size() ? m_element_types.data() : 0); | - | ||||||||||||
| 169 | QPainterPath path = vp.convertToPainterPath(); | - | ||||||||||||
| 170 | path = m_transform.map(path); | - | ||||||||||||
| 171 | if (!(m_outline.flags & 0x2)
| 0 | ||||||||||||
| 172 | path.setFillRule(Qt::WindingFill); never executed: path.setFillRule(Qt::WindingFill); | 0 | ||||||||||||
| 173 | if (path.isEmpty()
| 0 | ||||||||||||
| 174 | m_valid = false; | - | ||||||||||||
| 175 | } never executed: else {end of block | 0 | ||||||||||||
| 176 | QTransform oldTransform = m_transform; | - | ||||||||||||
| 177 | m_transform.reset(); | - | ||||||||||||
| 178 | convertPath(path); | - | ||||||||||||
| 179 | m_transform = oldTransform; | - | ||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||
| 181 | return; never executed: return; | 0 | ||||||||||||
| 182 | } | - | ||||||||||||
| 183 | - | |||||||||||||
| 184 | controlPointRect = boundingRect(elements, m_elements.size()); | - | ||||||||||||
| 185 | const bool do_clip = !m_in_clip_elements
| 0 | ||||||||||||
| 186 | || controlPointRect.right() > QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||
| 187 | || controlPointRect.top() < -QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||
| 188 | || controlPointRect.bottom() > QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||
| 189 | || controlPointRect.width() > QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||
| 190 | || controlPointRect.height() > QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||
| 191 | - | |||||||||||||
| 192 | if (do_clip
| 0 | ||||||||||||
| 193 | clipElements(elements, elementTypes(), m_elements.size()); | - | ||||||||||||
| 194 | } never executed: else {end of block | 0 | ||||||||||||
| 195 | convertElements(elements, elementTypes(), m_elements.size()); | - | ||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||
| 197 | } | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | void QOutlineMapper::convertElements(const QPointF *elements, | - | ||||||||||||
| 200 | const QPainterPath::ElementType *types, | - | ||||||||||||
| 201 | int element_count) | - | ||||||||||||
| 202 | { | - | ||||||||||||
| 203 | - | |||||||||||||
| 204 | if (types
| 0 | ||||||||||||
| 205 | - | |||||||||||||
| 206 | const QPointF *e = elements; | - | ||||||||||||
| 207 | for (int i=0; i<element_count
| 0 | ||||||||||||
| 208 | switch (*types) { | - | ||||||||||||
| 209 | case never executed: QPainterPath::MoveToElement:case QPainterPath::MoveToElement:never executed: case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 210 | { | - | ||||||||||||
| 211 | QT_FT_Vector pt_fixed = { (qRound(e->x() * 64)), | - | ||||||||||||
| 212 | (qRound(e->y() * 64)) }; | - | ||||||||||||
| 213 | if (i != 0
| 0 | ||||||||||||
| 214 | m_contours << m_points.size() - 1; never executed: m_contours << m_points.size() - 1; | 0 | ||||||||||||
| 215 | m_points << pt_fixed; | - | ||||||||||||
| 216 | m_tags << 1; | - | ||||||||||||
| 217 | } | - | ||||||||||||
| 218 | break; never executed: break; | 0 | ||||||||||||
| 219 | - | |||||||||||||
| 220 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||
| 221 | { | - | ||||||||||||
| 222 | QT_FT_Vector pt_fixed = { (qRound(e->x() * 64)), | - | ||||||||||||
| 223 | (qRound(e->y() * 64)) }; | - | ||||||||||||
| 224 | m_points << pt_fixed; | - | ||||||||||||
| 225 | m_tags << 1; | - | ||||||||||||
| 226 | } | - | ||||||||||||
| 227 | break; never executed: break; | 0 | ||||||||||||
| 228 | - | |||||||||||||
| 229 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 230 | { | - | ||||||||||||
| 231 | QT_FT_Vector cp1_fixed = { (qRound(e->x() * 64)), | - | ||||||||||||
| 232 | (qRound(e->y() * 64)) }; | - | ||||||||||||
| 233 | ++e; | - | ||||||||||||
| 234 | QT_FT_Vector cp2_fixed = { (qRound((e)->x() * 64)), | - | ||||||||||||
| 235 | (qRound((e)->y() * 64)) }; | - | ||||||||||||
| 236 | ++e; | - | ||||||||||||
| 237 | QT_FT_Vector ep_fixed = { (qRound((e)->x() * 64)), | - | ||||||||||||
| 238 | (qRound((e)->y() * 64)) }; | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | m_points << cp1_fixed << cp2_fixed << ep_fixed; | - | ||||||||||||
| 241 | m_tags << 2 | - | ||||||||||||
| 242 | << 2 | - | ||||||||||||
| 243 | << 1; | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | types += 2; | - | ||||||||||||
| 246 | i += 2; | - | ||||||||||||
| 247 | } | - | ||||||||||||
| 248 | break; never executed: break; | 0 | ||||||||||||
| 249 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 250 | break; never executed: break; | 0 | ||||||||||||
| 251 | } | - | ||||||||||||
| 252 | ++types; | - | ||||||||||||
| 253 | ++e; | - | ||||||||||||
| 254 | } never executed: end of block | 0 | ||||||||||||
| 255 | } never executed: else {end of block | 0 | ||||||||||||
| 256 | - | |||||||||||||
| 257 | const QPointF *last = elements + element_count; | - | ||||||||||||
| 258 | const QPointF *e = elements; | - | ||||||||||||
| 259 | while (e < last
| 0 | ||||||||||||
| 260 | QT_FT_Vector pt_fixed = { (qRound(e->x() * 64)), | - | ||||||||||||
| 261 | (qRound(e->y() * 64)) }; | - | ||||||||||||
| 262 | m_points << pt_fixed; | - | ||||||||||||
| 263 | m_tags << 1; | - | ||||||||||||
| 264 | ++e; | - | ||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||
| 266 | } never executed: end of block | 0 | ||||||||||||
| 267 | - | |||||||||||||
| 268 | - | |||||||||||||
| 269 | m_contours << m_points.size() - 1; | - | ||||||||||||
| 270 | - | |||||||||||||
| 271 | m_outline.n_contours = m_contours.size(); | - | ||||||||||||
| 272 | m_outline.n_points = m_points.size(); | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | m_outline.points = m_points.data(); | - | ||||||||||||
| 275 | m_outline.tags = m_tags.data(); | - | ||||||||||||
| 276 | m_outline.contours = m_contours.data(); | - | ||||||||||||
| 277 | } never executed: end of block | 0 | ||||||||||||
| 278 | - | |||||||||||||
| 279 | void QOutlineMapper::clipElements(const QPointF *elements, | - | ||||||||||||
| 280 | const QPainterPath::ElementType *types, | - | ||||||||||||
| 281 | int element_count) | - | ||||||||||||
| 282 | { | - | ||||||||||||
| 283 | - | |||||||||||||
| 284 | - | |||||||||||||
| 285 | - | |||||||||||||
| 286 | - | |||||||||||||
| 287 | m_in_clip_elements = true; | - | ||||||||||||
| 288 | - | |||||||||||||
| 289 | QPainterPath path; | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | if (!(m_outline.flags & 0x2)
| 0 | ||||||||||||
| 292 | path.setFillRule(Qt::WindingFill); never executed: path.setFillRule(Qt::WindingFill); | 0 | ||||||||||||
| 293 | - | |||||||||||||
| 294 | if (types
| 0 | ||||||||||||
| 295 | for (int i=0; i<element_count
| 0 | ||||||||||||
| 296 | switch (types[i]) { | - | ||||||||||||
| 297 | case never executed: QPainterPath::MoveToElement:case QPainterPath::MoveToElement:never executed: case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 298 | path.moveTo(elements[i]); | - | ||||||||||||
| 299 | break; never executed: break; | 0 | ||||||||||||
| 300 | - | |||||||||||||
| 301 | case never executed: QPainterPath::LineToElement:case QPainterPath::LineToElement:never executed: case QPainterPath::LineToElement: | 0 | ||||||||||||
| 302 | path.lineTo(elements[i]); | - | ||||||||||||
| 303 | break; never executed: break; | 0 | ||||||||||||
| 304 | - | |||||||||||||
| 305 | case never executed: QPainterPath::CurveToElement:case QPainterPath::CurveToElement:never executed: case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 306 | path.cubicTo(elements[i], elements[i+1], elements[i+2]); | - | ||||||||||||
| 307 | i += 2; | - | ||||||||||||
| 308 | break; never executed: break; | 0 | ||||||||||||
| 309 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 310 | break; never executed: break; | 0 | ||||||||||||
| 311 | } | - | ||||||||||||
| 312 | } | - | ||||||||||||
| 313 | } never executed: else {end of block | 0 | ||||||||||||
| 314 | path.moveTo(elements[0]); | - | ||||||||||||
| 315 | for (int i=1; i<element_count
| 0 | ||||||||||||
| 316 | path.lineTo(elements[i]); never executed: path.lineTo(elements[i]); | 0 | ||||||||||||
| 317 | } never executed: end of block | 0 | ||||||||||||
| 318 | - | |||||||||||||
| 319 | QPainterPath clipPath; | - | ||||||||||||
| 320 | clipPath.addRect(m_clip_rect); | - | ||||||||||||
| 321 | QPainterPath clippedPath = path.intersected(clipPath); | - | ||||||||||||
| 322 | if (clippedPath.isEmpty()
| 0 | ||||||||||||
| 323 | m_valid = false; | - | ||||||||||||
| 324 | } never executed: else {end of block | 0 | ||||||||||||
| 325 | QTransform oldTransform = m_transform; | - | ||||||||||||
| 326 | m_transform.reset(); | - | ||||||||||||
| 327 | convertPath(clippedPath); | - | ||||||||||||
| 328 | m_transform = oldTransform; | - | ||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||
| 330 | - | |||||||||||||
| 331 | m_in_clip_elements = false; | - | ||||||||||||
| 332 | } never executed: end of block | 0 | ||||||||||||
| 333 | - | |||||||||||||
| 334 | - | |||||||||||||
| Switch to Source code | Preprocessed file |