| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qoutlinemapper.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qoutlinemapper_p.h" | - | ||||||||||||
| 35 | #include <private/qpainterpath_p.h> | - | ||||||||||||
| 36 | #include "qmath.h" | - | ||||||||||||
| 37 | #include <private/qbezier_p.h> | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | #include <stdlib.h> | - | ||||||||||||
| 40 | - | |||||||||||||
| 41 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #define qreal_to_fixed_26_6(f) (qRound(f * 64)) | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | - | |||||||||||||
| 46 | - | |||||||||||||
| 47 | - | |||||||||||||
| 48 | static const QRectF boundingRect(const QPointF *points, int pointCount) | - | ||||||||||||
| 49 | { | - | ||||||||||||
| 50 | const QPointF *e = points; | - | ||||||||||||
| 51 | const QPointF *last = points + pointCount; | - | ||||||||||||
| 52 | qreal minx, maxx, miny, maxy; | - | ||||||||||||
| 53 | minx = maxx = e->x(); | - | ||||||||||||
| 54 | miny = maxy = e->y(); | - | ||||||||||||
| 55 |     while (++e < last) {
  | 0 | ||||||||||||
| 56 |         if (e->x() < minx)
  | 0 | ||||||||||||
| 57 |             minx = e->x(); never executed:  minx = e->x(); | 0 | ||||||||||||
| 58 |         else if (e->x() > maxx)
  | 0 | ||||||||||||
| 59 |             maxx = e->x(); never executed:  maxx = e->x(); | 0 | ||||||||||||
| 60 |         if (e->y() < miny)
  | 0 | ||||||||||||
| 61 |             miny = e->y(); never executed:  miny = e->y(); | 0 | ||||||||||||
| 62 |         else if (e->y() > maxy)
  | 0 | ||||||||||||
| 63 |             maxy = e->y(); never executed:  maxy = e->y(); | 0 | ||||||||||||
| 64 |     } never executed:  end of block | 0 | ||||||||||||
| 65 |     return QRectF(QPointF(minx, miny), QPointF(maxx, maxy)); never executed:  return QRectF(QPointF(minx, miny), QPointF(maxx, maxy)); | 0 | ||||||||||||
| 66 | } | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | void QOutlineMapper::curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep) { | - | ||||||||||||
| 69 | #ifdef QT_DEBUG_CONVERT | - | ||||||||||||
| 70 | printf("QOutlineMapper::curveTo() (%f, %f)\n", ep.x(), ep.y()); | - | ||||||||||||
| 71 | #endif | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | QBezier bezier = QBezier::fromPoints(m_elements.last(), cp1, cp2, ep); | - | ||||||||||||
| 74 | bezier.addToPolygon(m_elements, m_curve_threshold); | - | ||||||||||||
| 75 | m_element_types.reserve(m_elements.size()); | - | ||||||||||||
| 76 |     for (int i = m_elements.size() - m_element_types.size(); i; --i)
  | 0 | ||||||||||||
| 77 |         m_element_types << QPainterPath::LineToElement; never executed:  m_element_types << QPainterPath::LineToElement; | 0 | ||||||||||||
| 78 | Q_ASSERT(m_elements.size() == m_element_types.size()); | - | ||||||||||||
| 79 | } never executed:  end of block | 0 | ||||||||||||
| 80 | - | |||||||||||||
| 81 | - | |||||||||||||
| 82 | QT_FT_Outline *QOutlineMapper::convertPath(const QPainterPath &path) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||
| 85 | int elmCount = path.elementCount(); | - | ||||||||||||
| 86 | #ifdef QT_DEBUG_CONVERT | - | ||||||||||||
| 87 | printf("QOutlineMapper::convertPath(), size=%d\n", elmCount); | - | ||||||||||||
| 88 | #endif | - | ||||||||||||
| 89 | beginOutline(path.fillRule()); | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 |     for (int index=0; index<elmCount; ++index) {
  | 0 | ||||||||||||
| 92 | const QPainterPath::Element &elm = path.elementAt(index); | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | switch (elm.type) { | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 |         case QPainterPath::MoveToElement: never executed:  case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 97 |             if (index == elmCount - 1)
  | 0 | ||||||||||||
| 98 |                 continue; never executed:  continue; | 0 | ||||||||||||
| 99 | moveTo(elm); | - | ||||||||||||
| 100 |             break; never executed:  break; | 0 | ||||||||||||
| 101 | - | |||||||||||||
| 102 |         case QPainterPath::LineToElement: never executed:  case QPainterPath::LineToElement: | 0 | ||||||||||||
| 103 | lineTo(elm); | - | ||||||||||||
| 104 |             break; never executed:  break; | 0 | ||||||||||||
| 105 | - | |||||||||||||
| 106 |         case QPainterPath::CurveToElement: never executed:  case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 107 | curveTo(elm, path.elementAt(index + 1), path.elementAt(index + 2)); | - | ||||||||||||
| 108 | index += 2; | - | ||||||||||||
| 109 |             break; never executed:  break; | 0 | ||||||||||||
| 110 | - | |||||||||||||
| 111 |         default: never executed:  default: | 0 | ||||||||||||
| 112 |             break; // This will never hit.. never executed:  break; | 0 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | endOutline(); | - | ||||||||||||
| 117 |     return outline(); never executed:  return outline(); | 0 | ||||||||||||
| 118 | } | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | QT_FT_Outline *QOutlineMapper::convertPath(const QVectorPath &path) | - | ||||||||||||
| 121 | { | - | ||||||||||||
| 122 | int count = path.elementCount(); | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | #ifdef QT_DEBUG_CONVERT | - | ||||||||||||
| 125 | printf("QOutlineMapper::convertPath(VP), size=%d\n", count); | - | ||||||||||||
| 126 | #endif | - | ||||||||||||
| 127 | beginOutline(path.hasWindingFill() ? Qt::WindingFill : Qt::OddEvenFill); | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 |     if (path.elements()) {
  | 0 | ||||||||||||
| 130 | // TODO: if we do closing of subpaths in convertElements instead we | - | ||||||||||||
| 131 | // could avoid this loop | - | ||||||||||||
| 132 | const QPainterPath::ElementType *elements = path.elements(); | - | ||||||||||||
| 133 | const QPointF *points = reinterpret_cast<const QPointF *>(path.points()); | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 |         for (int index = 0; index < count; ++index) {
  | 0 | ||||||||||||
| 136 | switch (elements[index]) { | - | ||||||||||||
| 137 |                 case QPainterPath::MoveToElement: never executed:  case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 138 |                     if (index == count - 1)
  | 0 | ||||||||||||
| 139 |                         continue; never executed:  continue; | 0 | ||||||||||||
| 140 | moveTo(points[index]); | - | ||||||||||||
| 141 |                     break; never executed:  break; | 0 | ||||||||||||
| 142 | - | |||||||||||||
| 143 |                 case QPainterPath::LineToElement: never executed:  case QPainterPath::LineToElement: | 0 | ||||||||||||
| 144 | lineTo(points[index]); | - | ||||||||||||
| 145 |                     break; never executed:  break; | 0 | ||||||||||||
| 146 | - | |||||||||||||
| 147 |                 case QPainterPath::CurveToElement: never executed:  case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 148 | curveTo(points[index], points[index+1], points[index+2]); | - | ||||||||||||
| 149 | index += 2; | - | ||||||||||||
| 150 |                     break; never executed:  break; | 0 | ||||||||||||
| 151 | - | |||||||||||||
| 152 |                 default: never executed:  default: | 0 | ||||||||||||
| 153 |                     break; // This will never hit.. never executed:  break; | 0 | ||||||||||||
| 154 | } | - | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 |     } else { never executed:  end of block | 0 | ||||||||||||
| 158 | // ### We can kill this copying and just use the buffer straight... | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | m_elements.resize(count); | - | ||||||||||||
| 161 |         if (count)
  | 0 | ||||||||||||
| 162 |             memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); never executed:  memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); | 0 | ||||||||||||
| 163 | - | |||||||||||||
| 164 | m_element_types.resize(0); | - | ||||||||||||
| 165 |     } never executed:  end of block | 0 | ||||||||||||
| 166 | - | |||||||||||||
| 167 | endOutline(); | - | ||||||||||||
| 168 |     return outline(); never executed:  return outline(); | 0 | ||||||||||||
| 169 | } | - | ||||||||||||
| 170 | - | |||||||||||||
| 171 | - | |||||||||||||
| 172 | void QOutlineMapper::endOutline() | - | ||||||||||||
| 173 | { | - | ||||||||||||
| 174 | closeSubpath(); | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 |     if (m_elements.isEmpty()) {
  | 0 | ||||||||||||
| 177 | memset(&m_outline, 0, sizeof(m_outline)); | - | ||||||||||||
| 178 |         return; never executed:  return; | 0 | ||||||||||||
| 179 | } | - | ||||||||||||
| 180 | - | |||||||||||||
| 181 | QPointF *elements = m_elements.data(); | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | // Transform the outline | - | ||||||||||||
| 184 |     if (m_txop == QTransform::TxNone) {
  | 0 | ||||||||||||
| 185 | // Nothing to do. | - | ||||||||||||
| 186 |     } else if (m_txop == QTransform::TxTranslate) { never executed:  end of block
  | 0 | ||||||||||||
| 187 |         for (int i = 0; i < m_elements.size(); ++i) {
  | 0 | ||||||||||||
| 188 | QPointF &e = elements[i]; | - | ||||||||||||
| 189 | e = QPointF(e.x() + m_dx, e.y() + m_dy); | - | ||||||||||||
| 190 |         } never executed:  end of block | 0 | ||||||||||||
| 191 |     } else if (m_txop == QTransform::TxScale) { never executed:  end of block
  | 0 | ||||||||||||
| 192 |         for (int i = 0; i < m_elements.size(); ++i) {
  | 0 | ||||||||||||
| 193 | QPointF &e = elements[i]; | - | ||||||||||||
| 194 | e = QPointF(m_m11 * e.x() + m_dx, m_m22 * e.y() + m_dy); | - | ||||||||||||
| 195 |         } never executed:  end of block | 0 | ||||||||||||
| 196 |     } else if (m_txop < QTransform::TxProject) { never executed:  end of block
  | 0 | ||||||||||||
| 197 |         for (int i = 0; i < m_elements.size(); ++i) {
  | 0 | ||||||||||||
| 198 | QPointF &e = elements[i]; | - | ||||||||||||
| 199 | e = QPointF(m_m11 * e.x() + m_m21 * e.y() + m_dx, | - | ||||||||||||
| 200 | m_m22 * e.y() + m_m12 * e.x() + m_dy); | - | ||||||||||||
| 201 |         } never executed:  end of block | 0 | ||||||||||||
| 202 |     } else { never executed:  end of block | 0 | ||||||||||||
| 203 | const QVectorPath vp((qreal *)elements, m_elements.size(), | - | ||||||||||||
| 204 | m_element_types.size() ? m_element_types.data() : 0); | - | ||||||||||||
| 205 | QPainterPath path = vp.convertToPainterPath(); | - | ||||||||||||
| 206 | path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path); | - | ||||||||||||
| 207 |         if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL))
  | 0 | ||||||||||||
| 208 |             path.setFillRule(Qt::WindingFill); never executed:  path.setFillRule(Qt::WindingFill); | 0 | ||||||||||||
| 209 | uint old_txop = m_txop; | - | ||||||||||||
| 210 | m_txop = QTransform::TxNone; | - | ||||||||||||
| 211 |         if (path.isEmpty())
  | 0 | ||||||||||||
| 212 |             m_valid = false; never executed:  m_valid = false; | 0 | ||||||||||||
| 213 | else | - | ||||||||||||
| 214 |             convertPath(path); never executed:  convertPath(path); | 0 | ||||||||||||
| 215 | m_txop = old_txop; | - | ||||||||||||
| 216 |         return; never executed:  return; | 0 | ||||||||||||
| 217 | } | - | ||||||||||||
| 218 | - | |||||||||||||
| 219 | controlPointRect = boundingRect(elements, m_elements.size()); | - | ||||||||||||
| 220 | - | |||||||||||||
| 221 | #ifdef QT_DEBUG_CONVERT | - | ||||||||||||
| 222 | printf(" - control point rect (%.2f, %.2f) %.2f x %.2f, clip=(%d,%d, %dx%d)\n", | - | ||||||||||||
| 223 | controlPointRect.x(), controlPointRect.y(), | - | ||||||||||||
| 224 | controlPointRect.width(), controlPointRect.height(), | - | ||||||||||||
| 225 | m_clip_rect.x(), m_clip_rect.y(), m_clip_rect.width(), m_clip_rect.height()); | - | ||||||||||||
| 226 | #endif | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | - | |||||||||||||
| 229 | // Check for out of dev bounds... | - | ||||||||||||
| 230 |     const bool do_clip = !m_in_clip_elements && ((controlPointRect.left() < -QT_RASTER_COORD_LIMIT
 
  | 0 | ||||||||||||
| 231 |                           || controlPointRect.right() > QT_RASTER_COORD_LIMIT
  | 0 | ||||||||||||
| 232 |                           || controlPointRect.top() < -QT_RASTER_COORD_LIMIT
  | 0 | ||||||||||||
| 233 |                           || controlPointRect.bottom() > QT_RASTER_COORD_LIMIT
  | 0 | ||||||||||||
| 234 |                           || controlPointRect.width() > QT_RASTER_COORD_LIMIT
  | 0 | ||||||||||||
| 235 |                           || controlPointRect.height() > QT_RASTER_COORD_LIMIT));
  | 0 | ||||||||||||
| 236 | - | |||||||||||||
| 237 |     if (do_clip) {
  | 0 | ||||||||||||
| 238 | clipElements(elements, elementTypes(), m_elements.size()); | - | ||||||||||||
| 239 |     } else { never executed:  end of block | 0 | ||||||||||||
| 240 | convertElements(elements, elementTypes(), m_elements.size()); | - | ||||||||||||
| 241 |     } never executed:  end of block | 0 | ||||||||||||
| 242 | } | - | ||||||||||||
| 243 | - | |||||||||||||
| 244 | void QOutlineMapper::convertElements(const QPointF *elements, | - | ||||||||||||
| 245 | const QPainterPath::ElementType *types, | - | ||||||||||||
| 246 | int element_count) | - | ||||||||||||
| 247 | { | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 |     if (types) {
  | 0 | ||||||||||||
| 250 | // Translate into FT coords | - | ||||||||||||
| 251 | const QPointF *e = elements; | - | ||||||||||||
| 252 |         for (int i=0; i<element_count; ++i) {
  | 0 | ||||||||||||
| 253 | switch (*types) { | - | ||||||||||||
| 254 |             case QPainterPath::MoveToElement: never executed:  case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 255 | { | - | ||||||||||||
| 256 | QT_FT_Vector pt_fixed = { qreal_to_fixed_26_6(e->x()), | - | ||||||||||||
| 257 | qreal_to_fixed_26_6(e->y()) }; | - | ||||||||||||
| 258 |                     if (i != 0)
  | 0 | ||||||||||||
| 259 |                         m_contours << m_points.size() - 1; never executed:  m_contours << m_points.size() - 1; | 0 | ||||||||||||
| 260 | m_points << pt_fixed; | - | ||||||||||||
| 261 | m_tags << QT_FT_CURVE_TAG_ON; | - | ||||||||||||
| 262 | } | - | ||||||||||||
| 263 |                 break; never executed:  break; | 0 | ||||||||||||
| 264 | - | |||||||||||||
| 265 |             case QPainterPath::LineToElement: never executed:  case QPainterPath::LineToElement: | 0 | ||||||||||||
| 266 | { | - | ||||||||||||
| 267 | QT_FT_Vector pt_fixed = { qreal_to_fixed_26_6(e->x()), | - | ||||||||||||
| 268 | qreal_to_fixed_26_6(e->y()) }; | - | ||||||||||||
| 269 | m_points << pt_fixed; | - | ||||||||||||
| 270 | m_tags << QT_FT_CURVE_TAG_ON; | - | ||||||||||||
| 271 | } | - | ||||||||||||
| 272 |                 break; never executed:  break; | 0 | ||||||||||||
| 273 | - | |||||||||||||
| 274 |             case QPainterPath::CurveToElement: never executed:  case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 275 | { | - | ||||||||||||
| 276 | QT_FT_Vector cp1_fixed = { qreal_to_fixed_26_6(e->x()), | - | ||||||||||||
| 277 | qreal_to_fixed_26_6(e->y()) }; | - | ||||||||||||
| 278 | ++e; | - | ||||||||||||
| 279 | QT_FT_Vector cp2_fixed = { qreal_to_fixed_26_6((e)->x()), | - | ||||||||||||
| 280 | qreal_to_fixed_26_6((e)->y()) }; | - | ||||||||||||
| 281 | ++e; | - | ||||||||||||
| 282 | QT_FT_Vector ep_fixed = { qreal_to_fixed_26_6((e)->x()), | - | ||||||||||||
| 283 | qreal_to_fixed_26_6((e)->y()) }; | - | ||||||||||||
| 284 | - | |||||||||||||
| 285 | m_points << cp1_fixed << cp2_fixed << ep_fixed; | - | ||||||||||||
| 286 | m_tags << QT_FT_CURVE_TAG_CUBIC | - | ||||||||||||
| 287 | << QT_FT_CURVE_TAG_CUBIC | - | ||||||||||||
| 288 | << QT_FT_CURVE_TAG_ON; | - | ||||||||||||
| 289 | - | |||||||||||||
| 290 | types += 2; | - | ||||||||||||
| 291 | i += 2; | - | ||||||||||||
| 292 | } | - | ||||||||||||
| 293 |                 break; never executed:  break; | 0 | ||||||||||||
| 294 |             default: never executed:  default: | 0 | ||||||||||||
| 295 |                 break; never executed:  break; | 0 | ||||||||||||
| 296 | } | - | ||||||||||||
| 297 | ++types; | - | ||||||||||||
| 298 | ++e; | - | ||||||||||||
| 299 |         } never executed:  end of block | 0 | ||||||||||||
| 300 |     } else { never executed:  end of block | 0 | ||||||||||||
| 301 | // Plain polygon... | - | ||||||||||||
| 302 | const QPointF *last = elements + element_count; | - | ||||||||||||
| 303 | const QPointF *e = elements; | - | ||||||||||||
| 304 |         while (e < last) {
  | 0 | ||||||||||||
| 305 | QT_FT_Vector pt_fixed = { qreal_to_fixed_26_6(e->x()), | - | ||||||||||||
| 306 | qreal_to_fixed_26_6(e->y()) }; | - | ||||||||||||
| 307 | m_points << pt_fixed; | - | ||||||||||||
| 308 | m_tags << QT_FT_CURVE_TAG_ON; | - | ||||||||||||
| 309 | ++e; | - | ||||||||||||
| 310 |         } never executed:  end of block | 0 | ||||||||||||
| 311 |     } never executed:  end of block | 0 | ||||||||||||
| 312 | - | |||||||||||||
| 313 | // close the very last subpath | - | ||||||||||||
| 314 | m_contours << m_points.size() - 1; | - | ||||||||||||
| 315 | - | |||||||||||||
| 316 | m_outline.n_contours = m_contours.size(); | - | ||||||||||||
| 317 | m_outline.n_points = m_points.size(); | - | ||||||||||||
| 318 | - | |||||||||||||
| 319 | m_outline.points = m_points.data(); | - | ||||||||||||
| 320 | m_outline.tags = m_tags.data(); | - | ||||||||||||
| 321 | m_outline.contours = m_contours.data(); | - | ||||||||||||
| 322 | - | |||||||||||||
| 323 | #ifdef QT_DEBUG_CONVERT | - | ||||||||||||
| 324 | printf("QOutlineMapper::endOutline\n"); | - | ||||||||||||
| 325 | - | |||||||||||||
| 326 | printf(" - contours: %d\n", m_outline.n_contours); | - | ||||||||||||
| 327 | for (int i=0; i<m_outline.n_contours; ++i) { | - | ||||||||||||
| 328 | printf(" - %d\n", m_outline.contours[i]); | - | ||||||||||||
| 329 | } | - | ||||||||||||
| 330 | - | |||||||||||||
| 331 | printf(" - points: %d\n", m_outline.n_points); | - | ||||||||||||
| 332 | for (int i=0; i<m_outline.n_points; ++i) { | - | ||||||||||||
| 333 | printf(" - %d -- %.2f, %.2f, (%d, %d)\n", i, | - | ||||||||||||
| 334 | (double) (m_outline.points[i].x / 64.0), | - | ||||||||||||
| 335 | (double) (m_outline.points[i].y / 64.0), | - | ||||||||||||
| 336 | (int) m_outline.points[i].x, (int) m_outline.points[i].y); | - | ||||||||||||
| 337 | } | - | ||||||||||||
| 338 | #endif | - | ||||||||||||
| 339 | } never executed:  end of block | 0 | ||||||||||||
| 340 | - | |||||||||||||
| 341 | void QOutlineMapper::clipElements(const QPointF *elements, | - | ||||||||||||
| 342 | const QPainterPath::ElementType *types, | - | ||||||||||||
| 343 | int element_count) | - | ||||||||||||
| 344 | { | - | ||||||||||||
| 345 | // We could save a bit of time by actually implementing them fully | - | ||||||||||||
| 346 | // instead of going through convenience functionallity, but since | - | ||||||||||||
| 347 | // this part of code hardly every used, it shouldn't matter. | - | ||||||||||||
| 348 | - | |||||||||||||
| 349 | m_in_clip_elements = true; | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | QPainterPath path; | - | ||||||||||||
| 352 | - | |||||||||||||
| 353 |     if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL))
  | 0 | ||||||||||||
| 354 |         path.setFillRule(Qt::WindingFill); never executed:  path.setFillRule(Qt::WindingFill); | 0 | ||||||||||||
| 355 | - | |||||||||||||
| 356 |     if (types) {
  | 0 | ||||||||||||
| 357 |         for (int i=0; i<element_count; ++i) {
  | 0 | ||||||||||||
| 358 | switch (types[i]) { | - | ||||||||||||
| 359 |             case QPainterPath::MoveToElement: never executed:  case QPainterPath::MoveToElement: | 0 | ||||||||||||
| 360 | path.moveTo(elements[i]); | - | ||||||||||||
| 361 |                 break; never executed:  break; | 0 | ||||||||||||
| 362 | - | |||||||||||||
| 363 |             case QPainterPath::LineToElement: never executed:  case QPainterPath::LineToElement: | 0 | ||||||||||||
| 364 | path.lineTo(elements[i]); | - | ||||||||||||
| 365 |                 break; never executed:  break; | 0 | ||||||||||||
| 366 | - | |||||||||||||
| 367 |             case QPainterPath::CurveToElement: never executed:  case QPainterPath::CurveToElement: | 0 | ||||||||||||
| 368 | path.cubicTo(elements[i], elements[i+1], elements[i+2]); | - | ||||||||||||
| 369 | i += 2; | - | ||||||||||||
| 370 |                 break; never executed:  break; | 0 | ||||||||||||
| 371 |             default: never executed:  default: | 0 | ||||||||||||
| 372 |                 break; never executed:  break; | 0 | ||||||||||||
| 373 | } | - | ||||||||||||
| 374 | } | - | ||||||||||||
| 375 |     } else { never executed:  end of block | 0 | ||||||||||||
| 376 | path.moveTo(elements[0]); | - | ||||||||||||
| 377 |         for (int i=1; i<element_count; ++i)
  | 0 | ||||||||||||
| 378 |             path.lineTo(elements[i]); never executed:  path.lineTo(elements[i]); | 0 | ||||||||||||
| 379 |     } never executed:  end of block | 0 | ||||||||||||
| 380 | - | |||||||||||||
| 381 | QPainterPath clipPath; | - | ||||||||||||
| 382 | clipPath.addRect(m_clip_rect); | - | ||||||||||||
| 383 | QPainterPath clippedPath = path.intersected(clipPath); | - | ||||||||||||
| 384 | uint old_txop = m_txop; | - | ||||||||||||
| 385 | m_txop = QTransform::TxNone; | - | ||||||||||||
| 386 |     if (clippedPath.isEmpty())
  | 0 | ||||||||||||
| 387 |         m_valid = false; never executed:  m_valid = false; | 0 | ||||||||||||
| 388 | else | - | ||||||||||||
| 389 |         convertPath(clippedPath); never executed:  convertPath(clippedPath); | 0 | ||||||||||||
| 390 | m_txop = old_txop; | - | ||||||||||||
| 391 | - | |||||||||||||
| 392 | m_in_clip_elements = false; | - | ||||||||||||
| 393 | } never executed:  end of block | 0 | ||||||||||||
| 394 | - | |||||||||||||
| 395 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |