| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qpaintengine_raster.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 <QtCore/qglobal.h> | - | ||||||||||||||||||||||||||||||
| 35 | #include <QtCore/qmutex.h> | - | ||||||||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||||||||
| 37 | #define QT_FT_BEGIN_HEADER | - | ||||||||||||||||||||||||||||||
| 38 | #define QT_FT_END_HEADER | - | ||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||
| 40 | #include <private/qrasterdefs_p.h> | - | ||||||||||||||||||||||||||||||
| 41 | #include <private/qgrayraster_p.h> | - | ||||||||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||||||||
| 43 | #include <qpainterpath.h> | - | ||||||||||||||||||||||||||||||
| 44 | #include <qdebug.h> | - | ||||||||||||||||||||||||||||||
| 45 | #include <qbitmap.h> | - | ||||||||||||||||||||||||||||||
| 46 | #include <qmath.h> | - | ||||||||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||||||||
| 48 | // #include <private/qdatabuffer_p.h> | - | ||||||||||||||||||||||||||||||
| 49 | // #include <private/qpainter_p.h> | - | ||||||||||||||||||||||||||||||
| 50 | #include <private/qtextengine_p.h> | - | ||||||||||||||||||||||||||||||
| 51 | #include <private/qfontengine_p.h> | - | ||||||||||||||||||||||||||||||
| 52 | #include <private/qpixmap_raster_p.h> | - | ||||||||||||||||||||||||||||||
| 53 | // #include <private/qpolygonclipper_p.h> | - | ||||||||||||||||||||||||||||||
| 54 | // #include <private/qrasterizer_p.h> | - | ||||||||||||||||||||||||||||||
| 55 | #include <private/qimage_p.h> | - | ||||||||||||||||||||||||||||||
| 56 | #include <private/qstatictext_p.h> | - | ||||||||||||||||||||||||||||||
| 57 | #include <private/qcosmeticstroker_p.h> | - | ||||||||||||||||||||||||||||||
| 58 | #include "qmemrotate_p.h" | - | ||||||||||||||||||||||||||||||
| 59 | #include "qrgba64_p.h" | - | ||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | #include "qpaintengine_raster_p.h" | - | ||||||||||||||||||||||||||||||
| 62 | // #include "qbezier_p.h" | - | ||||||||||||||||||||||||||||||
| 63 | #include "qoutlinemapper_p.h" | - | ||||||||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||||||||
| 65 | #include <limits.h> | - | ||||||||||||||||||||||||||||||
| 66 | #include <algorithm> | - | ||||||||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||||||||
| 68 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||
| 69 | # include <qvarlengtharray.h> | - | ||||||||||||||||||||||||||||||
| 70 | # include <private/qfontengine_p.h> | - | ||||||||||||||||||||||||||||||
| 71 | # include <qt_windows.h> | - | ||||||||||||||||||||||||||||||
| 72 | #ifdef Q_OS_WIN64 | - | ||||||||||||||||||||||||||||||
| 73 | # include <malloc.h> | - | ||||||||||||||||||||||||||||||
| 74 | # endif | - | ||||||||||||||||||||||||||||||
| 75 | #endif | - | ||||||||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||||||||
| 77 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | class QRectVectorPath : public QVectorPath { | - | ||||||||||||||||||||||||||||||
| 80 | public: | - | ||||||||||||||||||||||||||||||
| 81 | inline void set(const QRect &r) { | - | ||||||||||||||||||||||||||||||
| 82 | qreal left = r.x(); | - | ||||||||||||||||||||||||||||||
| 83 | qreal right = r.x() + r.width(); | - | ||||||||||||||||||||||||||||||
| 84 | qreal top = r.y(); | - | ||||||||||||||||||||||||||||||
| 85 | qreal bottom = r.y() + r.height(); | - | ||||||||||||||||||||||||||||||
| 86 | pts[0] = left; | - | ||||||||||||||||||||||||||||||
| 87 | pts[1] = top; | - | ||||||||||||||||||||||||||||||
| 88 | pts[2] = right; | - | ||||||||||||||||||||||||||||||
| 89 | pts[3] = top; | - | ||||||||||||||||||||||||||||||
| 90 | pts[4] = right; | - | ||||||||||||||||||||||||||||||
| 91 | pts[5] = bottom; | - | ||||||||||||||||||||||||||||||
| 92 | pts[6] = left; | - | ||||||||||||||||||||||||||||||
| 93 | pts[7] = bottom; | - | ||||||||||||||||||||||||||||||
| 94 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||||||||
| 96 | inline void set(const QRectF &r) { | - | ||||||||||||||||||||||||||||||
| 97 | qreal left = r.x(); | - | ||||||||||||||||||||||||||||||
| 98 | qreal right = r.x() + r.width(); | - | ||||||||||||||||||||||||||||||
| 99 | qreal top = r.y(); | - | ||||||||||||||||||||||||||||||
| 100 | qreal bottom = r.y() + r.height(); | - | ||||||||||||||||||||||||||||||
| 101 | pts[0] = left; | - | ||||||||||||||||||||||||||||||
| 102 | pts[1] = top; | - | ||||||||||||||||||||||||||||||
| 103 | pts[2] = right; | - | ||||||||||||||||||||||||||||||
| 104 | pts[3] = top; | - | ||||||||||||||||||||||||||||||
| 105 | pts[4] = right; | - | ||||||||||||||||||||||||||||||
| 106 | pts[5] = bottom; | - | ||||||||||||||||||||||||||||||
| 107 | pts[6] = left; | - | ||||||||||||||||||||||||||||||
| 108 | pts[7] = bottom; | - | ||||||||||||||||||||||||||||||
| 109 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 110 | inline QRectVectorPath(const QRect &r) | - | ||||||||||||||||||||||||||||||
| 111 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) | - | ||||||||||||||||||||||||||||||
| 112 | { | - | ||||||||||||||||||||||||||||||
| 113 | set(r); | - | ||||||||||||||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 115 | inline QRectVectorPath(const QRectF &r) | - | ||||||||||||||||||||||||||||||
| 116 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) | - | ||||||||||||||||||||||||||||||
| 117 | { | - | ||||||||||||||||||||||||||||||
| 118 | set(r); | - | ||||||||||||||||||||||||||||||
| 119 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 120 | inline QRectVectorPath() | - | ||||||||||||||||||||||||||||||
| 121 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) | - | ||||||||||||||||||||||||||||||
| 122 | { } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||||||||
| 124 | qreal pts[8]; | - | ||||||||||||||||||||||||||||||
| 125 | }; | - | ||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||
| 127 | Q_GUI_EXPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp | - | ||||||||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||||||||
| 129 | #define qreal_to_fixed_26_6(f) (int(f * 64)) | - | ||||||||||||||||||||||||||||||
| 130 | #define qt_swap_int(x, y) { int tmp = (x); (x) = (y); (y) = tmp; } | - | ||||||||||||||||||||||||||||||
| 131 | #define qt_swap_qreal(x, y) { qreal tmp = (x); (x) = (y); (y) = tmp; } | - | ||||||||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||||||||
| 133 | // #define QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 134 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 135 | void dumpClip(int width, int height, const QClipData *clip); | - | ||||||||||||||||||||||||||||||
| 136 | #endif | - | ||||||||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||||||||
| 138 | #define QT_FAST_SPANS | - | ||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||||||||
| 141 | // A little helper macro to get a better approximation of dimensions. | - | ||||||||||||||||||||||||||||||
| 142 | // If we have a rect that starting at 0.5 of width 3.5 it should span | - | ||||||||||||||||||||||||||||||
| 143 | // 4 pixels. | - | ||||||||||||||||||||||||||||||
| 144 | #define int_dim(pos, dim) (int(pos+dim) - int(pos)) | - | ||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; | - | ||||||||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||||||||
| 148 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||||||||
| 150 | static inline bool winClearTypeFontsEnabled() | - | ||||||||||||||||||||||||||||||
| 151 | { | - | ||||||||||||||||||||||||||||||
| 152 | #ifdef Q_OS_WINRT | - | ||||||||||||||||||||||||||||||
| 153 | return false; | - | ||||||||||||||||||||||||||||||
| 154 | #else // Q_OS_WINRT | - | ||||||||||||||||||||||||||||||
| 155 | UINT result = 0; | - | ||||||||||||||||||||||||||||||
| 156 | #if !defined(SPI_GETFONTSMOOTHINGTYPE) // MinGW | - | ||||||||||||||||||||||||||||||
| 157 | # define SPI_GETFONTSMOOTHINGTYPE 0x200A | - | ||||||||||||||||||||||||||||||
| 158 | # define FE_FONTSMOOTHINGCLEARTYPE 0x002 | - | ||||||||||||||||||||||||||||||
| 159 | #endif | - | ||||||||||||||||||||||||||||||
| 160 | SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0); | - | ||||||||||||||||||||||||||||||
| 161 | return result == FE_FONTSMOOTHINGCLEARTYPE; | - | ||||||||||||||||||||||||||||||
| 162 | #endif // !Q_OS_WINRT | - | ||||||||||||||||||||||||||||||
| 163 | } | - | ||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | /*! | - | ||||||||||||||||||||||||||||||
| 166 | \internal | - | ||||||||||||||||||||||||||||||
| 167 | */ | - | ||||||||||||||||||||||||||||||
| 168 | bool QRasterPaintEngine::clearTypeFontsEnabled() | - | ||||||||||||||||||||||||||||||
| 169 | { | - | ||||||||||||||||||||||||||||||
| 170 | static const bool result = winClearTypeFontsEnabled(); | - | ||||||||||||||||||||||||||||||
| 171 | return result; | - | ||||||||||||||||||||||||||||||
| 172 | } | - | ||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||
| 174 | #endif // Q_OS_WIN | - | ||||||||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||||||||
| 178 | /******************************************************************************** | - | ||||||||||||||||||||||||||||||
| 179 | * Span functions | - | ||||||||||||||||||||||||||||||
| 180 | */ | - | ||||||||||||||||||||||||||||||
| 181 | static void qt_span_fill_clipRect(int count, const QSpan *spans, void *userData); | - | ||||||||||||||||||||||||||||||
| 182 | static void qt_span_fill_clipped(int count, const QSpan *spans, void *userData); | - | ||||||||||||||||||||||||||||||
| 183 | static void qt_span_clip(int count, const QSpan *spans, void *userData); | - | ||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | struct ClipData | - | ||||||||||||||||||||||||||||||
| 186 | { | - | ||||||||||||||||||||||||||||||
| 187 | QClipData *oldClip; | - | ||||||||||||||||||||||||||||||
| 188 | QClipData *newClip; | - | ||||||||||||||||||||||||||||||
| 189 | Qt::ClipOperation operation; | - | ||||||||||||||||||||||||||||||
| 190 | }; | - | ||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | enum LineDrawMode { | - | ||||||||||||||||||||||||||||||
| 193 | LineDrawClipped, | - | ||||||||||||||||||||||||||||||
| 194 | LineDrawNormal, | - | ||||||||||||||||||||||||||||||
| 195 | LineDrawIncludeLastPixel | - | ||||||||||||||||||||||||||||||
| 196 | }; | - | ||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, | - | ||||||||||||||||||||||||||||||
| 199 | ProcessSpans pen_func, ProcessSpans brush_func, | - | ||||||||||||||||||||||||||||||
| 200 | QSpanData *pen_data, QSpanData *brush_data); | - | ||||||||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||||||||
| 202 | struct QRasterFloatPoint { | - | ||||||||||||||||||||||||||||||
| 203 | qreal x; | - | ||||||||||||||||||||||||||||||
| 204 | qreal y; | - | ||||||||||||||||||||||||||||||
| 205 | }; | - | ||||||||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||||||||
| 207 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 208 | static const QRectF boundingRect(const QPointF *points, int pointCount) | - | ||||||||||||||||||||||||||||||
| 209 | { | - | ||||||||||||||||||||||||||||||
| 210 | const QPointF *e = points; | - | ||||||||||||||||||||||||||||||
| 211 | const QPointF *last = points + pointCount; | - | ||||||||||||||||||||||||||||||
| 212 | qreal minx, maxx, miny, maxy; | - | ||||||||||||||||||||||||||||||
| 213 | minx = maxx = e->x(); | - | ||||||||||||||||||||||||||||||
| 214 | miny = maxy = e->y(); | - | ||||||||||||||||||||||||||||||
| 215 | while (++e < last) { | - | ||||||||||||||||||||||||||||||
| 216 | if (e->x() < minx) | - | ||||||||||||||||||||||||||||||
| 217 | minx = e->x(); | - | ||||||||||||||||||||||||||||||
| 218 | else if (e->x() > maxx) | - | ||||||||||||||||||||||||||||||
| 219 | maxx = e->x(); | - | ||||||||||||||||||||||||||||||
| 220 | if (e->y() < miny) | - | ||||||||||||||||||||||||||||||
| 221 | miny = e->y(); | - | ||||||||||||||||||||||||||||||
| 222 | else if (e->y() > maxy) | - | ||||||||||||||||||||||||||||||
| 223 | maxy = e->y(); | - | ||||||||||||||||||||||||||||||
| 224 | } | - | ||||||||||||||||||||||||||||||
| 225 | return QRectF(QPointF(minx, miny), QPointF(maxx, maxy)); | - | ||||||||||||||||||||||||||||||
| 226 | } | - | ||||||||||||||||||||||||||||||
| 227 | #endif | - | ||||||||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||||||||
| 229 | static void qt_ft_outline_move_to(qfixed x, qfixed y, void *data) | - | ||||||||||||||||||||||||||||||
| 230 | { | - | ||||||||||||||||||||||||||||||
| 231 | ((QOutlineMapper *) data)->moveTo(QPointF(qt_fixed_to_real(x), qt_fixed_to_real(y))); | - | ||||||||||||||||||||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | static void qt_ft_outline_line_to(qfixed x, qfixed y, void *data) | - | ||||||||||||||||||||||||||||||
| 235 | { | - | ||||||||||||||||||||||||||||||
| 236 | ((QOutlineMapper *) data)->lineTo(QPointF(qt_fixed_to_real(x), qt_fixed_to_real(y))); | - | ||||||||||||||||||||||||||||||
| 237 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||||||||
| 239 | static void qt_ft_outline_cubic_to(qfixed c1x, qfixed c1y, | - | ||||||||||||||||||||||||||||||
| 240 | qfixed c2x, qfixed c2y, | - | ||||||||||||||||||||||||||||||
| 241 | qfixed ex, qfixed ey, | - | ||||||||||||||||||||||||||||||
| 242 | void *data) | - | ||||||||||||||||||||||||||||||
| 243 | { | - | ||||||||||||||||||||||||||||||
| 244 | ((QOutlineMapper *) data)->curveTo(QPointF(qt_fixed_to_real(c1x), qt_fixed_to_real(c1y)), | - | ||||||||||||||||||||||||||||||
| 245 | QPointF(qt_fixed_to_real(c2x), qt_fixed_to_real(c2y)), | - | ||||||||||||||||||||||||||||||
| 246 | QPointF(qt_fixed_to_real(ex), qt_fixed_to_real(ey))); | - | ||||||||||||||||||||||||||||||
| 247 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||
| 250 | #if !defined(QT_NO_DEBUG) && 0 | - | ||||||||||||||||||||||||||||||
| 251 | static void qt_debug_path(const QPainterPath &path) | - | ||||||||||||||||||||||||||||||
| 252 | { | - | ||||||||||||||||||||||||||||||
| 253 | const char *names[] = { | - | ||||||||||||||||||||||||||||||
| 254 | "MoveTo ", | - | ||||||||||||||||||||||||||||||
| 255 | "LineTo ", | - | ||||||||||||||||||||||||||||||
| 256 | "CurveTo ", | - | ||||||||||||||||||||||||||||||
| 257 | "CurveToData" | - | ||||||||||||||||||||||||||||||
| 258 | }; | - | ||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||
| 260 | fprintf(stderr,"\nQPainterPath: elementCount=%d\n", path.elementCount()); | - | ||||||||||||||||||||||||||||||
| 261 | for (int i=0; i<path.elementCount(); ++i) { | - | ||||||||||||||||||||||||||||||
| 262 | const QPainterPath::Element &e = path.elementAt(i); | - | ||||||||||||||||||||||||||||||
| 263 | Q_ASSERT(e.type >= 0 && e.type <= QPainterPath::CurveToDataElement); | - | ||||||||||||||||||||||||||||||
| 264 | fprintf(stderr," - %3d:: %s, (%.2f, %.2f)\n", i, names[e.type], e.x, e.y); | - | ||||||||||||||||||||||||||||||
| 265 | } | - | ||||||||||||||||||||||||||||||
| 266 | } | - | ||||||||||||||||||||||||||||||
| 267 | #endif | - | ||||||||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||||||||
| 269 | QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() : | - | ||||||||||||||||||||||||||||||
| 270 | QPaintEngineExPrivate(), | - | ||||||||||||||||||||||||||||||
| 271 | cachedLines(0) | - | ||||||||||||||||||||||||||||||
| 272 | { | - | ||||||||||||||||||||||||||||||
| 273 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||||||||
| 276 | /*! | - | ||||||||||||||||||||||||||||||
| 277 | \class QRasterPaintEngine | - | ||||||||||||||||||||||||||||||
| 278 | \preliminary | - | ||||||||||||||||||||||||||||||
| 279 | \ingroup qws | - | ||||||||||||||||||||||||||||||
| 280 | \inmodule QtGui | - | ||||||||||||||||||||||||||||||
| 281 | \since 4.2 | - | ||||||||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||||||||
| 283 | \brief The QRasterPaintEngine class enables hardware acceleration | - | ||||||||||||||||||||||||||||||
| 284 | of painting operations in Qt for Embedded Linux. | - | ||||||||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||||||||
| 286 | Note that this functionality is only available in | - | ||||||||||||||||||||||||||||||
| 287 | Qt for Embedded Linux. | - | ||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | In Qt for Embedded Linux, painting is a pure software | - | ||||||||||||||||||||||||||||||
| 290 | implementation. But starting with Qt 4.2, it is | - | ||||||||||||||||||||||||||||||
| 291 | possible to add an accelerated graphics driver to take advantage | - | ||||||||||||||||||||||||||||||
| 292 | of available hardware resources. | - | ||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | Hardware acceleration is accomplished by creating a custom screen | - | ||||||||||||||||||||||||||||||
| 295 | driver, accelerating the copying from memory to the screen, and | - | ||||||||||||||||||||||||||||||
| 296 | implementing a custom paint engine accelerating the various | - | ||||||||||||||||||||||||||||||
| 297 | painting operations. Then a custom paint device and a custom | - | ||||||||||||||||||||||||||||||
| 298 | window surface must be implemented to make | - | ||||||||||||||||||||||||||||||
| 299 | Qt for Embedded Linux aware of the accelerated driver. | - | ||||||||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||||||||
| 301 | \note The QRasterPaintEngine class does not support 8-bit images. | - | ||||||||||||||||||||||||||||||
| 302 | Instead, they need to be converted to a supported format, such as | - | ||||||||||||||||||||||||||||||
| 303 | QImage::Format_ARGB32_Premultiplied. | - | ||||||||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||||||||
| 305 | \sa QPaintEngine | - | ||||||||||||||||||||||||||||||
| 306 | */ | - | ||||||||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||||||||
| 308 | /*! | - | ||||||||||||||||||||||||||||||
| 309 | \fn Type QRasterPaintEngine::type() const | - | ||||||||||||||||||||||||||||||
| 310 | \reimp | - | ||||||||||||||||||||||||||||||
| 311 | */ | - | ||||||||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||||||||
| 313 | /*! | - | ||||||||||||||||||||||||||||||
| 314 | \typedef QSpan | - | ||||||||||||||||||||||||||||||
| 315 | \relates QRasterPaintEngine | - | ||||||||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||||||||
| 317 | A struct equivalent to QT_FT_Span, containing a position (x, | - | ||||||||||||||||||||||||||||||
| 318 | y), the span's length in pixels and its color/coverage (a value | - | ||||||||||||||||||||||||||||||
| 319 | ranging from 0 to 255). | - | ||||||||||||||||||||||||||||||
| 320 | */ | - | ||||||||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||||||||
| 322 | /*! | - | ||||||||||||||||||||||||||||||
| 323 | \since 4.5 | - | ||||||||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||||||||
| 325 | Creates a raster based paint engine for operating on the given | - | ||||||||||||||||||||||||||||||
| 326 | \a device, with the complete set of \l | - | ||||||||||||||||||||||||||||||
| 327 | {QPaintEngine::PaintEngineFeature}{paint engine features and | - | ||||||||||||||||||||||||||||||
| 328 | capabilities}. | - | ||||||||||||||||||||||||||||||
| 329 | */ | - | ||||||||||||||||||||||||||||||
| 330 | QRasterPaintEngine::QRasterPaintEngine(QPaintDevice *device) | - | ||||||||||||||||||||||||||||||
| 331 | : QPaintEngineEx(*(new QRasterPaintEnginePrivate)) | - | ||||||||||||||||||||||||||||||
| 332 | { | - | ||||||||||||||||||||||||||||||
| 333 | d_func()->device = device; | - | ||||||||||||||||||||||||||||||
| 334 | init(); | - | ||||||||||||||||||||||||||||||
| 335 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||||||||
| 337 | /*! | - | ||||||||||||||||||||||||||||||
| 338 | \internal | - | ||||||||||||||||||||||||||||||
| 339 | */ | - | ||||||||||||||||||||||||||||||
| 340 | QRasterPaintEngine::QRasterPaintEngine(QRasterPaintEnginePrivate &dd, QPaintDevice *device) | - | ||||||||||||||||||||||||||||||
| 341 | : QPaintEngineEx(dd) | - | ||||||||||||||||||||||||||||||
| 342 | { | - | ||||||||||||||||||||||||||||||
| 343 | d_func()->device = device; | - | ||||||||||||||||||||||||||||||
| 344 | init(); | - | ||||||||||||||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||||||||
| 347 | void QRasterPaintEngine::init() | - | ||||||||||||||||||||||||||||||
| 348 | { | - | ||||||||||||||||||||||||||||||
| 349 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||||||||
| 352 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||
| 353 | d->hdc = 0; | - | ||||||||||||||||||||||||||||||
| 354 | #endif | - | ||||||||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||||||||
| 356 | // The antialiasing raster. | - | ||||||||||||||||||||||||||||||
| 357 | d->grayRaster.reset(new QT_FT_Raster); | - | ||||||||||||||||||||||||||||||
| 358 | Q_CHECK_PTR(d->grayRaster.data()); never executed: qt_check_pointer(__FILE__,358);
| 0 | ||||||||||||||||||||||||||||||
| 359 | if (qt_ft_grays_raster.raster_new(d->grayRaster.data()))
| 0 | ||||||||||||||||||||||||||||||
| 360 | QT_THROW(std::bad_alloc()); // an error creating the raster is caused by a bad malloc never executed: qt_noop(); | 0 | ||||||||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||
| 363 | d->rasterizer.reset(new QRasterizer); | - | ||||||||||||||||||||||||||||||
| 364 | d->rasterBuffer.reset(new QRasterBuffer()); | - | ||||||||||||||||||||||||||||||
| 365 | d->outlineMapper.reset(new QOutlineMapper); | - | ||||||||||||||||||||||||||||||
| 366 | d->outlinemapper_xform_dirty = true; | - | ||||||||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||||||||
| 368 | d->basicStroker.setMoveToHook(qt_ft_outline_move_to); | - | ||||||||||||||||||||||||||||||
| 369 | d->basicStroker.setLineToHook(qt_ft_outline_line_to); | - | ||||||||||||||||||||||||||||||
| 370 | d->basicStroker.setCubicToHook(qt_ft_outline_cubic_to); | - | ||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | d->baseClip.reset(new QClipData(d->device->height())); | - | ||||||||||||||||||||||||||||||
| 373 | d->baseClip->setClipRect(QRect(0, 0, d->device->width(), d->device->height())); | - | ||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | d->image_filler.init(d->rasterBuffer.data(), this); | - | ||||||||||||||||||||||||||||||
| 376 | d->image_filler.type = QSpanData::Texture; | - | ||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | d->image_filler_xform.init(d->rasterBuffer.data(), this); | - | ||||||||||||||||||||||||||||||
| 379 | d->image_filler_xform.type = QSpanData::Texture; | - | ||||||||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||||||||
| 381 | d->solid_color_filler.init(d->rasterBuffer.data(), this); | - | ||||||||||||||||||||||||||||||
| 382 | d->solid_color_filler.type = QSpanData::Solid; | - | ||||||||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||||||||
| 384 | d->deviceDepth = d->device->depth(); | - | ||||||||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||||||||
| 386 | d->mono_surface = false; | - | ||||||||||||||||||||||||||||||
| 387 | gccaps &= ~PorterDuff; | - | ||||||||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||||||||
| 389 | QImage::Format format = QImage::Format_Invalid; | - | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | switch (d->device->devType()) { | - | ||||||||||||||||||||||||||||||
| 392 | case QInternal::Pixmap: never executed: case QInternal::Pixmap: | 0 | ||||||||||||||||||||||||||||||
| 393 | qWarning("QRasterPaintEngine: unsupported for pixmaps..."); | - | ||||||||||||||||||||||||||||||
| 394 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 395 | case QInternal::Image: never executed: case QInternal::Image: | 0 | ||||||||||||||||||||||||||||||
| 396 | format = d->rasterBuffer->prepare(static_cast<QImage *>(d->device)); | - | ||||||||||||||||||||||||||||||
| 397 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 398 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 399 | qWarning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType()); | - | ||||||||||||||||||||||||||||||
| 400 | d->device = 0; | - | ||||||||||||||||||||||||||||||
| 401 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 402 | } | - | ||||||||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||||||||
| 404 | switch (format) { | - | ||||||||||||||||||||||||||||||
| 405 | case QImage::Format_MonoLSB: never executed: case QImage::Format_MonoLSB: | 0 | ||||||||||||||||||||||||||||||
| 406 | case QImage::Format_Mono: never executed: case QImage::Format_Mono: | 0 | ||||||||||||||||||||||||||||||
| 407 | d->mono_surface = true; | - | ||||||||||||||||||||||||||||||
| 408 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 409 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 410 | if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha)
| 0 | ||||||||||||||||||||||||||||||
| 411 | gccaps |= PorterDuff; never executed: gccaps |= PorterDuff; | 0 | ||||||||||||||||||||||||||||||
| 412 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 413 | } | - | ||||||||||||||||||||||||||||||
| 414 | } | - | ||||||||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||||||||
| 417 | /*! | - | ||||||||||||||||||||||||||||||
| 418 | Destroys this paint engine. | - | ||||||||||||||||||||||||||||||
| 419 | */ | - | ||||||||||||||||||||||||||||||
| 420 | QRasterPaintEngine::~QRasterPaintEngine() | - | ||||||||||||||||||||||||||||||
| 421 | { | - | ||||||||||||||||||||||||||||||
| 422 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||||||||
| 424 | qt_ft_grays_raster.raster_done(*d->grayRaster.data()); | - | ||||||||||||||||||||||||||||||
| 425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||
| 427 | /*! | - | ||||||||||||||||||||||||||||||
| 428 | \reimp | - | ||||||||||||||||||||||||||||||
| 429 | */ | - | ||||||||||||||||||||||||||||||
| 430 | bool QRasterPaintEngine::begin(QPaintDevice *device) | - | ||||||||||||||||||||||||||||||
| 431 | { | - | ||||||||||||||||||||||||||||||
| 432 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||||||||
| 434 | if (device->devType() == QInternal::Pixmap) {
| 0 | ||||||||||||||||||||||||||||||
| 435 | QPixmap *pixmap = static_cast<QPixmap *>(device); | - | ||||||||||||||||||||||||||||||
| 436 | QPlatformPixmap *pd = pixmap->handle(); | - | ||||||||||||||||||||||||||||||
| 437 | if (pd->classId() == QPlatformPixmap::RasterClass || pd->classId() == QPlatformPixmap::BlitterClass)
| 0 | ||||||||||||||||||||||||||||||
| 438 | d->device = pd->buffer(); never executed: d->device = pd->buffer(); | 0 | ||||||||||||||||||||||||||||||
| 439 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 440 | d->device = device; | - | ||||||||||||||||||||||||||||||
| 441 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||||||||
| 443 | // Make sure QPaintEngine::paintDevice() returns the proper device. | - | ||||||||||||||||||||||||||||||
| 444 | d->pdev = d->device; | - | ||||||||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||||||||
| 446 | Q_ASSERT(d->device->devType() == QInternal::Image | - | ||||||||||||||||||||||||||||||
| 447 | || d->device->devType() == QInternal::CustomRaster); | - | ||||||||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||||||||
| 449 | d->systemStateChanged(); | - | ||||||||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||||||||
| 451 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 452 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 453 | d->outlineMapper->m_clip_rect = d->deviceRect; | - | ||||||||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||||||||
| 455 | if (d->outlineMapper->m_clip_rect.width() > QT_RASTER_COORD_LIMIT)
| 0 | ||||||||||||||||||||||||||||||
| 456 | d->outlineMapper->m_clip_rect.setWidth(QT_RASTER_COORD_LIMIT); never executed: d->outlineMapper->m_clip_rect.setWidth(QT_RASTER_COORD_LIMIT); | 0 | ||||||||||||||||||||||||||||||
| 457 | if (d->outlineMapper->m_clip_rect.height() > QT_RASTER_COORD_LIMIT)
| 0 | ||||||||||||||||||||||||||||||
| 458 | d->outlineMapper->m_clip_rect.setHeight(QT_RASTER_COORD_LIMIT); never executed: d->outlineMapper->m_clip_rect.setHeight(QT_RASTER_COORD_LIMIT); | 0 | ||||||||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||||||||
| 460 | d->rasterizer->setClipRect(d->deviceRect); | - | ||||||||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||||||||
| 462 | s->penData.init(d->rasterBuffer.data(), this); | - | ||||||||||||||||||||||||||||||
| 463 | s->penData.setup(s->pen.brush(), s->intOpacity, s->composition_mode); | - | ||||||||||||||||||||||||||||||
| 464 | s->stroker = &d->basicStroker; | - | ||||||||||||||||||||||||||||||
| 465 | d->basicStroker.setClipRect(d->deviceRect); | - | ||||||||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||||||||
| 467 | s->brushData.init(d->rasterBuffer.data(), this); | - | ||||||||||||||||||||||||||||||
| 468 | s->brushData.setup(s->brush, s->intOpacity, s->composition_mode); | - | ||||||||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||||||||
| 470 | d->rasterBuffer->compositionMode = QPainter::CompositionMode_SourceOver; | - | ||||||||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||||||||
| 472 | setDirty(DirtyBrushOrigin); | - | ||||||||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||||||||
| 474 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 475 | qDebug() << "QRasterPaintEngine::begin(" << (void *) device | - | ||||||||||||||||||||||||||||||
| 476 | << ") devType:" << device->devType() | - | ||||||||||||||||||||||||||||||
| 477 | << "devRect:" << d->deviceRect; | - | ||||||||||||||||||||||||||||||
| 478 | if (d->baseClip) { | - | ||||||||||||||||||||||||||||||
| 479 | dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->baseClip); | - | ||||||||||||||||||||||||||||||
| 480 | } | - | ||||||||||||||||||||||||||||||
| 481 | #endif | - | ||||||||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||||||||
| 483 | if (d->mono_surface)
| 0 | ||||||||||||||||||||||||||||||
| 484 | d->glyphCacheFormat = QFontEngine::Format_Mono; never executed: d->glyphCacheFormat = QFontEngine::Format_Mono; | 0 | ||||||||||||||||||||||||||||||
| 485 | #if defined(Q_OS_WIN) | - | ||||||||||||||||||||||||||||||
| 486 | else if (clearTypeFontsEnabled()) | - | ||||||||||||||||||||||||||||||
| 487 | #else | - | ||||||||||||||||||||||||||||||
| 488 | else if (false) dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 489 | #endif dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 490 | { dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 491 | QImage::Format format = static_cast<QImage *>(d->device)->format(); dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 492 | if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 493 | d->glyphCacheFormat = QFontEngine::Format_A32; dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 494 | else dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 495 | d->glyphCacheFormat = QFontEngine::Format_A8; dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 496 | } else dead code: { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) d->glyphCacheFormat = QFontEngine::Format_A32; else d->glyphCacheFormat = QFontEngine::Format_A8; } | - | ||||||||||||||||||||||||||||||
| 497 | d->glyphCacheFormat = QFontEngine::Format_A8; never executed: d->glyphCacheFormat = QFontEngine::Format_A8; | 0 | ||||||||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||||||||
| 499 | setActive(true); | - | ||||||||||||||||||||||||||||||
| 500 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 501 | } | - | ||||||||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||||||||
| 503 | /*! | - | ||||||||||||||||||||||||||||||
| 504 | \reimp | - | ||||||||||||||||||||||||||||||
| 505 | */ | - | ||||||||||||||||||||||||||||||
| 506 | bool QRasterPaintEngine::end() | - | ||||||||||||||||||||||||||||||
| 507 | { | - | ||||||||||||||||||||||||||||||
| 508 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 509 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 510 | qDebug() << "QRasterPaintEngine::end devRect:" << d->deviceRect; | - | ||||||||||||||||||||||||||||||
| 511 | if (d->baseClip) { | - | ||||||||||||||||||||||||||||||
| 512 | dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->baseClip); | - | ||||||||||||||||||||||||||||||
| 513 | } | - | ||||||||||||||||||||||||||||||
| 514 | #endif | - | ||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||
| 516 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 517 | } | - | ||||||||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||||||||
| 519 | /*! | - | ||||||||||||||||||||||||||||||
| 520 | \internal | - | ||||||||||||||||||||||||||||||
| 521 | */ | - | ||||||||||||||||||||||||||||||
| 522 | void QRasterPaintEngine::releaseBuffer() | - | ||||||||||||||||||||||||||||||
| 523 | { | - | ||||||||||||||||||||||||||||||
| 524 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 525 | d->rasterBuffer.reset(new QRasterBuffer); | - | ||||||||||||||||||||||||||||||
| 526 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||||||||
| 528 | /*! | - | ||||||||||||||||||||||||||||||
| 529 | \internal | - | ||||||||||||||||||||||||||||||
| 530 | */ | - | ||||||||||||||||||||||||||||||
| 531 | QSize QRasterPaintEngine::size() const | - | ||||||||||||||||||||||||||||||
| 532 | { | - | ||||||||||||||||||||||||||||||
| 533 | Q_D(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 534 | return QSize(d->rasterBuffer->width(), d->rasterBuffer->height()); never executed: return QSize(d->rasterBuffer->width(), d->rasterBuffer->height()); | 0 | ||||||||||||||||||||||||||||||
| 535 | } | - | ||||||||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||||||||
| 537 | /*! | - | ||||||||||||||||||||||||||||||
| 538 | \internal | - | ||||||||||||||||||||||||||||||
| 539 | */ | - | ||||||||||||||||||||||||||||||
| 540 | #ifndef QT_NO_DEBUG | - | ||||||||||||||||||||||||||||||
| 541 | void QRasterPaintEngine::saveBuffer(const QString &s) const | - | ||||||||||||||||||||||||||||||
| 542 | { | - | ||||||||||||||||||||||||||||||
| 543 | Q_D(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 544 | d->rasterBuffer->bufferImage().save(s, "PNG"); | - | ||||||||||||||||||||||||||||||
| 545 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 546 | #endif | - | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | /*! | - | ||||||||||||||||||||||||||||||
| 549 | \internal | - | ||||||||||||||||||||||||||||||
| 550 | */ | - | ||||||||||||||||||||||||||||||
| 551 | void QRasterPaintEngine::updateMatrix(const QTransform &matrix) | - | ||||||||||||||||||||||||||||||
| 552 | { | - | ||||||||||||||||||||||||||||||
| 553 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 554 | // FALCON: get rid of this line, see drawImage call below. | - | ||||||||||||||||||||||||||||||
| 555 | s->matrix = matrix; | - | ||||||||||||||||||||||||||||||
| 556 | QTransform::TransformationType txop = s->matrix.type(); | - | ||||||||||||||||||||||||||||||
| 557 | - | |||||||||||||||||||||||||||||||
| 558 | switch (txop) { | - | ||||||||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||||||||
| 560 | case QTransform::TxNone: never executed: case QTransform::TxNone: | 0 | ||||||||||||||||||||||||||||||
| 561 | s->flags.int_xform = true; | - | ||||||||||||||||||||||||||||||
| 562 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||||||||
| 564 | case QTransform::TxTranslate: never executed: case QTransform::TxTranslate: | 0 | ||||||||||||||||||||||||||||||
| 565 | s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
| 0 | ||||||||||||||||||||||||||||||
| 566 | && qreal(int(s->matrix.dy())) == s->matrix.dy();
| 0 | ||||||||||||||||||||||||||||||
| 567 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||||||||
| 569 | case QTransform::TxScale: never executed: case QTransform::TxScale: | 0 | ||||||||||||||||||||||||||||||
| 570 | s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
| 0 | ||||||||||||||||||||||||||||||
| 571 | && qreal(int(s->matrix.dy())) == s->matrix.dy()
| 0 | ||||||||||||||||||||||||||||||
| 572 | && qreal(int(s->matrix.m11())) == s->matrix.m11()
| 0 | ||||||||||||||||||||||||||||||
| 573 | && qreal(int(s->matrix.m22())) == s->matrix.m22();
| 0 | ||||||||||||||||||||||||||||||
| 574 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||||||||
| 576 | default: // shear / perspective... never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 577 | s->flags.int_xform = false; | - | ||||||||||||||||||||||||||||||
| 578 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 579 | } | - | ||||||||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||||||||
| 581 | s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale); | - | ||||||||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||||||||
| 583 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 584 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||||||||
| 588 | QRasterPaintEngineState::~QRasterPaintEngineState() | - | ||||||||||||||||||||||||||||||
| 589 | { | - | ||||||||||||||||||||||||||||||
| 590 | if (flags.has_clip_ownership)
| 0 | ||||||||||||||||||||||||||||||
| 591 | delete clip; never executed: delete clip; | 0 | ||||||||||||||||||||||||||||||
| 592 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 593 | - | |||||||||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||||||||
| 595 | QRasterPaintEngineState::QRasterPaintEngineState() | - | ||||||||||||||||||||||||||||||
| 596 | { | - | ||||||||||||||||||||||||||||||
| 597 | stroker = 0; | - | ||||||||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||||||||
| 599 | fillFlags = 0; | - | ||||||||||||||||||||||||||||||
| 600 | strokeFlags = 0; | - | ||||||||||||||||||||||||||||||
| 601 | pixmapFlags = 0; | - | ||||||||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||||||||
| 603 | intOpacity = 256; | - | ||||||||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||||||||
| 605 | txscale = 1.; | - | ||||||||||||||||||||||||||||||
| 606 | - | |||||||||||||||||||||||||||||||
| 607 | flags.fast_pen = true; | - | ||||||||||||||||||||||||||||||
| 608 | flags.antialiased = false; | - | ||||||||||||||||||||||||||||||
| 609 | flags.bilinear = false; | - | ||||||||||||||||||||||||||||||
| 610 | flags.legacy_rounding = false; | - | ||||||||||||||||||||||||||||||
| 611 | flags.fast_text = true; | - | ||||||||||||||||||||||||||||||
| 612 | flags.int_xform = true; | - | ||||||||||||||||||||||||||||||
| 613 | flags.tx_noshear = true; | - | ||||||||||||||||||||||||||||||
| 614 | flags.fast_images = true; | - | ||||||||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||||||||
| 616 | clip = 0; | - | ||||||||||||||||||||||||||||||
| 617 | flags.has_clip_ownership = false; | - | ||||||||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||||||||
| 619 | dirty = 0; | - | ||||||||||||||||||||||||||||||
| 620 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||||||||
| 622 | QRasterPaintEngineState::QRasterPaintEngineState(QRasterPaintEngineState &s) | - | ||||||||||||||||||||||||||||||
| 623 | : QPainterState(s) | - | ||||||||||||||||||||||||||||||
| 624 | , lastPen(s.lastPen) | - | ||||||||||||||||||||||||||||||
| 625 | , penData(s.penData) | - | ||||||||||||||||||||||||||||||
| 626 | , stroker(s.stroker) | - | ||||||||||||||||||||||||||||||
| 627 | , strokeFlags(s.strokeFlags) | - | ||||||||||||||||||||||||||||||
| 628 | , lastBrush(s.lastBrush) | - | ||||||||||||||||||||||||||||||
| 629 | , brushData(s.brushData) | - | ||||||||||||||||||||||||||||||
| 630 | , fillFlags(s.fillFlags) | - | ||||||||||||||||||||||||||||||
| 631 | , pixmapFlags(s.pixmapFlags) | - | ||||||||||||||||||||||||||||||
| 632 | , intOpacity(s.intOpacity) | - | ||||||||||||||||||||||||||||||
| 633 | , txscale(s.txscale) | - | ||||||||||||||||||||||||||||||
| 634 | , clip(s.clip) | - | ||||||||||||||||||||||||||||||
| 635 | , dirty(s.dirty) | - | ||||||||||||||||||||||||||||||
| 636 | , flag_bits(s.flag_bits) | - | ||||||||||||||||||||||||||||||
| 637 | { | - | ||||||||||||||||||||||||||||||
| 638 | brushData.tempImage = 0; | - | ||||||||||||||||||||||||||||||
| 639 | penData.tempImage = 0; | - | ||||||||||||||||||||||||||||||
| 640 | flags.has_clip_ownership = false; | - | ||||||||||||||||||||||||||||||
| 641 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||||||||
| 643 | /*! | - | ||||||||||||||||||||||||||||||
| 644 | \internal | - | ||||||||||||||||||||||||||||||
| 645 | */ | - | ||||||||||||||||||||||||||||||
| 646 | QPainterState *QRasterPaintEngine::createState(QPainterState *orig) const | - | ||||||||||||||||||||||||||||||
| 647 | { | - | ||||||||||||||||||||||||||||||
| 648 | QRasterPaintEngineState *s; | - | ||||||||||||||||||||||||||||||
| 649 | if (!orig)
| 0 | ||||||||||||||||||||||||||||||
| 650 | s = new QRasterPaintEngineState(); never executed: s = new QRasterPaintEngineState(); | 0 | ||||||||||||||||||||||||||||||
| 651 | else | - | ||||||||||||||||||||||||||||||
| 652 | s = new QRasterPaintEngineState(*static_cast<QRasterPaintEngineState *>(orig)); never executed: s = new QRasterPaintEngineState(*static_cast<QRasterPaintEngineState *>(orig)); | 0 | ||||||||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||||||||
| 654 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||||||||
| 655 | } | - | ||||||||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||||||||
| 657 | /*! | - | ||||||||||||||||||||||||||||||
| 658 | \internal | - | ||||||||||||||||||||||||||||||
| 659 | */ | - | ||||||||||||||||||||||||||||||
| 660 | void QRasterPaintEngine::setState(QPainterState *s) | - | ||||||||||||||||||||||||||||||
| 661 | { | - | ||||||||||||||||||||||||||||||
| 662 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 663 | QPaintEngineEx::setState(s); | - | ||||||||||||||||||||||||||||||
| 664 | d->rasterBuffer->compositionMode = s->composition_mode; | - | ||||||||||||||||||||||||||||||
| 665 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||||||||
| 667 | /*! | - | ||||||||||||||||||||||||||||||
| 668 | \fn QRasterPaintEngineState *QRasterPaintEngine::state() | - | ||||||||||||||||||||||||||||||
| 669 | \internal | - | ||||||||||||||||||||||||||||||
| 670 | */ | - | ||||||||||||||||||||||||||||||
| 671 | - | |||||||||||||||||||||||||||||||
| 672 | /*! | - | ||||||||||||||||||||||||||||||
| 673 | \fn const QRasterPaintEngineState *QRasterPaintEngine::state() const | - | ||||||||||||||||||||||||||||||
| 674 | \internal | - | ||||||||||||||||||||||||||||||
| 675 | */ | - | ||||||||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||||||||
| 677 | /*! | - | ||||||||||||||||||||||||||||||
| 678 | \internal | - | ||||||||||||||||||||||||||||||
| 679 | */ | - | ||||||||||||||||||||||||||||||
| 680 | void QRasterPaintEngine::penChanged() | - | ||||||||||||||||||||||||||||||
| 681 | { | - | ||||||||||||||||||||||||||||||
| 682 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 683 | qDebug() << "QRasterPaintEngine::penChanged():" << state()->pen; | - | ||||||||||||||||||||||||||||||
| 684 | #endif | - | ||||||||||||||||||||||||||||||
| 685 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 686 | Q_ASSERT(s); | - | ||||||||||||||||||||||||||||||
| 687 | s->strokeFlags |= DirtyPen; | - | ||||||||||||||||||||||||||||||
| 688 | s->dirty |= DirtyPen; | - | ||||||||||||||||||||||||||||||
| 689 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||||||||
| 691 | /*! | - | ||||||||||||||||||||||||||||||
| 692 | \internal | - | ||||||||||||||||||||||||||||||
| 693 | */ | - | ||||||||||||||||||||||||||||||
| 694 | void QRasterPaintEngine::updatePen(const QPen &pen) | - | ||||||||||||||||||||||||||||||
| 695 | { | - | ||||||||||||||||||||||||||||||
| 696 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 697 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 698 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 699 | qDebug() << "QRasterPaintEngine::updatePen():" << s->pen; | - | ||||||||||||||||||||||||||||||
| 700 | #endif | - | ||||||||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||||||||
| 702 | Qt::PenStyle pen_style = qpen_style(pen); | - | ||||||||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||||||||
| 704 | s->lastPen = pen; | - | ||||||||||||||||||||||||||||||
| 705 | s->strokeFlags = 0; | - | ||||||||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||||||||
| 707 | s->penData.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 708 | s->penData.setup(pen_style == Qt::NoPen ? QBrush() : pen.brush(), s->intOpacity, s->composition_mode); | - | ||||||||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||||||||
| 710 | if (s->strokeFlags & QRasterPaintEngine::DirtyTransform
| 0 | ||||||||||||||||||||||||||||||
| 711 | || pen.brush().transform().type() >= QTransform::TxNone) {
| 0 | ||||||||||||||||||||||||||||||
| 712 | d->updateMatrixData(&s->penData, pen.brush(), s->matrix); | - | ||||||||||||||||||||||||||||||
| 713 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||||||||
| 715 | // Slightly ugly handling of an uncommon case... We need to change | - | ||||||||||||||||||||||||||||||
| 716 | // the pen because it is reused in draw_midpoint to decide dashed | - | ||||||||||||||||||||||||||||||
| 717 | // or non-dashed. | - | ||||||||||||||||||||||||||||||
| 718 | if (pen_style == Qt::CustomDashLine && pen.dashPattern().size() == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 719 | pen_style = Qt::SolidLine; | - | ||||||||||||||||||||||||||||||
| 720 | s->lastPen.setStyle(Qt::SolidLine); | - | ||||||||||||||||||||||||||||||
| 721 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||||||||
| 723 | d->basicStroker.setJoinStyle(qpen_joinStyle(pen)); | - | ||||||||||||||||||||||||||||||
| 724 | d->basicStroker.setCapStyle(qpen_capStyle(pen)); | - | ||||||||||||||||||||||||||||||
| 725 | d->basicStroker.setMiterLimit(pen.miterLimit()); | - | ||||||||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||||||||
| 727 | qreal penWidth = qpen_widthf(pen); | - | ||||||||||||||||||||||||||||||
| 728 | if (penWidth == 0)
| 0 | ||||||||||||||||||||||||||||||
| 729 | d->basicStroker.setStrokeWidth(1); never executed: d->basicStroker.setStrokeWidth(1); | 0 | ||||||||||||||||||||||||||||||
| 730 | else | - | ||||||||||||||||||||||||||||||
| 731 | d->basicStroker.setStrokeWidth(penWidth); never executed: d->basicStroker.setStrokeWidth(penWidth); | 0 | ||||||||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||||||||
| 733 | if(pen_style == Qt::SolidLine) {
| 0 | ||||||||||||||||||||||||||||||
| 734 | s->stroker = &d->basicStroker; | - | ||||||||||||||||||||||||||||||
| 735 | } else if (pen_style != Qt::NoPen) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 736 | if (!d->dashStroker)
| 0 | ||||||||||||||||||||||||||||||
| 737 | d->dashStroker.reset(new QDashStroker(&d->basicStroker)); never executed: d->dashStroker.reset(new QDashStroker(&d->basicStroker)); | 0 | ||||||||||||||||||||||||||||||
| 738 | if (qt_pen_is_cosmetic(pen, s->renderHints)) {
| 0 | ||||||||||||||||||||||||||||||
| 739 | d->dashStroker->setClipRect(d->deviceRect); | - | ||||||||||||||||||||||||||||||
| 740 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 741 | // ### I've seen this inverted devrect multiple places now... | - | ||||||||||||||||||||||||||||||
| 742 | QRectF clipRect = s->matrix.inverted().mapRect(QRectF(d->deviceRect)); | - | ||||||||||||||||||||||||||||||
| 743 | d->dashStroker->setClipRect(clipRect); | - | ||||||||||||||||||||||||||||||
| 744 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 745 | d->dashStroker->setDashPattern(pen.dashPattern()); | - | ||||||||||||||||||||||||||||||
| 746 | d->dashStroker->setDashOffset(pen.dashOffset()); | - | ||||||||||||||||||||||||||||||
| 747 | s->stroker = d->dashStroker.data(); | - | ||||||||||||||||||||||||||||||
| 748 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 749 | s->stroker = 0; | - | ||||||||||||||||||||||||||||||
| 750 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||||||||
| 752 | ensureRasterState(); // needed because of tx_noshear... | - | ||||||||||||||||||||||||||||||
| 753 | bool cosmetic = qt_pen_is_cosmetic(pen, s->renderHints); | - | ||||||||||||||||||||||||||||||
| 754 | s->flags.fast_pen = pen_style > Qt::NoPen
| 0 | ||||||||||||||||||||||||||||||
| 755 | && s->penData.blend
| 0 | ||||||||||||||||||||||||||||||
| 756 | && ((cosmetic && penWidth <= 1)
| 0 | ||||||||||||||||||||||||||||||
| 757 | || (!cosmetic && s->flags.tx_noshear && penWidth * s->txscale <= 1));
| 0 | ||||||||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||||||||
| 759 | s->flags.non_complex_pen = qpen_capStyle(s->lastPen) <= Qt::SquareCap && s->flags.tx_noshear;
| 0 | ||||||||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||||||||
| 761 | s->strokeFlags = 0; | - | ||||||||||||||||||||||||||||||
| 762 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 763 | - | |||||||||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||||||||
| 766 | /*! | - | ||||||||||||||||||||||||||||||
| 767 | \internal | - | ||||||||||||||||||||||||||||||
| 768 | */ | - | ||||||||||||||||||||||||||||||
| 769 | void QRasterPaintEngine::brushOriginChanged() | - | ||||||||||||||||||||||||||||||
| 770 | { | - | ||||||||||||||||||||||||||||||
| 771 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 772 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 773 | qDebug() << "QRasterPaintEngine::brushOriginChanged()" << s->brushOrigin; | - | ||||||||||||||||||||||||||||||
| 774 | #endif | - | ||||||||||||||||||||||||||||||
| 775 | - | |||||||||||||||||||||||||||||||
| 776 | s->fillFlags |= DirtyBrushOrigin; | - | ||||||||||||||||||||||||||||||
| 777 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||||||||
| 779 | - | |||||||||||||||||||||||||||||||
| 780 | /*! | - | ||||||||||||||||||||||||||||||
| 781 | \internal | - | ||||||||||||||||||||||||||||||
| 782 | */ | - | ||||||||||||||||||||||||||||||
| 783 | void QRasterPaintEngine::brushChanged() | - | ||||||||||||||||||||||||||||||
| 784 | { | - | ||||||||||||||||||||||||||||||
| 785 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 786 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 787 | qDebug() << "QRasterPaintEngine::brushChanged():" << s->brush; | - | ||||||||||||||||||||||||||||||
| 788 | #endif | - | ||||||||||||||||||||||||||||||
| 789 | s->fillFlags |= DirtyBrush; | - | ||||||||||||||||||||||||||||||
| 790 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||||||||
| 795 | /*! | - | ||||||||||||||||||||||||||||||
| 796 | \internal | - | ||||||||||||||||||||||||||||||
| 797 | */ | - | ||||||||||||||||||||||||||||||
| 798 | void QRasterPaintEngine::updateBrush(const QBrush &brush) | - | ||||||||||||||||||||||||||||||
| 799 | { | - | ||||||||||||||||||||||||||||||
| 800 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 801 | qDebug() << "QRasterPaintEngine::updateBrush()" << brush; | - | ||||||||||||||||||||||||||||||
| 802 | #endif | - | ||||||||||||||||||||||||||||||
| 803 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 804 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 805 | // must set clip prior to setup, as setup uses it... | - | ||||||||||||||||||||||||||||||
| 806 | s->brushData.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 807 | s->brushData.setup(brush, s->intOpacity, s->composition_mode); | - | ||||||||||||||||||||||||||||||
| 808 | if (s->fillFlags & DirtyTransform
| 0 | ||||||||||||||||||||||||||||||
| 809 | || brush.transform().type() >= QTransform::TxNone)
| 0 | ||||||||||||||||||||||||||||||
| 810 | d_func()->updateMatrixData(&s->brushData, brush, d->brushMatrix()); never executed: d_func()->updateMatrixData(&s->brushData, brush, d->brushMatrix()); | 0 | ||||||||||||||||||||||||||||||
| 811 | s->lastBrush = brush; | - | ||||||||||||||||||||||||||||||
| 812 | s->fillFlags = 0; | - | ||||||||||||||||||||||||||||||
| 813 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 814 | - | |||||||||||||||||||||||||||||||
| 815 | void QRasterPaintEngine::updateOutlineMapper() | - | ||||||||||||||||||||||||||||||
| 816 | { | - | ||||||||||||||||||||||||||||||
| 817 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 818 | d->outlineMapper->setMatrix(state()->matrix); | - | ||||||||||||||||||||||||||||||
| 819 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 820 | - | |||||||||||||||||||||||||||||||
| 821 | void QRasterPaintEngine::updateRasterState() | - | ||||||||||||||||||||||||||||||
| 822 | { | - | ||||||||||||||||||||||||||||||
| 823 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||||||||
| 825 | if (s->dirty & DirtyTransform)
| 0 | ||||||||||||||||||||||||||||||
| 826 | updateMatrix(s->matrix); never executed: updateMatrix(s->matrix); | 0 | ||||||||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||||||||
| 828 | if (s->dirty & (DirtyPen|DirtyCompositionMode|DirtyOpacity)) {
| 0 | ||||||||||||||||||||||||||||||
| 829 | const QPainter::CompositionMode mode = s->composition_mode; | - | ||||||||||||||||||||||||||||||
| 830 | s->flags.fast_text = (s->penData.type == QSpanData::Solid)
| 0 | ||||||||||||||||||||||||||||||
| 831 | && s->intOpacity == 256
| 0 | ||||||||||||||||||||||||||||||
| 832 | && (mode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 833 | || (mode == QPainter::CompositionMode_SourceOver
| 0 | ||||||||||||||||||||||||||||||
| 834 | && s->penData.solid.color.isOpaque()));
| 0 | ||||||||||||||||||||||||||||||
| 835 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 836 | - | |||||||||||||||||||||||||||||||
| 837 | s->dirty = 0; | - | ||||||||||||||||||||||||||||||
| 838 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||||||||
| 841 | /*! | - | ||||||||||||||||||||||||||||||
| 842 | \internal | - | ||||||||||||||||||||||||||||||
| 843 | */ | - | ||||||||||||||||||||||||||||||
| 844 | void QRasterPaintEngine::opacityChanged() | - | ||||||||||||||||||||||||||||||
| 845 | { | - | ||||||||||||||||||||||||||||||
| 846 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||||||||
| 848 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 849 | qDebug() << "QRasterPaintEngine::opacityChanged()" << s->opacity; | - | ||||||||||||||||||||||||||||||
| 850 | #endif | - | ||||||||||||||||||||||||||||||
| 851 | - | |||||||||||||||||||||||||||||||
| 852 | s->fillFlags |= DirtyOpacity; | - | ||||||||||||||||||||||||||||||
| 853 | s->strokeFlags |= DirtyOpacity; | - | ||||||||||||||||||||||||||||||
| 854 | s->pixmapFlags |= DirtyOpacity; | - | ||||||||||||||||||||||||||||||
| 855 | s->dirty |= DirtyOpacity; | - | ||||||||||||||||||||||||||||||
| 856 | s->intOpacity = (int) (s->opacity * 256); | - | ||||||||||||||||||||||||||||||
| 857 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||||||||
| 859 | /*! | - | ||||||||||||||||||||||||||||||
| 860 | \internal | - | ||||||||||||||||||||||||||||||
| 861 | */ | - | ||||||||||||||||||||||||||||||
| 862 | void QRasterPaintEngine::compositionModeChanged() | - | ||||||||||||||||||||||||||||||
| 863 | { | - | ||||||||||||||||||||||||||||||
| 864 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 865 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 866 | - | |||||||||||||||||||||||||||||||
| 867 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 868 | qDebug() << "QRasterPaintEngine::compositionModeChanged()" << s->composition_mode; | - | ||||||||||||||||||||||||||||||
| 869 | #endif | - | ||||||||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||||||||
| 871 | s->fillFlags |= DirtyCompositionMode; | - | ||||||||||||||||||||||||||||||
| 872 | s->dirty |= DirtyCompositionMode; | - | ||||||||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||||||||
| 874 | s->strokeFlags |= DirtyCompositionMode; | - | ||||||||||||||||||||||||||||||
| 875 | d->rasterBuffer->compositionMode = s->composition_mode; | - | ||||||||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||||||||
| 877 | d->recalculateFastImages(); | - | ||||||||||||||||||||||||||||||
| 878 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 879 | - | |||||||||||||||||||||||||||||||
| 880 | /*! | - | ||||||||||||||||||||||||||||||
| 881 | \internal | - | ||||||||||||||||||||||||||||||
| 882 | */ | - | ||||||||||||||||||||||||||||||
| 883 | void QRasterPaintEngine::renderHintsChanged() | - | ||||||||||||||||||||||||||||||
| 884 | { | - | ||||||||||||||||||||||||||||||
| 885 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||||||||
| 887 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 888 | qDebug() << "QRasterPaintEngine::renderHintsChanged()" << hex << s->renderHints; | - | ||||||||||||||||||||||||||||||
| 889 | #endif | - | ||||||||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||||||||
| 891 | bool was_aa = s->flags.antialiased; | - | ||||||||||||||||||||||||||||||
| 892 | bool was_bilinear = s->flags.bilinear; | - | ||||||||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||||||||
| 894 | s->flags.antialiased = bool(s->renderHints & (QPainter::Antialiasing | QPainter::HighQualityAntialiasing)); | - | ||||||||||||||||||||||||||||||
| 895 | s->flags.bilinear = bool(s->renderHints & QPainter::SmoothPixmapTransform); | - | ||||||||||||||||||||||||||||||
| 896 | s->flags.legacy_rounding = !bool(s->renderHints & QPainter::Antialiasing) && bool(s->renderHints & QPainter::Qt4CompatiblePainting);
| 0 | ||||||||||||||||||||||||||||||
| 897 | - | |||||||||||||||||||||||||||||||
| 898 | if (was_aa != s->flags.antialiased)
| 0 | ||||||||||||||||||||||||||||||
| 899 | s->strokeFlags |= DirtyHints; never executed: s->strokeFlags |= DirtyHints; | 0 | ||||||||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||||||||
| 901 | if (was_bilinear != s->flags.bilinear) {
| 0 | ||||||||||||||||||||||||||||||
| 902 | s->strokeFlags |= DirtyPen; | - | ||||||||||||||||||||||||||||||
| 903 | s->fillFlags |= DirtyBrush; | - | ||||||||||||||||||||||||||||||
| 904 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 905 | - | |||||||||||||||||||||||||||||||
| 906 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 907 | d->recalculateFastImages(); | - | ||||||||||||||||||||||||||||||
| 908 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||||||||
| 910 | /*! | - | ||||||||||||||||||||||||||||||
| 911 | \internal | - | ||||||||||||||||||||||||||||||
| 912 | */ | - | ||||||||||||||||||||||||||||||
| 913 | void QRasterPaintEngine::transformChanged() | - | ||||||||||||||||||||||||||||||
| 914 | { | - | ||||||||||||||||||||||||||||||
| 915 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||||||||
| 917 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 918 | qDebug() << "QRasterPaintEngine::transformChanged()" << s->matrix; | - | ||||||||||||||||||||||||||||||
| 919 | #endif | - | ||||||||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||||||||
| 921 | s->fillFlags |= DirtyTransform; | - | ||||||||||||||||||||||||||||||
| 922 | s->strokeFlags |= DirtyTransform; | - | ||||||||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||||||||
| 924 | s->dirty |= DirtyTransform; | - | ||||||||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||||||||
| 926 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 927 | d->recalculateFastImages(); | - | ||||||||||||||||||||||||||||||
| 928 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 929 | - | |||||||||||||||||||||||||||||||
| 930 | /*! | - | ||||||||||||||||||||||||||||||
| 931 | \internal | - | ||||||||||||||||||||||||||||||
| 932 | */ | - | ||||||||||||||||||||||||||||||
| 933 | void QRasterPaintEngine::clipEnabledChanged() | - | ||||||||||||||||||||||||||||||
| 934 | { | - | ||||||||||||||||||||||||||||||
| 935 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||||||||
| 937 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 938 | qDebug() << "QRasterPaintEngine::clipEnabledChanged()" << s->clipEnabled; | - | ||||||||||||||||||||||||||||||
| 939 | #endif | - | ||||||||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||||||||
| 941 | if (s->clip) {
| 0 | ||||||||||||||||||||||||||||||
| 942 | s->clip->enabled = s->clipEnabled; | - | ||||||||||||||||||||||||||||||
| 943 | s->fillFlags |= DirtyClipEnabled; | - | ||||||||||||||||||||||||||||||
| 944 | s->strokeFlags |= DirtyClipEnabled; | - | ||||||||||||||||||||||||||||||
| 945 | s->pixmapFlags |= DirtyClipEnabled; | - | ||||||||||||||||||||||||||||||
| 946 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 947 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||||||||
| 949 | void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, | - | ||||||||||||||||||||||||||||||
| 950 | const QImage &img, | - | ||||||||||||||||||||||||||||||
| 951 | SrcOverBlendFunc func, | - | ||||||||||||||||||||||||||||||
| 952 | const QRect &clip, | - | ||||||||||||||||||||||||||||||
| 953 | int alpha, | - | ||||||||||||||||||||||||||||||
| 954 | const QRect &sr) | - | ||||||||||||||||||||||||||||||
| 955 | { | - | ||||||||||||||||||||||||||||||
| 956 | if (alpha == 0 || !clip.isValid())
| 0 | ||||||||||||||||||||||||||||||
| 957 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 958 | - | |||||||||||||||||||||||||||||||
| 959 | Q_ASSERT(img.depth() >= 8); | - | ||||||||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||||||||
| 961 | int srcBPL = img.bytesPerLine(); | - | ||||||||||||||||||||||||||||||
| 962 | const uchar *srcBits = img.bits(); | - | ||||||||||||||||||||||||||||||
| 963 | int srcSize = img.depth() >> 3; // This is the part that is incompatible with lower than 8-bit.. | - | ||||||||||||||||||||||||||||||
| 964 | int iw = img.width(); | - | ||||||||||||||||||||||||||||||
| 965 | int ih = img.height(); | - | ||||||||||||||||||||||||||||||
| 966 | - | |||||||||||||||||||||||||||||||
| 967 | if (!sr.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||
| 968 | iw = sr.width(); | - | ||||||||||||||||||||||||||||||
| 969 | ih = sr.height(); | - | ||||||||||||||||||||||||||||||
| 970 | // Adjust the image according to the source offset... | - | ||||||||||||||||||||||||||||||
| 971 | srcBits += ((sr.y() * srcBPL) + sr.x() * srcSize); | - | ||||||||||||||||||||||||||||||
| 972 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||||||||
| 974 | // adapt the x parameters | - | ||||||||||||||||||||||||||||||
| 975 | int x = qRound(pt.x()); | - | ||||||||||||||||||||||||||||||
| 976 | int cx1 = clip.x(); | - | ||||||||||||||||||||||||||||||
| 977 | int cx2 = clip.x() + clip.width(); | - | ||||||||||||||||||||||||||||||
| 978 | if (x < cx1) {
| 0 | ||||||||||||||||||||||||||||||
| 979 | int d = cx1 - x; | - | ||||||||||||||||||||||||||||||
| 980 | srcBits += srcSize * d; | - | ||||||||||||||||||||||||||||||
| 981 | iw -= d; | - | ||||||||||||||||||||||||||||||
| 982 | x = cx1; | - | ||||||||||||||||||||||||||||||
| 983 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 984 | if (x + iw > cx2) {
| 0 | ||||||||||||||||||||||||||||||
| 985 | int d = x + iw - cx2; | - | ||||||||||||||||||||||||||||||
| 986 | iw -= d; | - | ||||||||||||||||||||||||||||||
| 987 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 988 | if (iw <= 0)
| 0 | ||||||||||||||||||||||||||||||
| 989 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||||||||
| 991 | // adapt the y paremeters... | - | ||||||||||||||||||||||||||||||
| 992 | int cy1 = clip.y(); | - | ||||||||||||||||||||||||||||||
| 993 | int cy2 = clip.y() + clip.height(); | - | ||||||||||||||||||||||||||||||
| 994 | int y = qRound(pt.y()); | - | ||||||||||||||||||||||||||||||
| 995 | if (y < cy1) {
| 0 | ||||||||||||||||||||||||||||||
| 996 | int d = cy1 - y; | - | ||||||||||||||||||||||||||||||
| 997 | srcBits += srcBPL * d; | - | ||||||||||||||||||||||||||||||
| 998 | ih -= d; | - | ||||||||||||||||||||||||||||||
| 999 | y = cy1; | - | ||||||||||||||||||||||||||||||
| 1000 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1001 | if (y + ih > cy2) {
| 0 | ||||||||||||||||||||||||||||||
| 1002 | int d = y + ih - cy2; | - | ||||||||||||||||||||||||||||||
| 1003 | ih -= d; | - | ||||||||||||||||||||||||||||||
| 1004 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1005 | if (ih <= 0)
| 0 | ||||||||||||||||||||||||||||||
| 1006 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||||||||
| 1008 | // call the blend function... | - | ||||||||||||||||||||||||||||||
| 1009 | int dstSize = rasterBuffer->bytesPerPixel(); | - | ||||||||||||||||||||||||||||||
| 1010 | int dstBPL = rasterBuffer->bytesPerLine(); | - | ||||||||||||||||||||||||||||||
| 1011 | func(rasterBuffer->buffer() + x * dstSize + y * dstBPL, dstBPL, | - | ||||||||||||||||||||||||||||||
| 1012 | srcBits, srcBPL, | - | ||||||||||||||||||||||||||||||
| 1013 | iw, ih, | - | ||||||||||||||||||||||||||||||
| 1014 | alpha); | - | ||||||||||||||||||||||||||||||
| 1015 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||||||||
| 1018 | void QRasterPaintEnginePrivate::systemStateChanged() | - | ||||||||||||||||||||||||||||||
| 1019 | { | - | ||||||||||||||||||||||||||||||
| 1020 | deviceRectUnclipped = QRect(0, 0, | - | ||||||||||||||||||||||||||||||
| 1021 | qMin(QT_RASTER_COORD_LIMIT, device->width()), | - | ||||||||||||||||||||||||||||||
| 1022 | qMin(QT_RASTER_COORD_LIMIT, device->height())); | - | ||||||||||||||||||||||||||||||
| 1023 | - | |||||||||||||||||||||||||||||||
| 1024 | if (!systemClip.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||
| 1025 | QRegion clippedDeviceRgn = systemClip & deviceRectUnclipped; | - | ||||||||||||||||||||||||||||||
| 1026 | deviceRect = clippedDeviceRgn.boundingRect(); | - | ||||||||||||||||||||||||||||||
| 1027 | baseClip->setClipRegion(clippedDeviceRgn); | - | ||||||||||||||||||||||||||||||
| 1028 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1029 | deviceRect = deviceRectUnclipped; | - | ||||||||||||||||||||||||||||||
| 1030 | baseClip->setClipRect(deviceRect); | - | ||||||||||||||||||||||||||||||
| 1031 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1032 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1033 | qDebug() << "systemStateChanged" << this << "deviceRect" << deviceRect << deviceRectUnclipped << systemClip; | - | ||||||||||||||||||||||||||||||
| 1034 | #endif | - | ||||||||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||||||||
| 1036 | exDeviceRect = deviceRect; | - | ||||||||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||||||||
| 1038 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1039 | if (q->state()) {
| 0 | ||||||||||||||||||||||||||||||
| 1040 | q->state()->strokeFlags |= QPaintEngine::DirtyClipRegion; | - | ||||||||||||||||||||||||||||||
| 1041 | q->state()->fillFlags |= QPaintEngine::DirtyClipRegion; | - | ||||||||||||||||||||||||||||||
| 1042 | q->state()->pixmapFlags |= QPaintEngine::DirtyClipRegion; | - | ||||||||||||||||||||||||||||||
| 1043 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1044 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||||||||
| 1046 | void QRasterPaintEnginePrivate::updateMatrixData(QSpanData *spanData, const QBrush &b, const QTransform &m) | - | ||||||||||||||||||||||||||||||
| 1047 | { | - | ||||||||||||||||||||||||||||||
| 1048 | if (b.d->style == Qt::NoBrush || b.d->style == Qt::SolidPattern)
| 0 | ||||||||||||||||||||||||||||||
| 1049 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||||||||
| 1051 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1052 | bool bilinear = q->state()->flags.bilinear; | - | ||||||||||||||||||||||||||||||
| 1053 | - | |||||||||||||||||||||||||||||||
| 1054 | if (b.d->transform.type() > QTransform::TxNone) { // FALCON: optimize
| 0 | ||||||||||||||||||||||||||||||
| 1055 | spanData->setupMatrix(b.transform() * m, bilinear); | - | ||||||||||||||||||||||||||||||
| 1056 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1057 | if (m.type() <= QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 1058 | // specialize setupMatrix for translation matrices | - | ||||||||||||||||||||||||||||||
| 1059 | // to avoid needless matrix inversion | - | ||||||||||||||||||||||||||||||
| 1060 | spanData->m11 = 1; | - | ||||||||||||||||||||||||||||||
| 1061 | spanData->m12 = 0; | - | ||||||||||||||||||||||||||||||
| 1062 | spanData->m13 = 0; | - | ||||||||||||||||||||||||||||||
| 1063 | spanData->m21 = 0; | - | ||||||||||||||||||||||||||||||
| 1064 | spanData->m22 = 1; | - | ||||||||||||||||||||||||||||||
| 1065 | spanData->m23 = 0; | - | ||||||||||||||||||||||||||||||
| 1066 | spanData->m33 = 1; | - | ||||||||||||||||||||||||||||||
| 1067 | spanData->dx = -m.dx(); | - | ||||||||||||||||||||||||||||||
| 1068 | spanData->dy = -m.dy(); | - | ||||||||||||||||||||||||||||||
| 1069 | spanData->txop = m.type(); | - | ||||||||||||||||||||||||||||||
| 1070 | spanData->bilinear = bilinear; | - | ||||||||||||||||||||||||||||||
| 1071 | spanData->fast_matrix = qAbs(m.dx()) < 1e4 && qAbs(m.dy()) < 1e4;
| 0 | ||||||||||||||||||||||||||||||
| 1072 | spanData->adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 1073 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1074 | spanData->setupMatrix(m, bilinear); | - | ||||||||||||||||||||||||||||||
| 1075 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1076 | } | - | ||||||||||||||||||||||||||||||
| 1077 | } | - | ||||||||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||||||||
| 1079 | // #define QT_CLIPPING_RATIOS | - | ||||||||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||||||||
| 1081 | #ifdef QT_CLIPPING_RATIOS | - | ||||||||||||||||||||||||||||||
| 1082 | int rectClips; | - | ||||||||||||||||||||||||||||||
| 1083 | int regionClips; | - | ||||||||||||||||||||||||||||||
| 1084 | int totalClips; | - | ||||||||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||||||||
| 1086 | static void checkClipRatios(QRasterPaintEnginePrivate *d) | - | ||||||||||||||||||||||||||||||
| 1087 | { | - | ||||||||||||||||||||||||||||||
| 1088 | if (d->clip()->hasRectClip) | - | ||||||||||||||||||||||||||||||
| 1089 | rectClips++; | - | ||||||||||||||||||||||||||||||
| 1090 | if (d->clip()->hasRegionClip) | - | ||||||||||||||||||||||||||||||
| 1091 | regionClips++; | - | ||||||||||||||||||||||||||||||
| 1092 | totalClips++; | - | ||||||||||||||||||||||||||||||
| 1093 | - | |||||||||||||||||||||||||||||||
| 1094 | if ((totalClips % 5000) == 0) { | - | ||||||||||||||||||||||||||||||
| 1095 | printf("Clipping ratio: rectangular=%f%%, region=%f%%, complex=%f%%\n", | - | ||||||||||||||||||||||||||||||
| 1096 | rectClips * 100.0 / (qreal) totalClips, | - | ||||||||||||||||||||||||||||||
| 1097 | regionClips * 100.0 / (qreal) totalClips, | - | ||||||||||||||||||||||||||||||
| 1098 | (totalClips - rectClips - regionClips) * 100.0 / (qreal) totalClips); | - | ||||||||||||||||||||||||||||||
| 1099 | totalClips = 0; | - | ||||||||||||||||||||||||||||||
| 1100 | rectClips = 0; | - | ||||||||||||||||||||||||||||||
| 1101 | regionClips = 0; | - | ||||||||||||||||||||||||||||||
| 1102 | } | - | ||||||||||||||||||||||||||||||
| 1103 | - | |||||||||||||||||||||||||||||||
| 1104 | } | - | ||||||||||||||||||||||||||||||
| 1105 | #endif | - | ||||||||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||||||||
| 1107 | static void qrasterpaintengine_state_setNoClip(QRasterPaintEngineState *s) | - | ||||||||||||||||||||||||||||||
| 1108 | { | - | ||||||||||||||||||||||||||||||
| 1109 | if (s->flags.has_clip_ownership)
| 0 | ||||||||||||||||||||||||||||||
| 1110 | delete s->clip; never executed: delete s->clip; | 0 | ||||||||||||||||||||||||||||||
| 1111 | s->clip = 0; | - | ||||||||||||||||||||||||||||||
| 1112 | s->flags.has_clip_ownership = false; | - | ||||||||||||||||||||||||||||||
| 1113 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||||||||
| 1115 | static void qrasterpaintengine_dirty_clip(QRasterPaintEnginePrivate *d, QRasterPaintEngineState *s) | - | ||||||||||||||||||||||||||||||
| 1116 | { | - | ||||||||||||||||||||||||||||||
| 1117 | s->fillFlags |= QPaintEngine::DirtyClipPath; | - | ||||||||||||||||||||||||||||||
| 1118 | s->strokeFlags |= QPaintEngine::DirtyClipPath; | - | ||||||||||||||||||||||||||||||
| 1119 | s->pixmapFlags |= QPaintEngine::DirtyClipPath; | - | ||||||||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||||||||
| 1121 | d->solid_color_filler.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 1122 | d->solid_color_filler.adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||||||||
| 1124 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1125 | dumpClip(d->rasterBuffer->width(), d->rasterBuffer->height(), &*d->clip()); | - | ||||||||||||||||||||||||||||||
| 1126 | #endif | - | ||||||||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||||||||
| 1128 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||||||||
| 1130 | - | |||||||||||||||||||||||||||||||
| 1131 | /*! | - | ||||||||||||||||||||||||||||||
| 1132 | \internal | - | ||||||||||||||||||||||||||||||
| 1133 | */ | - | ||||||||||||||||||||||||||||||
| 1134 | void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) | - | ||||||||||||||||||||||||||||||
| 1135 | { | - | ||||||||||||||||||||||||||||||
| 1136 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1137 | qDebug() << "QRasterPaintEngine::clip(): " << path << op; | - | ||||||||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||||||||
| 1139 | if (path.elements()) { | - | ||||||||||||||||||||||||||||||
| 1140 | for (int i=0; i<path.elementCount(); ++i) { | - | ||||||||||||||||||||||||||||||
| 1141 | qDebug() << " - " << path.elements()[i] | - | ||||||||||||||||||||||||||||||
| 1142 | << '(' << path.points()[i*2] << ", " << path.points()[i*2+1] << ')'; | - | ||||||||||||||||||||||||||||||
| 1143 | } | - | ||||||||||||||||||||||||||||||
| 1144 | } else { | - | ||||||||||||||||||||||||||||||
| 1145 | for (int i=0; i<path.elementCount(); ++i) { | - | ||||||||||||||||||||||||||||||
| 1146 | qDebug() << " ---- " | - | ||||||||||||||||||||||||||||||
| 1147 | << '(' << path.points()[i*2] << ", " << path.points()[i*2+1] << ')'; | - | ||||||||||||||||||||||||||||||
| 1148 | } | - | ||||||||||||||||||||||||||||||
| 1149 | } | - | ||||||||||||||||||||||||||||||
| 1150 | #endif | - | ||||||||||||||||||||||||||||||
| 1151 | - | |||||||||||||||||||||||||||||||
| 1152 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1153 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1154 | - | |||||||||||||||||||||||||||||||
| 1155 | // There are some cases that are not supported by clip(QRect) | - | ||||||||||||||||||||||||||||||
| 1156 | if (op != Qt::IntersectClip || !s->clip || s->clip->hasRectClip || s->clip->hasRegionClip) {
| 0 | ||||||||||||||||||||||||||||||
| 1157 | if (s->matrix.type() <= QTransform::TxScale
| 0 | ||||||||||||||||||||||||||||||
| 1158 | && path.isRect()) {
| 0 | ||||||||||||||||||||||||||||||
| 1159 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1160 | qDebug() << " --- optimizing vector clip to rect clip..."; | - | ||||||||||||||||||||||||||||||
| 1161 | #endif | - | ||||||||||||||||||||||||||||||
| 1162 | const qreal *points = path.points(); | - | ||||||||||||||||||||||||||||||
| 1163 | QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]); | - | ||||||||||||||||||||||||||||||
| 1164 | if (setClipRectInDeviceCoords(s->matrix.mapRect(r).toRect(), op))
| 0 | ||||||||||||||||||||||||||||||
| 1165 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1166 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1167 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||||||||
| 1169 | if (op == Qt::NoClip) {
| 0 | ||||||||||||||||||||||||||||||
| 1170 | qrasterpaintengine_state_setNoClip(s); | - | ||||||||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||||||||
| 1172 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1173 | QClipData *base = d->baseClip.data(); | - | ||||||||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||||||||
| 1175 | // Intersect with current clip when available... | - | ||||||||||||||||||||||||||||||
| 1176 | if (op == Qt::IntersectClip && s->clip)
| 0 | ||||||||||||||||||||||||||||||
| 1177 | base = s->clip; never executed: base = s->clip; | 0 | ||||||||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||||||||
| 1179 | // We always intersect, except when there is nothing to | - | ||||||||||||||||||||||||||||||
| 1180 | // intersect with, in which case we simplify the operation to | - | ||||||||||||||||||||||||||||||
| 1181 | // a replace... | - | ||||||||||||||||||||||||||||||
| 1182 | Qt::ClipOperation isectOp = Qt::IntersectClip; | - | ||||||||||||||||||||||||||||||
| 1183 | if (base == 0)
| 0 | ||||||||||||||||||||||||||||||
| 1184 | isectOp = Qt::ReplaceClip; never executed: isectOp = Qt::ReplaceClip; | 0 | ||||||||||||||||||||||||||||||
| 1185 | - | |||||||||||||||||||||||||||||||
| 1186 | QClipData *newClip = new QClipData(d->rasterBuffer->height()); | - | ||||||||||||||||||||||||||||||
| 1187 | newClip->initialize(); | - | ||||||||||||||||||||||||||||||
| 1188 | ClipData clipData = { base, newClip, isectOp }; | - | ||||||||||||||||||||||||||||||
| 1189 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 1190 | d->rasterize(d->outlineMapper->convertPath(path), qt_span_clip, &clipData, 0); | - | ||||||||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||||||||
| 1192 | newClip->fixup(); | - | ||||||||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||||||||
| 1194 | if (s->flags.has_clip_ownership)
| 0 | ||||||||||||||||||||||||||||||
| 1195 | delete s->clip; never executed: delete s->clip; | 0 | ||||||||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||||||||
| 1197 | s->clip = newClip; | - | ||||||||||||||||||||||||||||||
| 1198 | s->flags.has_clip_ownership = true; | - | ||||||||||||||||||||||||||||||
| 1199 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1200 | qrasterpaintengine_dirty_clip(d, s); | - | ||||||||||||||||||||||||||||||
| 1201 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||||||||
| 1205 | /*! | - | ||||||||||||||||||||||||||||||
| 1206 | \internal | - | ||||||||||||||||||||||||||||||
| 1207 | */ | - | ||||||||||||||||||||||||||||||
| 1208 | void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) | - | ||||||||||||||||||||||||||||||
| 1209 | { | - | ||||||||||||||||||||||||||||||
| 1210 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1211 | qDebug() << "QRasterPaintEngine::clip(): " << rect << op; | - | ||||||||||||||||||||||||||||||
| 1212 | #endif | - | ||||||||||||||||||||||||||||||
| 1213 | - | |||||||||||||||||||||||||||||||
| 1214 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||||||||
| 1216 | if (op == Qt::NoClip) {
| 0 | ||||||||||||||||||||||||||||||
| 1217 | qrasterpaintengine_state_setNoClip(s); | - | ||||||||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||||||||
| 1219 | } else if (s->matrix.type() > QTransform::TxScale) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1220 | QPaintEngineEx::clip(rect, op); | - | ||||||||||||||||||||||||||||||
| 1221 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1222 | - | |||||||||||||||||||||||||||||||
| 1223 | } else if (!setClipRectInDeviceCoords(s->matrix.mapRect(rect), op)) {
| 0 | ||||||||||||||||||||||||||||||
| 1224 | QPaintEngineEx::clip(rect, op); | - | ||||||||||||||||||||||||||||||
| 1225 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1226 | } | - | ||||||||||||||||||||||||||||||
| 1227 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||||||||
| 1229 | - | |||||||||||||||||||||||||||||||
| 1230 | bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op) | - | ||||||||||||||||||||||||||||||
| 1231 | { | - | ||||||||||||||||||||||||||||||
| 1232 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1233 | QRect clipRect = r & d->deviceRect; | - | ||||||||||||||||||||||||||||||
| 1234 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1235 | - | |||||||||||||||||||||||||||||||
| 1236 | if (op == Qt::ReplaceClip || s->clip == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 1237 | - | |||||||||||||||||||||||||||||||
| 1238 | // No current clip, hence we intersect with sysclip and be | - | ||||||||||||||||||||||||||||||
| 1239 | // done with it... | - | ||||||||||||||||||||||||||||||
| 1240 | QRegion clipRegion = systemClip(); | - | ||||||||||||||||||||||||||||||
| 1241 | QClipData *clip = new QClipData(d->rasterBuffer->height()); | - | ||||||||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||||||||
| 1243 | if (clipRegion.isEmpty())
| 0 | ||||||||||||||||||||||||||||||
| 1244 | clip->setClipRect(clipRect); never executed: clip->setClipRect(clipRect); | 0 | ||||||||||||||||||||||||||||||
| 1245 | else | - | ||||||||||||||||||||||||||||||
| 1246 | clip->setClipRegion(clipRegion & clipRect); never executed: clip->setClipRegion(clipRegion & clipRect); | 0 | ||||||||||||||||||||||||||||||
| 1247 | - | |||||||||||||||||||||||||||||||
| 1248 | if (s->flags.has_clip_ownership)
| 0 | ||||||||||||||||||||||||||||||
| 1249 | delete s->clip; never executed: delete s->clip; | 0 | ||||||||||||||||||||||||||||||
| 1250 | - | |||||||||||||||||||||||||||||||
| 1251 | s->clip = clip; | - | ||||||||||||||||||||||||||||||
| 1252 | s->clip->enabled = true; | - | ||||||||||||||||||||||||||||||
| 1253 | s->flags.has_clip_ownership = true; | - | ||||||||||||||||||||||||||||||
| 1254 | - | |||||||||||||||||||||||||||||||
| 1255 | } else if (op == Qt::IntersectClip){ // intersect clip with current clip never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1256 | QClipData *base = s->clip; | - | ||||||||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||||||||
| 1258 | Q_ASSERT(base); | - | ||||||||||||||||||||||||||||||
| 1259 | if (base->hasRectClip || base->hasRegionClip) {
| 0 | ||||||||||||||||||||||||||||||
| 1260 | if (!s->flags.has_clip_ownership) {
| 0 | ||||||||||||||||||||||||||||||
| 1261 | s->clip = new QClipData(d->rasterBuffer->height()); | - | ||||||||||||||||||||||||||||||
| 1262 | s->flags.has_clip_ownership = true; | - | ||||||||||||||||||||||||||||||
| 1263 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1264 | if (base->hasRectClip)
| 0 | ||||||||||||||||||||||||||||||
| 1265 | s->clip->setClipRect(base->clipRect & clipRect); never executed: s->clip->setClipRect(base->clipRect & clipRect); | 0 | ||||||||||||||||||||||||||||||
| 1266 | else | - | ||||||||||||||||||||||||||||||
| 1267 | s->clip->setClipRegion(base->clipRegion & clipRect); never executed: s->clip->setClipRegion(base->clipRegion & clipRect); | 0 | ||||||||||||||||||||||||||||||
| 1268 | s->clip->enabled = true; | - | ||||||||||||||||||||||||||||||
| 1269 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1270 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1271 | } | - | ||||||||||||||||||||||||||||||
| 1272 | } else { | - | ||||||||||||||||||||||||||||||
| 1273 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1274 | } | - | ||||||||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||||||||
| 1276 | qrasterpaintengine_dirty_clip(d, s); | - | ||||||||||||||||||||||||||||||
| 1277 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 1278 | } | - | ||||||||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||||||||
| 1281 | /*! | - | ||||||||||||||||||||||||||||||
| 1282 | \internal | - | ||||||||||||||||||||||||||||||
| 1283 | */ | - | ||||||||||||||||||||||||||||||
| 1284 | void QRasterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) | - | ||||||||||||||||||||||||||||||
| 1285 | { | - | ||||||||||||||||||||||||||||||
| 1286 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1287 | qDebug() << "QRasterPaintEngine::clip(): " << region << op; | - | ||||||||||||||||||||||||||||||
| 1288 | #endif | - | ||||||||||||||||||||||||||||||
| 1289 | - | |||||||||||||||||||||||||||||||
| 1290 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||||||||
| 1292 | if (region.rectCount() == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 1293 | clip(region.boundingRect(), op); | - | ||||||||||||||||||||||||||||||
| 1294 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1295 | } | - | ||||||||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||||||||
| 1297 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1298 | const QClipData *clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 1299 | const QClipData *baseClip = d->baseClip.data(); | - | ||||||||||||||||||||||||||||||
| 1300 | - | |||||||||||||||||||||||||||||||
| 1301 | if (op == Qt::NoClip) {
| 0 | ||||||||||||||||||||||||||||||
| 1302 | qrasterpaintengine_state_setNoClip(s); | - | ||||||||||||||||||||||||||||||
| 1303 | } else if (s->matrix.type() > QTransform::TxScale never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1304 | || (op == Qt::IntersectClip && !clip->hasRectClip && !clip->hasRegionClip)
| 0 | ||||||||||||||||||||||||||||||
| 1305 | || (op == Qt::ReplaceClip && !baseClip->hasRectClip && !baseClip->hasRegionClip)) {
| 0 | ||||||||||||||||||||||||||||||
| 1306 | QPaintEngineEx::clip(region, op); | - | ||||||||||||||||||||||||||||||
| 1307 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1308 | const QClipData *curClip; | - | ||||||||||||||||||||||||||||||
| 1309 | QClipData *newClip; | - | ||||||||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||||||||
| 1311 | if (op == Qt::IntersectClip)
| 0 | ||||||||||||||||||||||||||||||
| 1312 | curClip = clip; never executed: curClip = clip; | 0 | ||||||||||||||||||||||||||||||
| 1313 | else | - | ||||||||||||||||||||||||||||||
| 1314 | curClip = baseClip; never executed: curClip = baseClip; | 0 | ||||||||||||||||||||||||||||||
| 1315 | - | |||||||||||||||||||||||||||||||
| 1316 | if (s->flags.has_clip_ownership) {
| 0 | ||||||||||||||||||||||||||||||
| 1317 | newClip = s->clip; | - | ||||||||||||||||||||||||||||||
| 1318 | Q_ASSERT(newClip); | - | ||||||||||||||||||||||||||||||
| 1319 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1320 | newClip = new QClipData(d->rasterBuffer->height()); | - | ||||||||||||||||||||||||||||||
| 1321 | s->clip = newClip; | - | ||||||||||||||||||||||||||||||
| 1322 | s->flags.has_clip_ownership = true; | - | ||||||||||||||||||||||||||||||
| 1323 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1324 | - | |||||||||||||||||||||||||||||||
| 1325 | QRegion r = s->matrix.map(region); | - | ||||||||||||||||||||||||||||||
| 1326 | if (curClip->hasRectClip)
| 0 | ||||||||||||||||||||||||||||||
| 1327 | newClip->setClipRegion(r & curClip->clipRect); never executed: newClip->setClipRegion(r & curClip->clipRect); | 0 | ||||||||||||||||||||||||||||||
| 1328 | else if (curClip->hasRegionClip)
| 0 | ||||||||||||||||||||||||||||||
| 1329 | newClip->setClipRegion(r & curClip->clipRegion); never executed: newClip->setClipRegion(r & curClip->clipRegion); | 0 | ||||||||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||||||||
| 1331 | qrasterpaintengine_dirty_clip(d, s); | - | ||||||||||||||||||||||||||||||
| 1332 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1333 | } | - | ||||||||||||||||||||||||||||||
| 1334 | - | |||||||||||||||||||||||||||||||
| 1335 | /*! | - | ||||||||||||||||||||||||||||||
| 1336 | \fn const QClipData *QRasterPaintEngine::clipData() const | - | ||||||||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||||||||
| 1338 | \internal | - | ||||||||||||||||||||||||||||||
| 1339 | */ | - | ||||||||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||||||||
| 1342 | /*! | - | ||||||||||||||||||||||||||||||
| 1343 | \internal | - | ||||||||||||||||||||||||||||||
| 1344 | */ | - | ||||||||||||||||||||||||||||||
| 1345 | void QRasterPaintEngine::fillPath(const QPainterPath &path, QSpanData *fillData) | - | ||||||||||||||||||||||||||||||
| 1346 | { | - | ||||||||||||||||||||||||||||||
| 1347 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1348 | qDebug() << " --- fillPath, bounds=" << path.boundingRect(); | - | ||||||||||||||||||||||||||||||
| 1349 | #endif | - | ||||||||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||||||||
| 1351 | if (!fillData->blend)
| 0 | ||||||||||||||||||||||||||||||
| 1352 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1353 | - | |||||||||||||||||||||||||||||||
| 1354 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||||||||
| 1356 | const QRectF controlPointRect = path.controlPointRect(); | - | ||||||||||||||||||||||||||||||
| 1357 | - | |||||||||||||||||||||||||||||||
| 1358 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1359 | const QRect deviceRect = s->matrix.mapRect(controlPointRect).toRect(); | - | ||||||||||||||||||||||||||||||
| 1360 | ProcessSpans blend = d->getBrushFunc(deviceRect, fillData); | - | ||||||||||||||||||||||||||||||
| 1361 | const bool do_clip = (deviceRect.left() < -QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||||||||||||||||||||
| 1362 | || deviceRect.right() > QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||||||||||||||||||||
| 1363 | || deviceRect.top() < -QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||||||||||||||||||||
| 1364 | || deviceRect.bottom() > QT_RASTER_COORD_LIMIT);
| 0 | ||||||||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||||||||
| 1366 | if (!s->flags.antialiased && !do_clip) {
| 0 | ||||||||||||||||||||||||||||||
| 1367 | d->initializeRasterizer(fillData); | - | ||||||||||||||||||||||||||||||
| 1368 | d->rasterizer->rasterize(path * s->matrix, path.fillRule()); | - | ||||||||||||||||||||||||||||||
| 1369 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1370 | } | - | ||||||||||||||||||||||||||||||
| 1371 | - | |||||||||||||||||||||||||||||||
| 1372 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 1373 | d->rasterize(d->outlineMapper->convertPath(path), blend, fillData, d->rasterBuffer.data()); | - | ||||||||||||||||||||||||||||||
| 1374 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1375 | - | |||||||||||||||||||||||||||||||
| 1376 | static void fillRect_normalized(const QRect &r, QSpanData *data, | - | ||||||||||||||||||||||||||||||
| 1377 | QRasterPaintEnginePrivate *pe) | - | ||||||||||||||||||||||||||||||
| 1378 | { | - | ||||||||||||||||||||||||||||||
| 1379 | int x1, x2, y1, y2; | - | ||||||||||||||||||||||||||||||
| 1380 | - | |||||||||||||||||||||||||||||||
| 1381 | bool rectClipped = true; | - | ||||||||||||||||||||||||||||||
| 1382 | - | |||||||||||||||||||||||||||||||
| 1383 | if (data->clip) {
| 0 | ||||||||||||||||||||||||||||||
| 1384 | x1 = qMax(r.x(), data->clip->xmin); | - | ||||||||||||||||||||||||||||||
| 1385 | x2 = qMin(r.x() + r.width(), data->clip->xmax); | - | ||||||||||||||||||||||||||||||
| 1386 | y1 = qMax(r.y(), data->clip->ymin); | - | ||||||||||||||||||||||||||||||
| 1387 | y2 = qMin(r.y() + r.height(), data->clip->ymax); | - | ||||||||||||||||||||||||||||||
| 1388 | rectClipped = data->clip->hasRectClip; | - | ||||||||||||||||||||||||||||||
| 1389 | - | |||||||||||||||||||||||||||||||
| 1390 | } else if (pe) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1391 | x1 = qMax(r.x(), pe->deviceRect.x()); | - | ||||||||||||||||||||||||||||||
| 1392 | x2 = qMin(r.x() + r.width(), pe->deviceRect.x() + pe->deviceRect.width()); | - | ||||||||||||||||||||||||||||||
| 1393 | y1 = qMax(r.y(), pe->deviceRect.y()); | - | ||||||||||||||||||||||||||||||
| 1394 | y2 = qMin(r.y() + r.height(), pe->deviceRect.y() + pe->deviceRect.height()); | - | ||||||||||||||||||||||||||||||
| 1395 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1396 | x1 = qMax(r.x(), 0); | - | ||||||||||||||||||||||||||||||
| 1397 | x2 = qMin(r.x() + r.width(), data->rasterBuffer->width()); | - | ||||||||||||||||||||||||||||||
| 1398 | y1 = qMax(r.y(), 0); | - | ||||||||||||||||||||||||||||||
| 1399 | y2 = qMin(r.y() + r.height(), data->rasterBuffer->height()); | - | ||||||||||||||||||||||||||||||
| 1400 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1401 | - | |||||||||||||||||||||||||||||||
| 1402 | if (x2 <= x1 || y2 <= y1)
| 0 | ||||||||||||||||||||||||||||||
| 1403 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1404 | - | |||||||||||||||||||||||||||||||
| 1405 | const int width = x2 - x1; | - | ||||||||||||||||||||||||||||||
| 1406 | const int height = y2 - y1; | - | ||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 | bool isUnclipped = rectClipped
| 0 | ||||||||||||||||||||||||||||||
| 1409 | || (pe && pe->isUnclipped_normalized(QRect(x1, y1, width, height)));
| 0 | ||||||||||||||||||||||||||||||
| 1410 | - | |||||||||||||||||||||||||||||||
| 1411 | if (pe && isUnclipped) {
| 0 | ||||||||||||||||||||||||||||||
| 1412 | const QPainter::CompositionMode mode = pe->rasterBuffer->compositionMode; | - | ||||||||||||||||||||||||||||||
| 1413 | - | |||||||||||||||||||||||||||||||
| 1414 | if (data->fillRect && (mode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1415 | || (mode == QPainter::CompositionMode_SourceOver
| 0 | ||||||||||||||||||||||||||||||
| 1416 | && data->solid.color.isOpaque())))
| 0 | ||||||||||||||||||||||||||||||
| 1417 | { | - | ||||||||||||||||||||||||||||||
| 1418 | data->fillRect(data->rasterBuffer, x1, y1, width, height, data->solid.color); | - | ||||||||||||||||||||||||||||||
| 1419 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1420 | } | - | ||||||||||||||||||||||||||||||
| 1421 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1422 | - | |||||||||||||||||||||||||||||||
| 1423 | ProcessSpans blend = isUnclipped ? data->unclipped_blend : data->blend;
| 0 | ||||||||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||||||||
| 1425 | const int nspans = 256; | - | ||||||||||||||||||||||||||||||
| 1426 | QT_FT_Span spans[nspans]; | - | ||||||||||||||||||||||||||||||
| 1427 | - | |||||||||||||||||||||||||||||||
| 1428 | Q_ASSERT(data->blend); | - | ||||||||||||||||||||||||||||||
| 1429 | int y = y1; | - | ||||||||||||||||||||||||||||||
| 1430 | while (y < y2) {
| 0 | ||||||||||||||||||||||||||||||
| 1431 | int n = qMin(nspans, y2 - y); | - | ||||||||||||||||||||||||||||||
| 1432 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 1433 | while (i < n) {
| 0 | ||||||||||||||||||||||||||||||
| 1434 | spans[i].x = x1; | - | ||||||||||||||||||||||||||||||
| 1435 | spans[i].len = width; | - | ||||||||||||||||||||||||||||||
| 1436 | spans[i].y = y + i; | - | ||||||||||||||||||||||||||||||
| 1437 | spans[i].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 1438 | ++i; | - | ||||||||||||||||||||||||||||||
| 1439 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||||||||
| 1441 | blend(n, spans, data); | - | ||||||||||||||||||||||||||||||
| 1442 | y += n; | - | ||||||||||||||||||||||||||||||
| 1443 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1444 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1445 | - | |||||||||||||||||||||||||||||||
| 1446 | /*! | - | ||||||||||||||||||||||||||||||
| 1447 | \reimp | - | ||||||||||||||||||||||||||||||
| 1448 | */ | - | ||||||||||||||||||||||||||||||
| 1449 | void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) | - | ||||||||||||||||||||||||||||||
| 1450 | { | - | ||||||||||||||||||||||||||||||
| 1451 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1452 | qDebug(" - QRasterPaintEngine::drawRect(), rectCount=%d", rectCount); | - | ||||||||||||||||||||||||||||||
| 1453 | #endif | - | ||||||||||||||||||||||||||||||
| 1454 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1455 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 1456 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1457 | - | |||||||||||||||||||||||||||||||
| 1458 | // Fill | - | ||||||||||||||||||||||||||||||
| 1459 | ensureBrush(); | - | ||||||||||||||||||||||||||||||
| 1460 | if (s->brushData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1461 | if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 1462 | const QRect *r = rects; | - | ||||||||||||||||||||||||||||||
| 1463 | const QRect *lastRect = rects + rectCount; | - | ||||||||||||||||||||||||||||||
| 1464 | - | |||||||||||||||||||||||||||||||
| 1465 | int offset_x = int(s->matrix.dx()); | - | ||||||||||||||||||||||||||||||
| 1466 | int offset_y = int(s->matrix.dy()); | - | ||||||||||||||||||||||||||||||
| 1467 | while (r < lastRect) {
| 0 | ||||||||||||||||||||||||||||||
| 1468 | QRect rect = r->normalized(); | - | ||||||||||||||||||||||||||||||
| 1469 | QRect rr = rect.translated(offset_x, offset_y); | - | ||||||||||||||||||||||||||||||
| 1470 | fillRect_normalized(rr, &s->brushData, d); | - | ||||||||||||||||||||||||||||||
| 1471 | ++r; | - | ||||||||||||||||||||||||||||||
| 1472 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1473 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1474 | QRectVectorPath path; | - | ||||||||||||||||||||||||||||||
| 1475 | for (int i=0; i<rectCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1476 | path.set(rects[i]); | - | ||||||||||||||||||||||||||||||
| 1477 | fill(path, s->brush); | - | ||||||||||||||||||||||||||||||
| 1478 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1479 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1480 | } | - | ||||||||||||||||||||||||||||||
| 1481 | - | |||||||||||||||||||||||||||||||
| 1482 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 1483 | if (s->penData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1484 | QRectVectorPath path; | - | ||||||||||||||||||||||||||||||
| 1485 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 1486 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 1487 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 1488 | for (int i = 0; i < rectCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1489 | path.set(rects[i]); | - | ||||||||||||||||||||||||||||||
| 1490 | stroker.drawPath(path); | - | ||||||||||||||||||||||||||||||
| 1491 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1492 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1493 | for (int i = 0; i < rectCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1494 | path.set(rects[i]); | - | ||||||||||||||||||||||||||||||
| 1495 | stroke(path, s->pen); | - | ||||||||||||||||||||||||||||||
| 1496 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1497 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1498 | } | - | ||||||||||||||||||||||||||||||
| 1499 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||||||||
| 1501 | /*! | - | ||||||||||||||||||||||||||||||
| 1502 | \reimp | - | ||||||||||||||||||||||||||||||
| 1503 | */ | - | ||||||||||||||||||||||||||||||
| 1504 | void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount) | - | ||||||||||||||||||||||||||||||
| 1505 | { | - | ||||||||||||||||||||||||||||||
| 1506 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1507 | qDebug(" - QRasterPaintEngine::drawRect(QRectF*), rectCount=%d", rectCount); | - | ||||||||||||||||||||||||||||||
| 1508 | #endif | - | ||||||||||||||||||||||||||||||
| 1509 | #ifdef QT_FAST_SPANS | - | ||||||||||||||||||||||||||||||
| 1510 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1511 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 1512 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1513 | - | |||||||||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||||||||
| 1515 | if (s->flags.tx_noshear) {
| 0 | ||||||||||||||||||||||||||||||
| 1516 | ensureBrush(); | - | ||||||||||||||||||||||||||||||
| 1517 | if (s->brushData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1518 | d->initializeRasterizer(&s->brushData); | - | ||||||||||||||||||||||||||||||
| 1519 | for (int i = 0; i < rectCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1520 | const QRectF &rect = rects[i].normalized(); | - | ||||||||||||||||||||||||||||||
| 1521 | if (rect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||
| 1522 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 1523 | const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 1524 | const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 1525 | d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); | - | ||||||||||||||||||||||||||||||
| 1526 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1527 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1528 | - | |||||||||||||||||||||||||||||||
| 1529 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 1530 | if (s->penData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1531 | QRectVectorPath path; | - | ||||||||||||||||||||||||||||||
| 1532 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 1533 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 1534 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 1535 | for (int i = 0; i < rectCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1536 | path.set(rects[i]); | - | ||||||||||||||||||||||||||||||
| 1537 | stroker.drawPath(path); | - | ||||||||||||||||||||||||||||||
| 1538 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1539 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1540 | for (int i = 0; i < rectCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1541 | path.set(rects[i]); | - | ||||||||||||||||||||||||||||||
| 1542 | QPaintEngineEx::stroke(path, s->lastPen); | - | ||||||||||||||||||||||||||||||
| 1543 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1544 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1545 | } | - | ||||||||||||||||||||||||||||||
| 1546 | - | |||||||||||||||||||||||||||||||
| 1547 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||||||||||||||
| 1549 | #endif // QT_FAST_SPANS | - | ||||||||||||||||||||||||||||||
| 1550 | QPaintEngineEx::drawRects(rects, rectCount); | - | ||||||||||||||||||||||||||||||
| 1551 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||||||||
| 1553 | - | |||||||||||||||||||||||||||||||
| 1554 | /*! | - | ||||||||||||||||||||||||||||||
| 1555 | \internal | - | ||||||||||||||||||||||||||||||
| 1556 | */ | - | ||||||||||||||||||||||||||||||
| 1557 | void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) | - | ||||||||||||||||||||||||||||||
| 1558 | { | - | ||||||||||||||||||||||||||||||
| 1559 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1560 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1561 | - | |||||||||||||||||||||||||||||||
| 1562 | ensurePen(pen); | - | ||||||||||||||||||||||||||||||
| 1563 | if (!s->penData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 1564 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1565 | - | |||||||||||||||||||||||||||||||
| 1566 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 1567 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 1568 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 1569 | stroker.drawPath(path); | - | ||||||||||||||||||||||||||||||
| 1570 | } else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1571 | qreal width = qt_pen_is_cosmetic(s->lastPen, s->renderHints)
| 0 | ||||||||||||||||||||||||||||||
| 1572 | ? (qpen_widthf(s->lastPen) == 0 ? 1 : qpen_widthf(s->lastPen))
| 0 | ||||||||||||||||||||||||||||||
| 1573 | : qpen_widthf(s->lastPen) * s->txscale; | - | ||||||||||||||||||||||||||||||
| 1574 | int dashIndex = 0; | - | ||||||||||||||||||||||||||||||
| 1575 | qreal dashOffset = s->lastPen.dashOffset(); | - | ||||||||||||||||||||||||||||||
| 1576 | bool inDash = true; | - | ||||||||||||||||||||||||||||||
| 1577 | qreal patternLength = 0; | - | ||||||||||||||||||||||||||||||
| 1578 | const QVector<qreal> pattern = s->lastPen.dashPattern(); | - | ||||||||||||||||||||||||||||||
| 1579 | for (int i = 0; i < pattern.size(); ++i)
| 0 | ||||||||||||||||||||||||||||||
| 1580 | patternLength += pattern.at(i); never executed: patternLength += pattern.at(i); | 0 | ||||||||||||||||||||||||||||||
| 1581 | - | |||||||||||||||||||||||||||||||
| 1582 | if (patternLength > 0) {
| 0 | ||||||||||||||||||||||||||||||
| 1583 | int n = qFloor(dashOffset / patternLength); | - | ||||||||||||||||||||||||||||||
| 1584 | dashOffset -= n * patternLength; | - | ||||||||||||||||||||||||||||||
| 1585 | while (dashOffset >= pattern.at(dashIndex)) {
| 0 | ||||||||||||||||||||||||||||||
| 1586 | dashOffset -= pattern.at(dashIndex); | - | ||||||||||||||||||||||||||||||
| 1587 | if (++dashIndex >= pattern.size())
| 0 | ||||||||||||||||||||||||||||||
| 1588 | dashIndex = 0; never executed: dashIndex = 0; | 0 | ||||||||||||||||||||||||||||||
| 1589 | inDash = !inDash; | - | ||||||||||||||||||||||||||||||
| 1590 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1591 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1592 | - | |||||||||||||||||||||||||||||||
| 1593 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1594 | d->initializeRasterizer(&s->penData); | - | ||||||||||||||||||||||||||||||
| 1595 | int lineCount = path.elementCount() / 2; | - | ||||||||||||||||||||||||||||||
| 1596 | const QLineF *lines = reinterpret_cast<const QLineF *>(path.points()); | - | ||||||||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||||||||
| 1598 | for (int i = 0; i < lineCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1599 | if (lines[i].p1() == lines[i].p2()) {
| 0 | ||||||||||||||||||||||||||||||
| 1600 | if (s->lastPen.capStyle() != Qt::FlatCap) {
| 0 | ||||||||||||||||||||||||||||||
| 1601 | QPointF p = lines[i].p1(); | - | ||||||||||||||||||||||||||||||
| 1602 | QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()), | - | ||||||||||||||||||||||||||||||
| 1603 | QPointF(p.x() + width*0.5, p.y()))); | - | ||||||||||||||||||||||||||||||
| 1604 | d->rasterizer->rasterizeLine(line.p1(), line.p2(), 1); | - | ||||||||||||||||||||||||||||||
| 1605 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1606 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 1607 | } | - | ||||||||||||||||||||||||||||||
| 1608 | - | |||||||||||||||||||||||||||||||
| 1609 | const QLineF line = s->matrix.map(lines[i]); | - | ||||||||||||||||||||||||||||||
| 1610 | if (qpen_style(s->lastPen) == Qt::SolidLine) {
| 0 | ||||||||||||||||||||||||||||||
| 1611 | d->rasterizer->rasterizeLine(line.p1(), line.p2(), | - | ||||||||||||||||||||||||||||||
| 1612 | width / line.length(), | - | ||||||||||||||||||||||||||||||
| 1613 | s->lastPen.capStyle() == Qt::SquareCap); | - | ||||||||||||||||||||||||||||||
| 1614 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1615 | d->rasterizeLine_dashed(line, width, | - | ||||||||||||||||||||||||||||||
| 1616 | &dashIndex, &dashOffset, &inDash); | - | ||||||||||||||||||||||||||||||
| 1617 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1618 | } | - | ||||||||||||||||||||||||||||||
| 1619 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1620 | else | - | ||||||||||||||||||||||||||||||
| 1621 | QPaintEngineEx::stroke(path, pen); never executed: QPaintEngineEx::stroke(path, pen); | 0 | ||||||||||||||||||||||||||||||
| 1622 | } | - | ||||||||||||||||||||||||||||||
| 1623 | - | |||||||||||||||||||||||||||||||
| 1624 | QRect QRasterPaintEngine::toNormalizedFillRect(const QRectF &rect) | - | ||||||||||||||||||||||||||||||
| 1625 | { | - | ||||||||||||||||||||||||||||||
| 1626 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||||||||
| 1628 | qreal delta = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0);
| 0 | ||||||||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||||||||
| 1630 | int x1 = qRound(rect.x() + delta); | - | ||||||||||||||||||||||||||||||
| 1631 | int y1 = qRound(rect.y() + delta); | - | ||||||||||||||||||||||||||||||
| 1632 | int x2 = qRound(rect.right() + delta); | - | ||||||||||||||||||||||||||||||
| 1633 | int y2 = qRound(rect.bottom() + delta); | - | ||||||||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||||||||
| 1635 | if (x2 < x1)
| 0 | ||||||||||||||||||||||||||||||
| 1636 | qSwap(x1, x2); never executed: qSwap(x1, x2); | 0 | ||||||||||||||||||||||||||||||
| 1637 | if (y2 < y1)
| 0 | ||||||||||||||||||||||||||||||
| 1638 | qSwap(y1, y2); never executed: qSwap(y1, y2); | 0 | ||||||||||||||||||||||||||||||
| 1639 | - | |||||||||||||||||||||||||||||||
| 1640 | return QRect(x1, y1, x2 - x1, y2 - y1); never executed: return QRect(x1, y1, x2 - x1, y2 - y1); | 0 | ||||||||||||||||||||||||||||||
| 1641 | } | - | ||||||||||||||||||||||||||||||
| 1642 | - | |||||||||||||||||||||||||||||||
| 1643 | /*! | - | ||||||||||||||||||||||||||||||
| 1644 | \internal | - | ||||||||||||||||||||||||||||||
| 1645 | */ | - | ||||||||||||||||||||||||||||||
| 1646 | void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) | - | ||||||||||||||||||||||||||||||
| 1647 | { | - | ||||||||||||||||||||||||||||||
| 1648 | if (path.isEmpty())
| 0 | ||||||||||||||||||||||||||||||
| 1649 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1650 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1651 | QRectF rf = path.controlPointRect(); | - | ||||||||||||||||||||||||||||||
| 1652 | qDebug() << "QRasterPaintEngine::fill(): " | - | ||||||||||||||||||||||||||||||
| 1653 | << "size=" << path.elementCount() | - | ||||||||||||||||||||||||||||||
| 1654 | << ", hints=" << hex << path.hints() | - | ||||||||||||||||||||||||||||||
| 1655 | << rf << brush; | - | ||||||||||||||||||||||||||||||
| 1656 | #endif | - | ||||||||||||||||||||||||||||||
| 1657 | - | |||||||||||||||||||||||||||||||
| 1658 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1659 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1660 | - | |||||||||||||||||||||||||||||||
| 1661 | ensureBrush(brush); | - | ||||||||||||||||||||||||||||||
| 1662 | if (!s->brushData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 1663 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1664 | - | |||||||||||||||||||||||||||||||
| 1665 | if (path.shape() == QVectorPath::RectangleHint) {
| 0 | ||||||||||||||||||||||||||||||
| 1666 | if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxScale) {
| 0 | ||||||||||||||||||||||||||||||
| 1667 | const qreal *p = path.points(); | - | ||||||||||||||||||||||||||||||
| 1668 | QPointF tl = QPointF(p[0], p[1]) * s->matrix; | - | ||||||||||||||||||||||||||||||
| 1669 | QPointF br = QPointF(p[4], p[5]) * s->matrix; | - | ||||||||||||||||||||||||||||||
| 1670 | fillRect_normalized(toNormalizedFillRect(QRectF(tl, br)), &s->brushData, d); | - | ||||||||||||||||||||||||||||||
| 1671 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1672 | } | - | ||||||||||||||||||||||||||||||
| 1673 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 1674 | if (s->flags.tx_noshear) {
| 0 | ||||||||||||||||||||||||||||||
| 1675 | d->initializeRasterizer(&s->brushData); | - | ||||||||||||||||||||||||||||||
| 1676 | // ### Is normalizing really necessary here? | - | ||||||||||||||||||||||||||||||
| 1677 | const qreal *p = path.points(); | - | ||||||||||||||||||||||||||||||
| 1678 | QRectF r = QRectF(p[0], p[1], p[2] - p[0], p[7] - p[1]).normalized(); | - | ||||||||||||||||||||||||||||||
| 1679 | if (!r.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||
| 1680 | const QPointF a = s->matrix.map((r.topLeft() + r.bottomLeft()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 1681 | const QPointF b = s->matrix.map((r.topRight() + r.bottomRight()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 1682 | d->rasterizer->rasterizeLine(a, b, r.height() / r.width()); | - | ||||||||||||||||||||||||||||||
| 1683 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1684 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1685 | } | - | ||||||||||||||||||||||||||||||
| 1686 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||||||||
| 1688 | // ### Optimize for non transformed ellipses and rectangles... | - | ||||||||||||||||||||||||||||||
| 1689 | QRectF cpRect = path.controlPointRect(); | - | ||||||||||||||||||||||||||||||
| 1690 | const QRect deviceRect = s->matrix.mapRect(cpRect).toRect(); | - | ||||||||||||||||||||||||||||||
| 1691 | ProcessSpans blend = d->getBrushFunc(deviceRect, &s->brushData); | - | ||||||||||||||||||||||||||||||
| 1692 | - | |||||||||||||||||||||||||||||||
| 1693 | // ### Falcon | - | ||||||||||||||||||||||||||||||
| 1694 | // const bool do_clip = (deviceRect.left() < -QT_RASTER_COORD_LIMIT | - | ||||||||||||||||||||||||||||||
| 1695 | // || deviceRect.right() > QT_RASTER_COORD_LIMIT | - | ||||||||||||||||||||||||||||||
| 1696 | // || deviceRect.top() < -QT_RASTER_COORD_LIMIT | - | ||||||||||||||||||||||||||||||
| 1697 | // || deviceRect.bottom() > QT_RASTER_COORD_LIMIT); | - | ||||||||||||||||||||||||||||||
| 1698 | - | |||||||||||||||||||||||||||||||
| 1699 | // ### Falonc: implement.... | - | ||||||||||||||||||||||||||||||
| 1700 | // if (!s->flags.antialiased && !do_clip) { | - | ||||||||||||||||||||||||||||||
| 1701 | // d->initializeRasterizer(&s->brushData); | - | ||||||||||||||||||||||||||||||
| 1702 | // d->rasterizer->rasterize(path * d->matrix, path.fillRule()); | - | ||||||||||||||||||||||||||||||
| 1703 | // return; | - | ||||||||||||||||||||||||||||||
| 1704 | // } | - | ||||||||||||||||||||||||||||||
| 1705 | - | |||||||||||||||||||||||||||||||
| 1706 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 1707 | d->rasterize(d->outlineMapper->convertPath(path), blend, &s->brushData, d->rasterBuffer.data()); | - | ||||||||||||||||||||||||||||||
| 1708 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1709 | - | |||||||||||||||||||||||||||||||
| 1710 | void QRasterPaintEngine::fillRect(const QRectF &r, QSpanData *data) | - | ||||||||||||||||||||||||||||||
| 1711 | { | - | ||||||||||||||||||||||||||||||
| 1712 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1713 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1714 | - | |||||||||||||||||||||||||||||||
| 1715 | if (!s->flags.antialiased) {
| 0 | ||||||||||||||||||||||||||||||
| 1716 | uint txop = s->matrix.type(); | - | ||||||||||||||||||||||||||||||
| 1717 | if (txop == QTransform::TxNone) {
| 0 | ||||||||||||||||||||||||||||||
| 1718 | fillRect_normalized(toNormalizedFillRect(r), data, d); | - | ||||||||||||||||||||||||||||||
| 1719 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1720 | } else if (txop == QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 1721 | const QRect rr = toNormalizedFillRect(r.translated(s->matrix.dx(), s->matrix.dy())); | - | ||||||||||||||||||||||||||||||
| 1722 | fillRect_normalized(rr, data, d); | - | ||||||||||||||||||||||||||||||
| 1723 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1724 | } else if (txop == QTransform::TxScale) {
| 0 | ||||||||||||||||||||||||||||||
| 1725 | const QRect rr = toNormalizedFillRect(s->matrix.mapRect(r)); | - | ||||||||||||||||||||||||||||||
| 1726 | fillRect_normalized(rr, data, d); | - | ||||||||||||||||||||||||||||||
| 1727 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1728 | } | - | ||||||||||||||||||||||||||||||
| 1729 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1730 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 1731 | if (s->flags.tx_noshear) {
| 0 | ||||||||||||||||||||||||||||||
| 1732 | d->initializeRasterizer(data); | - | ||||||||||||||||||||||||||||||
| 1733 | QRectF nr = r.normalized(); | - | ||||||||||||||||||||||||||||||
| 1734 | if (!nr.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||
| 1735 | const QPointF a = s->matrix.map((nr.topLeft() + nr.bottomLeft()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 1736 | const QPointF b = s->matrix.map((nr.topRight() + nr.bottomRight()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 1737 | d->rasterizer->rasterizeLine(a, b, nr.height() / nr.width()); | - | ||||||||||||||||||||||||||||||
| 1738 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1739 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1740 | } | - | ||||||||||||||||||||||||||||||
| 1741 | - | |||||||||||||||||||||||||||||||
| 1742 | QPainterPath path; | - | ||||||||||||||||||||||||||||||
| 1743 | path.addRect(r); | - | ||||||||||||||||||||||||||||||
| 1744 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 1745 | fillPath(path, data); | - | ||||||||||||||||||||||||||||||
| 1746 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1747 | - | |||||||||||||||||||||||||||||||
| 1748 | /*! | - | ||||||||||||||||||||||||||||||
| 1749 | \reimp | - | ||||||||||||||||||||||||||||||
| 1750 | */ | - | ||||||||||||||||||||||||||||||
| 1751 | void QRasterPaintEngine::fillRect(const QRectF &r, const QBrush &brush) | - | ||||||||||||||||||||||||||||||
| 1752 | { | - | ||||||||||||||||||||||||||||||
| 1753 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1754 | qDebug() << "QRasterPaintEngine::fillRecct(): " << r << brush; | - | ||||||||||||||||||||||||||||||
| 1755 | #endif | - | ||||||||||||||||||||||||||||||
| 1756 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1757 | - | |||||||||||||||||||||||||||||||
| 1758 | ensureBrush(brush); | - | ||||||||||||||||||||||||||||||
| 1759 | if (!s->brushData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 1760 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||||||||
| 1762 | fillRect(r, &s->brushData); | - | ||||||||||||||||||||||||||||||
| 1763 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1764 | - | |||||||||||||||||||||||||||||||
| 1765 | /*! | - | ||||||||||||||||||||||||||||||
| 1766 | \reimp | - | ||||||||||||||||||||||||||||||
| 1767 | */ | - | ||||||||||||||||||||||||||||||
| 1768 | void QRasterPaintEngine::fillRect(const QRectF &r, const QColor &color) | - | ||||||||||||||||||||||||||||||
| 1769 | { | - | ||||||||||||||||||||||||||||||
| 1770 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1771 | qDebug() << "QRasterPaintEngine::fillRect(): " << r << color; | - | ||||||||||||||||||||||||||||||
| 1772 | #endif | - | ||||||||||||||||||||||||||||||
| 1773 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1774 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||||||||
| 1776 | d->solid_color_filler.solid.color = qPremultiply(combineAlpha256(color.rgba64(), s->intOpacity)); | - | ||||||||||||||||||||||||||||||
| 1777 | - | |||||||||||||||||||||||||||||||
| 1778 | if (d->solid_color_filler.solid.color.isTransparent()
| 0 | ||||||||||||||||||||||||||||||
| 1779 | && s->composition_mode == QPainter::CompositionMode_SourceOver) {
| 0 | ||||||||||||||||||||||||||||||
| 1780 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1781 | } | - | ||||||||||||||||||||||||||||||
| 1782 | d->solid_color_filler.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 1783 | d->solid_color_filler.adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 1784 | fillRect(r, &d->solid_color_filler); | - | ||||||||||||||||||||||||||||||
| 1785 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1786 | - | |||||||||||||||||||||||||||||||
| 1787 | static inline bool isAbove(const QPointF *a, const QPointF *b) | - | ||||||||||||||||||||||||||||||
| 1788 | { | - | ||||||||||||||||||||||||||||||
| 1789 | return a->y() < b->y(); never executed: return a->y() < b->y(); | 0 | ||||||||||||||||||||||||||||||
| 1790 | } | - | ||||||||||||||||||||||||||||||
| 1791 | - | |||||||||||||||||||||||||||||||
| 1792 | static bool splitPolygon(const QPointF *points, int pointCount, QVector<QPointF> *upper, QVector<QPointF> *lower) | - | ||||||||||||||||||||||||||||||
| 1793 | { | - | ||||||||||||||||||||||||||||||
| 1794 | Q_ASSERT(upper); | - | ||||||||||||||||||||||||||||||
| 1795 | Q_ASSERT(lower); | - | ||||||||||||||||||||||||||||||
| 1796 | - | |||||||||||||||||||||||||||||||
| 1797 | Q_ASSERT(pointCount >= 2); | - | ||||||||||||||||||||||||||||||
| 1798 | - | |||||||||||||||||||||||||||||||
| 1799 | QVector<const QPointF *> sorted; | - | ||||||||||||||||||||||||||||||
| 1800 | sorted.reserve(pointCount); | - | ||||||||||||||||||||||||||||||
| 1801 | - | |||||||||||||||||||||||||||||||
| 1802 | upper->reserve(pointCount * 3 / 4); | - | ||||||||||||||||||||||||||||||
| 1803 | lower->reserve(pointCount * 3 / 4); | - | ||||||||||||||||||||||||||||||
| 1804 | - | |||||||||||||||||||||||||||||||
| 1805 | for (int i = 0; i < pointCount; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 1806 | sorted << points + i; never executed: sorted << points + i; | 0 | ||||||||||||||||||||||||||||||
| 1807 | - | |||||||||||||||||||||||||||||||
| 1808 | std::sort(sorted.begin(), sorted.end(), isAbove); | - | ||||||||||||||||||||||||||||||
| 1809 | - | |||||||||||||||||||||||||||||||
| 1810 | qreal splitY = sorted.at(sorted.size() / 2)->y(); | - | ||||||||||||||||||||||||||||||
| 1811 | - | |||||||||||||||||||||||||||||||
| 1812 | const QPointF *end = points + pointCount; | - | ||||||||||||||||||||||||||||||
| 1813 | const QPointF *last = end - 1; | - | ||||||||||||||||||||||||||||||
| 1814 | - | |||||||||||||||||||||||||||||||
| 1815 | QVector<QPointF> *bin[2] = { upper, lower }; | - | ||||||||||||||||||||||||||||||
| 1816 | - | |||||||||||||||||||||||||||||||
| 1817 | for (const QPointF *p = points; p < end; ++p) {
| 0 | ||||||||||||||||||||||||||||||
| 1818 | int side = p->y() < splitY; | - | ||||||||||||||||||||||||||||||
| 1819 | int lastSide = last->y() < splitY; | - | ||||||||||||||||||||||||||||||
| 1820 | - | |||||||||||||||||||||||||||||||
| 1821 | if (side != lastSide) {
| 0 | ||||||||||||||||||||||||||||||
| 1822 | if (qFuzzyCompare(p->y(), splitY)) {
| 0 | ||||||||||||||||||||||||||||||
| 1823 | bin[!side]->append(*p); | - | ||||||||||||||||||||||||||||||
| 1824 | } else if (qFuzzyCompare(last->y(), splitY)) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1825 | bin[side]->append(*last); | - | ||||||||||||||||||||||||||||||
| 1826 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1827 | QPointF delta = *p - *last; | - | ||||||||||||||||||||||||||||||
| 1828 | QPointF intersection(p->x() + delta.x() * (splitY - p->y()) / delta.y(), splitY); | - | ||||||||||||||||||||||||||||||
| 1829 | - | |||||||||||||||||||||||||||||||
| 1830 | bin[0]->append(intersection); | - | ||||||||||||||||||||||||||||||
| 1831 | bin[1]->append(intersection); | - | ||||||||||||||||||||||||||||||
| 1832 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1833 | } | - | ||||||||||||||||||||||||||||||
| 1834 | - | |||||||||||||||||||||||||||||||
| 1835 | bin[side]->append(*p); | - | ||||||||||||||||||||||||||||||
| 1836 | - | |||||||||||||||||||||||||||||||
| 1837 | last = p; | - | ||||||||||||||||||||||||||||||
| 1838 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1839 | - | |||||||||||||||||||||||||||||||
| 1840 | // give up if we couldn't reduce the point count | - | ||||||||||||||||||||||||||||||
| 1841 | return upper->size() < pointCount && lower->size() < pointCount; never executed: return upper->size() < pointCount && lower->size() < pointCount;
| 0 | ||||||||||||||||||||||||||||||
| 1842 | } | - | ||||||||||||||||||||||||||||||
| 1843 | - | |||||||||||||||||||||||||||||||
| 1844 | /*! | - | ||||||||||||||||||||||||||||||
| 1845 | \internal | - | ||||||||||||||||||||||||||||||
| 1846 | */ | - | ||||||||||||||||||||||||||||||
| 1847 | void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) | - | ||||||||||||||||||||||||||||||
| 1848 | { | - | ||||||||||||||||||||||||||||||
| 1849 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1850 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1851 | - | |||||||||||||||||||||||||||||||
| 1852 | const int maxPoints = 0xffff; | - | ||||||||||||||||||||||||||||||
| 1853 | - | |||||||||||||||||||||||||||||||
| 1854 | // max amount of points that raster engine can reliably handle | - | ||||||||||||||||||||||||||||||
| 1855 | if (pointCount > maxPoints) {
| 0 | ||||||||||||||||||||||||||||||
| 1856 | QVector<QPointF> upper, lower; | - | ||||||||||||||||||||||||||||||
| 1857 | - | |||||||||||||||||||||||||||||||
| 1858 | if (splitPolygon(points, pointCount, &upper, &lower)) {
| 0 | ||||||||||||||||||||||||||||||
| 1859 | fillPolygon(upper.constData(), upper.size(), mode); | - | ||||||||||||||||||||||||||||||
| 1860 | fillPolygon(lower.constData(), lower.size(), mode); | - | ||||||||||||||||||||||||||||||
| 1861 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1862 | qWarning("Polygon too complex for filling."); never executed: QMessageLogger(__FILE__, 1862, __PRETTY_FUNCTION__).warning("Polygon too complex for filling."); | 0 | ||||||||||||||||||||||||||||||
| 1863 | - | |||||||||||||||||||||||||||||||
| 1864 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1865 | } | - | ||||||||||||||||||||||||||||||
| 1866 | - | |||||||||||||||||||||||||||||||
| 1867 | // Compose polygon fill.., | - | ||||||||||||||||||||||||||||||
| 1868 | QVectorPath vp((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); | - | ||||||||||||||||||||||||||||||
| 1869 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 1870 | QT_FT_Outline *outline = d->outlineMapper->convertPath(vp); | - | ||||||||||||||||||||||||||||||
| 1871 | - | |||||||||||||||||||||||||||||||
| 1872 | // scanconvert. | - | ||||||||||||||||||||||||||||||
| 1873 | ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect, | - | ||||||||||||||||||||||||||||||
| 1874 | &s->brushData); | - | ||||||||||||||||||||||||||||||
| 1875 | d->rasterize(outline, brushBlend, &s->brushData, d->rasterBuffer.data()); | - | ||||||||||||||||||||||||||||||
| 1876 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||||||||
| 1878 | /*! | - | ||||||||||||||||||||||||||||||
| 1879 | \reimp | - | ||||||||||||||||||||||||||||||
| 1880 | */ | - | ||||||||||||||||||||||||||||||
| 1881 | void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) | - | ||||||||||||||||||||||||||||||
| 1882 | { | - | ||||||||||||||||||||||||||||||
| 1883 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1884 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1885 | - | |||||||||||||||||||||||||||||||
| 1886 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1887 | qDebug(" - QRasterPaintEngine::drawPolygon(F), pointCount=%d", pointCount); | - | ||||||||||||||||||||||||||||||
| 1888 | for (int i=0; i<pointCount; ++i) | - | ||||||||||||||||||||||||||||||
| 1889 | qDebug() << " - " << points[i]; | - | ||||||||||||||||||||||||||||||
| 1890 | #endif | - | ||||||||||||||||||||||||||||||
| 1891 | Q_ASSERT(pointCount >= 2); | - | ||||||||||||||||||||||||||||||
| 1892 | - | |||||||||||||||||||||||||||||||
| 1893 | if (mode != PolylineMode && QVectorPath::isRect((const qreal *) points, pointCount)) {
| 0 | ||||||||||||||||||||||||||||||
| 1894 | QRectF r(points[0], points[2]); | - | ||||||||||||||||||||||||||||||
| 1895 | drawRects(&r, 1); | - | ||||||||||||||||||||||||||||||
| 1896 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1897 | } | - | ||||||||||||||||||||||||||||||
| 1898 | - | |||||||||||||||||||||||||||||||
| 1899 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 1900 | if (mode != PolylineMode) {
| 0 | ||||||||||||||||||||||||||||||
| 1901 | // Do the fill... | - | ||||||||||||||||||||||||||||||
| 1902 | ensureBrush(); | - | ||||||||||||||||||||||||||||||
| 1903 | if (s->brushData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 1904 | fillPolygon(points, pointCount, mode); never executed: fillPolygon(points, pointCount, mode); | 0 | ||||||||||||||||||||||||||||||
| 1905 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1906 | - | |||||||||||||||||||||||||||||||
| 1907 | // Do the outline... | - | ||||||||||||||||||||||||||||||
| 1908 | if (s->penData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1909 | QVectorPath vp((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); | - | ||||||||||||||||||||||||||||||
| 1910 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 1911 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 1912 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 1913 | stroker.drawPath(vp); | - | ||||||||||||||||||||||||||||||
| 1914 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1915 | QPaintEngineEx::stroke(vp, s->lastPen); | - | ||||||||||||||||||||||||||||||
| 1916 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1917 | } | - | ||||||||||||||||||||||||||||||
| 1918 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1919 | - | |||||||||||||||||||||||||||||||
| 1920 | /*! | - | ||||||||||||||||||||||||||||||
| 1921 | \reimp | - | ||||||||||||||||||||||||||||||
| 1922 | */ | - | ||||||||||||||||||||||||||||||
| 1923 | void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) | - | ||||||||||||||||||||||||||||||
| 1924 | { | - | ||||||||||||||||||||||||||||||
| 1925 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1926 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1927 | - | |||||||||||||||||||||||||||||||
| 1928 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1929 | qDebug(" - QRasterPaintEngine::drawPolygon(I), pointCount=%d", pointCount); | - | ||||||||||||||||||||||||||||||
| 1930 | for (int i=0; i<pointCount; ++i) | - | ||||||||||||||||||||||||||||||
| 1931 | qDebug() << " - " << points[i]; | - | ||||||||||||||||||||||||||||||
| 1932 | #endif | - | ||||||||||||||||||||||||||||||
| 1933 | Q_ASSERT(pointCount >= 2); | - | ||||||||||||||||||||||||||||||
| 1934 | if (mode != PolylineMode && QVectorPath::isRect((const int *) points, pointCount)) {
| 0 | ||||||||||||||||||||||||||||||
| 1935 | QRect r(points[0].x(), | - | ||||||||||||||||||||||||||||||
| 1936 | points[0].y(), | - | ||||||||||||||||||||||||||||||
| 1937 | points[2].x() - points[0].x(), | - | ||||||||||||||||||||||||||||||
| 1938 | points[2].y() - points[0].y()); | - | ||||||||||||||||||||||||||||||
| 1939 | drawRects(&r, 1); | - | ||||||||||||||||||||||||||||||
| 1940 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1941 | } | - | ||||||||||||||||||||||||||||||
| 1942 | - | |||||||||||||||||||||||||||||||
| 1943 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 1944 | - | |||||||||||||||||||||||||||||||
| 1945 | // Do the fill | - | ||||||||||||||||||||||||||||||
| 1946 | if (mode != PolylineMode) {
| 0 | ||||||||||||||||||||||||||||||
| 1947 | ensureBrush(); | - | ||||||||||||||||||||||||||||||
| 1948 | if (s->brushData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1949 | // Compose polygon fill.., | - | ||||||||||||||||||||||||||||||
| 1950 | ensureOutlineMapper(); | - | ||||||||||||||||||||||||||||||
| 1951 | d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill); | - | ||||||||||||||||||||||||||||||
| 1952 | d->outlineMapper->moveTo(*points); | - | ||||||||||||||||||||||||||||||
| 1953 | const QPoint *p = points; | - | ||||||||||||||||||||||||||||||
| 1954 | const QPoint *ep = points + pointCount - 1; | - | ||||||||||||||||||||||||||||||
| 1955 | do { | - | ||||||||||||||||||||||||||||||
| 1956 | d->outlineMapper->lineTo(*(++p)); | - | ||||||||||||||||||||||||||||||
| 1957 | } while (p < ep); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 1958 | d->outlineMapper->endOutline(); | - | ||||||||||||||||||||||||||||||
| 1959 | - | |||||||||||||||||||||||||||||||
| 1960 | // scanconvert. | - | ||||||||||||||||||||||||||||||
| 1961 | ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect, | - | ||||||||||||||||||||||||||||||
| 1962 | &s->brushData); | - | ||||||||||||||||||||||||||||||
| 1963 | d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer.data()); | - | ||||||||||||||||||||||||||||||
| 1964 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1965 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1966 | - | |||||||||||||||||||||||||||||||
| 1967 | // Do the outline... | - | ||||||||||||||||||||||||||||||
| 1968 | if (s->penData.blend) {
| 0 | ||||||||||||||||||||||||||||||
| 1969 | int count = pointCount * 2; | - | ||||||||||||||||||||||||||||||
| 1970 | QVarLengthArray<qreal> fpoints(count); | - | ||||||||||||||||||||||||||||||
| 1971 | for (int i=0; i<count; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 1972 | fpoints[i] = ((const int *) points)[i]; never executed: fpoints[i] = ((const int *) points)[i]; | 0 | ||||||||||||||||||||||||||||||
| 1973 | QVectorPath vp((qreal *) fpoints.data(), pointCount, 0, QVectorPath::polygonFlags(mode)); | - | ||||||||||||||||||||||||||||||
| 1974 | - | |||||||||||||||||||||||||||||||
| 1975 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 1976 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 1977 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 1978 | stroker.drawPath(vp); | - | ||||||||||||||||||||||||||||||
| 1979 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1980 | QPaintEngineEx::stroke(vp, s->lastPen); | - | ||||||||||||||||||||||||||||||
| 1981 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1982 | } | - | ||||||||||||||||||||||||||||||
| 1983 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1984 | - | |||||||||||||||||||||||||||||||
| 1985 | /*! | - | ||||||||||||||||||||||||||||||
| 1986 | \internal | - | ||||||||||||||||||||||||||||||
| 1987 | */ | - | ||||||||||||||||||||||||||||||
| 1988 | void QRasterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pixmap) | - | ||||||||||||||||||||||||||||||
| 1989 | { | - | ||||||||||||||||||||||||||||||
| 1990 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 1991 | qDebug() << " - QRasterPaintEngine::drawPixmap(), pos=" << pos << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth(); | - | ||||||||||||||||||||||||||||||
| 1992 | #endif | - | ||||||||||||||||||||||||||||||
| 1993 | - | |||||||||||||||||||||||||||||||
| 1994 | QPlatformPixmap *pd = pixmap.handle(); | - | ||||||||||||||||||||||||||||||
| 1995 | if (pd->classId() == QPlatformPixmap::RasterClass) {
| 0 | ||||||||||||||||||||||||||||||
| 1996 | const QImage &image = static_cast<QRasterPlatformPixmap *>(pd)->image; | - | ||||||||||||||||||||||||||||||
| 1997 | if (image.depth() == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 1998 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 1999 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2000 | if (s->matrix.type() <= QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 2001 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 2002 | drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2003 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2004 | drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color())); | - | ||||||||||||||||||||||||||||||
| 2005 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2006 | } else { | - | ||||||||||||||||||||||||||||||
| 2007 | QRasterPaintEngine::drawImage(pos, image); | - | ||||||||||||||||||||||||||||||
| 2008 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2009 | } else { | - | ||||||||||||||||||||||||||||||
| 2010 | const QImage image = pixmap.toImage(); | - | ||||||||||||||||||||||||||||||
| 2011 | if (pixmap.depth() == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 2012 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2013 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2014 | if (s->matrix.type() <= QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 2015 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 2016 | drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2017 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2018 | drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color())); | - | ||||||||||||||||||||||||||||||
| 2019 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2020 | } else { | - | ||||||||||||||||||||||||||||||
| 2021 | QRasterPaintEngine::drawImage(pos, image); | - | ||||||||||||||||||||||||||||||
| 2022 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2023 | } | - | ||||||||||||||||||||||||||||||
| 2024 | } | - | ||||||||||||||||||||||||||||||
| 2025 | - | |||||||||||||||||||||||||||||||
| 2026 | /*! | - | ||||||||||||||||||||||||||||||
| 2027 | \reimp | - | ||||||||||||||||||||||||||||||
| 2028 | */ | - | ||||||||||||||||||||||||||||||
| 2029 | void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr) | - | ||||||||||||||||||||||||||||||
| 2030 | { | - | ||||||||||||||||||||||||||||||
| 2031 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 2032 | qDebug() << " - QRasterPaintEngine::drawPixmap(), r=" << r << " sr=" << sr << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth(); | - | ||||||||||||||||||||||||||||||
| 2033 | #endif | - | ||||||||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||||||||
| 2035 | QPlatformPixmap* pd = pixmap.handle(); | - | ||||||||||||||||||||||||||||||
| 2036 | if (pd->classId() == QPlatformPixmap::RasterClass) {
| 0 | ||||||||||||||||||||||||||||||
| 2037 | const QImage &image = static_cast<QRasterPlatformPixmap *>(pd)->image; | - | ||||||||||||||||||||||||||||||
| 2038 | if (image.depth() == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 2039 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2040 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2041 | if (s->matrix.type() <= QTransform::TxTranslate
| 0 | ||||||||||||||||||||||||||||||
| 2042 | && r.size() == sr.size()
| 0 | ||||||||||||||||||||||||||||||
| 2043 | && r.size() == pixmap.size()) {
| 0 | ||||||||||||||||||||||||||||||
| 2044 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 2045 | drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2046 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2047 | } else { | - | ||||||||||||||||||||||||||||||
| 2048 | drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr); | - | ||||||||||||||||||||||||||||||
| 2049 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2050 | } else { | - | ||||||||||||||||||||||||||||||
| 2051 | drawImage(r, image, sr); | - | ||||||||||||||||||||||||||||||
| 2052 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2053 | } else { | - | ||||||||||||||||||||||||||||||
| 2054 | QRect clippedSource = sr.toAlignedRect().intersected(pixmap.rect()); | - | ||||||||||||||||||||||||||||||
| 2055 | const QImage image = pd->toImage(clippedSource); | - | ||||||||||||||||||||||||||||||
| 2056 | QRectF translatedSource = sr.translated(-clippedSource.topLeft()); | - | ||||||||||||||||||||||||||||||
| 2057 | if (image.depth() == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 2058 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2059 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2060 | if (s->matrix.type() <= QTransform::TxTranslate
| 0 | ||||||||||||||||||||||||||||||
| 2061 | && r.size() == sr.size()
| 0 | ||||||||||||||||||||||||||||||
| 2062 | && r.size() == pixmap.size()) {
| 0 | ||||||||||||||||||||||||||||||
| 2063 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 2064 | drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2065 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2066 | } else { | - | ||||||||||||||||||||||||||||||
| 2067 | drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), translatedSource); | - | ||||||||||||||||||||||||||||||
| 2068 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2069 | } else { | - | ||||||||||||||||||||||||||||||
| 2070 | drawImage(r, image, translatedSource); | - | ||||||||||||||||||||||||||||||
| 2071 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2072 | } | - | ||||||||||||||||||||||||||||||
| 2073 | } | - | ||||||||||||||||||||||||||||||
| 2074 | - | |||||||||||||||||||||||||||||||
| 2075 | static inline int fast_ceil_positive(const qreal &v) | - | ||||||||||||||||||||||||||||||
| 2076 | { | - | ||||||||||||||||||||||||||||||
| 2077 | const int iv = int(v); | - | ||||||||||||||||||||||||||||||
| 2078 | if (v - iv == 0)
| 0 | ||||||||||||||||||||||||||||||
| 2079 | return iv; never executed: return iv; | 0 | ||||||||||||||||||||||||||||||
| 2080 | else | - | ||||||||||||||||||||||||||||||
| 2081 | return iv + 1; never executed: return iv + 1; | 0 | ||||||||||||||||||||||||||||||
| 2082 | } | - | ||||||||||||||||||||||||||||||
| 2083 | - | |||||||||||||||||||||||||||||||
| 2084 | static inline const QRect toAlignedRect_positive(const QRectF &rect) | - | ||||||||||||||||||||||||||||||
| 2085 | { | - | ||||||||||||||||||||||||||||||
| 2086 | const int xmin = int(rect.x()); | - | ||||||||||||||||||||||||||||||
| 2087 | const int xmax = int(fast_ceil_positive(rect.right())); | - | ||||||||||||||||||||||||||||||
| 2088 | const int ymin = int(rect.y()); | - | ||||||||||||||||||||||||||||||
| 2089 | const int ymax = int(fast_ceil_positive(rect.bottom())); | - | ||||||||||||||||||||||||||||||
| 2090 | return QRect(xmin, ymin, xmax - xmin, ymax - ymin); never executed: return QRect(xmin, ymin, xmax - xmin, ymax - ymin); | 0 | ||||||||||||||||||||||||||||||
| 2091 | } | - | ||||||||||||||||||||||||||||||
| 2092 | - | |||||||||||||||||||||||||||||||
| 2093 | /*! | - | ||||||||||||||||||||||||||||||
| 2094 | \internal | - | ||||||||||||||||||||||||||||||
| 2095 | */ | - | ||||||||||||||||||||||||||||||
| 2096 | void QRasterPaintEngine::drawImage(const QPointF &p, const QImage &img) | - | ||||||||||||||||||||||||||||||
| 2097 | { | - | ||||||||||||||||||||||||||||||
| 2098 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 2099 | qDebug() << " - QRasterPaintEngine::drawImage(), p=" << p << " image=" << img.size() << "depth=" << img.depth(); | - | ||||||||||||||||||||||||||||||
| 2100 | #endif | - | ||||||||||||||||||||||||||||||
| 2101 | - | |||||||||||||||||||||||||||||||
| 2102 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2103 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2104 | qreal scale = img.devicePixelRatio(); | - | ||||||||||||||||||||||||||||||
| 2105 | - | |||||||||||||||||||||||||||||||
| 2106 | if (scale > 1.0 || s->matrix.type() > QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 2107 | drawImage(QRectF(p.x(), p.y(), img.width() / scale, img.height() / scale), | - | ||||||||||||||||||||||||||||||
| 2108 | img, | - | ||||||||||||||||||||||||||||||
| 2109 | QRectF(0, 0, img.width(), img.height())); | - | ||||||||||||||||||||||||||||||
| 2110 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2111 | - | |||||||||||||||||||||||||||||||
| 2112 | const QClipData *clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 2113 | QPointF pt(p.x() + s->matrix.dx(), p.y() + s->matrix.dy()); | - | ||||||||||||||||||||||||||||||
| 2114 | - | |||||||||||||||||||||||||||||||
| 2115 | if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) {
| 0 | ||||||||||||||||||||||||||||||
| 2116 | SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; | - | ||||||||||||||||||||||||||||||
| 2117 | if (func) {
| 0 | ||||||||||||||||||||||||||||||
| 2118 | if (!clip) {
| 0 | ||||||||||||||||||||||||||||||
| 2119 | d->drawImage(pt, img, func, d->deviceRect, s->intOpacity); | - | ||||||||||||||||||||||||||||||
| 2120 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2121 | } else if (clip->hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 2122 | d->drawImage(pt, img, func, clip->clipRect, s->intOpacity); | - | ||||||||||||||||||||||||||||||
| 2123 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2124 | } | - | ||||||||||||||||||||||||||||||
| 2125 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2126 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2127 | - | |||||||||||||||||||||||||||||||
| 2128 | - | |||||||||||||||||||||||||||||||
| 2129 | - | |||||||||||||||||||||||||||||||
| 2130 | d->image_filler.clip = clip; | - | ||||||||||||||||||||||||||||||
| 2131 | d->image_filler.initTexture(&img, s->intOpacity, QTextureData::Plain, img.rect()); | - | ||||||||||||||||||||||||||||||
| 2132 | if (!d->image_filler.blend)
| 0 | ||||||||||||||||||||||||||||||
| 2133 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2134 | d->image_filler.dx = -pt.x(); | - | ||||||||||||||||||||||||||||||
| 2135 | d->image_filler.dy = -pt.y(); | - | ||||||||||||||||||||||||||||||
| 2136 | QRect rr = img.rect().translated(qRound(pt.x()), qRound(pt.y())); | - | ||||||||||||||||||||||||||||||
| 2137 | - | |||||||||||||||||||||||||||||||
| 2138 | fillRect_normalized(rr, &d->image_filler, d); | - | ||||||||||||||||||||||||||||||
| 2139 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2140 | - | |||||||||||||||||||||||||||||||
| 2141 | } | - | ||||||||||||||||||||||||||||||
| 2142 | - | |||||||||||||||||||||||||||||||
| 2143 | QRectF qt_mapRect_non_normalizing(const QRectF &r, const QTransform &t) | - | ||||||||||||||||||||||||||||||
| 2144 | { | - | ||||||||||||||||||||||||||||||
| 2145 | return QRectF(r.topLeft() * t, r.bottomRight() * t); never executed: return QRectF(r.topLeft() * t, r.bottomRight() * t); | 0 | ||||||||||||||||||||||||||||||
| 2146 | } | - | ||||||||||||||||||||||||||||||
| 2147 | - | |||||||||||||||||||||||||||||||
| 2148 | namespace { | - | ||||||||||||||||||||||||||||||
| 2149 | enum RotationType { | - | ||||||||||||||||||||||||||||||
| 2150 | Rotation90, | - | ||||||||||||||||||||||||||||||
| 2151 | Rotation180, | - | ||||||||||||||||||||||||||||||
| 2152 | Rotation270, | - | ||||||||||||||||||||||||||||||
| 2153 | NoRotation | - | ||||||||||||||||||||||||||||||
| 2154 | }; | - | ||||||||||||||||||||||||||||||
| 2155 | - | |||||||||||||||||||||||||||||||
| 2156 | inline RotationType qRotationType(const QTransform &transform) | - | ||||||||||||||||||||||||||||||
| 2157 | { | - | ||||||||||||||||||||||||||||||
| 2158 | QTransform::TransformationType type = transform.type(); | - | ||||||||||||||||||||||||||||||
| 2159 | - | |||||||||||||||||||||||||||||||
| 2160 | if (type > QTransform::TxRotate)
| 0 | ||||||||||||||||||||||||||||||
| 2161 | return NoRotation; never executed: return NoRotation; | 0 | ||||||||||||||||||||||||||||||
| 2162 | - | |||||||||||||||||||||||||||||||
| 2163 | if (type == QTransform::TxRotate && qFuzzyIsNull(transform.m11()) && qFuzzyCompare(transform.m12(), qreal(-1))
| 0 | ||||||||||||||||||||||||||||||
| 2164 | && qFuzzyCompare(transform.m21(), qreal(1)) && qFuzzyIsNull(transform.m22()))
| 0 | ||||||||||||||||||||||||||||||
| 2165 | return Rotation90; never executed: return Rotation90; | 0 | ||||||||||||||||||||||||||||||
| 2166 | - | |||||||||||||||||||||||||||||||
| 2167 | if (type == QTransform::TxScale && qFuzzyCompare(transform.m11(), qreal(-1)) && qFuzzyIsNull(transform.m12())
| 0 | ||||||||||||||||||||||||||||||
| 2168 | && qFuzzyIsNull(transform.m21()) && qFuzzyCompare(transform.m22(), qreal(-1)))
| 0 | ||||||||||||||||||||||||||||||
| 2169 | return Rotation180; never executed: return Rotation180; | 0 | ||||||||||||||||||||||||||||||
| 2170 | - | |||||||||||||||||||||||||||||||
| 2171 | if (type == QTransform::TxRotate && qFuzzyIsNull(transform.m11()) && qFuzzyCompare(transform.m12(), qreal(1))
| 0 | ||||||||||||||||||||||||||||||
| 2172 | && qFuzzyCompare(transform.m21(), qreal(-1)) && qFuzzyIsNull(transform.m22()))
| 0 | ||||||||||||||||||||||||||||||
| 2173 | return Rotation270; never executed: return Rotation270; | 0 | ||||||||||||||||||||||||||||||
| 2174 | - | |||||||||||||||||||||||||||||||
| 2175 | return NoRotation; never executed: return NoRotation; | 0 | ||||||||||||||||||||||||||||||
| 2176 | } | - | ||||||||||||||||||||||||||||||
| 2177 | - | |||||||||||||||||||||||||||||||
| 2178 | inline bool isPixelAligned(const QRectF &rect) { | - | ||||||||||||||||||||||||||||||
| 2179 | return QRectF(rect.toRect()) == rect; never executed: return QRectF(rect.toRect()) == rect; | 0 | ||||||||||||||||||||||||||||||
| 2180 | } | - | ||||||||||||||||||||||||||||||
| 2181 | } | - | ||||||||||||||||||||||||||||||
| 2182 | - | |||||||||||||||||||||||||||||||
| 2183 | /*! | - | ||||||||||||||||||||||||||||||
| 2184 | \reimp | - | ||||||||||||||||||||||||||||||
| 2185 | */ | - | ||||||||||||||||||||||||||||||
| 2186 | void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRectF &sr, | - | ||||||||||||||||||||||||||||||
| 2187 | Qt::ImageConversionFlags) | - | ||||||||||||||||||||||||||||||
| 2188 | { | - | ||||||||||||||||||||||||||||||
| 2189 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 2190 | qDebug() << " - QRasterPaintEngine::drawImage(), r=" << r << " sr=" << sr << " image=" << img.size() << "depth=" << img.depth(); | - | ||||||||||||||||||||||||||||||
| 2191 | #endif | - | ||||||||||||||||||||||||||||||
| 2192 | - | |||||||||||||||||||||||||||||||
| 2193 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||
| 2194 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2195 | - | |||||||||||||||||||||||||||||||
| 2196 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2197 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2198 | Q_ASSERT(s); | - | ||||||||||||||||||||||||||||||
| 2199 | int sr_l = qFloor(sr.left()); | - | ||||||||||||||||||||||||||||||
| 2200 | int sr_r = qCeil(sr.right()) - 1; | - | ||||||||||||||||||||||||||||||
| 2201 | int sr_t = qFloor(sr.top()); | - | ||||||||||||||||||||||||||||||
| 2202 | int sr_b = qCeil(sr.bottom()) - 1; | - | ||||||||||||||||||||||||||||||
| 2203 | - | |||||||||||||||||||||||||||||||
| 2204 | if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) {
| 0 | ||||||||||||||||||||||||||||||
| 2205 | // as fillRect will apply the aliased coordinate delta we need to | - | ||||||||||||||||||||||||||||||
| 2206 | // subtract it here as we don't use it for image drawing | - | ||||||||||||||||||||||||||||||
| 2207 | QTransform old = s->matrix; | - | ||||||||||||||||||||||||||||||
| 2208 | - | |||||||||||||||||||||||||||||||
| 2209 | if (s->flags.legacy_rounding)
| 0 | ||||||||||||||||||||||||||||||
| 2210 | s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); never executed: s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); | 0 | ||||||||||||||||||||||||||||||
| 2211 | - | |||||||||||||||||||||||||||||||
| 2212 | // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied. | - | ||||||||||||||||||||||||||||||
| 2213 | QRgb color = img.pixel(sr_l, sr_t); | - | ||||||||||||||||||||||||||||||
| 2214 | switch (img.format()) { | - | ||||||||||||||||||||||||||||||
| 2215 | case QImage::Format_ARGB32_Premultiplied: never executed: case QImage::Format_ARGB32_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2216 | case QImage::Format_ARGB8565_Premultiplied: never executed: case QImage::Format_ARGB8565_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2217 | case QImage::Format_ARGB6666_Premultiplied: never executed: case QImage::Format_ARGB6666_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2218 | case QImage::Format_ARGB8555_Premultiplied: never executed: case QImage::Format_ARGB8555_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2219 | case QImage::Format_ARGB4444_Premultiplied: never executed: case QImage::Format_ARGB4444_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2220 | case QImage::Format_RGBA8888_Premultiplied: never executed: case QImage::Format_RGBA8888_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2221 | case QImage::Format_A2BGR30_Premultiplied: never executed: case QImage::Format_A2BGR30_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2222 | case QImage::Format_A2RGB30_Premultiplied: never executed: case QImage::Format_A2RGB30_Premultiplied: | 0 | ||||||||||||||||||||||||||||||
| 2223 | // Combine premultiplied color with the opacity set on the painter. | - | ||||||||||||||||||||||||||||||
| 2224 | d->solid_color_filler.solid.color = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity); | - | ||||||||||||||||||||||||||||||
| 2225 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2226 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 2227 | d->solid_color_filler.solid.color = qPremultiply(combineAlpha256(QRgba64::fromArgb32(color), s->intOpacity)); | - | ||||||||||||||||||||||||||||||
| 2228 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2229 | } | - | ||||||||||||||||||||||||||||||
| 2230 | - | |||||||||||||||||||||||||||||||
| 2231 | if (d->solid_color_filler.solid.color.isTransparent() && s->composition_mode == QPainter::CompositionMode_SourceOver)
| 0 | ||||||||||||||||||||||||||||||
| 2232 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2233 | - | |||||||||||||||||||||||||||||||
| 2234 | d->solid_color_filler.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 2235 | d->solid_color_filler.adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 2236 | fillRect(r, &d->solid_color_filler); | - | ||||||||||||||||||||||||||||||
| 2237 | - | |||||||||||||||||||||||||||||||
| 2238 | s->matrix = old; | - | ||||||||||||||||||||||||||||||
| 2239 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2240 | } | - | ||||||||||||||||||||||||||||||
| 2241 | - | |||||||||||||||||||||||||||||||
| 2242 | bool stretch_sr = r.width() != sr.width() || r.height() != sr.height();
| 0 | ||||||||||||||||||||||||||||||
| 2243 | - | |||||||||||||||||||||||||||||||
| 2244 | const QClipData *clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 2245 | - | |||||||||||||||||||||||||||||||
| 2246 | if (s->matrix.type() > QTransform::TxTranslate
| 0 | ||||||||||||||||||||||||||||||
| 2247 | && !stretch_sr
| 0 | ||||||||||||||||||||||||||||||
| 2248 | && (!clip || clip->hasRectClip)
| 0 | ||||||||||||||||||||||||||||||
| 2249 | && s->intOpacity == 256
| 0 | ||||||||||||||||||||||||||||||
| 2250 | && (d->rasterBuffer->compositionMode == QPainter::CompositionMode_SourceOver
| 0 | ||||||||||||||||||||||||||||||
| 2251 | || d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source)
| 0 | ||||||||||||||||||||||||||||||
| 2252 | && d->rasterBuffer->format == img.format()
| 0 | ||||||||||||||||||||||||||||||
| 2253 | && (d->rasterBuffer->format == QImage::Format_RGB16
| 0 | ||||||||||||||||||||||||||||||
| 2254 | || d->rasterBuffer->format == QImage::Format_RGB32
| 0 | ||||||||||||||||||||||||||||||
| 2255 | || (d->rasterBuffer->format == QImage::Format_ARGB32_Premultiplied
| 0 | ||||||||||||||||||||||||||||||
| 2256 | && d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source)))
| 0 | ||||||||||||||||||||||||||||||
| 2257 | { | - | ||||||||||||||||||||||||||||||
| 2258 | RotationType rotationType = qRotationType(s->matrix); | - | ||||||||||||||||||||||||||||||
| 2259 | - | |||||||||||||||||||||||||||||||
| 2260 | if (rotationType != NoRotation && qMemRotateFunctions[d->rasterBuffer->format][rotationType] && img.rect().contains(sr.toAlignedRect())) {
| 0 | ||||||||||||||||||||||||||||||
| 2261 | QRectF transformedTargetRect = s->matrix.mapRect(r); | - | ||||||||||||||||||||||||||||||
| 2262 | - | |||||||||||||||||||||||||||||||
| 2263 | if ((!(s->renderHints & QPainter::SmoothPixmapTransform) && !(s->renderHints & QPainter::Antialiasing))
| 0 | ||||||||||||||||||||||||||||||
| 2264 | || (isPixelAligned(transformedTargetRect) && isPixelAligned(sr)))
| 0 | ||||||||||||||||||||||||||||||
| 2265 | { | - | ||||||||||||||||||||||||||||||
| 2266 | QRect clippedTransformedTargetRect = transformedTargetRect.toRect().intersected(clip ? clip->clipRect : d->deviceRect); | - | ||||||||||||||||||||||||||||||
| 2267 | if (clippedTransformedTargetRect.isNull())
| 0 | ||||||||||||||||||||||||||||||
| 2268 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2269 | - | |||||||||||||||||||||||||||||||
| 2270 | QRectF clippedTargetRect = s->matrix.inverted().mapRect(QRectF(clippedTransformedTargetRect)); | - | ||||||||||||||||||||||||||||||
| 2271 | - | |||||||||||||||||||||||||||||||
| 2272 | QRect clippedSourceRect | - | ||||||||||||||||||||||||||||||
| 2273 | = QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(), | - | ||||||||||||||||||||||||||||||
| 2274 | clippedTargetRect.width(), clippedTargetRect.height()).toRect(); | - | ||||||||||||||||||||||||||||||
| 2275 | - | |||||||||||||||||||||||||||||||
| 2276 | clippedSourceRect = clippedSourceRect.intersected(img.rect()); | - | ||||||||||||||||||||||||||||||
| 2277 | - | |||||||||||||||||||||||||||||||
| 2278 | uint dbpl = d->rasterBuffer->bytesPerLine(); | - | ||||||||||||||||||||||||||||||
| 2279 | uint sbpl = img.bytesPerLine(); | - | ||||||||||||||||||||||||||||||
| 2280 | - | |||||||||||||||||||||||||||||||
| 2281 | uchar *dst = d->rasterBuffer->buffer(); | - | ||||||||||||||||||||||||||||||
| 2282 | uint bpp = img.depth() >> 3; | - | ||||||||||||||||||||||||||||||
| 2283 | - | |||||||||||||||||||||||||||||||
| 2284 | const uchar *srcBase = img.bits() + clippedSourceRect.y() * sbpl + clippedSourceRect.x() * bpp; | - | ||||||||||||||||||||||||||||||
| 2285 | uchar *dstBase = dst + clippedTransformedTargetRect.y() * dbpl + clippedTransformedTargetRect.x() * bpp; | - | ||||||||||||||||||||||||||||||
| 2286 | - | |||||||||||||||||||||||||||||||
| 2287 | uint cw = clippedSourceRect.width(); | - | ||||||||||||||||||||||||||||||
| 2288 | uint ch = clippedSourceRect.height(); | - | ||||||||||||||||||||||||||||||
| 2289 | - | |||||||||||||||||||||||||||||||
| 2290 | qMemRotateFunctions[d->rasterBuffer->format][rotationType](srcBase, cw, ch, sbpl, dstBase, dbpl); | - | ||||||||||||||||||||||||||||||
| 2291 | - | |||||||||||||||||||||||||||||||
| 2292 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2293 | } | - | ||||||||||||||||||||||||||||||
| 2294 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2295 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2296 | - | |||||||||||||||||||||||||||||||
| 2297 | if (s->matrix.type() > QTransform::TxTranslate || stretch_sr) {
| 0 | ||||||||||||||||||||||||||||||
| 2298 | - | |||||||||||||||||||||||||||||||
| 2299 | QRectF targetBounds = s->matrix.mapRect(r); | - | ||||||||||||||||||||||||||||||
| 2300 | bool exceedsPrecision = targetBounds.width() > 0xffff
| 0 | ||||||||||||||||||||||||||||||
| 2301 | || targetBounds.height() > 0xffff;
| 0 | ||||||||||||||||||||||||||||||
| 2302 | - | |||||||||||||||||||||||||||||||
| 2303 | if (!exceedsPrecision && d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) {
| 0 | ||||||||||||||||||||||||||||||
| 2304 | if (s->matrix.type() > QTransform::TxScale) {
| 0 | ||||||||||||||||||||||||||||||
| 2305 | SrcOverTransformFunc func = qTransformFunctions[d->rasterBuffer->format][img.format()]; | - | ||||||||||||||||||||||||||||||
| 2306 | if (func && (!clip || clip->hasRectClip)) {
| 0 | ||||||||||||||||||||||||||||||
| 2307 | func(d->rasterBuffer->buffer(), d->rasterBuffer->bytesPerLine(), img.bits(), | - | ||||||||||||||||||||||||||||||
| 2308 | img.bytesPerLine(), r, sr, !clip ? d->deviceRect : clip->clipRect, | - | ||||||||||||||||||||||||||||||
| 2309 | s->matrix, s->intOpacity); | - | ||||||||||||||||||||||||||||||
| 2310 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2311 | } | - | ||||||||||||||||||||||||||||||
| 2312 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2313 | // Test for optimized high-dpi case: 2x source on 2x target. (Could be generalized to nX.) | - | ||||||||||||||||||||||||||||||
| 2314 | bool sourceRect2x = r.width() * 2 == sr.width() && r.height() * 2 == sr.height();
| 0 | ||||||||||||||||||||||||||||||
| 2315 | bool scale2x = (s->matrix.m11() == qreal(2)) && (s->matrix.m22() == qreal(2));
| 0 | ||||||||||||||||||||||||||||||
| 2316 | if (s->matrix.type() == QTransform::TxScale && sourceRect2x && scale2x) {
| 0 | ||||||||||||||||||||||||||||||
| 2317 | SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; | - | ||||||||||||||||||||||||||||||
| 2318 | if (func) {
| 0 | ||||||||||||||||||||||||||||||
| 2319 | QPointF pt(r.x() * 2 + s->matrix.dx(), r.y() * 2 + s->matrix.dy()); | - | ||||||||||||||||||||||||||||||
| 2320 | if (!clip) {
| 0 | ||||||||||||||||||||||||||||||
| 2321 | d->drawImage(pt, img, func, d->deviceRect, s->intOpacity, sr.toRect()); | - | ||||||||||||||||||||||||||||||
| 2322 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2323 | } else if (clip->hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 2324 | d->drawImage(pt, img, func, clip->clipRect, s->intOpacity, sr.toRect()); | - | ||||||||||||||||||||||||||||||
| 2325 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2326 | } | - | ||||||||||||||||||||||||||||||
| 2327 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2328 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2329 | SrcOverScaleFunc func = qScaleFunctions[d->rasterBuffer->format][img.format()]; | - | ||||||||||||||||||||||||||||||
| 2330 | if (func && (!clip || clip->hasRectClip)) {
| 0 | ||||||||||||||||||||||||||||||
| 2331 | func(d->rasterBuffer->buffer(), d->rasterBuffer->bytesPerLine(), | - | ||||||||||||||||||||||||||||||
| 2332 | img.bits(), img.bytesPerLine(), img.height(), | - | ||||||||||||||||||||||||||||||
| 2333 | qt_mapRect_non_normalizing(r, s->matrix), sr, | - | ||||||||||||||||||||||||||||||
| 2334 | !clip ? d->deviceRect : clip->clipRect, | - | ||||||||||||||||||||||||||||||
| 2335 | s->intOpacity); | - | ||||||||||||||||||||||||||||||
| 2336 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2337 | } | - | ||||||||||||||||||||||||||||||
| 2338 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2339 | } | - | ||||||||||||||||||||||||||||||
| 2340 | - | |||||||||||||||||||||||||||||||
| 2341 | QTransform copy = s->matrix; | - | ||||||||||||||||||||||||||||||
| 2342 | copy.translate(r.x(), r.y()); | - | ||||||||||||||||||||||||||||||
| 2343 | if (stretch_sr)
| 0 | ||||||||||||||||||||||||||||||
| 2344 | copy.scale(r.width() / sr.width(), r.height() / sr.height()); never executed: copy.scale(r.width() / sr.width(), r.height() / sr.height()); | 0 | ||||||||||||||||||||||||||||||
| 2345 | copy.translate(-sr.x(), -sr.y()); | - | ||||||||||||||||||||||||||||||
| 2346 | - | |||||||||||||||||||||||||||||||
| 2347 | d->image_filler_xform.clip = clip; | - | ||||||||||||||||||||||||||||||
| 2348 | d->image_filler_xform.initTexture(&img, s->intOpacity, QTextureData::Plain, toAlignedRect_positive(sr)); | - | ||||||||||||||||||||||||||||||
| 2349 | if (!d->image_filler_xform.blend)
| 0 | ||||||||||||||||||||||||||||||
| 2350 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2351 | d->image_filler_xform.setupMatrix(copy, s->flags.bilinear); | - | ||||||||||||||||||||||||||||||
| 2352 | - | |||||||||||||||||||||||||||||||
| 2353 | if (!s->flags.antialiased && s->matrix.type() == QTransform::TxScale) {
| 0 | ||||||||||||||||||||||||||||||
| 2354 | QRectF rr = s->matrix.mapRect(r); | - | ||||||||||||||||||||||||||||||
| 2355 | - | |||||||||||||||||||||||||||||||
| 2356 | const int x1 = qRound(rr.x()); | - | ||||||||||||||||||||||||||||||
| 2357 | const int y1 = qRound(rr.y()); | - | ||||||||||||||||||||||||||||||
| 2358 | const int x2 = qRound(rr.right()); | - | ||||||||||||||||||||||||||||||
| 2359 | const int y2 = qRound(rr.bottom()); | - | ||||||||||||||||||||||||||||||
| 2360 | - | |||||||||||||||||||||||||||||||
| 2361 | fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler_xform, d); | - | ||||||||||||||||||||||||||||||
| 2362 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2363 | } | - | ||||||||||||||||||||||||||||||
| 2364 | - | |||||||||||||||||||||||||||||||
| 2365 | #ifdef QT_FAST_SPANS | - | ||||||||||||||||||||||||||||||
| 2366 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 2367 | if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) {
| 0 | ||||||||||||||||||||||||||||||
| 2368 | d->initializeRasterizer(&d->image_filler_xform); | - | ||||||||||||||||||||||||||||||
| 2369 | d->rasterizer->setAntialiased(s->flags.antialiased); | - | ||||||||||||||||||||||||||||||
| 2370 | d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 2371 | - | |||||||||||||||||||||||||||||||
| 2372 | const QPointF offs = s->flags.legacy_rounding ? QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta) : QPointF();
| 0 | ||||||||||||||||||||||||||||||
| 2373 | - | |||||||||||||||||||||||||||||||
| 2374 | const QRectF &rect = r.normalized(); | - | ||||||||||||||||||||||||||||||
| 2375 | const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs; | - | ||||||||||||||||||||||||||||||
| 2376 | const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f) - offs; | - | ||||||||||||||||||||||||||||||
| 2377 | - | |||||||||||||||||||||||||||||||
| 2378 | if (s->flags.tx_noshear)
| 0 | ||||||||||||||||||||||||||||||
| 2379 | d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); never executed: d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); | 0 | ||||||||||||||||||||||||||||||
| 2380 | else | - | ||||||||||||||||||||||||||||||
| 2381 | d->rasterizer->rasterizeLine(a, b, qAbs((s->matrix.m22() * rect.height()) / (s->matrix.m11() * rect.width()))); never executed: d->rasterizer->rasterizeLine(a, b, qAbs((s->matrix.m22() * rect.height()) / (s->matrix.m11() * rect.width()))); | 0 | ||||||||||||||||||||||||||||||
| 2382 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2383 | } | - | ||||||||||||||||||||||||||||||
| 2384 | #endif | - | ||||||||||||||||||||||||||||||
| 2385 | const qreal offs = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0);
| 0 | ||||||||||||||||||||||||||||||
| 2386 | QPainterPath path; | - | ||||||||||||||||||||||||||||||
| 2387 | path.addRect(r); | - | ||||||||||||||||||||||||||||||
| 2388 | QTransform m = s->matrix; | - | ||||||||||||||||||||||||||||||
| 2389 | s->matrix = QTransform(m.m11(), m.m12(), m.m13(), | - | ||||||||||||||||||||||||||||||
| 2390 | m.m21(), m.m22(), m.m23(), | - | ||||||||||||||||||||||||||||||
| 2391 | m.m31() - offs, m.m32() - offs, m.m33()); | - | ||||||||||||||||||||||||||||||
| 2392 | fillPath(path, &d->image_filler_xform); | - | ||||||||||||||||||||||||||||||
| 2393 | s->matrix = m; | - | ||||||||||||||||||||||||||||||
| 2394 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2395 | if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) {
| 0 | ||||||||||||||||||||||||||||||
| 2396 | SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; | - | ||||||||||||||||||||||||||||||
| 2397 | if (func) {
| 0 | ||||||||||||||||||||||||||||||
| 2398 | QPointF pt(r.x() + s->matrix.dx(), r.y() + s->matrix.dy()); | - | ||||||||||||||||||||||||||||||
| 2399 | if (!clip) {
| 0 | ||||||||||||||||||||||||||||||
| 2400 | d->drawImage(pt, img, func, d->deviceRect, s->intOpacity, sr.toRect()); | - | ||||||||||||||||||||||||||||||
| 2401 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2402 | } else if (clip->hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 2403 | d->drawImage(pt, img, func, clip->clipRect, s->intOpacity, sr.toRect()); | - | ||||||||||||||||||||||||||||||
| 2404 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2405 | } | - | ||||||||||||||||||||||||||||||
| 2406 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2407 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2408 | - | |||||||||||||||||||||||||||||||
| 2409 | d->image_filler.clip = clip; | - | ||||||||||||||||||||||||||||||
| 2410 | d->image_filler.initTexture(&img, s->intOpacity, QTextureData::Plain, toAlignedRect_positive(sr)); | - | ||||||||||||||||||||||||||||||
| 2411 | if (!d->image_filler.blend)
| 0 | ||||||||||||||||||||||||||||||
| 2412 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2413 | d->image_filler.dx = -(r.x() + s->matrix.dx()) + sr.x(); | - | ||||||||||||||||||||||||||||||
| 2414 | d->image_filler.dy = -(r.y() + s->matrix.dy()) + sr.y(); | - | ||||||||||||||||||||||||||||||
| 2415 | - | |||||||||||||||||||||||||||||||
| 2416 | QRectF rr = r; | - | ||||||||||||||||||||||||||||||
| 2417 | rr.translate(s->matrix.dx(), s->matrix.dy()); | - | ||||||||||||||||||||||||||||||
| 2418 | - | |||||||||||||||||||||||||||||||
| 2419 | const int x1 = qRound(rr.x()); | - | ||||||||||||||||||||||||||||||
| 2420 | const int y1 = qRound(rr.y()); | - | ||||||||||||||||||||||||||||||
| 2421 | const int x2 = qRound(rr.right()); | - | ||||||||||||||||||||||||||||||
| 2422 | const int y2 = qRound(rr.bottom()); | - | ||||||||||||||||||||||||||||||
| 2423 | - | |||||||||||||||||||||||||||||||
| 2424 | fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler, d); | - | ||||||||||||||||||||||||||||||
| 2425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2426 | } | - | ||||||||||||||||||||||||||||||
| 2427 | - | |||||||||||||||||||||||||||||||
| 2428 | /*! | - | ||||||||||||||||||||||||||||||
| 2429 | \reimp | - | ||||||||||||||||||||||||||||||
| 2430 | */ | - | ||||||||||||||||||||||||||||||
| 2431 | void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &sr) | - | ||||||||||||||||||||||||||||||
| 2432 | { | - | ||||||||||||||||||||||||||||||
| 2433 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 2434 | qDebug() << " - QRasterPaintEngine::drawTiledPixmap(), r=" << r << "pixmap=" << pixmap.size(); | - | ||||||||||||||||||||||||||||||
| 2435 | #endif | - | ||||||||||||||||||||||||||||||
| 2436 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2437 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2438 | Q_ASSERT(s); | - | ||||||||||||||||||||||||||||||
| 2439 | - | |||||||||||||||||||||||||||||||
| 2440 | QImage image; | - | ||||||||||||||||||||||||||||||
| 2441 | - | |||||||||||||||||||||||||||||||
| 2442 | QPlatformPixmap *pd = pixmap.handle(); | - | ||||||||||||||||||||||||||||||
| 2443 | if (pd->classId() == QPlatformPixmap::RasterClass) {
| 0 | ||||||||||||||||||||||||||||||
| 2444 | image = static_cast<QRasterPlatformPixmap *>(pd)->image; | - | ||||||||||||||||||||||||||||||
| 2445 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2446 | image = pixmap.toImage(); | - | ||||||||||||||||||||||||||||||
| 2447 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2448 | - | |||||||||||||||||||||||||||||||
| 2449 | if (image.depth() == 1)
| 0 | ||||||||||||||||||||||||||||||
| 2450 | image = d->rasterBuffer->colorizeBitmap(image, s->pen.color()); never executed: image = d->rasterBuffer->colorizeBitmap(image, s->pen.color()); | 0 | ||||||||||||||||||||||||||||||
| 2451 | - | |||||||||||||||||||||||||||||||
| 2452 | if (s->matrix.type() > QTransform::TxTranslate) {
| 0 | ||||||||||||||||||||||||||||||
| 2453 | QTransform copy = s->matrix; | - | ||||||||||||||||||||||||||||||
| 2454 | copy.translate(r.x(), r.y()); | - | ||||||||||||||||||||||||||||||
| 2455 | copy.translate(-sr.x(), -sr.y()); | - | ||||||||||||||||||||||||||||||
| 2456 | d->image_filler_xform.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 2457 | d->image_filler_xform.initTexture(&image, s->intOpacity, QTextureData::Tiled); | - | ||||||||||||||||||||||||||||||
| 2458 | if (!d->image_filler_xform.blend)
| 0 | ||||||||||||||||||||||||||||||
| 2459 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2460 | d->image_filler_xform.setupMatrix(copy, s->flags.bilinear); | - | ||||||||||||||||||||||||||||||
| 2461 | - | |||||||||||||||||||||||||||||||
| 2462 | #ifdef QT_FAST_SPANS | - | ||||||||||||||||||||||||||||||
| 2463 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 2464 | if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) {
| 0 | ||||||||||||||||||||||||||||||
| 2465 | d->initializeRasterizer(&d->image_filler_xform); | - | ||||||||||||||||||||||||||||||
| 2466 | d->rasterizer->setAntialiased(s->flags.antialiased); | - | ||||||||||||||||||||||||||||||
| 2467 | d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 2468 | - | |||||||||||||||||||||||||||||||
| 2469 | const QRectF &rect = r.normalized(); | - | ||||||||||||||||||||||||||||||
| 2470 | const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 2471 | const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f); | - | ||||||||||||||||||||||||||||||
| 2472 | if (s->flags.tx_noshear)
| 0 | ||||||||||||||||||||||||||||||
| 2473 | d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); never executed: d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); | 0 | ||||||||||||||||||||||||||||||
| 2474 | else | - | ||||||||||||||||||||||||||||||
| 2475 | d->rasterizer->rasterizeLine(a, b, qAbs((s->matrix.m22() * rect.height()) / (s->matrix.m11() * rect.width()))); never executed: d->rasterizer->rasterizeLine(a, b, qAbs((s->matrix.m22() * rect.height()) / (s->matrix.m11() * rect.width()))); | 0 | ||||||||||||||||||||||||||||||
| 2476 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2477 | } | - | ||||||||||||||||||||||||||||||
| 2478 | #endif | - | ||||||||||||||||||||||||||||||
| 2479 | QPainterPath path; | - | ||||||||||||||||||||||||||||||
| 2480 | path.addRect(r); | - | ||||||||||||||||||||||||||||||
| 2481 | fillPath(path, &d->image_filler_xform); | - | ||||||||||||||||||||||||||||||
| 2482 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2483 | d->image_filler.clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 2484 | - | |||||||||||||||||||||||||||||||
| 2485 | d->image_filler.initTexture(&image, s->intOpacity, QTextureData::Tiled); | - | ||||||||||||||||||||||||||||||
| 2486 | if (!d->image_filler.blend)
| 0 | ||||||||||||||||||||||||||||||
| 2487 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2488 | d->image_filler.dx = -(r.x() + s->matrix.dx()) + sr.x(); | - | ||||||||||||||||||||||||||||||
| 2489 | d->image_filler.dy = -(r.y() + s->matrix.dy()) + sr.y(); | - | ||||||||||||||||||||||||||||||
| 2490 | - | |||||||||||||||||||||||||||||||
| 2491 | QRectF rr = r; | - | ||||||||||||||||||||||||||||||
| 2492 | rr.translate(s->matrix.dx(), s->matrix.dy()); | - | ||||||||||||||||||||||||||||||
| 2493 | fillRect_normalized(rr.toRect().normalized(), &d->image_filler, d); | - | ||||||||||||||||||||||||||||||
| 2494 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2495 | } | - | ||||||||||||||||||||||||||||||
| 2496 | - | |||||||||||||||||||||||||||||||
| 2497 | - | |||||||||||||||||||||||||||||||
| 2498 | //QWS hack | - | ||||||||||||||||||||||||||||||
| 2499 | static inline bool monoVal(const uchar* s, int x) | - | ||||||||||||||||||||||||||||||
| 2500 | { | - | ||||||||||||||||||||||||||||||
| 2501 | return (s[x>>3] << (x&7)) & 0x80; never executed: return (s[x>>3] << (x&7)) & 0x80; | 0 | ||||||||||||||||||||||||||||||
| 2502 | } | - | ||||||||||||||||||||||||||||||
| 2503 | - | |||||||||||||||||||||||||||||||
| 2504 | /*! | - | ||||||||||||||||||||||||||||||
| 2505 | \internal | - | ||||||||||||||||||||||||||||||
| 2506 | */ | - | ||||||||||||||||||||||||||||||
| 2507 | QRasterBuffer *QRasterPaintEngine::rasterBuffer() | - | ||||||||||||||||||||||||||||||
| 2508 | { | - | ||||||||||||||||||||||||||||||
| 2509 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2510 | return d->rasterBuffer.data(); never executed: return d->rasterBuffer.data(); | 0 | ||||||||||||||||||||||||||||||
| 2511 | } | - | ||||||||||||||||||||||||||||||
| 2512 | - | |||||||||||||||||||||||||||||||
| 2513 | /*! | - | ||||||||||||||||||||||||||||||
| 2514 | \internal | - | ||||||||||||||||||||||||||||||
| 2515 | */ | - | ||||||||||||||||||||||||||||||
| 2516 | void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx,int ry,int w,int h) | - | ||||||||||||||||||||||||||||||
| 2517 | { | - | ||||||||||||||||||||||||||||||
| 2518 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2519 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2520 | - | |||||||||||||||||||||||||||||||
| 2521 | if (!s->penData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 2522 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2523 | - | |||||||||||||||||||||||||||||||
| 2524 | QRasterBuffer *rb = d->rasterBuffer.data(); | - | ||||||||||||||||||||||||||||||
| 2525 | - | |||||||||||||||||||||||||||||||
| 2526 | const QRect rect(rx, ry, w, h); | - | ||||||||||||||||||||||||||||||
| 2527 | const QClipData *clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 2528 | bool unclipped = false; | - | ||||||||||||||||||||||||||||||
| 2529 | if (clip) {
| 0 | ||||||||||||||||||||||||||||||
| 2530 | // inlined QRect::intersects | - | ||||||||||||||||||||||||||||||
| 2531 | const bool intersects = qMax(clip->xmin, rect.left()) <= qMin(clip->xmax - 1, rect.right())
| 0 | ||||||||||||||||||||||||||||||
| 2532 | && qMax(clip->ymin, rect.top()) <= qMin(clip->ymax - 1, rect.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2533 | - | |||||||||||||||||||||||||||||||
| 2534 | if (clip->hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 2535 | unclipped = rx > clip->xmin
| 0 | ||||||||||||||||||||||||||||||
| 2536 | && rx + w < clip->xmax
| 0 | ||||||||||||||||||||||||||||||
| 2537 | && ry > clip->ymin
| 0 | ||||||||||||||||||||||||||||||
| 2538 | && ry + h < clip->ymax;
| 0 | ||||||||||||||||||||||||||||||
| 2539 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2540 | - | |||||||||||||||||||||||||||||||
| 2541 | if (!intersects)
| 0 | ||||||||||||||||||||||||||||||
| 2542 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2543 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2544 | // inlined QRect::intersects | - | ||||||||||||||||||||||||||||||
| 2545 | const bool intersects = qMax(0, rect.left()) <= qMin(rb->width() - 1, rect.right())
| 0 | ||||||||||||||||||||||||||||||
| 2546 | && qMax(0, rect.top()) <= qMin(rb->height() - 1, rect.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2547 | if (!intersects)
| 0 | ||||||||||||||||||||||||||||||
| 2548 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2549 | - | |||||||||||||||||||||||||||||||
| 2550 | // inlined QRect::contains | - | ||||||||||||||||||||||||||||||
| 2551 | const bool contains = rect.left() >= 0 && rect.right() < rb->width()
| 0 | ||||||||||||||||||||||||||||||
| 2552 | && rect.top() >= 0 && rect.bottom() < rb->height();
| 0 | ||||||||||||||||||||||||||||||
| 2553 | - | |||||||||||||||||||||||||||||||
| 2554 | unclipped = contains && d->isUnclipped_normalized(rect);
| 0 | ||||||||||||||||||||||||||||||
| 2555 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||||||||
| 2557 | ProcessSpans blend = unclipped ? s->penData.unclipped_blend : s->penData.blend;
| 0 | ||||||||||||||||||||||||||||||
| 2558 | const uchar * scanline = static_cast<const uchar *>(src); | - | ||||||||||||||||||||||||||||||
| 2559 | - | |||||||||||||||||||||||||||||||
| 2560 | if (s->flags.fast_text) {
| 0 | ||||||||||||||||||||||||||||||
| 2561 | if (unclipped) {
| 0 | ||||||||||||||||||||||||||||||
| 2562 | if (depth == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 2563 | if (s->penData.bitmapBlit) {
| 0 | ||||||||||||||||||||||||||||||
| 2564 | s->penData.bitmapBlit(rb, rx, ry, s->penData.solid.color, | - | ||||||||||||||||||||||||||||||
| 2565 | scanline, w, h, bpl); | - | ||||||||||||||||||||||||||||||
| 2566 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2567 | } | - | ||||||||||||||||||||||||||||||
| 2568 | } else if (depth == 8) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 2569 | if (s->penData.alphamapBlit) {
| 0 | ||||||||||||||||||||||||||||||
| 2570 | s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, | - | ||||||||||||||||||||||||||||||
| 2571 | scanline, w, h, bpl, 0); | - | ||||||||||||||||||||||||||||||
| 2572 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2573 | } | - | ||||||||||||||||||||||||||||||
| 2574 | } else if (depth == 32) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 2575 | // (A)RGB Alpha mask where the alpha component is not used. | - | ||||||||||||||||||||||||||||||
| 2576 | if (s->penData.alphaRGBBlit) {
| 0 | ||||||||||||||||||||||||||||||
| 2577 | s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, | - | ||||||||||||||||||||||||||||||
| 2578 | (const uint *) scanline, w, h, bpl / 4, 0); | - | ||||||||||||||||||||||||||||||
| 2579 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2580 | } | - | ||||||||||||||||||||||||||||||
| 2581 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2582 | } else if (d->deviceDepth == 32 && ((depth == 8 && s->penData.alphamapBlit) || (depth == 32 && s->penData.alphaRGBBlit))) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 2583 | // (A)RGB Alpha mask where the alpha component is not used. | - | ||||||||||||||||||||||||||||||
| 2584 | if (!clip) {
| 0 | ||||||||||||||||||||||||||||||
| 2585 | int nx = qMax(0, rx); | - | ||||||||||||||||||||||||||||||
| 2586 | int ny = qMax(0, ry); | - | ||||||||||||||||||||||||||||||
| 2587 | - | |||||||||||||||||||||||||||||||
| 2588 | // Move scanline pointer to compensate for moved x and y | - | ||||||||||||||||||||||||||||||
| 2589 | int xdiff = nx - rx; | - | ||||||||||||||||||||||||||||||
| 2590 | int ydiff = ny - ry; | - | ||||||||||||||||||||||||||||||
| 2591 | scanline += ydiff * bpl; | - | ||||||||||||||||||||||||||||||
| 2592 | scanline += xdiff * (depth == 32 ? 4 : 1); | - | ||||||||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||||||||
| 2594 | w -= xdiff; | - | ||||||||||||||||||||||||||||||
| 2595 | h -= ydiff; | - | ||||||||||||||||||||||||||||||
| 2596 | - | |||||||||||||||||||||||||||||||
| 2597 | if (nx + w > d->rasterBuffer->width())
| 0 | ||||||||||||||||||||||||||||||
| 2598 | w = d->rasterBuffer->width() - nx; never executed: w = d->rasterBuffer->width() - nx; | 0 | ||||||||||||||||||||||||||||||
| 2599 | if (ny + h > d->rasterBuffer->height())
| 0 | ||||||||||||||||||||||||||||||
| 2600 | h = d->rasterBuffer->height() - ny; never executed: h = d->rasterBuffer->height() - ny; | 0 | ||||||||||||||||||||||||||||||
| 2601 | - | |||||||||||||||||||||||||||||||
| 2602 | rx = nx; | - | ||||||||||||||||||||||||||||||
| 2603 | ry = ny; | - | ||||||||||||||||||||||||||||||
| 2604 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2605 | if (depth == 8)
| 0 | ||||||||||||||||||||||||||||||
| 2606 | s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, never executed: s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, scanline, w, h, bpl, clip); | 0 | ||||||||||||||||||||||||||||||
| 2607 | scanline, w, h, bpl, clip); never executed: s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, scanline, w, h, bpl, clip); | 0 | ||||||||||||||||||||||||||||||
| 2608 | else if (depth == 32)
| 0 | ||||||||||||||||||||||||||||||
| 2609 | s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, never executed: s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, (const uint *) scanline, w, h, bpl / 4, clip); | 0 | ||||||||||||||||||||||||||||||
| 2610 | (const uint *) scanline, w, h, bpl / 4, clip); never executed: s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, (const uint *) scanline, w, h, bpl / 4, clip); | 0 | ||||||||||||||||||||||||||||||
| 2611 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2612 | } | - | ||||||||||||||||||||||||||||||
| 2613 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2614 | - | |||||||||||||||||||||||||||||||
| 2615 | int x0 = 0; | - | ||||||||||||||||||||||||||||||
| 2616 | if (rx < 0) {
| 0 | ||||||||||||||||||||||||||||||
| 2617 | x0 = -rx; | - | ||||||||||||||||||||||||||||||
| 2618 | w -= x0; | - | ||||||||||||||||||||||||||||||
| 2619 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2620 | - | |||||||||||||||||||||||||||||||
| 2621 | int y0 = 0; | - | ||||||||||||||||||||||||||||||
| 2622 | if (ry < 0) {
| 0 | ||||||||||||||||||||||||||||||
| 2623 | y0 = -ry; | - | ||||||||||||||||||||||||||||||
| 2624 | scanline += bpl * y0; | - | ||||||||||||||||||||||||||||||
| 2625 | h -= y0; | - | ||||||||||||||||||||||||||||||
| 2626 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2627 | - | |||||||||||||||||||||||||||||||
| 2628 | w = qMin(w, rb->width() - qMax(0, rx)); | - | ||||||||||||||||||||||||||||||
| 2629 | h = qMin(h, rb->height() - qMax(0, ry)); | - | ||||||||||||||||||||||||||||||
| 2630 | - | |||||||||||||||||||||||||||||||
| 2631 | if (w <= 0 || h <= 0)
| 0 | ||||||||||||||||||||||||||||||
| 2632 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2633 | - | |||||||||||||||||||||||||||||||
| 2634 | const int NSPANS = 256; | - | ||||||||||||||||||||||||||||||
| 2635 | QSpan spans[NSPANS]; | - | ||||||||||||||||||||||||||||||
| 2636 | int current = 0; | - | ||||||||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||||||||
| 2638 | const int x1 = x0 + w; | - | ||||||||||||||||||||||||||||||
| 2639 | const int y1 = y0 + h; | - | ||||||||||||||||||||||||||||||
| 2640 | - | |||||||||||||||||||||||||||||||
| 2641 | if (depth == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 2642 | for (int y = y0; y < y1; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 2643 | for (int x = x0; x < x1; ) {
| 0 | ||||||||||||||||||||||||||||||
| 2644 | if (!monoVal(scanline, x)) {
| 0 | ||||||||||||||||||||||||||||||
| 2645 | ++x; | - | ||||||||||||||||||||||||||||||
| 2646 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 2647 | } | - | ||||||||||||||||||||||||||||||
| 2648 | - | |||||||||||||||||||||||||||||||
| 2649 | if (current == NSPANS) {
| 0 | ||||||||||||||||||||||||||||||
| 2650 | blend(current, spans, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2651 | current = 0; | - | ||||||||||||||||||||||||||||||
| 2652 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2653 | spans[current].x = x + rx; | - | ||||||||||||||||||||||||||||||
| 2654 | spans[current].y = y + ry; | - | ||||||||||||||||||||||||||||||
| 2655 | spans[current].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 2656 | int len = 1; | - | ||||||||||||||||||||||||||||||
| 2657 | ++x; | - | ||||||||||||||||||||||||||||||
| 2658 | // extend span until we find a different one. | - | ||||||||||||||||||||||||||||||
| 2659 | while (x < x1 && monoVal(scanline, x)) {
| 0 | ||||||||||||||||||||||||||||||
| 2660 | ++x; | - | ||||||||||||||||||||||||||||||
| 2661 | ++len; | - | ||||||||||||||||||||||||||||||
| 2662 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2663 | spans[current].len = len; | - | ||||||||||||||||||||||||||||||
| 2664 | ++current; | - | ||||||||||||||||||||||||||||||
| 2665 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2666 | scanline += bpl; | - | ||||||||||||||||||||||||||||||
| 2667 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2668 | } else if (depth == 8) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 2669 | for (int y = y0; y < y1; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 2670 | for (int x = x0; x < x1; ) {
| 0 | ||||||||||||||||||||||||||||||
| 2671 | // Skip those with 0 coverage | - | ||||||||||||||||||||||||||||||
| 2672 | if (scanline[x] == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 2673 | ++x; | - | ||||||||||||||||||||||||||||||
| 2674 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 2675 | } | - | ||||||||||||||||||||||||||||||
| 2676 | - | |||||||||||||||||||||||||||||||
| 2677 | if (current == NSPANS) {
| 0 | ||||||||||||||||||||||||||||||
| 2678 | blend(current, spans, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2679 | current = 0; | - | ||||||||||||||||||||||||||||||
| 2680 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2681 | int coverage = scanline[x]; | - | ||||||||||||||||||||||||||||||
| 2682 | spans[current].x = x + rx; | - | ||||||||||||||||||||||||||||||
| 2683 | spans[current].y = y + ry; | - | ||||||||||||||||||||||||||||||
| 2684 | spans[current].coverage = coverage; | - | ||||||||||||||||||||||||||||||
| 2685 | int len = 1; | - | ||||||||||||||||||||||||||||||
| 2686 | ++x; | - | ||||||||||||||||||||||||||||||
| 2687 | - | |||||||||||||||||||||||||||||||
| 2688 | // extend span until we find a different one. | - | ||||||||||||||||||||||||||||||
| 2689 | while (x < x1 && scanline[x] == coverage) {
| 0 | ||||||||||||||||||||||||||||||
| 2690 | ++x; | - | ||||||||||||||||||||||||||||||
| 2691 | ++len; | - | ||||||||||||||||||||||||||||||
| 2692 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2693 | spans[current].len = len; | - | ||||||||||||||||||||||||||||||
| 2694 | ++current; | - | ||||||||||||||||||||||||||||||
| 2695 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2696 | scanline += bpl; | - | ||||||||||||||||||||||||||||||
| 2697 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2698 | } else { // 32-bit alpha... never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2699 | const uint *sl = (const uint *) scanline; | - | ||||||||||||||||||||||||||||||
| 2700 | for (int y = y0; y < y1; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 2701 | for (int x = x0; x < x1; ) {
| 0 | ||||||||||||||||||||||||||||||
| 2702 | // Skip those with 0 coverage | - | ||||||||||||||||||||||||||||||
| 2703 | if ((sl[x] & 0x00ffffff) == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 2704 | ++x; | - | ||||||||||||||||||||||||||||||
| 2705 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 2706 | } | - | ||||||||||||||||||||||||||||||
| 2707 | - | |||||||||||||||||||||||||||||||
| 2708 | if (current == NSPANS) {
| 0 | ||||||||||||||||||||||||||||||
| 2709 | blend(current, spans, &s->penData); | - | ||||||||||||||||||||||||||||||
| 2710 | current = 0; | - | ||||||||||||||||||||||||||||||
| 2711 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2712 | uint rgbCoverage = sl[x]; | - | ||||||||||||||||||||||||||||||
| 2713 | int coverage = qGreen(rgbCoverage); | - | ||||||||||||||||||||||||||||||
| 2714 | spans[current].x = x + rx; | - | ||||||||||||||||||||||||||||||
| 2715 | spans[current].y = y + ry; | - | ||||||||||||||||||||||||||||||
| 2716 | spans[current].coverage = coverage; | - | ||||||||||||||||||||||||||||||
| 2717 | int len = 1; | - | ||||||||||||||||||||||||||||||
| 2718 | ++x; | - | ||||||||||||||||||||||||||||||
| 2719 | - | |||||||||||||||||||||||||||||||
| 2720 | // extend span until we find a different one. | - | ||||||||||||||||||||||||||||||
| 2721 | while (x < x1 && sl[x] == rgbCoverage) {
| 0 | ||||||||||||||||||||||||||||||
| 2722 | ++x; | - | ||||||||||||||||||||||||||||||
| 2723 | ++len; | - | ||||||||||||||||||||||||||||||
| 2724 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2725 | spans[current].len = len; | - | ||||||||||||||||||||||||||||||
| 2726 | ++current; | - | ||||||||||||||||||||||||||||||
| 2727 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2728 | sl += bpl / sizeof(uint); | - | ||||||||||||||||||||||||||||||
| 2729 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2730 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2731 | // qDebug() << "alphaPenBlt: num spans=" << current | - | ||||||||||||||||||||||||||||||
| 2732 | // << "span:" << spans->x << spans->y << spans->len << spans->coverage; | - | ||||||||||||||||||||||||||||||
| 2733 | // Call span func for current set of spans. | - | ||||||||||||||||||||||||||||||
| 2734 | if (current != 0)
| 0 | ||||||||||||||||||||||||||||||
| 2735 | blend(current, spans, &s->penData); never executed: blend(current, spans, &s->penData); | 0 | ||||||||||||||||||||||||||||||
| 2736 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2737 | - | |||||||||||||||||||||||||||||||
| 2738 | /*! | - | ||||||||||||||||||||||||||||||
| 2739 | \internal | - | ||||||||||||||||||||||||||||||
| 2740 | */ | - | ||||||||||||||||||||||||||||||
| 2741 | bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, | - | ||||||||||||||||||||||||||||||
| 2742 | const QFixedPoint *positions, QFontEngine *fontEngine) | - | ||||||||||||||||||||||||||||||
| 2743 | { | - | ||||||||||||||||||||||||||||||
| 2744 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2745 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 2746 | - | |||||||||||||||||||||||||||||||
| 2747 | if (fontEngine->hasInternalCaching()) {
| 0 | ||||||||||||||||||||||||||||||
| 2748 | QFontEngine::GlyphFormat neededFormat = | - | ||||||||||||||||||||||||||||||
| 2749 | painter()->device()->devType() == QInternal::Widget
| 0 | ||||||||||||||||||||||||||||||
| 2750 | ? QFontEngine::Format_None | - | ||||||||||||||||||||||||||||||
| 2751 | : QFontEngine::Format_A8; | - | ||||||||||||||||||||||||||||||
| 2752 | - | |||||||||||||||||||||||||||||||
| 2753 | if (d_func()->mono_surface) // alphaPenBlt can handle mono, too
| 0 | ||||||||||||||||||||||||||||||
| 2754 | neededFormat = QFontEngine::Format_Mono; never executed: neededFormat = QFontEngine::Format_Mono; | 0 | ||||||||||||||||||||||||||||||
| 2755 | - | |||||||||||||||||||||||||||||||
| 2756 | for (int i = 0; i < numGlyphs; i++) {
| 0 | ||||||||||||||||||||||||||||||
| 2757 | QFixed spp = fontEngine->subPixelPositionForX(positions[i].x); | - | ||||||||||||||||||||||||||||||
| 2758 | - | |||||||||||||||||||||||||||||||
| 2759 | QPoint offset; | - | ||||||||||||||||||||||||||||||
| 2760 | const QImage *alphaMap = fontEngine->lockedAlphaMapForGlyph(glyphs[i], spp, neededFormat, s->matrix, | - | ||||||||||||||||||||||||||||||
| 2761 | &offset); | - | ||||||||||||||||||||||||||||||
| 2762 | if (alphaMap == 0 || alphaMap->isNull())
| 0 | ||||||||||||||||||||||||||||||
| 2763 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 2764 | - | |||||||||||||||||||||||||||||||
| 2765 | alphaPenBlt(alphaMap->constBits(), alphaMap->bytesPerLine(), alphaMap->depth(), | - | ||||||||||||||||||||||||||||||
| 2766 | qFloor(positions[i].x) + offset.x(), | - | ||||||||||||||||||||||||||||||
| 2767 | qRound(positions[i].y) + offset.y(), | - | ||||||||||||||||||||||||||||||
| 2768 | alphaMap->width(), alphaMap->height()); | - | ||||||||||||||||||||||||||||||
| 2769 | - | |||||||||||||||||||||||||||||||
| 2770 | fontEngine->unlockAlphaMapForGlyph(); | - | ||||||||||||||||||||||||||||||
| 2771 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2772 | - | |||||||||||||||||||||||||||||||
| 2773 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2774 | QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None ? fontEngine->glyphFormat : d->glyphCacheFormat;
| 0 | ||||||||||||||||||||||||||||||
| 2775 | - | |||||||||||||||||||||||||||||||
| 2776 | QImageTextureGlyphCache *cache = | - | ||||||||||||||||||||||||||||||
| 2777 | static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphFormat, s->matrix)); | - | ||||||||||||||||||||||||||||||
| 2778 | if (!cache) {
| 0 | ||||||||||||||||||||||||||||||
| 2779 | cache = new QImageTextureGlyphCache(glyphFormat, s->matrix); | - | ||||||||||||||||||||||||||||||
| 2780 | fontEngine->setGlyphCache(0, cache); | - | ||||||||||||||||||||||||||||||
| 2781 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2782 | - | |||||||||||||||||||||||||||||||
| 2783 | cache->populate(fontEngine, numGlyphs, glyphs, positions); | - | ||||||||||||||||||||||||||||||
| 2784 | cache->fillInPendingGlyphs(); | - | ||||||||||||||||||||||||||||||
| 2785 | - | |||||||||||||||||||||||||||||||
| 2786 | const QImage &image = cache->image(); | - | ||||||||||||||||||||||||||||||
| 2787 | int bpl = image.bytesPerLine(); | - | ||||||||||||||||||||||||||||||
| 2788 | - | |||||||||||||||||||||||||||||||
| 2789 | int depth = image.depth(); | - | ||||||||||||||||||||||||||||||
| 2790 | int rightShift = 0; | - | ||||||||||||||||||||||||||||||
| 2791 | int leftShift = 0; | - | ||||||||||||||||||||||||||||||
| 2792 | if (depth == 32)
| 0 | ||||||||||||||||||||||||||||||
| 2793 | leftShift = 2; // multiply by 4 never executed: leftShift = 2; | 0 | ||||||||||||||||||||||||||||||
| 2794 | else if (depth == 1)
| 0 | ||||||||||||||||||||||||||||||
| 2795 | rightShift = 3; // divide by 8 never executed: rightShift = 3; | 0 | ||||||||||||||||||||||||||||||
| 2796 | - | |||||||||||||||||||||||||||||||
| 2797 | int margin = fontEngine->glyphMargin(glyphFormat); | - | ||||||||||||||||||||||||||||||
| 2798 | const uchar *bits = image.bits(); | - | ||||||||||||||||||||||||||||||
| 2799 | for (int i=0; i<numGlyphs; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 2800 | - | |||||||||||||||||||||||||||||||
| 2801 | QFixed subPixelPosition = fontEngine->subPixelPositionForX(positions[i].x); | - | ||||||||||||||||||||||||||||||
| 2802 | QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphs[i], subPixelPosition); | - | ||||||||||||||||||||||||||||||
| 2803 | const QTextureGlyphCache::Coord &c = cache->coords[glyph]; | - | ||||||||||||||||||||||||||||||
| 2804 | if (c.isNull())
| 0 | ||||||||||||||||||||||||||||||
| 2805 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 2806 | - | |||||||||||||||||||||||||||||||
| 2807 | int x = qFloor(positions[i].x) + c.baseLineX - margin; | - | ||||||||||||||||||||||||||||||
| 2808 | int y = qRound(positions[i].y) - c.baseLineY - margin; | - | ||||||||||||||||||||||||||||||
| 2809 | - | |||||||||||||||||||||||||||||||
| 2810 | // printf("drawing [%d %d %d %d] baseline [%d %d], glyph: %d, to: %d %d, pos: %d %d\n", | - | ||||||||||||||||||||||||||||||
| 2811 | // c.x, c.y, | - | ||||||||||||||||||||||||||||||
| 2812 | // c.w, c.h, | - | ||||||||||||||||||||||||||||||
| 2813 | // c.baseLineX, c.baseLineY, | - | ||||||||||||||||||||||||||||||
| 2814 | // glyphs[i], | - | ||||||||||||||||||||||||||||||
| 2815 | // x, y, | - | ||||||||||||||||||||||||||||||
| 2816 | // positions[i].x.toInt(), positions[i].y.toInt()); | - | ||||||||||||||||||||||||||||||
| 2817 | - | |||||||||||||||||||||||||||||||
| 2818 | const uchar *glyphBits = bits + ((c.x << leftShift) >> rightShift) + c.y * bpl; | - | ||||||||||||||||||||||||||||||
| 2819 | - | |||||||||||||||||||||||||||||||
| 2820 | if (glyphFormat == QFontEngine::Format_ARGB) {
| 0 | ||||||||||||||||||||||||||||||
| 2821 | // The current state transform has already been applied to the positions, | - | ||||||||||||||||||||||||||||||
| 2822 | // so we prevent drawImage() from re-applying the transform by clearing | - | ||||||||||||||||||||||||||||||
| 2823 | // the state for the duration of the call. | - | ||||||||||||||||||||||||||||||
| 2824 | QTransform originalTransform = s->matrix; | - | ||||||||||||||||||||||||||||||
| 2825 | s->matrix = QTransform(); | - | ||||||||||||||||||||||||||||||
| 2826 | drawImage(QPoint(x, y), QImage(glyphBits, c.w, c.h, bpl, image.format())); | - | ||||||||||||||||||||||||||||||
| 2827 | s->matrix = originalTransform; | - | ||||||||||||||||||||||||||||||
| 2828 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2829 | alphaPenBlt(glyphBits, bpl, depth, x, y, c.w, c.h); | - | ||||||||||||||||||||||||||||||
| 2830 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2831 | } | - | ||||||||||||||||||||||||||||||
| 2832 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2833 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 2834 | } | - | ||||||||||||||||||||||||||||||
| 2835 | - | |||||||||||||||||||||||||||||||
| 2836 | - | |||||||||||||||||||||||||||||||
| 2837 | /*! | - | ||||||||||||||||||||||||||||||
| 2838 | * Returns \c true if the rectangle is completely within the current clip | - | ||||||||||||||||||||||||||||||
| 2839 | * state of the paint engine. | - | ||||||||||||||||||||||||||||||
| 2840 | */ | - | ||||||||||||||||||||||||||||||
| 2841 | bool QRasterPaintEnginePrivate::isUnclipped_normalized(const QRect &r) const | - | ||||||||||||||||||||||||||||||
| 2842 | { | - | ||||||||||||||||||||||||||||||
| 2843 | const QClipData *cl = clip(); | - | ||||||||||||||||||||||||||||||
| 2844 | if (!cl) {
| 0 | ||||||||||||||||||||||||||||||
| 2845 | // inline contains() for performance (we know the rects are normalized) | - | ||||||||||||||||||||||||||||||
| 2846 | const QRect &r1 = deviceRect; | - | ||||||||||||||||||||||||||||||
| 2847 | return (r.left() >= r1.left() && r.right() <= r1.right() never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2848 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2849 | } | - | ||||||||||||||||||||||||||||||
| 2850 | - | |||||||||||||||||||||||||||||||
| 2851 | - | |||||||||||||||||||||||||||||||
| 2852 | if (cl->hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 2853 | // currently all painting functions clips to deviceRect internally | - | ||||||||||||||||||||||||||||||
| 2854 | if (cl->clipRect == deviceRect)
| 0 | ||||||||||||||||||||||||||||||
| 2855 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 2856 | - | |||||||||||||||||||||||||||||||
| 2857 | // inline contains() for performance (we know the rects are normalized) | - | ||||||||||||||||||||||||||||||
| 2858 | const QRect &r1 = cl->clipRect; | - | ||||||||||||||||||||||||||||||
| 2859 | return (r.left() >= r1.left() && r.right() <= r1.right() never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2860 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2861 | } else { | - | ||||||||||||||||||||||||||||||
| 2862 | return qt_region_strictContains(cl->clipRegion, r); never executed: return qt_region_strictContains(cl->clipRegion, r); | 0 | ||||||||||||||||||||||||||||||
| 2863 | } | - | ||||||||||||||||||||||||||||||
| 2864 | } | - | ||||||||||||||||||||||||||||||
| 2865 | - | |||||||||||||||||||||||||||||||
| 2866 | bool QRasterPaintEnginePrivate::isUnclipped(const QRect &rect, | - | ||||||||||||||||||||||||||||||
| 2867 | int penWidth) const | - | ||||||||||||||||||||||||||||||
| 2868 | { | - | ||||||||||||||||||||||||||||||
| 2869 | Q_Q(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2870 | const QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 2871 | const QClipData *cl = clip(); | - | ||||||||||||||||||||||||||||||
| 2872 | if (!cl) {
| 0 | ||||||||||||||||||||||||||||||
| 2873 | QRect r = rect.normalized(); | - | ||||||||||||||||||||||||||||||
| 2874 | // inline contains() for performance (we know the rects are normalized) | - | ||||||||||||||||||||||||||||||
| 2875 | const QRect &r1 = deviceRect; | - | ||||||||||||||||||||||||||||||
| 2876 | return (r.left() >= r1.left() && r.right() <= r1.right() never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2877 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2878 | } | - | ||||||||||||||||||||||||||||||
| 2879 | - | |||||||||||||||||||||||||||||||
| 2880 | - | |||||||||||||||||||||||||||||||
| 2881 | // currently all painting functions that call this function clip to deviceRect internally | - | ||||||||||||||||||||||||||||||
| 2882 | if (cl->hasRectClip && cl->clipRect == deviceRect)
| 0 | ||||||||||||||||||||||||||||||
| 2883 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 2884 | - | |||||||||||||||||||||||||||||||
| 2885 | if (s->flags.antialiased)
| 0 | ||||||||||||||||||||||||||||||
| 2886 | ++penWidth; never executed: ++penWidth; | 0 | ||||||||||||||||||||||||||||||
| 2887 | - | |||||||||||||||||||||||||||||||
| 2888 | QRect r = rect.normalized(); | - | ||||||||||||||||||||||||||||||
| 2889 | if (penWidth > 0) {
| 0 | ||||||||||||||||||||||||||||||
| 2890 | r.setX(r.x() - penWidth); | - | ||||||||||||||||||||||||||||||
| 2891 | r.setY(r.y() - penWidth); | - | ||||||||||||||||||||||||||||||
| 2892 | r.setWidth(r.width() + 2 * penWidth); | - | ||||||||||||||||||||||||||||||
| 2893 | r.setHeight(r.height() + 2 * penWidth); | - | ||||||||||||||||||||||||||||||
| 2894 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2895 | - | |||||||||||||||||||||||||||||||
| 2896 | if (cl->hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 2897 | // inline contains() for performance (we know the rects are normalized) | - | ||||||||||||||||||||||||||||||
| 2898 | const QRect &r1 = cl->clipRect; | - | ||||||||||||||||||||||||||||||
| 2899 | return (r.left() >= r1.left() && r.right() <= r1.right() never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2900 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); never executed: return (r.left() >= r1.left() && r.right() <= r1.right() && r.top() >= r1.top() && r.bottom() <= r1.bottom());
| 0 | ||||||||||||||||||||||||||||||
| 2901 | } else { | - | ||||||||||||||||||||||||||||||
| 2902 | return qt_region_strictContains(cl->clipRegion, r); never executed: return qt_region_strictContains(cl->clipRegion, r); | 0 | ||||||||||||||||||||||||||||||
| 2903 | } | - | ||||||||||||||||||||||||||||||
| 2904 | } | - | ||||||||||||||||||||||||||||||
| 2905 | - | |||||||||||||||||||||||||||||||
| 2906 | inline bool QRasterPaintEnginePrivate::isUnclipped(const QRectF &rect, | - | ||||||||||||||||||||||||||||||
| 2907 | int penWidth) const | - | ||||||||||||||||||||||||||||||
| 2908 | { | - | ||||||||||||||||||||||||||||||
| 2909 | return isUnclipped(rect.normalized().toAlignedRect(), penWidth); never executed: return isUnclipped(rect.normalized().toAlignedRect(), penWidth); | 0 | ||||||||||||||||||||||||||||||
| 2910 | } | - | ||||||||||||||||||||||||||||||
| 2911 | - | |||||||||||||||||||||||||||||||
| 2912 | inline ProcessSpans | - | ||||||||||||||||||||||||||||||
| 2913 | QRasterPaintEnginePrivate::getBrushFunc(const QRect &rect, | - | ||||||||||||||||||||||||||||||
| 2914 | const QSpanData *data) const | - | ||||||||||||||||||||||||||||||
| 2915 | { | - | ||||||||||||||||||||||||||||||
| 2916 | return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend; never executed: return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend;
| 0 | ||||||||||||||||||||||||||||||
| 2917 | } | - | ||||||||||||||||||||||||||||||
| 2918 | - | |||||||||||||||||||||||||||||||
| 2919 | inline ProcessSpans | - | ||||||||||||||||||||||||||||||
| 2920 | QRasterPaintEnginePrivate::getBrushFunc(const QRectF &rect, | - | ||||||||||||||||||||||||||||||
| 2921 | const QSpanData *data) const | - | ||||||||||||||||||||||||||||||
| 2922 | { | - | ||||||||||||||||||||||||||||||
| 2923 | return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend; never executed: return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend;
| 0 | ||||||||||||||||||||||||||||||
| 2924 | } | - | ||||||||||||||||||||||||||||||
| 2925 | - | |||||||||||||||||||||||||||||||
| 2926 | inline ProcessSpans | - | ||||||||||||||||||||||||||||||
| 2927 | QRasterPaintEnginePrivate::getPenFunc(const QRectF &rect, | - | ||||||||||||||||||||||||||||||
| 2928 | const QSpanData *data) const | - | ||||||||||||||||||||||||||||||
| 2929 | { | - | ||||||||||||||||||||||||||||||
| 2930 | Q_Q(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 2931 | const QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 2932 | - | |||||||||||||||||||||||||||||||
| 2933 | if (!s->flags.fast_pen && s->matrix.type() > QTransform::TxTranslate)
| 0 | ||||||||||||||||||||||||||||||
| 2934 | return data->blend; never executed: return data->blend; | 0 | ||||||||||||||||||||||||||||||
| 2935 | const int penWidth = s->flags.fast_pen ? 1 : qCeil(s->lastPen.widthF());
| 0 | ||||||||||||||||||||||||||||||
| 2936 | return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend; never executed: return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend;
| 0 | ||||||||||||||||||||||||||||||
| 2937 | } | - | ||||||||||||||||||||||||||||||
| 2938 | - | |||||||||||||||||||||||||||||||
| 2939 | static QPair<int, int> visibleGlyphRange(const QRectF &clip, QFontEngine *fontEngine, | - | ||||||||||||||||||||||||||||||
| 2940 | glyph_t *glyphs, QFixedPoint *positions, int numGlyphs) | - | ||||||||||||||||||||||||||||||
| 2941 | { | - | ||||||||||||||||||||||||||||||
| 2942 | QFixed clipLeft = QFixed::fromReal(clip.left()); | - | ||||||||||||||||||||||||||||||
| 2943 | QFixed clipRight = QFixed::fromReal(clip.right()); | - | ||||||||||||||||||||||||||||||
| 2944 | QFixed clipTop = QFixed::fromReal(clip.top()); | - | ||||||||||||||||||||||||||||||
| 2945 | QFixed clipBottom = QFixed::fromReal(clip.bottom()); | - | ||||||||||||||||||||||||||||||
| 2946 | - | |||||||||||||||||||||||||||||||
| 2947 | int first = 0; | - | ||||||||||||||||||||||||||||||
| 2948 | while (first < numGlyphs) {
| 0 | ||||||||||||||||||||||||||||||
| 2949 | glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[first]); | - | ||||||||||||||||||||||||||||||
| 2950 | QFixed left = metrics.x + positions[first].x; | - | ||||||||||||||||||||||||||||||
| 2951 | QFixed top = metrics.y + positions[first].y; | - | ||||||||||||||||||||||||||||||
| 2952 | QFixed right = left + metrics.width; | - | ||||||||||||||||||||||||||||||
| 2953 | QFixed bottom = top + metrics.height; | - | ||||||||||||||||||||||||||||||
| 2954 | if (left < clipRight && right > clipLeft && top < clipBottom && bottom > clipTop)
| 0 | ||||||||||||||||||||||||||||||
| 2955 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2956 | ++first; | - | ||||||||||||||||||||||||||||||
| 2957 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2958 | int last = numGlyphs - 1; | - | ||||||||||||||||||||||||||||||
| 2959 | while (last > first) {
| 0 | ||||||||||||||||||||||||||||||
| 2960 | glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[last]); | - | ||||||||||||||||||||||||||||||
| 2961 | QFixed left = metrics.x + positions[last].x; | - | ||||||||||||||||||||||||||||||
| 2962 | QFixed top = metrics.y + positions[last].y; | - | ||||||||||||||||||||||||||||||
| 2963 | QFixed right = left + metrics.width; | - | ||||||||||||||||||||||||||||||
| 2964 | QFixed bottom = top + metrics.height; | - | ||||||||||||||||||||||||||||||
| 2965 | if (left < clipRight && right > clipLeft && top < clipBottom && bottom > clipTop)
| 0 | ||||||||||||||||||||||||||||||
| 2966 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2967 | --last; | - | ||||||||||||||||||||||||||||||
| 2968 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2969 | return QPair<int, int>(first, last + 1); never executed: return QPair<int, int>(first, last + 1); | 0 | ||||||||||||||||||||||||||||||
| 2970 | } | - | ||||||||||||||||||||||||||||||
| 2971 | - | |||||||||||||||||||||||||||||||
| 2972 | /*! | - | ||||||||||||||||||||||||||||||
| 2973 | \reimp | - | ||||||||||||||||||||||||||||||
| 2974 | */ | - | ||||||||||||||||||||||||||||||
| 2975 | void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) | - | ||||||||||||||||||||||||||||||
| 2976 | { | - | ||||||||||||||||||||||||||||||
| 2977 | if (textItem->numGlyphs == 0)
| 0 | ||||||||||||||||||||||||||||||
| 2978 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2979 | - | |||||||||||||||||||||||||||||||
| 2980 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 2981 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 2982 | - | |||||||||||||||||||||||||||||||
| 2983 | QTransform matrix = state()->matrix; | - | ||||||||||||||||||||||||||||||
| 2984 | - | |||||||||||||||||||||||||||||||
| 2985 | QFontEngine *fontEngine = textItem->fontEngine(); | - | ||||||||||||||||||||||||||||||
| 2986 | if (shouldDrawCachedGlyphs(fontEngine, matrix)) {
| 0 | ||||||||||||||||||||||||||||||
| 2987 | drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, | - | ||||||||||||||||||||||||||||||
| 2988 | fontEngine); | - | ||||||||||||||||||||||||||||||
| 2989 | } else if (matrix.type() < QTransform::TxProject) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 2990 | bool invertible; | - | ||||||||||||||||||||||||||||||
| 2991 | QTransform invMat = matrix.inverted(&invertible); | - | ||||||||||||||||||||||||||||||
| 2992 | if (!invertible)
| 0 | ||||||||||||||||||||||||||||||
| 2993 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2994 | - | |||||||||||||||||||||||||||||||
| 2995 | QPair<int, int> range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()), | - | ||||||||||||||||||||||||||||||
| 2996 | textItem->fontEngine(), textItem->glyphs, | - | ||||||||||||||||||||||||||||||
| 2997 | textItem->glyphPositions, textItem->numGlyphs); | - | ||||||||||||||||||||||||||||||
| 2998 | QStaticTextItem copy = *textItem; | - | ||||||||||||||||||||||||||||||
| 2999 | copy.glyphs += range.first; | - | ||||||||||||||||||||||||||||||
| 3000 | copy.glyphPositions += range.first; | - | ||||||||||||||||||||||||||||||
| 3001 | copy.numGlyphs = range.second - range.first; | - | ||||||||||||||||||||||||||||||
| 3002 | QPaintEngineEx::drawStaticTextItem(©); | - | ||||||||||||||||||||||||||||||
| 3003 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3004 | QPaintEngineEx::drawStaticTextItem(textItem); | - | ||||||||||||||||||||||||||||||
| 3005 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3006 | } | - | ||||||||||||||||||||||||||||||
| 3007 | - | |||||||||||||||||||||||||||||||
| 3008 | /*! | - | ||||||||||||||||||||||||||||||
| 3009 | \reimp | - | ||||||||||||||||||||||||||||||
| 3010 | */ | - | ||||||||||||||||||||||||||||||
| 3011 | void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) | - | ||||||||||||||||||||||||||||||
| 3012 | { | - | ||||||||||||||||||||||||||||||
| 3013 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - | ||||||||||||||||||||||||||||||
| 3014 | - | |||||||||||||||||||||||||||||||
| 3015 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 3016 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3017 | fprintf(stderr," - QRasterPaintEngine::drawTextItem(), (%.2f,%.2f), string=%s ct=%d\n", | - | ||||||||||||||||||||||||||||||
| 3018 | p.x(), p.y(), QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data(), | - | ||||||||||||||||||||||||||||||
| 3019 | d->glyphCacheFormat); | - | ||||||||||||||||||||||||||||||
| 3020 | #endif | - | ||||||||||||||||||||||||||||||
| 3021 | - | |||||||||||||||||||||||||||||||
| 3022 | if (ti.glyphs.numGlyphs == 0)
| 0 | ||||||||||||||||||||||||||||||
| 3023 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3024 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 3025 | ensureRasterState(); | - | ||||||||||||||||||||||||||||||
| 3026 | - | |||||||||||||||||||||||||||||||
| 3027 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 3028 | QTransform matrix = s->matrix; | - | ||||||||||||||||||||||||||||||
| 3029 | - | |||||||||||||||||||||||||||||||
| 3030 | if (shouldDrawCachedGlyphs(ti.fontEngine, matrix)) {
| 0 | ||||||||||||||||||||||||||||||
| 3031 | QVarLengthArray<QFixedPoint> positions; | - | ||||||||||||||||||||||||||||||
| 3032 | QVarLengthArray<glyph_t> glyphs; | - | ||||||||||||||||||||||||||||||
| 3033 | - | |||||||||||||||||||||||||||||||
| 3034 | matrix.translate(p.x(), p.y()); | - | ||||||||||||||||||||||||||||||
| 3035 | ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); | - | ||||||||||||||||||||||||||||||
| 3036 | - | |||||||||||||||||||||||||||||||
| 3037 | drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), ti.fontEngine); | - | ||||||||||||||||||||||||||||||
| 3038 | } else if (matrix.type() < QTransform::TxProject never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 3039 | && ti.fontEngine->supportsTransformation(matrix)) {
| 0 | ||||||||||||||||||||||||||||||
| 3040 | bool invertible; | - | ||||||||||||||||||||||||||||||
| 3041 | QTransform invMat = matrix.inverted(&invertible); | - | ||||||||||||||||||||||||||||||
| 3042 | if (!invertible)
| 0 | ||||||||||||||||||||||||||||||
| 3043 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3044 | - | |||||||||||||||||||||||||||||||
| 3045 | QVarLengthArray<QFixedPoint> positions; | - | ||||||||||||||||||||||||||||||
| 3046 | QVarLengthArray<glyph_t> glyphs; | - | ||||||||||||||||||||||||||||||
| 3047 | - | |||||||||||||||||||||||||||||||
| 3048 | ti.fontEngine->getGlyphPositions(ti.glyphs, QTransform::fromTranslate(p.x(), p.y()), | - | ||||||||||||||||||||||||||||||
| 3049 | ti.flags, glyphs, positions); | - | ||||||||||||||||||||||||||||||
| 3050 | QPair<int, int> range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()), | - | ||||||||||||||||||||||||||||||
| 3051 | ti.fontEngine, glyphs.data(), positions.data(), | - | ||||||||||||||||||||||||||||||
| 3052 | glyphs.size()); | - | ||||||||||||||||||||||||||||||
| 3053 | - | |||||||||||||||||||||||||||||||
| 3054 | if (range.first >= range.second)
| 0 | ||||||||||||||||||||||||||||||
| 3055 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3056 | - | |||||||||||||||||||||||||||||||
| 3057 | QStaticTextItem staticTextItem; | - | ||||||||||||||||||||||||||||||
| 3058 | staticTextItem.color = s->pen.color(); | - | ||||||||||||||||||||||||||||||
| 3059 | staticTextItem.font = s->font; | - | ||||||||||||||||||||||||||||||
| 3060 | staticTextItem.setFontEngine(ti.fontEngine); | - | ||||||||||||||||||||||||||||||
| 3061 | staticTextItem.numGlyphs = range.second - range.first; | - | ||||||||||||||||||||||||||||||
| 3062 | staticTextItem.glyphs = glyphs.data() + range.first; | - | ||||||||||||||||||||||||||||||
| 3063 | staticTextItem.glyphPositions = positions.data() + range.first; | - | ||||||||||||||||||||||||||||||
| 3064 | QPaintEngineEx::drawStaticTextItem(&staticTextItem); | - | ||||||||||||||||||||||||||||||
| 3065 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3066 | QPaintEngineEx::drawTextItem(p, ti); | - | ||||||||||||||||||||||||||||||
| 3067 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3068 | } | - | ||||||||||||||||||||||||||||||
| 3069 | - | |||||||||||||||||||||||||||||||
| 3070 | /*! | - | ||||||||||||||||||||||||||||||
| 3071 | \reimp | - | ||||||||||||||||||||||||||||||
| 3072 | */ | - | ||||||||||||||||||||||||||||||
| 3073 | void QRasterPaintEngine::drawPoints(const QPointF *points, int pointCount) | - | ||||||||||||||||||||||||||||||
| 3074 | { | - | ||||||||||||||||||||||||||||||
| 3075 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3076 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 3077 | - | |||||||||||||||||||||||||||||||
| 3078 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 3079 | if (!s->penData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 3080 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3081 | - | |||||||||||||||||||||||||||||||
| 3082 | if (!s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 3083 | QPaintEngineEx::drawPoints(points, pointCount); | - | ||||||||||||||||||||||||||||||
| 3084 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3085 | } | - | ||||||||||||||||||||||||||||||
| 3086 | - | |||||||||||||||||||||||||||||||
| 3087 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 3088 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 3089 | stroker.drawPoints(points, pointCount); | - | ||||||||||||||||||||||||||||||
| 3090 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3091 | - | |||||||||||||||||||||||||||||||
| 3092 | - | |||||||||||||||||||||||||||||||
| 3093 | void QRasterPaintEngine::drawPoints(const QPoint *points, int pointCount) | - | ||||||||||||||||||||||||||||||
| 3094 | { | - | ||||||||||||||||||||||||||||||
| 3095 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3096 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 3097 | - | |||||||||||||||||||||||||||||||
| 3098 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 3099 | if (!s->penData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 3100 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3101 | - | |||||||||||||||||||||||||||||||
| 3102 | if (!s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 3103 | QPaintEngineEx::drawPoints(points, pointCount); | - | ||||||||||||||||||||||||||||||
| 3104 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3105 | } | - | ||||||||||||||||||||||||||||||
| 3106 | - | |||||||||||||||||||||||||||||||
| 3107 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 3108 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 3109 | stroker.drawPoints(points, pointCount); | - | ||||||||||||||||||||||||||||||
| 3110 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3111 | - | |||||||||||||||||||||||||||||||
| 3112 | /*! | - | ||||||||||||||||||||||||||||||
| 3113 | \reimp | - | ||||||||||||||||||||||||||||||
| 3114 | */ | - | ||||||||||||||||||||||||||||||
| 3115 | void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount) | - | ||||||||||||||||||||||||||||||
| 3116 | { | - | ||||||||||||||||||||||||||||||
| 3117 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 3118 | qDebug() << " - QRasterPaintEngine::drawLines(QLine*)" << lineCount; | - | ||||||||||||||||||||||||||||||
| 3119 | #endif | - | ||||||||||||||||||||||||||||||
| 3120 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3121 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 3122 | - | |||||||||||||||||||||||||||||||
| 3123 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 3124 | if (!s->penData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 3125 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3126 | - | |||||||||||||||||||||||||||||||
| 3127 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 3128 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 3129 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 3130 | for (int i=0; i<lineCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 3131 | const QLine &l = lines[i]; | - | ||||||||||||||||||||||||||||||
| 3132 | stroker.drawLine(l.p1(), l.p2()); | - | ||||||||||||||||||||||||||||||
| 3133 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3134 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3135 | QPaintEngineEx::drawLines(lines, lineCount); | - | ||||||||||||||||||||||||||||||
| 3136 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3137 | } | - | ||||||||||||||||||||||||||||||
| 3138 | - | |||||||||||||||||||||||||||||||
| 3139 | void QRasterPaintEnginePrivate::rasterizeLine_dashed(QLineF line, | - | ||||||||||||||||||||||||||||||
| 3140 | qreal width, | - | ||||||||||||||||||||||||||||||
| 3141 | int *dashIndex, | - | ||||||||||||||||||||||||||||||
| 3142 | qreal *dashOffset, | - | ||||||||||||||||||||||||||||||
| 3143 | bool *inDash) | - | ||||||||||||||||||||||||||||||
| 3144 | { | - | ||||||||||||||||||||||||||||||
| 3145 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3146 | QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 3147 | - | |||||||||||||||||||||||||||||||
| 3148 | const QPen &pen = s->lastPen; | - | ||||||||||||||||||||||||||||||
| 3149 | const bool squareCap = (pen.capStyle() == Qt::SquareCap); | - | ||||||||||||||||||||||||||||||
| 3150 | const QVector<qreal> pattern = pen.dashPattern(); | - | ||||||||||||||||||||||||||||||
| 3151 | - | |||||||||||||||||||||||||||||||
| 3152 | qreal patternLength = 0; | - | ||||||||||||||||||||||||||||||
| 3153 | for (int i = 0; i < pattern.size(); ++i)
| 0 | ||||||||||||||||||||||||||||||
| 3154 | patternLength += pattern.at(i); never executed: patternLength += pattern.at(i); | 0 | ||||||||||||||||||||||||||||||
| 3155 | - | |||||||||||||||||||||||||||||||
| 3156 | if (patternLength <= 0)
| 0 | ||||||||||||||||||||||||||||||
| 3157 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3158 | - | |||||||||||||||||||||||||||||||
| 3159 | qreal length = line.length(); | - | ||||||||||||||||||||||||||||||
| 3160 | Q_ASSERT(length > 0); | - | ||||||||||||||||||||||||||||||
| 3161 | while (length > 0) {
| 0 | ||||||||||||||||||||||||||||||
| 3162 | const bool rasterize = *inDash; | - | ||||||||||||||||||||||||||||||
| 3163 | qreal dash = (pattern.at(*dashIndex) - *dashOffset) * width; | - | ||||||||||||||||||||||||||||||
| 3164 | QLineF l = line; | - | ||||||||||||||||||||||||||||||
| 3165 | - | |||||||||||||||||||||||||||||||
| 3166 | if (dash >= length) {
| 0 | ||||||||||||||||||||||||||||||
| 3167 | dash = line.length(); // Avoid accumulated precision error in 'length' | - | ||||||||||||||||||||||||||||||
| 3168 | *dashOffset += dash / width; | - | ||||||||||||||||||||||||||||||
| 3169 | length = 0; | - | ||||||||||||||||||||||||||||||
| 3170 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3171 | *dashOffset = 0; | - | ||||||||||||||||||||||||||||||
| 3172 | *inDash = !(*inDash); | - | ||||||||||||||||||||||||||||||
| 3173 | if (++*dashIndex >= pattern.size())
| 0 | ||||||||||||||||||||||||||||||
| 3174 | *dashIndex = 0; never executed: *dashIndex = 0; | 0 | ||||||||||||||||||||||||||||||
| 3175 | length -= dash; | - | ||||||||||||||||||||||||||||||
| 3176 | l.setLength(dash); | - | ||||||||||||||||||||||||||||||
| 3177 | line.setP1(l.p2()); | - | ||||||||||||||||||||||||||||||
| 3178 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3179 | - | |||||||||||||||||||||||||||||||
| 3180 | if (rasterize && dash > 0)
| 0 | ||||||||||||||||||||||||||||||
| 3181 | rasterizer->rasterizeLine(l.p1(), l.p2(), width / dash, squareCap); never executed: rasterizer->rasterizeLine(l.p1(), l.p2(), width / dash, squareCap); | 0 | ||||||||||||||||||||||||||||||
| 3182 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3183 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3184 | - | |||||||||||||||||||||||||||||||
| 3185 | /*! | - | ||||||||||||||||||||||||||||||
| 3186 | \reimp | - | ||||||||||||||||||||||||||||||
| 3187 | */ | - | ||||||||||||||||||||||||||||||
| 3188 | void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) | - | ||||||||||||||||||||||||||||||
| 3189 | { | - | ||||||||||||||||||||||||||||||
| 3190 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 3191 | qDebug() << " - QRasterPaintEngine::drawLines(QLineF *)" << lineCount; | - | ||||||||||||||||||||||||||||||
| 3192 | #endif | - | ||||||||||||||||||||||||||||||
| 3193 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3194 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 3195 | - | |||||||||||||||||||||||||||||||
| 3196 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 3197 | if (!s->penData.blend)
| 0 | ||||||||||||||||||||||||||||||
| 3198 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3199 | if (s->flags.fast_pen) {
| 0 | ||||||||||||||||||||||||||||||
| 3200 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - | ||||||||||||||||||||||||||||||
| 3201 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 3202 | for (int i=0; i<lineCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 3203 | QLineF line = lines[i]; | - | ||||||||||||||||||||||||||||||
| 3204 | stroker.drawLine(line.p1(), line.p2()); | - | ||||||||||||||||||||||||||||||
| 3205 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3206 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3207 | QPaintEngineEx::drawLines(lines, lineCount); | - | ||||||||||||||||||||||||||||||
| 3208 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3209 | } | - | ||||||||||||||||||||||||||||||
| 3210 | - | |||||||||||||||||||||||||||||||
| 3211 | - | |||||||||||||||||||||||||||||||
| 3212 | /*! | - | ||||||||||||||||||||||||||||||
| 3213 | \reimp | - | ||||||||||||||||||||||||||||||
| 3214 | */ | - | ||||||||||||||||||||||||||||||
| 3215 | void QRasterPaintEngine::drawEllipse(const QRectF &rect) | - | ||||||||||||||||||||||||||||||
| 3216 | { | - | ||||||||||||||||||||||||||||||
| 3217 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3218 | QRasterPaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 3219 | - | |||||||||||||||||||||||||||||||
| 3220 | ensurePen(); | - | ||||||||||||||||||||||||||||||
| 3221 | if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen)
| 0 | ||||||||||||||||||||||||||||||
| 3222 | || (qpen_style(s->lastPen) == Qt::NoPen))
| 0 | ||||||||||||||||||||||||||||||
| 3223 | && !s->flags.antialiased
| 0 | ||||||||||||||||||||||||||||||
| 3224 | && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
| 0 | ||||||||||||||||||||||||||||||
| 3225 | && !rect.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 3226 | && s->matrix.type() <= QTransform::TxScale) // no shear
| 0 | ||||||||||||||||||||||||||||||
| 3227 | { | - | ||||||||||||||||||||||||||||||
| 3228 | ensureBrush(); | - | ||||||||||||||||||||||||||||||
| 3229 | const QRectF r = s->matrix.mapRect(rect); | - | ||||||||||||||||||||||||||||||
| 3230 | ProcessSpans penBlend = d->getPenFunc(r, &s->penData); | - | ||||||||||||||||||||||||||||||
| 3231 | ProcessSpans brushBlend = d->getBrushFunc(r, &s->brushData); | - | ||||||||||||||||||||||||||||||
| 3232 | const QRect brect = QRect(int(r.x()), int(r.y()), | - | ||||||||||||||||||||||||||||||
| 3233 | int_dim(r.x(), r.width()), | - | ||||||||||||||||||||||||||||||
| 3234 | int_dim(r.y(), r.height())); | - | ||||||||||||||||||||||||||||||
| 3235 | if (brect == r) {
| 0 | ||||||||||||||||||||||||||||||
| 3236 | drawEllipse_midpoint_i(brect, d->deviceRect, penBlend, brushBlend, | - | ||||||||||||||||||||||||||||||
| 3237 | &s->penData, &s->brushData); | - | ||||||||||||||||||||||||||||||
| 3238 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3239 | } | - | ||||||||||||||||||||||||||||||
| 3240 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3241 | QPaintEngineEx::drawEllipse(rect); | - | ||||||||||||||||||||||||||||||
| 3242 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3243 | - | |||||||||||||||||||||||||||||||
| 3244 | - | |||||||||||||||||||||||||||||||
| 3245 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||
| 3246 | /*! | - | ||||||||||||||||||||||||||||||
| 3247 | \internal | - | ||||||||||||||||||||||||||||||
| 3248 | */ | - | ||||||||||||||||||||||||||||||
| 3249 | void QRasterPaintEngine::setDC(HDC hdc) { | - | ||||||||||||||||||||||||||||||
| 3250 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3251 | d->hdc = hdc; | - | ||||||||||||||||||||||||||||||
| 3252 | } | - | ||||||||||||||||||||||||||||||
| 3253 | - | |||||||||||||||||||||||||||||||
| 3254 | /*! | - | ||||||||||||||||||||||||||||||
| 3255 | \internal | - | ||||||||||||||||||||||||||||||
| 3256 | */ | - | ||||||||||||||||||||||||||||||
| 3257 | HDC QRasterPaintEngine::getDC() const | - | ||||||||||||||||||||||||||||||
| 3258 | { | - | ||||||||||||||||||||||||||||||
| 3259 | Q_D(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3260 | return d->hdc; | - | ||||||||||||||||||||||||||||||
| 3261 | } | - | ||||||||||||||||||||||||||||||
| 3262 | - | |||||||||||||||||||||||||||||||
| 3263 | /*! | - | ||||||||||||||||||||||||||||||
| 3264 | \internal | - | ||||||||||||||||||||||||||||||
| 3265 | */ | - | ||||||||||||||||||||||||||||||
| 3266 | void QRasterPaintEngine::releaseDC(HDC) const | - | ||||||||||||||||||||||||||||||
| 3267 | { | - | ||||||||||||||||||||||||||||||
| 3268 | } | - | ||||||||||||||||||||||||||||||
| 3269 | - | |||||||||||||||||||||||||||||||
| 3270 | #endif | - | ||||||||||||||||||||||||||||||
| 3271 | - | |||||||||||||||||||||||||||||||
| 3272 | /*! | - | ||||||||||||||||||||||||||||||
| 3273 | \internal | - | ||||||||||||||||||||||||||||||
| 3274 | */ | - | ||||||||||||||||||||||||||||||
| 3275 | bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const | - | ||||||||||||||||||||||||||||||
| 3276 | { | - | ||||||||||||||||||||||||||||||
| 3277 | // Cached glyphs always require pretransformed positions | - | ||||||||||||||||||||||||||||||
| 3278 | if (shouldDrawCachedGlyphs(fontEngine, m))
| 0 | ||||||||||||||||||||||||||||||
| 3279 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 3280 | - | |||||||||||||||||||||||||||||||
| 3281 | // Otherwise let the base-class decide based on the transform | - | ||||||||||||||||||||||||||||||
| 3282 | return QPaintEngineEx::requiresPretransformedGlyphPositions(fontEngine, m); never executed: return QPaintEngineEx::requiresPretransformedGlyphPositions(fontEngine, m); | 0 | ||||||||||||||||||||||||||||||
| 3283 | } | - | ||||||||||||||||||||||||||||||
| 3284 | - | |||||||||||||||||||||||||||||||
| 3285 | /*! | - | ||||||||||||||||||||||||||||||
| 3286 | Indicates whether glyph caching is supported by the font engine | - | ||||||||||||||||||||||||||||||
| 3287 | \a fontEngine with the given transform \a m applied. | - | ||||||||||||||||||||||||||||||
| 3288 | */ | - | ||||||||||||||||||||||||||||||
| 3289 | bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const | - | ||||||||||||||||||||||||||||||
| 3290 | { | - | ||||||||||||||||||||||||||||||
| 3291 | // The raster engine does not support projected cached glyph drawing | - | ||||||||||||||||||||||||||||||
| 3292 | if (m.type() >= QTransform::TxProject)
| 0 | ||||||||||||||||||||||||||||||
| 3293 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 3294 | - | |||||||||||||||||||||||||||||||
| 3295 | // The font engine might not support filling the glyph cache | - | ||||||||||||||||||||||||||||||
| 3296 | // with the given transform applied, in which case we need to | - | ||||||||||||||||||||||||||||||
| 3297 | // fall back to the QPainterPath code-path. This does not apply | - | ||||||||||||||||||||||||||||||
| 3298 | // for engines with internal caching, as we don't use the engine | - | ||||||||||||||||||||||||||||||
| 3299 | // to fill up our cache in that case. | - | ||||||||||||||||||||||||||||||
| 3300 | if (!fontEngine->hasInternalCaching() && !fontEngine->supportsTransformation(m))
| 0 | ||||||||||||||||||||||||||||||
| 3301 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 3302 | - | |||||||||||||||||||||||||||||||
| 3303 | return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m); never executed: return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m); | 0 | ||||||||||||||||||||||||||||||
| 3304 | } | - | ||||||||||||||||||||||||||||||
| 3305 | - | |||||||||||||||||||||||||||||||
| 3306 | /*! | - | ||||||||||||||||||||||||||||||
| 3307 | \internal | - | ||||||||||||||||||||||||||||||
| 3308 | */ | - | ||||||||||||||||||||||||||||||
| 3309 | QPoint QRasterPaintEngine::coordinateOffset() const | - | ||||||||||||||||||||||||||||||
| 3310 | { | - | ||||||||||||||||||||||||||||||
| 3311 | return QPoint(0, 0); never executed: return QPoint(0, 0); | 0 | ||||||||||||||||||||||||||||||
| 3312 | } | - | ||||||||||||||||||||||||||||||
| 3313 | - | |||||||||||||||||||||||||||||||
| 3314 | void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg) | - | ||||||||||||||||||||||||||||||
| 3315 | { | - | ||||||||||||||||||||||||||||||
| 3316 | Q_ASSERT(fg); | - | ||||||||||||||||||||||||||||||
| 3317 | if (!fg->blend)
| 0 | ||||||||||||||||||||||||||||||
| 3318 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3319 | Q_D(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3320 | - | |||||||||||||||||||||||||||||||
| 3321 | Q_ASSERT(image.depth() == 1); | - | ||||||||||||||||||||||||||||||
| 3322 | - | |||||||||||||||||||||||||||||||
| 3323 | const int spanCount = 256; | - | ||||||||||||||||||||||||||||||
| 3324 | QT_FT_Span spans[spanCount]; | - | ||||||||||||||||||||||||||||||
| 3325 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 3326 | - | |||||||||||||||||||||||||||||||
| 3327 | // Boundaries | - | ||||||||||||||||||||||||||||||
| 3328 | int w = image.width(); | - | ||||||||||||||||||||||||||||||
| 3329 | int h = image.height(); | - | ||||||||||||||||||||||||||||||
| 3330 | int ymax = qMin(qRound(pos.y() + h), d->rasterBuffer->height()); | - | ||||||||||||||||||||||||||||||
| 3331 | int ymin = qMax(qRound(pos.y()), 0); | - | ||||||||||||||||||||||||||||||
| 3332 | int xmax = qMin(qRound(pos.x() + w), d->rasterBuffer->width()); | - | ||||||||||||||||||||||||||||||
| 3333 | int xmin = qMax(qRound(pos.x()), 0); | - | ||||||||||||||||||||||||||||||
| 3334 | - | |||||||||||||||||||||||||||||||
| 3335 | int x_offset = xmin - qRound(pos.x()); | - | ||||||||||||||||||||||||||||||
| 3336 | - | |||||||||||||||||||||||||||||||
| 3337 | QImage::Format format = image.format(); | - | ||||||||||||||||||||||||||||||
| 3338 | for (int y = ymin; y < ymax; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 3339 | const uchar *src = image.scanLine(y - qRound(pos.y())); | - | ||||||||||||||||||||||||||||||
| 3340 | if (format == QImage::Format_MonoLSB) {
| 0 | ||||||||||||||||||||||||||||||
| 3341 | for (int x = 0; x < xmax - xmin; ++x) {
| 0 | ||||||||||||||||||||||||||||||
| 3342 | int src_x = x + x_offset; | - | ||||||||||||||||||||||||||||||
| 3343 | uchar pixel = src[src_x >> 3]; | - | ||||||||||||||||||||||||||||||
| 3344 | if (!pixel) {
| 0 | ||||||||||||||||||||||||||||||
| 3345 | x += 7 - (src_x%8); | - | ||||||||||||||||||||||||||||||
| 3346 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 3347 | } | - | ||||||||||||||||||||||||||||||
| 3348 | if (pixel & (0x1 << (src_x & 7))) {
| 0 | ||||||||||||||||||||||||||||||
| 3349 | spans[n].x = xmin + x; | - | ||||||||||||||||||||||||||||||
| 3350 | spans[n].y = y; | - | ||||||||||||||||||||||||||||||
| 3351 | spans[n].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 3352 | int len = 1; | - | ||||||||||||||||||||||||||||||
| 3353 | while (src_x+1 < w && src[(src_x+1) >> 3] & (0x1 << ((src_x+1) & 7))) {
| 0 | ||||||||||||||||||||||||||||||
| 3354 | ++src_x; | - | ||||||||||||||||||||||||||||||
| 3355 | ++len; | - | ||||||||||||||||||||||||||||||
| 3356 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3357 | spans[n].len = ((len + spans[n].x) > xmax) ? (xmax - spans[n].x) : len;
| 0 | ||||||||||||||||||||||||||||||
| 3358 | x += len; | - | ||||||||||||||||||||||||||||||
| 3359 | ++n; | - | ||||||||||||||||||||||||||||||
| 3360 | if (n == spanCount) {
| 0 | ||||||||||||||||||||||||||||||
| 3361 | fg->blend(n, spans, fg); | - | ||||||||||||||||||||||||||||||
| 3362 | n = 0; | - | ||||||||||||||||||||||||||||||
| 3363 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3364 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3365 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3366 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3367 | for (int x = 0; x < xmax - xmin; ++x) {
| 0 | ||||||||||||||||||||||||||||||
| 3368 | int src_x = x + x_offset; | - | ||||||||||||||||||||||||||||||
| 3369 | uchar pixel = src[src_x >> 3]; | - | ||||||||||||||||||||||||||||||
| 3370 | if (!pixel) {
| 0 | ||||||||||||||||||||||||||||||
| 3371 | x += 7 - (src_x%8); | - | ||||||||||||||||||||||||||||||
| 3372 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 3373 | } | - | ||||||||||||||||||||||||||||||
| 3374 | if (pixel & (0x80 >> (x & 7))) {
| 0 | ||||||||||||||||||||||||||||||
| 3375 | spans[n].x = xmin + x; | - | ||||||||||||||||||||||||||||||
| 3376 | spans[n].y = y; | - | ||||||||||||||||||||||||||||||
| 3377 | spans[n].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 3378 | int len = 1; | - | ||||||||||||||||||||||||||||||
| 3379 | while (src_x+1 < w && src[(src_x+1) >> 3] & (0x80 >> ((src_x+1) & 7))) {
| 0 | ||||||||||||||||||||||||||||||
| 3380 | ++src_x; | - | ||||||||||||||||||||||||||||||
| 3381 | ++len; | - | ||||||||||||||||||||||||||||||
| 3382 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3383 | spans[n].len = ((len + spans[n].x) > xmax) ? (xmax - spans[n].x) : len;
| 0 | ||||||||||||||||||||||||||||||
| 3384 | x += len; | - | ||||||||||||||||||||||||||||||
| 3385 | ++n; | - | ||||||||||||||||||||||||||||||
| 3386 | if (n == spanCount) {
| 0 | ||||||||||||||||||||||||||||||
| 3387 | fg->blend(n, spans, fg); | - | ||||||||||||||||||||||||||||||
| 3388 | n = 0; | - | ||||||||||||||||||||||||||||||
| 3389 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3390 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3391 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3392 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3393 | } | - | ||||||||||||||||||||||||||||||
| 3394 | if (n) {
| 0 | ||||||||||||||||||||||||||||||
| 3395 | fg->blend(n, spans, fg); | - | ||||||||||||||||||||||||||||||
| 3396 | n = 0; | - | ||||||||||||||||||||||||||||||
| 3397 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3398 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3399 | - | |||||||||||||||||||||||||||||||
| 3400 | /*! | - | ||||||||||||||||||||||||||||||
| 3401 | \enum QRasterPaintEngine::ClipType | - | ||||||||||||||||||||||||||||||
| 3402 | \internal | - | ||||||||||||||||||||||||||||||
| 3403 | - | |||||||||||||||||||||||||||||||
| 3404 | \value RectClip Indicates that the currently set clip is a single rectangle. | - | ||||||||||||||||||||||||||||||
| 3405 | \value ComplexClip Indicates that the currently set clip is a combination of several shapes. | - | ||||||||||||||||||||||||||||||
| 3406 | */ | - | ||||||||||||||||||||||||||||||
| 3407 | - | |||||||||||||||||||||||||||||||
| 3408 | /*! | - | ||||||||||||||||||||||||||||||
| 3409 | \internal | - | ||||||||||||||||||||||||||||||
| 3410 | Returns the type of the clip currently set. | - | ||||||||||||||||||||||||||||||
| 3411 | */ | - | ||||||||||||||||||||||||||||||
| 3412 | QRasterPaintEngine::ClipType QRasterPaintEngine::clipType() const | - | ||||||||||||||||||||||||||||||
| 3413 | { | - | ||||||||||||||||||||||||||||||
| 3414 | Q_D(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3415 | - | |||||||||||||||||||||||||||||||
| 3416 | const QClipData *clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 3417 | if (!clip || clip->hasRectClip)
| 0 | ||||||||||||||||||||||||||||||
| 3418 | return RectClip; never executed: return RectClip; | 0 | ||||||||||||||||||||||||||||||
| 3419 | else | - | ||||||||||||||||||||||||||||||
| 3420 | return ComplexClip; never executed: return ComplexClip; | 0 | ||||||||||||||||||||||||||||||
| 3421 | } | - | ||||||||||||||||||||||||||||||
| 3422 | - | |||||||||||||||||||||||||||||||
| 3423 | /*! | - | ||||||||||||||||||||||||||||||
| 3424 | \internal | - | ||||||||||||||||||||||||||||||
| 3425 | Returns the bounding rect of the currently set clip. | - | ||||||||||||||||||||||||||||||
| 3426 | */ | - | ||||||||||||||||||||||||||||||
| 3427 | QRect QRasterPaintEngine::clipBoundingRect() const | - | ||||||||||||||||||||||||||||||
| 3428 | { | - | ||||||||||||||||||||||||||||||
| 3429 | Q_D(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3430 | - | |||||||||||||||||||||||||||||||
| 3431 | const QClipData *clip = d->clip(); | - | ||||||||||||||||||||||||||||||
| 3432 | - | |||||||||||||||||||||||||||||||
| 3433 | if (!clip)
| 0 | ||||||||||||||||||||||||||||||
| 3434 | return d->deviceRect; never executed: return d->deviceRect; | 0 | ||||||||||||||||||||||||||||||
| 3435 | - | |||||||||||||||||||||||||||||||
| 3436 | if (clip->hasRectClip)
| 0 | ||||||||||||||||||||||||||||||
| 3437 | return clip->clipRect; never executed: return clip->clipRect; | 0 | ||||||||||||||||||||||||||||||
| 3438 | - | |||||||||||||||||||||||||||||||
| 3439 | return QRect(clip->xmin, clip->ymin, clip->xmax - clip->xmin, clip->ymax - clip->ymin); never executed: return QRect(clip->xmin, clip->ymin, clip->xmax - clip->xmin, clip->ymax - clip->ymin); | 0 | ||||||||||||||||||||||||||||||
| 3440 | } | - | ||||||||||||||||||||||||||||||
| 3441 | - | |||||||||||||||||||||||||||||||
| 3442 | void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data) | - | ||||||||||||||||||||||||||||||
| 3443 | { | - | ||||||||||||||||||||||||||||||
| 3444 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3445 | QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 3446 | - | |||||||||||||||||||||||||||||||
| 3447 | rasterizer->setAntialiased(s->flags.antialiased); | - | ||||||||||||||||||||||||||||||
| 3448 | rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 3449 | - | |||||||||||||||||||||||||||||||
| 3450 | QRect clipRect(deviceRect); | - | ||||||||||||||||||||||||||||||
| 3451 | ProcessSpans blend; | - | ||||||||||||||||||||||||||||||
| 3452 | // ### get from optimized rectbased QClipData | - | ||||||||||||||||||||||||||||||
| 3453 | - | |||||||||||||||||||||||||||||||
| 3454 | const QClipData *c = clip(); | - | ||||||||||||||||||||||||||||||
| 3455 | if (c) {
| 0 | ||||||||||||||||||||||||||||||
| 3456 | const QRect r(QPoint(c->xmin, c->ymin), | - | ||||||||||||||||||||||||||||||
| 3457 | QSize(c->xmax - c->xmin, c->ymax - c->ymin)); | - | ||||||||||||||||||||||||||||||
| 3458 | clipRect = clipRect.intersected(r); | - | ||||||||||||||||||||||||||||||
| 3459 | blend = data->blend; | - | ||||||||||||||||||||||||||||||
| 3460 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3461 | blend = data->unclipped_blend; | - | ||||||||||||||||||||||||||||||
| 3462 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3463 | - | |||||||||||||||||||||||||||||||
| 3464 | rasterizer->setClipRect(clipRect); | - | ||||||||||||||||||||||||||||||
| 3465 | rasterizer->initialize(blend, data); | - | ||||||||||||||||||||||||||||||
| 3466 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3467 | - | |||||||||||||||||||||||||||||||
| 3468 | void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, | - | ||||||||||||||||||||||||||||||
| 3469 | ProcessSpans callback, | - | ||||||||||||||||||||||||||||||
| 3470 | QSpanData *spanData, QRasterBuffer *rasterBuffer) | - | ||||||||||||||||||||||||||||||
| 3471 | { | - | ||||||||||||||||||||||||||||||
| 3472 | if (!callback || !outline)
| 0 | ||||||||||||||||||||||||||||||
| 3473 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3474 | - | |||||||||||||||||||||||||||||||
| 3475 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3476 | QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 3477 | - | |||||||||||||||||||||||||||||||
| 3478 | if (!s->flags.antialiased) {
| 0 | ||||||||||||||||||||||||||||||
| 3479 | initializeRasterizer(spanData); | - | ||||||||||||||||||||||||||||||
| 3480 | - | |||||||||||||||||||||||||||||||
| 3481 | const Qt::FillRule fillRule = outline->flags == QT_FT_OUTLINE_NONE
| 0 | ||||||||||||||||||||||||||||||
| 3482 | ? Qt::WindingFill | - | ||||||||||||||||||||||||||||||
| 3483 | : Qt::OddEvenFill; | - | ||||||||||||||||||||||||||||||
| 3484 | - | |||||||||||||||||||||||||||||||
| 3485 | rasterizer->rasterize(outline, fillRule); | - | ||||||||||||||||||||||||||||||
| 3486 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3487 | } | - | ||||||||||||||||||||||||||||||
| 3488 | - | |||||||||||||||||||||||||||||||
| 3489 | rasterize(outline, callback, (void *)spanData, rasterBuffer); | - | ||||||||||||||||||||||||||||||
| 3490 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3491 | - | |||||||||||||||||||||||||||||||
| 3492 | extern "C" { | - | ||||||||||||||||||||||||||||||
| 3493 | int q_gray_rendered_spans(QT_FT_Raster raster); | - | ||||||||||||||||||||||||||||||
| 3494 | } | - | ||||||||||||||||||||||||||||||
| 3495 | - | |||||||||||||||||||||||||||||||
| 3496 | static inline uchar *alignAddress(uchar *address, quintptr alignmentMask) | - | ||||||||||||||||||||||||||||||
| 3497 | { | - | ||||||||||||||||||||||||||||||
| 3498 | return (uchar *)(((quintptr)address + alignmentMask) & ~alignmentMask); never executed: return (uchar *)(((quintptr)address + alignmentMask) & ~alignmentMask); | 0 | ||||||||||||||||||||||||||||||
| 3499 | } | - | ||||||||||||||||||||||||||||||
| 3500 | - | |||||||||||||||||||||||||||||||
| 3501 | void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, | - | ||||||||||||||||||||||||||||||
| 3502 | ProcessSpans callback, | - | ||||||||||||||||||||||||||||||
| 3503 | void *userData, QRasterBuffer *) | - | ||||||||||||||||||||||||||||||
| 3504 | { | - | ||||||||||||||||||||||||||||||
| 3505 | if (!callback || !outline)
| 0 | ||||||||||||||||||||||||||||||
| 3506 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3507 | - | |||||||||||||||||||||||||||||||
| 3508 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3509 | QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 3510 | - | |||||||||||||||||||||||||||||||
| 3511 | if (!s->flags.antialiased) {
| 0 | ||||||||||||||||||||||||||||||
| 3512 | rasterizer->setAntialiased(s->flags.antialiased); | - | ||||||||||||||||||||||||||||||
| 3513 | rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - | ||||||||||||||||||||||||||||||
| 3514 | rasterizer->setClipRect(deviceRect); | - | ||||||||||||||||||||||||||||||
| 3515 | rasterizer->initialize(callback, userData); | - | ||||||||||||||||||||||||||||||
| 3516 | - | |||||||||||||||||||||||||||||||
| 3517 | const Qt::FillRule fillRule = outline->flags == QT_FT_OUTLINE_NONE
| 0 | ||||||||||||||||||||||||||||||
| 3518 | ? Qt::WindingFill | - | ||||||||||||||||||||||||||||||
| 3519 | : Qt::OddEvenFill; | - | ||||||||||||||||||||||||||||||
| 3520 | - | |||||||||||||||||||||||||||||||
| 3521 | rasterizer->rasterize(outline, fillRule); | - | ||||||||||||||||||||||||||||||
| 3522 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3523 | } | - | ||||||||||||||||||||||||||||||
| 3524 | - | |||||||||||||||||||||||||||||||
| 3525 | // Initial size for raster pool is MINIMUM_POOL_SIZE so as to | - | ||||||||||||||||||||||||||||||
| 3526 | // minimize memory reallocations. However if initial size for | - | ||||||||||||||||||||||||||||||
| 3527 | // raster pool is changed for lower value, reallocations will | - | ||||||||||||||||||||||||||||||
| 3528 | // occur normally. | - | ||||||||||||||||||||||||||||||
| 3529 | int rasterPoolSize = MINIMUM_POOL_SIZE; | - | ||||||||||||||||||||||||||||||
| 3530 | uchar rasterPoolOnStack[MINIMUM_POOL_SIZE + 0xf]; | - | ||||||||||||||||||||||||||||||
| 3531 | uchar *rasterPoolBase = alignAddress(rasterPoolOnStack, 0xf); | - | ||||||||||||||||||||||||||||||
| 3532 | uchar *rasterPoolOnHeap = 0; | - | ||||||||||||||||||||||||||||||
| 3533 | - | |||||||||||||||||||||||||||||||
| 3534 | qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); | - | ||||||||||||||||||||||||||||||
| 3535 | - | |||||||||||||||||||||||||||||||
| 3536 | void *data = userData; | - | ||||||||||||||||||||||||||||||
| 3537 | - | |||||||||||||||||||||||||||||||
| 3538 | QT_FT_BBox clip_box = { deviceRect.x(), | - | ||||||||||||||||||||||||||||||
| 3539 | deviceRect.y(), | - | ||||||||||||||||||||||||||||||
| 3540 | deviceRect.x() + deviceRect.width(), | - | ||||||||||||||||||||||||||||||
| 3541 | deviceRect.y() + deviceRect.height() }; | - | ||||||||||||||||||||||||||||||
| 3542 | - | |||||||||||||||||||||||||||||||
| 3543 | QT_FT_Raster_Params rasterParams; | - | ||||||||||||||||||||||||||||||
| 3544 | rasterParams.target = 0; | - | ||||||||||||||||||||||||||||||
| 3545 | rasterParams.source = outline; | - | ||||||||||||||||||||||||||||||
| 3546 | rasterParams.flags = QT_FT_RASTER_FLAG_CLIP; | - | ||||||||||||||||||||||||||||||
| 3547 | rasterParams.gray_spans = 0; | - | ||||||||||||||||||||||||||||||
| 3548 | rasterParams.black_spans = 0; | - | ||||||||||||||||||||||||||||||
| 3549 | rasterParams.bit_test = 0; | - | ||||||||||||||||||||||||||||||
| 3550 | rasterParams.bit_set = 0; | - | ||||||||||||||||||||||||||||||
| 3551 | rasterParams.user = data; | - | ||||||||||||||||||||||||||||||
| 3552 | rasterParams.clip_box = clip_box; | - | ||||||||||||||||||||||||||||||
| 3553 | - | |||||||||||||||||||||||||||||||
| 3554 | bool done = false; | - | ||||||||||||||||||||||||||||||
| 3555 | int error; | - | ||||||||||||||||||||||||||||||
| 3556 | - | |||||||||||||||||||||||||||||||
| 3557 | int rendered_spans = 0; | - | ||||||||||||||||||||||||||||||
| 3558 | - | |||||||||||||||||||||||||||||||
| 3559 | while (!done) {
| 0 | ||||||||||||||||||||||||||||||
| 3560 | - | |||||||||||||||||||||||||||||||
| 3561 | rasterParams.flags |= (QT_FT_RASTER_FLAG_AA | QT_FT_RASTER_FLAG_DIRECT); | - | ||||||||||||||||||||||||||||||
| 3562 | rasterParams.gray_spans = callback; | - | ||||||||||||||||||||||||||||||
| 3563 | rasterParams.skip_spans = rendered_spans; | - | ||||||||||||||||||||||||||||||
| 3564 | error = qt_ft_grays_raster.raster_render(*grayRaster.data(), &rasterParams); | - | ||||||||||||||||||||||||||||||
| 3565 | - | |||||||||||||||||||||||||||||||
| 3566 | // Out of memory, reallocate some more and try again... | - | ||||||||||||||||||||||||||||||
| 3567 | if (error == -6) { // ErrRaster_OutOfMemory from qgrayraster.c
| 0 | ||||||||||||||||||||||||||||||
| 3568 | rasterPoolSize *= 2; | - | ||||||||||||||||||||||||||||||
| 3569 | if (rasterPoolSize > 1024 * 1024) {
| 0 | ||||||||||||||||||||||||||||||
| 3570 | qWarning("QPainter: Rasterization of primitive failed"); | - | ||||||||||||||||||||||||||||||
| 3571 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3572 | } | - | ||||||||||||||||||||||||||||||
| 3573 | - | |||||||||||||||||||||||||||||||
| 3574 | rendered_spans += q_gray_rendered_spans(*grayRaster.data()); | - | ||||||||||||||||||||||||||||||
| 3575 | - | |||||||||||||||||||||||||||||||
| 3576 | free(rasterPoolOnHeap); | - | ||||||||||||||||||||||||||||||
| 3577 | rasterPoolOnHeap = (uchar *)malloc(rasterPoolSize + 0xf); | - | ||||||||||||||||||||||||||||||
| 3578 | - | |||||||||||||||||||||||||||||||
| 3579 | Q_CHECK_PTR(rasterPoolOnHeap); // note: we just freed the old rasterPoolBase. I hope it's not fatal. never executed: qt_check_pointer(__FILE__,3579);
| 0 | ||||||||||||||||||||||||||||||
| 3580 | - | |||||||||||||||||||||||||||||||
| 3581 | rasterPoolBase = alignAddress(rasterPoolOnHeap, 0xf); | - | ||||||||||||||||||||||||||||||
| 3582 | - | |||||||||||||||||||||||||||||||
| 3583 | qt_ft_grays_raster.raster_done(*grayRaster.data()); | - | ||||||||||||||||||||||||||||||
| 3584 | qt_ft_grays_raster.raster_new(grayRaster.data()); | - | ||||||||||||||||||||||||||||||
| 3585 | qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); | - | ||||||||||||||||||||||||||||||
| 3586 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3587 | done = true; | - | ||||||||||||||||||||||||||||||
| 3588 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3589 | } | - | ||||||||||||||||||||||||||||||
| 3590 | - | |||||||||||||||||||||||||||||||
| 3591 | free(rasterPoolOnHeap); | - | ||||||||||||||||||||||||||||||
| 3592 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3593 | - | |||||||||||||||||||||||||||||||
| 3594 | void QRasterPaintEnginePrivate::recalculateFastImages() | - | ||||||||||||||||||||||||||||||
| 3595 | { | - | ||||||||||||||||||||||||||||||
| 3596 | Q_Q(QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3597 | QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 3598 | - | |||||||||||||||||||||||||||||||
| 3599 | s->flags.fast_images = !(s->renderHints & QPainter::SmoothPixmapTransform)
| 0 | ||||||||||||||||||||||||||||||
| 3600 | && s->matrix.type() <= QTransform::TxShear;
| 0 | ||||||||||||||||||||||||||||||
| 3601 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3602 | - | |||||||||||||||||||||||||||||||
| 3603 | bool QRasterPaintEnginePrivate::canUseFastImageBlending(QPainter::CompositionMode mode, const QImage &image) const | - | ||||||||||||||||||||||||||||||
| 3604 | { | - | ||||||||||||||||||||||||||||||
| 3605 | Q_Q(const QRasterPaintEngine); | - | ||||||||||||||||||||||||||||||
| 3606 | const QRasterPaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 3607 | - | |||||||||||||||||||||||||||||||
| 3608 | return s->flags.fast_images never executed: return s->flags.fast_images && (mode == QPainter::CompositionMode_SourceOver || (mode == QPainter::CompositionMode_Source && !image.hasAlphaChannel()));
| 0 | ||||||||||||||||||||||||||||||
| 3609 | && (mode == QPainter::CompositionMode_SourceOver never executed: return s->flags.fast_images && (mode == QPainter::CompositionMode_SourceOver || (mode == QPainter::CompositionMode_Source && !image.hasAlphaChannel()));
| 0 | ||||||||||||||||||||||||||||||
| 3610 | || (mode == QPainter::CompositionMode_Source never executed: return s->flags.fast_images && (mode == QPainter::CompositionMode_SourceOver || (mode == QPainter::CompositionMode_Source && !image.hasAlphaChannel()));
| 0 | ||||||||||||||||||||||||||||||
| 3611 | && !image.hasAlphaChannel())); never executed: return s->flags.fast_images && (mode == QPainter::CompositionMode_SourceOver || (mode == QPainter::CompositionMode_Source && !image.hasAlphaChannel()));
| 0 | ||||||||||||||||||||||||||||||
| 3612 | } | - | ||||||||||||||||||||||||||||||
| 3613 | - | |||||||||||||||||||||||||||||||
| 3614 | QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color) | - | ||||||||||||||||||||||||||||||
| 3615 | { | - | ||||||||||||||||||||||||||||||
| 3616 | Q_ASSERT(image.depth() == 1); | - | ||||||||||||||||||||||||||||||
| 3617 | - | |||||||||||||||||||||||||||||||
| 3618 | const QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB); | - | ||||||||||||||||||||||||||||||
| 3619 | QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||||||||
| 3620 | - | |||||||||||||||||||||||||||||||
| 3621 | QRgb fg = qPremultiply(color.rgba()); | - | ||||||||||||||||||||||||||||||
| 3622 | QRgb bg = 0; | - | ||||||||||||||||||||||||||||||
| 3623 | - | |||||||||||||||||||||||||||||||
| 3624 | int height = sourceImage.height(); | - | ||||||||||||||||||||||||||||||
| 3625 | int width = sourceImage.width(); | - | ||||||||||||||||||||||||||||||
| 3626 | for (int y=0; y<height; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 3627 | const uchar *source = sourceImage.constScanLine(y); | - | ||||||||||||||||||||||||||||||
| 3628 | QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y)); | - | ||||||||||||||||||||||||||||||
| 3629 | if (!source || !target)
| 0 | ||||||||||||||||||||||||||||||
| 3630 | QT_THROW(std::bad_alloc()); // we must have run out of memory never executed: qt_noop(); | 0 | ||||||||||||||||||||||||||||||
| 3631 | for (int x=0; x < width; ++x)
| 0 | ||||||||||||||||||||||||||||||
| 3632 | target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg; never executed: target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg;
| 0 | ||||||||||||||||||||||||||||||
| 3633 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3634 | return dest; never executed: return dest; | 0 | ||||||||||||||||||||||||||||||
| 3635 | } | - | ||||||||||||||||||||||||||||||
| 3636 | - | |||||||||||||||||||||||||||||||
| 3637 | QRasterBuffer::~QRasterBuffer() | - | ||||||||||||||||||||||||||||||
| 3638 | { | - | ||||||||||||||||||||||||||||||
| 3639 | } | - | ||||||||||||||||||||||||||||||
| 3640 | - | |||||||||||||||||||||||||||||||
| 3641 | void QRasterBuffer::init() | - | ||||||||||||||||||||||||||||||
| 3642 | { | - | ||||||||||||||||||||||||||||||
| 3643 | compositionMode = QPainter::CompositionMode_SourceOver; | - | ||||||||||||||||||||||||||||||
| 3644 | monoDestinationWithClut = false; | - | ||||||||||||||||||||||||||||||
| 3645 | destColor0 = 0; | - | ||||||||||||||||||||||||||||||
| 3646 | destColor1 = 0; | - | ||||||||||||||||||||||||||||||
| 3647 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3648 | - | |||||||||||||||||||||||||||||||
| 3649 | QImage::Format QRasterBuffer::prepare(QImage *image) | - | ||||||||||||||||||||||||||||||
| 3650 | { | - | ||||||||||||||||||||||||||||||
| 3651 | m_buffer = (uchar *)image->bits(); | - | ||||||||||||||||||||||||||||||
| 3652 | m_width = qMin(QT_RASTER_COORD_LIMIT, image->width()); | - | ||||||||||||||||||||||||||||||
| 3653 | m_height = qMin(QT_RASTER_COORD_LIMIT, image->height()); | - | ||||||||||||||||||||||||||||||
| 3654 | bytes_per_pixel = image->depth()/8; | - | ||||||||||||||||||||||||||||||
| 3655 | bytes_per_line = image->bytesPerLine(); | - | ||||||||||||||||||||||||||||||
| 3656 | - | |||||||||||||||||||||||||||||||
| 3657 | format = image->format(); | - | ||||||||||||||||||||||||||||||
| 3658 | drawHelper = qDrawHelper + format; | - | ||||||||||||||||||||||||||||||
| 3659 | if (image->depth() == 1 && image->colorTable().size() == 2) {
| 0 | ||||||||||||||||||||||||||||||
| 3660 | monoDestinationWithClut = true; | - | ||||||||||||||||||||||||||||||
| 3661 | const QVector<QRgb> colorTable = image->colorTable(); | - | ||||||||||||||||||||||||||||||
| 3662 | destColor0 = qPremultiply(colorTable[0]); | - | ||||||||||||||||||||||||||||||
| 3663 | destColor1 = qPremultiply(colorTable[1]); | - | ||||||||||||||||||||||||||||||
| 3664 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3665 | - | |||||||||||||||||||||||||||||||
| 3666 | return format; never executed: return format; | 0 | ||||||||||||||||||||||||||||||
| 3667 | } | - | ||||||||||||||||||||||||||||||
| 3668 | - | |||||||||||||||||||||||||||||||
| 3669 | void QRasterBuffer::resetBuffer(int val) | - | ||||||||||||||||||||||||||||||
| 3670 | { | - | ||||||||||||||||||||||||||||||
| 3671 | memset(m_buffer, val, m_height*bytes_per_line); | - | ||||||||||||||||||||||||||||||
| 3672 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3673 | - | |||||||||||||||||||||||||||||||
| 3674 | QClipData::QClipData(int height) | - | ||||||||||||||||||||||||||||||
| 3675 | { | - | ||||||||||||||||||||||||||||||
| 3676 | clipSpanHeight = height; | - | ||||||||||||||||||||||||||||||
| 3677 | m_clipLines = 0; | - | ||||||||||||||||||||||||||||||
| 3678 | - | |||||||||||||||||||||||||||||||
| 3679 | allocated = 0; | - | ||||||||||||||||||||||||||||||
| 3680 | m_spans = 0; | - | ||||||||||||||||||||||||||||||
| 3681 | xmin = xmax = ymin = ymax = 0; | - | ||||||||||||||||||||||||||||||
| 3682 | count = 0; | - | ||||||||||||||||||||||||||||||
| 3683 | - | |||||||||||||||||||||||||||||||
| 3684 | enabled = true; | - | ||||||||||||||||||||||||||||||
| 3685 | hasRectClip = hasRegionClip = false; | - | ||||||||||||||||||||||||||||||
| 3686 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3687 | - | |||||||||||||||||||||||||||||||
| 3688 | QClipData::~QClipData() | - | ||||||||||||||||||||||||||||||
| 3689 | { | - | ||||||||||||||||||||||||||||||
| 3690 | if (m_clipLines)
| 0 | ||||||||||||||||||||||||||||||
| 3691 | free(m_clipLines); never executed: free(m_clipLines); | 0 | ||||||||||||||||||||||||||||||
| 3692 | if (m_spans)
| 0 | ||||||||||||||||||||||||||||||
| 3693 | free(m_spans); never executed: free(m_spans); | 0 | ||||||||||||||||||||||||||||||
| 3694 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3695 | - | |||||||||||||||||||||||||||||||
| 3696 | void QClipData::initialize() | - | ||||||||||||||||||||||||||||||
| 3697 | { | - | ||||||||||||||||||||||||||||||
| 3698 | if (m_spans)
| 0 | ||||||||||||||||||||||||||||||
| 3699 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3700 | - | |||||||||||||||||||||||||||||||
| 3701 | if (!m_clipLines)
| 0 | ||||||||||||||||||||||||||||||
| 3702 | m_clipLines = (ClipLine *)calloc(sizeof(ClipLine), clipSpanHeight); never executed: m_clipLines = (ClipLine *)calloc(sizeof(ClipLine), clipSpanHeight); | 0 | ||||||||||||||||||||||||||||||
| 3703 | - | |||||||||||||||||||||||||||||||
| 3704 | Q_CHECK_PTR(m_clipLines); never executed: qt_check_pointer(__FILE__,3704);
| 0 | ||||||||||||||||||||||||||||||
| 3705 | QT_TRY { | - | ||||||||||||||||||||||||||||||
| 3706 | m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan)); | - | ||||||||||||||||||||||||||||||
| 3707 | allocated = clipSpanHeight; | - | ||||||||||||||||||||||||||||||
| 3708 | Q_CHECK_PTR(m_spans); never executed: qt_check_pointer(__FILE__,3708);
| 0 | ||||||||||||||||||||||||||||||
| 3709 | - | |||||||||||||||||||||||||||||||
| 3710 | QT_TRY { | - | ||||||||||||||||||||||||||||||
| 3711 | if (hasRectClip) {
| 0 | ||||||||||||||||||||||||||||||
| 3712 | int y = 0; | - | ||||||||||||||||||||||||||||||
| 3713 | while (y < ymin) {
| 0 | ||||||||||||||||||||||||||||||
| 3714 | m_clipLines[y].spans = 0; | - | ||||||||||||||||||||||||||||||
| 3715 | m_clipLines[y].count = 0; | - | ||||||||||||||||||||||||||||||
| 3716 | ++y; | - | ||||||||||||||||||||||||||||||
| 3717 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3718 | - | |||||||||||||||||||||||||||||||
| 3719 | const int len = clipRect.width(); | - | ||||||||||||||||||||||||||||||
| 3720 | count = 0; | - | ||||||||||||||||||||||||||||||
| 3721 | while (y < ymax) {
| 0 | ||||||||||||||||||||||||||||||
| 3722 | QSpan *span = m_spans + count; | - | ||||||||||||||||||||||||||||||
| 3723 | span->x = xmin; | - | ||||||||||||||||||||||||||||||
| 3724 | span->len = len; | - | ||||||||||||||||||||||||||||||
| 3725 | span->y = y; | - | ||||||||||||||||||||||||||||||
| 3726 | span->coverage = 255; | - | ||||||||||||||||||||||||||||||
| 3727 | ++count; | - | ||||||||||||||||||||||||||||||
| 3728 | - | |||||||||||||||||||||||||||||||
| 3729 | m_clipLines[y].spans = span; | - | ||||||||||||||||||||||||||||||
| 3730 | m_clipLines[y].count = 1; | - | ||||||||||||||||||||||||||||||
| 3731 | ++y; | - | ||||||||||||||||||||||||||||||
| 3732 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3733 | - | |||||||||||||||||||||||||||||||
| 3734 | while (y < clipSpanHeight) {
| 0 | ||||||||||||||||||||||||||||||
| 3735 | m_clipLines[y].spans = 0; | - | ||||||||||||||||||||||||||||||
| 3736 | m_clipLines[y].count = 0; | - | ||||||||||||||||||||||||||||||
| 3737 | ++y; | - | ||||||||||||||||||||||||||||||
| 3738 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3739 | } else if (hasRegionClip) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 3740 | - | |||||||||||||||||||||||||||||||
| 3741 | const QVector<QRect> rects = clipRegion.rects(); | - | ||||||||||||||||||||||||||||||
| 3742 | const int numRects = rects.size(); | - | ||||||||||||||||||||||||||||||
| 3743 | - | |||||||||||||||||||||||||||||||
| 3744 | { // resize | - | ||||||||||||||||||||||||||||||
| 3745 | const int maxSpans = (ymax - ymin) * numRects; | - | ||||||||||||||||||||||||||||||
| 3746 | if (maxSpans > allocated) {
| 0 | ||||||||||||||||||||||||||||||
| 3747 | m_spans = q_check_ptr((QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan))); | - | ||||||||||||||||||||||||||||||
| 3748 | allocated = maxSpans; | - | ||||||||||||||||||||||||||||||
| 3749 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3750 | } | - | ||||||||||||||||||||||||||||||
| 3751 | - | |||||||||||||||||||||||||||||||
| 3752 | int y = 0; | - | ||||||||||||||||||||||||||||||
| 3753 | int firstInBand = 0; | - | ||||||||||||||||||||||||||||||
| 3754 | count = 0; | - | ||||||||||||||||||||||||||||||
| 3755 | while (firstInBand < numRects) {
| 0 | ||||||||||||||||||||||||||||||
| 3756 | const int currMinY = rects.at(firstInBand).y(); | - | ||||||||||||||||||||||||||||||
| 3757 | const int currMaxY = currMinY + rects.at(firstInBand).height(); | - | ||||||||||||||||||||||||||||||
| 3758 | - | |||||||||||||||||||||||||||||||
| 3759 | while (y < currMinY) {
| 0 | ||||||||||||||||||||||||||||||
| 3760 | m_clipLines[y].spans = 0; | - | ||||||||||||||||||||||||||||||
| 3761 | m_clipLines[y].count = 0; | - | ||||||||||||||||||||||||||||||
| 3762 | ++y; | - | ||||||||||||||||||||||||||||||
| 3763 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3764 | - | |||||||||||||||||||||||||||||||
| 3765 | int lastInBand = firstInBand; | - | ||||||||||||||||||||||||||||||
| 3766 | while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y)
| 0 | ||||||||||||||||||||||||||||||
| 3767 | ++lastInBand; never executed: ++lastInBand; | 0 | ||||||||||||||||||||||||||||||
| 3768 | - | |||||||||||||||||||||||||||||||
| 3769 | while (y < currMaxY) {
| 0 | ||||||||||||||||||||||||||||||
| 3770 | - | |||||||||||||||||||||||||||||||
| 3771 | m_clipLines[y].spans = m_spans + count; | - | ||||||||||||||||||||||||||||||
| 3772 | m_clipLines[y].count = lastInBand - firstInBand + 1; | - | ||||||||||||||||||||||||||||||
| 3773 | - | |||||||||||||||||||||||||||||||
| 3774 | for (int r = firstInBand; r <= lastInBand; ++r) {
| 0 | ||||||||||||||||||||||||||||||
| 3775 | const QRect &currRect = rects.at(r); | - | ||||||||||||||||||||||||||||||
| 3776 | QSpan *span = m_spans + count; | - | ||||||||||||||||||||||||||||||
| 3777 | span->x = currRect.x(); | - | ||||||||||||||||||||||||||||||
| 3778 | span->len = currRect.width(); | - | ||||||||||||||||||||||||||||||
| 3779 | span->y = y; | - | ||||||||||||||||||||||||||||||
| 3780 | span->coverage = 255; | - | ||||||||||||||||||||||||||||||
| 3781 | ++count; | - | ||||||||||||||||||||||||||||||
| 3782 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3783 | ++y; | - | ||||||||||||||||||||||||||||||
| 3784 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3785 | - | |||||||||||||||||||||||||||||||
| 3786 | firstInBand = lastInBand + 1; | - | ||||||||||||||||||||||||||||||
| 3787 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3788 | - | |||||||||||||||||||||||||||||||
| 3789 | Q_ASSERT(count <= allocated); | - | ||||||||||||||||||||||||||||||
| 3790 | - | |||||||||||||||||||||||||||||||
| 3791 | while (y < clipSpanHeight) {
| 0 | ||||||||||||||||||||||||||||||
| 3792 | m_clipLines[y].spans = 0; | - | ||||||||||||||||||||||||||||||
| 3793 | m_clipLines[y].count = 0; | - | ||||||||||||||||||||||||||||||
| 3794 | ++y; | - | ||||||||||||||||||||||||||||||
| 3795 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3796 | - | |||||||||||||||||||||||||||||||
| 3797 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3798 | } QT_CATCH(...) { never executed: end of blockdead code: { free(m_spans); m_spans = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3799 | free(m_spans); // have to free m_spans again or someone might think that we were successfully initialized. dead code: { free(m_spans); m_spans = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3800 | m_spans = 0; dead code: { free(m_spans); m_spans = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3801 | QT_RETHROW; dead code: { free(m_spans); m_spans = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3802 | } dead code: { free(m_spans); m_spans = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3803 | } QT_CATCH(...) { dead code: { free(m_clipLines); m_clipLines = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3804 | free(m_clipLines); // same for clipLines dead code: { free(m_clipLines); m_clipLines = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3805 | m_clipLines = 0; dead code: { free(m_clipLines); m_clipLines = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3806 | QT_RETHROW; dead code: { free(m_clipLines); m_clipLines = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3807 | } dead code: { free(m_clipLines); m_clipLines = 0; qt_noop(); } | - | ||||||||||||||||||||||||||||||
| 3808 | } | - | ||||||||||||||||||||||||||||||
| 3809 | - | |||||||||||||||||||||||||||||||
| 3810 | void QClipData::fixup() | - | ||||||||||||||||||||||||||||||
| 3811 | { | - | ||||||||||||||||||||||||||||||
| 3812 | Q_ASSERT(m_spans); | - | ||||||||||||||||||||||||||||||
| 3813 | - | |||||||||||||||||||||||||||||||
| 3814 | if (count == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 3815 | ymin = ymax = xmin = xmax = 0; | - | ||||||||||||||||||||||||||||||
| 3816 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3817 | } | - | ||||||||||||||||||||||||||||||
| 3818 | - | |||||||||||||||||||||||||||||||
| 3819 | int y = -1; | - | ||||||||||||||||||||||||||||||
| 3820 | ymin = m_spans[0].y; | - | ||||||||||||||||||||||||||||||
| 3821 | ymax = m_spans[count-1].y + 1; | - | ||||||||||||||||||||||||||||||
| 3822 | xmin = INT_MAX; | - | ||||||||||||||||||||||||||||||
| 3823 | xmax = 0; | - | ||||||||||||||||||||||||||||||
| 3824 | - | |||||||||||||||||||||||||||||||
| 3825 | const int firstLeft = m_spans[0].x; | - | ||||||||||||||||||||||||||||||
| 3826 | const int firstRight = m_spans[0].x + m_spans[0].len; | - | ||||||||||||||||||||||||||||||
| 3827 | bool isRect = true; | - | ||||||||||||||||||||||||||||||
| 3828 | - | |||||||||||||||||||||||||||||||
| 3829 | for (int i = 0; i < count; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 3830 | QT_FT_Span_& span = m_spans[i]; | - | ||||||||||||||||||||||||||||||
| 3831 | - | |||||||||||||||||||||||||||||||
| 3832 | if (span.y != y) {
| 0 | ||||||||||||||||||||||||||||||
| 3833 | if (span.y != y + 1 && y != -1)
| 0 | ||||||||||||||||||||||||||||||
| 3834 | isRect = false; never executed: isRect = false; | 0 | ||||||||||||||||||||||||||||||
| 3835 | y = span.y; | - | ||||||||||||||||||||||||||||||
| 3836 | m_clipLines[y].spans = &span; | - | ||||||||||||||||||||||||||||||
| 3837 | m_clipLines[y].count = 1; | - | ||||||||||||||||||||||||||||||
| 3838 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3839 | ++m_clipLines[y].count; never executed: ++m_clipLines[y].count; | 0 | ||||||||||||||||||||||||||||||
| 3840 | - | |||||||||||||||||||||||||||||||
| 3841 | const int spanLeft = span.x; | - | ||||||||||||||||||||||||||||||
| 3842 | const int spanRight = spanLeft + span.len; | - | ||||||||||||||||||||||||||||||
| 3843 | - | |||||||||||||||||||||||||||||||
| 3844 | if (spanLeft < xmin)
| 0 | ||||||||||||||||||||||||||||||
| 3845 | xmin = spanLeft; never executed: xmin = spanLeft; | 0 | ||||||||||||||||||||||||||||||
| 3846 | - | |||||||||||||||||||||||||||||||
| 3847 | if (spanRight > xmax)
| 0 | ||||||||||||||||||||||||||||||
| 3848 | xmax = spanRight; never executed: xmax = spanRight; | 0 | ||||||||||||||||||||||||||||||
| 3849 | - | |||||||||||||||||||||||||||||||
| 3850 | if (spanLeft != firstLeft || spanRight != firstRight)
| 0 | ||||||||||||||||||||||||||||||
| 3851 | isRect = false; never executed: isRect = false; | 0 | ||||||||||||||||||||||||||||||
| 3852 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3853 | - | |||||||||||||||||||||||||||||||
| 3854 | if (isRect) {
| 0 | ||||||||||||||||||||||||||||||
| 3855 | hasRectClip = true; | - | ||||||||||||||||||||||||||||||
| 3856 | clipRect.setRect(xmin, ymin, xmax - xmin, ymax - ymin); | - | ||||||||||||||||||||||||||||||
| 3857 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3858 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3859 | - | |||||||||||||||||||||||||||||||
| 3860 | /* | - | ||||||||||||||||||||||||||||||
| 3861 | Convert \a rect to clip spans. | - | ||||||||||||||||||||||||||||||
| 3862 | */ | - | ||||||||||||||||||||||||||||||
| 3863 | void QClipData::setClipRect(const QRect &rect) | - | ||||||||||||||||||||||||||||||
| 3864 | { | - | ||||||||||||||||||||||||||||||
| 3865 | if (hasRectClip && rect == clipRect)
| 0 | ||||||||||||||||||||||||||||||
| 3866 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3867 | - | |||||||||||||||||||||||||||||||
| 3868 | // qDebug() << "setClipRect" << clipSpanHeight << count << allocated << rect; | - | ||||||||||||||||||||||||||||||
| 3869 | hasRectClip = true; | - | ||||||||||||||||||||||||||||||
| 3870 | hasRegionClip = false; | - | ||||||||||||||||||||||||||||||
| 3871 | clipRect = rect; | - | ||||||||||||||||||||||||||||||
| 3872 | - | |||||||||||||||||||||||||||||||
| 3873 | xmin = rect.x(); | - | ||||||||||||||||||||||||||||||
| 3874 | xmax = rect.x() + rect.width(); | - | ||||||||||||||||||||||||||||||
| 3875 | ymin = qMin(rect.y(), clipSpanHeight); | - | ||||||||||||||||||||||||||||||
| 3876 | ymax = qMin(rect.y() + rect.height(), clipSpanHeight); | - | ||||||||||||||||||||||||||||||
| 3877 | - | |||||||||||||||||||||||||||||||
| 3878 | if (m_spans) {
| 0 | ||||||||||||||||||||||||||||||
| 3879 | free(m_spans); | - | ||||||||||||||||||||||||||||||
| 3880 | m_spans = 0; | - | ||||||||||||||||||||||||||||||
| 3881 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3882 | - | |||||||||||||||||||||||||||||||
| 3883 | // qDebug() << xmin << xmax << ymin << ymax; | - | ||||||||||||||||||||||||||||||
| 3884 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3885 | - | |||||||||||||||||||||||||||||||
| 3886 | /* | - | ||||||||||||||||||||||||||||||
| 3887 | Convert \a region to clip spans. | - | ||||||||||||||||||||||||||||||
| 3888 | */ | - | ||||||||||||||||||||||||||||||
| 3889 | void QClipData::setClipRegion(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||
| 3890 | { | - | ||||||||||||||||||||||||||||||
| 3891 | if (region.rectCount() == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 3892 | setClipRect(region.boundingRect()); | - | ||||||||||||||||||||||||||||||
| 3893 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 3894 | } | - | ||||||||||||||||||||||||||||||
| 3895 | - | |||||||||||||||||||||||||||||||
| 3896 | hasRegionClip = true; | - | ||||||||||||||||||||||||||||||
| 3897 | hasRectClip = false; | - | ||||||||||||||||||||||||||||||
| 3898 | clipRegion = region; | - | ||||||||||||||||||||||||||||||
| 3899 | - | |||||||||||||||||||||||||||||||
| 3900 | { // set bounding rect | - | ||||||||||||||||||||||||||||||
| 3901 | const QRect rect = region.boundingRect(); | - | ||||||||||||||||||||||||||||||
| 3902 | xmin = rect.x(); | - | ||||||||||||||||||||||||||||||
| 3903 | xmax = rect.x() + rect.width(); | - | ||||||||||||||||||||||||||||||
| 3904 | ymin = rect.y(); | - | ||||||||||||||||||||||||||||||
| 3905 | ymax = rect.y() + rect.height(); | - | ||||||||||||||||||||||||||||||
| 3906 | } | - | ||||||||||||||||||||||||||||||
| 3907 | - | |||||||||||||||||||||||||||||||
| 3908 | if (m_spans) {
| 0 | ||||||||||||||||||||||||||||||
| 3909 | free(m_spans); | - | ||||||||||||||||||||||||||||||
| 3910 | m_spans = 0; | - | ||||||||||||||||||||||||||||||
| 3911 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3912 | - | |||||||||||||||||||||||||||||||
| 3913 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3914 | - | |||||||||||||||||||||||||||||||
| 3915 | /*! | - | ||||||||||||||||||||||||||||||
| 3916 | \internal | - | ||||||||||||||||||||||||||||||
| 3917 | spans must be sorted on y | - | ||||||||||||||||||||||||||||||
| 3918 | */ | - | ||||||||||||||||||||||||||||||
| 3919 | static const QSpan *qt_intersect_spans(const QClipData *clip, int *currentClip, | - | ||||||||||||||||||||||||||||||
| 3920 | const QSpan *spans, const QSpan *end, | - | ||||||||||||||||||||||||||||||
| 3921 | QSpan **outSpans, int available) | - | ||||||||||||||||||||||||||||||
| 3922 | { | - | ||||||||||||||||||||||||||||||
| 3923 | const_cast<QClipData *>(clip)->initialize(); | - | ||||||||||||||||||||||||||||||
| 3924 | - | |||||||||||||||||||||||||||||||
| 3925 | QSpan *out = *outSpans; | - | ||||||||||||||||||||||||||||||
| 3926 | - | |||||||||||||||||||||||||||||||
| 3927 | const QSpan *clipSpans = clip->m_spans + *currentClip; | - | ||||||||||||||||||||||||||||||
| 3928 | const QSpan *clipEnd = clip->m_spans + clip->count; | - | ||||||||||||||||||||||||||||||
| 3929 | - | |||||||||||||||||||||||||||||||
| 3930 | while (available && spans < end ) {
| 0 | ||||||||||||||||||||||||||||||
| 3931 | if (clipSpans >= clipEnd) {
| 0 | ||||||||||||||||||||||||||||||
| 3932 | spans = end; | - | ||||||||||||||||||||||||||||||
| 3933 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 3934 | } | - | ||||||||||||||||||||||||||||||
| 3935 | if (clipSpans->y > spans->y) {
| 0 | ||||||||||||||||||||||||||||||
| 3936 | ++spans; | - | ||||||||||||||||||||||||||||||
| 3937 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 3938 | } | - | ||||||||||||||||||||||||||||||
| 3939 | if (spans->y != clipSpans->y) {
| 0 | ||||||||||||||||||||||||||||||
| 3940 | if (spans->y < clip->count && clip->m_clipLines[spans->y].spans)
| 0 | ||||||||||||||||||||||||||||||
| 3941 | clipSpans = clip->m_clipLines[spans->y].spans; never executed: clipSpans = clip->m_clipLines[spans->y].spans; | 0 | ||||||||||||||||||||||||||||||
| 3942 | else | - | ||||||||||||||||||||||||||||||
| 3943 | ++clipSpans; never executed: ++clipSpans; | 0 | ||||||||||||||||||||||||||||||
| 3944 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 3945 | } | - | ||||||||||||||||||||||||||||||
| 3946 | Q_ASSERT(spans->y == clipSpans->y); | - | ||||||||||||||||||||||||||||||
| 3947 | - | |||||||||||||||||||||||||||||||
| 3948 | int sx1 = spans->x; | - | ||||||||||||||||||||||||||||||
| 3949 | int sx2 = sx1 + spans->len; | - | ||||||||||||||||||||||||||||||
| 3950 | int cx1 = clipSpans->x; | - | ||||||||||||||||||||||||||||||
| 3951 | int cx2 = cx1 + clipSpans->len; | - | ||||||||||||||||||||||||||||||
| 3952 | - | |||||||||||||||||||||||||||||||
| 3953 | if (cx1 < sx1 && cx2 < sx1) {
| 0 | ||||||||||||||||||||||||||||||
| 3954 | ++clipSpans; | - | ||||||||||||||||||||||||||||||
| 3955 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 3956 | } else if (sx1 < cx1 && sx2 < cx1) {
| 0 | ||||||||||||||||||||||||||||||
| 3957 | ++spans; | - | ||||||||||||||||||||||||||||||
| 3958 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 3959 | } | - | ||||||||||||||||||||||||||||||
| 3960 | int x = qMax(sx1, cx1); | - | ||||||||||||||||||||||||||||||
| 3961 | int len = qMin(sx2, cx2) - x; | - | ||||||||||||||||||||||||||||||
| 3962 | if (len) {
| 0 | ||||||||||||||||||||||||||||||
| 3963 | out->x = qMax(sx1, cx1); | - | ||||||||||||||||||||||||||||||
| 3964 | out->len = qMin(sx2, cx2) - out->x; | - | ||||||||||||||||||||||||||||||
| 3965 | out->y = spans->y; | - | ||||||||||||||||||||||||||||||
| 3966 | out->coverage = qt_div_255(spans->coverage * clipSpans->coverage); | - | ||||||||||||||||||||||||||||||
| 3967 | ++out; | - | ||||||||||||||||||||||||||||||
| 3968 | --available; | - | ||||||||||||||||||||||||||||||
| 3969 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3970 | if (sx2 < cx2) {
| 0 | ||||||||||||||||||||||||||||||
| 3971 | ++spans; | - | ||||||||||||||||||||||||||||||
| 3972 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3973 | ++clipSpans; | - | ||||||||||||||||||||||||||||||
| 3974 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 3975 | } | - | ||||||||||||||||||||||||||||||
| 3976 | - | |||||||||||||||||||||||||||||||
| 3977 | *outSpans = out; | - | ||||||||||||||||||||||||||||||
| 3978 | *currentClip = clipSpans - clip->m_spans; | - | ||||||||||||||||||||||||||||||
| 3979 | return spans; never executed: return spans; | 0 | ||||||||||||||||||||||||||||||
| 3980 | } | - | ||||||||||||||||||||||||||||||
| 3981 | - | |||||||||||||||||||||||||||||||
| 3982 | static void qt_span_fill_clipped(int spanCount, const QSpan *spans, void *userData) | - | ||||||||||||||||||||||||||||||
| 3983 | { | - | ||||||||||||||||||||||||||||||
| 3984 | // qDebug() << "qt_span_fill_clipped" << spanCount; | - | ||||||||||||||||||||||||||||||
| 3985 | QSpanData *fillData = reinterpret_cast<QSpanData *>(userData); | - | ||||||||||||||||||||||||||||||
| 3986 | - | |||||||||||||||||||||||||||||||
| 3987 | Q_ASSERT(fillData->blend && fillData->unclipped_blend); | - | ||||||||||||||||||||||||||||||
| 3988 | - | |||||||||||||||||||||||||||||||
| 3989 | const int NSPANS = 256; | - | ||||||||||||||||||||||||||||||
| 3990 | QSpan cspans[NSPANS]; | - | ||||||||||||||||||||||||||||||
| 3991 | int currentClip = 0; | - | ||||||||||||||||||||||||||||||
| 3992 | const QSpan *end = spans + spanCount; | - | ||||||||||||||||||||||||||||||
| 3993 | while (spans < end) {
| 0 | ||||||||||||||||||||||||||||||
| 3994 | QSpan *clipped = cspans; | - | ||||||||||||||||||||||||||||||
| 3995 | spans = qt_intersect_spans(fillData->clip, ¤tClip, spans, end, &clipped, NSPANS); | - | ||||||||||||||||||||||||||||||
| 3996 | // qDebug() << "processed " << spanCount - (end - spans) << "clipped" << clipped-cspans | - | ||||||||||||||||||||||||||||||
| 3997 | // << "span:" << cspans->x << cspans->y << cspans->len << spans->coverage; | - | ||||||||||||||||||||||||||||||
| 3998 | - | |||||||||||||||||||||||||||||||
| 3999 | if (clipped - cspans)
| 0 | ||||||||||||||||||||||||||||||
| 4000 | fillData->unclipped_blend(clipped - cspans, cspans, fillData); never executed: fillData->unclipped_blend(clipped - cspans, cspans, fillData); | 0 | ||||||||||||||||||||||||||||||
| 4001 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4002 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4003 | - | |||||||||||||||||||||||||||||||
| 4004 | /* | - | ||||||||||||||||||||||||||||||
| 4005 | \internal | - | ||||||||||||||||||||||||||||||
| 4006 | Clip spans to \a{clip}-rectangle. | - | ||||||||||||||||||||||||||||||
| 4007 | Returns number of unclipped spans | - | ||||||||||||||||||||||||||||||
| 4008 | */ | - | ||||||||||||||||||||||||||||||
| 4009 | static int qt_intersect_spans(QT_FT_Span *spans, int numSpans, | - | ||||||||||||||||||||||||||||||
| 4010 | const QRect &clip) | - | ||||||||||||||||||||||||||||||
| 4011 | { | - | ||||||||||||||||||||||||||||||
| 4012 | const short minx = clip.left(); | - | ||||||||||||||||||||||||||||||
| 4013 | const short miny = clip.top(); | - | ||||||||||||||||||||||||||||||
| 4014 | const short maxx = clip.right(); | - | ||||||||||||||||||||||||||||||
| 4015 | const short maxy = clip.bottom(); | - | ||||||||||||||||||||||||||||||
| 4016 | - | |||||||||||||||||||||||||||||||
| 4017 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 4018 | for (int i = 0; i < numSpans; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 4019 | if (spans[i].y > maxy)
| 0 | ||||||||||||||||||||||||||||||
| 4020 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4021 | if (spans[i].y < miny
| 0 | ||||||||||||||||||||||||||||||
| 4022 | || spans[i].x > maxx
| 0 | ||||||||||||||||||||||||||||||
| 4023 | || spans[i].x + spans[i].len <= minx) {
| 0 | ||||||||||||||||||||||||||||||
| 4024 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 4025 | } | - | ||||||||||||||||||||||||||||||
| 4026 | if (spans[i].x < minx) {
| 0 | ||||||||||||||||||||||||||||||
| 4027 | spans[n].len = qMin(spans[i].len - (minx - spans[i].x), maxx - minx + 1); | - | ||||||||||||||||||||||||||||||
| 4028 | spans[n].x = minx; | - | ||||||||||||||||||||||||||||||
| 4029 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4030 | spans[n].x = spans[i].x; | - | ||||||||||||||||||||||||||||||
| 4031 | spans[n].len = qMin(spans[i].len, ushort(maxx - spans[n].x + 1)); | - | ||||||||||||||||||||||||||||||
| 4032 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4033 | if (spans[n].len == 0)
| 0 | ||||||||||||||||||||||||||||||
| 4034 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 4035 | spans[n].y = spans[i].y; | - | ||||||||||||||||||||||||||||||
| 4036 | spans[n].coverage = spans[i].coverage; | - | ||||||||||||||||||||||||||||||
| 4037 | ++n; | - | ||||||||||||||||||||||||||||||
| 4038 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4039 | return n; never executed: return n; | 0 | ||||||||||||||||||||||||||||||
| 4040 | } | - | ||||||||||||||||||||||||||||||
| 4041 | - | |||||||||||||||||||||||||||||||
| 4042 | - | |||||||||||||||||||||||||||||||
| 4043 | static void qt_span_fill_clipRect(int count, const QSpan *spans, | - | ||||||||||||||||||||||||||||||
| 4044 | void *userData) | - | ||||||||||||||||||||||||||||||
| 4045 | { | - | ||||||||||||||||||||||||||||||
| 4046 | QSpanData *fillData = reinterpret_cast<QSpanData *>(userData); | - | ||||||||||||||||||||||||||||||
| 4047 | Q_ASSERT(fillData->blend && fillData->unclipped_blend); | - | ||||||||||||||||||||||||||||||
| 4048 | - | |||||||||||||||||||||||||||||||
| 4049 | Q_ASSERT(fillData->clip); | - | ||||||||||||||||||||||||||||||
| 4050 | Q_ASSERT(!fillData->clip->clipRect.isEmpty()); | - | ||||||||||||||||||||||||||||||
| 4051 | - | |||||||||||||||||||||||||||||||
| 4052 | // hw: check if this const_cast<> is safe!!! | - | ||||||||||||||||||||||||||||||
| 4053 | count = qt_intersect_spans(const_cast<QSpan*>(spans), count, | - | ||||||||||||||||||||||||||||||
| 4054 | fillData->clip->clipRect); | - | ||||||||||||||||||||||||||||||
| 4055 | if (count > 0)
| 0 | ||||||||||||||||||||||||||||||
| 4056 | fillData->unclipped_blend(count, spans, fillData); never executed: fillData->unclipped_blend(count, spans, fillData); | 0 | ||||||||||||||||||||||||||||||
| 4057 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4058 | - | |||||||||||||||||||||||||||||||
| 4059 | static void qt_span_clip(int count, const QSpan *spans, void *userData) | - | ||||||||||||||||||||||||||||||
| 4060 | { | - | ||||||||||||||||||||||||||||||
| 4061 | ClipData *clipData = reinterpret_cast<ClipData *>(userData); | - | ||||||||||||||||||||||||||||||
| 4062 | - | |||||||||||||||||||||||||||||||
| 4063 | // qDebug() << " qt_span_clip: " << count << clipData->operation; | - | ||||||||||||||||||||||||||||||
| 4064 | // for (int i = 0; i < qMin(count, 10); ++i) { | - | ||||||||||||||||||||||||||||||
| 4065 | // qDebug() << " " << spans[i].x << spans[i].y << spans[i].len << spans[i].coverage; | - | ||||||||||||||||||||||||||||||
| 4066 | // } | - | ||||||||||||||||||||||||||||||
| 4067 | - | |||||||||||||||||||||||||||||||
| 4068 | switch (clipData->operation) { | - | ||||||||||||||||||||||||||||||
| 4069 | - | |||||||||||||||||||||||||||||||
| 4070 | case Qt::IntersectClip: never executed: case Qt::IntersectClip: | 0 | ||||||||||||||||||||||||||||||
| 4071 | { | - | ||||||||||||||||||||||||||||||
| 4072 | QClipData *newClip = clipData->newClip; | - | ||||||||||||||||||||||||||||||
| 4073 | newClip->initialize(); | - | ||||||||||||||||||||||||||||||
| 4074 | - | |||||||||||||||||||||||||||||||
| 4075 | int currentClip = 0; | - | ||||||||||||||||||||||||||||||
| 4076 | const QSpan *end = spans + count; | - | ||||||||||||||||||||||||||||||
| 4077 | while (spans < end) {
| 0 | ||||||||||||||||||||||||||||||
| 4078 | QSpan *newspans = newClip->m_spans + newClip->count; | - | ||||||||||||||||||||||||||||||
| 4079 | spans = qt_intersect_spans(clipData->oldClip, ¤tClip, spans, end, | - | ||||||||||||||||||||||||||||||
| 4080 | &newspans, newClip->allocated - newClip->count); | - | ||||||||||||||||||||||||||||||
| 4081 | newClip->count = newspans - newClip->m_spans; | - | ||||||||||||||||||||||||||||||
| 4082 | if (spans < end) {
| 0 | ||||||||||||||||||||||||||||||
| 4083 | newClip->m_spans = q_check_ptr((QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan))); | - | ||||||||||||||||||||||||||||||
| 4084 | newClip->allocated *= 2; | - | ||||||||||||||||||||||||||||||
| 4085 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4086 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4087 | } | - | ||||||||||||||||||||||||||||||
| 4088 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4089 | - | |||||||||||||||||||||||||||||||
| 4090 | case Qt::ReplaceClip: never executed: case Qt::ReplaceClip: | 0 | ||||||||||||||||||||||||||||||
| 4091 | clipData->newClip->appendSpans(spans, count); | - | ||||||||||||||||||||||||||||||
| 4092 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4093 | case Qt::NoClip: never executed: case Qt::NoClip: | 0 | ||||||||||||||||||||||||||||||
| 4094 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4095 | } | - | ||||||||||||||||||||||||||||||
| 4096 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4097 | - | |||||||||||||||||||||||||||||||
| 4098 | #ifndef QT_NO_DEBUG | - | ||||||||||||||||||||||||||||||
| 4099 | QImage QRasterBuffer::bufferImage() const | - | ||||||||||||||||||||||||||||||
| 4100 | { | - | ||||||||||||||||||||||||||||||
| 4101 | QImage image(m_width, m_height, QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||||||||
| 4102 | - | |||||||||||||||||||||||||||||||
| 4103 | for (int y = 0; y < m_height; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 4104 | uint *span = (uint *)const_cast<QRasterBuffer *>(this)->scanLine(y); | - | ||||||||||||||||||||||||||||||
| 4105 | - | |||||||||||||||||||||||||||||||
| 4106 | for (int x=0; x<m_width; ++x) {
| 0 | ||||||||||||||||||||||||||||||
| 4107 | uint argb = span[x]; | - | ||||||||||||||||||||||||||||||
| 4108 | image.setPixel(x, y, argb); | - | ||||||||||||||||||||||||||||||
| 4109 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4110 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4111 | return image; never executed: return image; | 0 | ||||||||||||||||||||||||||||||
| 4112 | } | - | ||||||||||||||||||||||||||||||
| 4113 | #endif | - | ||||||||||||||||||||||||||||||
| 4114 | - | |||||||||||||||||||||||||||||||
| 4115 | - | |||||||||||||||||||||||||||||||
| 4116 | void QRasterBuffer::flushToARGBImage(QImage *target) const | - | ||||||||||||||||||||||||||||||
| 4117 | { | - | ||||||||||||||||||||||||||||||
| 4118 | int w = qMin(m_width, target->width()); | - | ||||||||||||||||||||||||||||||
| 4119 | int h = qMin(m_height, target->height()); | - | ||||||||||||||||||||||||||||||
| 4120 | - | |||||||||||||||||||||||||||||||
| 4121 | for (int y=0; y<h; ++y) {
| 0 | ||||||||||||||||||||||||||||||
| 4122 | uint *sourceLine = (uint *)const_cast<QRasterBuffer *>(this)->scanLine(y); | - | ||||||||||||||||||||||||||||||
| 4123 | QRgb *dest = (QRgb *) target->scanLine(y); | - | ||||||||||||||||||||||||||||||
| 4124 | for (int x=0; x<w; ++x) {
| 0 | ||||||||||||||||||||||||||||||
| 4125 | QRgb pixel = sourceLine[x]; | - | ||||||||||||||||||||||||||||||
| 4126 | int alpha = qAlpha(pixel); | - | ||||||||||||||||||||||||||||||
| 4127 | if (!alpha) {
| 0 | ||||||||||||||||||||||||||||||
| 4128 | dest[x] = 0; | - | ||||||||||||||||||||||||||||||
| 4129 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4130 | dest[x] = (alpha << 24) | - | ||||||||||||||||||||||||||||||
| 4131 | | ((255*qRed(pixel)/alpha) << 16) | - | ||||||||||||||||||||||||||||||
| 4132 | | ((255*qGreen(pixel)/alpha) << 8) | - | ||||||||||||||||||||||||||||||
| 4133 | | ((255*qBlue(pixel)/alpha) << 0); | - | ||||||||||||||||||||||||||||||
| 4134 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4135 | } | - | ||||||||||||||||||||||||||||||
| 4136 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4137 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4138 | - | |||||||||||||||||||||||||||||||
| 4139 | - | |||||||||||||||||||||||||||||||
| 4140 | class QGradientCache | - | ||||||||||||||||||||||||||||||
| 4141 | { | - | ||||||||||||||||||||||||||||||
| 4142 | public: | - | ||||||||||||||||||||||||||||||
| 4143 | struct CacheInfo : QSpanData::Pinnable | - | ||||||||||||||||||||||||||||||
| 4144 | { | - | ||||||||||||||||||||||||||||||
| 4145 | inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : | - | ||||||||||||||||||||||||||||||
| 4146 | stops(qMove(s)), opacity(op), interpolationMode(mode) {} never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4147 | QRgba64 buffer64[GRADIENT_STOPTABLE_SIZE]; | - | ||||||||||||||||||||||||||||||
| 4148 | QRgb buffer32[GRADIENT_STOPTABLE_SIZE]; | - | ||||||||||||||||||||||||||||||
| 4149 | QGradientStops stops; | - | ||||||||||||||||||||||||||||||
| 4150 | int opacity; | - | ||||||||||||||||||||||||||||||
| 4151 | QGradient::InterpolationMode interpolationMode; | - | ||||||||||||||||||||||||||||||
| 4152 | }; | - | ||||||||||||||||||||||||||||||
| 4153 | - | |||||||||||||||||||||||||||||||
| 4154 | typedef QMultiHash<quint64, QSharedPointer<const CacheInfo> > QGradientColorTableHash; | - | ||||||||||||||||||||||||||||||
| 4155 | - | |||||||||||||||||||||||||||||||
| 4156 | inline QSharedPointer<const CacheInfo> getBuffer(const QGradient &gradient, int opacity) { | - | ||||||||||||||||||||||||||||||
| 4157 | quint64 hash_val = 0; | - | ||||||||||||||||||||||||||||||
| 4158 | - | |||||||||||||||||||||||||||||||
| 4159 | const QGradientStops stops = gradient.stops(); | - | ||||||||||||||||||||||||||||||
| 4160 | for (int i = 0; i < stops.size() && i <= 2; i++)
| 0 | ||||||||||||||||||||||||||||||
| 4161 | hash_val += stops[i].second.rgba64(); never executed: hash_val += stops[i].second.rgba64(); | 0 | ||||||||||||||||||||||||||||||
| 4162 | - | |||||||||||||||||||||||||||||||
| 4163 | QMutexLocker lock(&mutex); | - | ||||||||||||||||||||||||||||||
| 4164 | QGradientColorTableHash::const_iterator it = cache.constFind(hash_val); | - | ||||||||||||||||||||||||||||||
| 4165 | - | |||||||||||||||||||||||||||||||
| 4166 | if (it == cache.constEnd())
| 0 | ||||||||||||||||||||||||||||||
| 4167 | return addCacheElement(hash_val, gradient, opacity); never executed: return addCacheElement(hash_val, gradient, opacity); | 0 | ||||||||||||||||||||||||||||||
| 4168 | else { | - | ||||||||||||||||||||||||||||||
| 4169 | do { | - | ||||||||||||||||||||||||||||||
| 4170 | const QSharedPointer<const CacheInfo> &cache_info = it.value(); | - | ||||||||||||||||||||||||||||||
| 4171 | if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode())
| 0 | ||||||||||||||||||||||||||||||
| 4172 | return cache_info; never executed: return cache_info; | 0 | ||||||||||||||||||||||||||||||
| 4173 | ++it; | - | ||||||||||||||||||||||||||||||
| 4174 | } while (it != cache.constEnd() && it.key() == hash_val); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 4175 | // an exact match for these stops and opacity was not found, create new cache | - | ||||||||||||||||||||||||||||||
| 4176 | return addCacheElement(hash_val, gradient, opacity); never executed: return addCacheElement(hash_val, gradient, opacity); | 0 | ||||||||||||||||||||||||||||||
| 4177 | } | - | ||||||||||||||||||||||||||||||
| 4178 | } | - | ||||||||||||||||||||||||||||||
| 4179 | - | |||||||||||||||||||||||||||||||
| 4180 | inline int paletteSize() const { return GRADIENT_STOPTABLE_SIZE; } never executed: return 1024; | 0 | ||||||||||||||||||||||||||||||
| 4181 | protected: | - | ||||||||||||||||||||||||||||||
| 4182 | inline int maxCacheSize() const { return 60; } never executed: return 60; | 0 | ||||||||||||||||||||||||||||||
| 4183 | inline void generateGradientColorTable(const QGradient& g, | - | ||||||||||||||||||||||||||||||
| 4184 | QRgba64 *colorTable, | - | ||||||||||||||||||||||||||||||
| 4185 | int size, int opacity) const; | - | ||||||||||||||||||||||||||||||
| 4186 | QSharedPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { | - | ||||||||||||||||||||||||||||||
| 4187 | if (cache.size() == maxCacheSize()) {
| 0 | ||||||||||||||||||||||||||||||
| 4188 | // may remove more than 1, but OK | - | ||||||||||||||||||||||||||||||
| 4189 | cache.erase(cache.begin() + (qrand() % maxCacheSize())); | - | ||||||||||||||||||||||||||||||
| 4190 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4191 | QSharedPointer<CacheInfo> cache_entry(new CacheInfo(gradient.stops(), opacity, gradient.interpolationMode())); | - | ||||||||||||||||||||||||||||||
| 4192 | generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity); | - | ||||||||||||||||||||||||||||||
| 4193 | for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 4194 | cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); never executed: cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); | 0 | ||||||||||||||||||||||||||||||
| 4195 | return cache.insert(hash_val, cache_entry).value(); never executed: return cache.insert(hash_val, cache_entry).value(); | 0 | ||||||||||||||||||||||||||||||
| 4196 | } | - | ||||||||||||||||||||||||||||||
| 4197 | - | |||||||||||||||||||||||||||||||
| 4198 | QGradientColorTableHash cache; | - | ||||||||||||||||||||||||||||||
| 4199 | QMutex mutex; | - | ||||||||||||||||||||||||||||||
| 4200 | }; | - | ||||||||||||||||||||||||||||||
| 4201 | - | |||||||||||||||||||||||||||||||
| 4202 | void QGradientCache::generateGradientColorTable(const QGradient& gradient, QRgba64 *colorTable, int size, int opacity) const | - | ||||||||||||||||||||||||||||||
| 4203 | { | - | ||||||||||||||||||||||||||||||
| 4204 | const QGradientStops stops = gradient.stops(); | - | ||||||||||||||||||||||||||||||
| 4205 | int stopCount = stops.count(); | - | ||||||||||||||||||||||||||||||
| 4206 | Q_ASSERT(stopCount > 0); | - | ||||||||||||||||||||||||||||||
| 4207 | - | |||||||||||||||||||||||||||||||
| 4208 | bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation); | - | ||||||||||||||||||||||||||||||
| 4209 | - | |||||||||||||||||||||||||||||||
| 4210 | if (stopCount == 2) {
| 0 | ||||||||||||||||||||||||||||||
| 4211 | QRgba64 first_color = combineAlpha256(stops[0].second.rgba64(), opacity); | - | ||||||||||||||||||||||||||||||
| 4212 | QRgba64 second_color = combineAlpha256(stops[1].second.rgba64(), opacity); | - | ||||||||||||||||||||||||||||||
| 4213 | - | |||||||||||||||||||||||||||||||
| 4214 | qreal first_stop = stops[0].first; | - | ||||||||||||||||||||||||||||||
| 4215 | qreal second_stop = stops[1].first; | - | ||||||||||||||||||||||||||||||
| 4216 | - | |||||||||||||||||||||||||||||||
| 4217 | if (second_stop < first_stop) {
| 0 | ||||||||||||||||||||||||||||||
| 4218 | quint64 tmp = first_color; | - | ||||||||||||||||||||||||||||||
| 4219 | first_color = second_color; | - | ||||||||||||||||||||||||||||||
| 4220 | second_color = tmp; | - | ||||||||||||||||||||||||||||||
| 4221 | qSwap(first_stop, second_stop); | - | ||||||||||||||||||||||||||||||
| 4222 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4223 | - | |||||||||||||||||||||||||||||||
| 4224 | if (colorInterpolation) {
| 0 | ||||||||||||||||||||||||||||||
| 4225 | first_color = qPremultiply(first_color); | - | ||||||||||||||||||||||||||||||
| 4226 | second_color = qPremultiply(second_color); | - | ||||||||||||||||||||||||||||||
| 4227 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4228 | - | |||||||||||||||||||||||||||||||
| 4229 | int first_index = qRound(first_stop * (GRADIENT_STOPTABLE_SIZE-1)); | - | ||||||||||||||||||||||||||||||
| 4230 | int second_index = qRound(second_stop * (GRADIENT_STOPTABLE_SIZE-1)); | - | ||||||||||||||||||||||||||||||
| 4231 | - | |||||||||||||||||||||||||||||||
| 4232 | uint red_first = uint(first_color.red()) << 16; | - | ||||||||||||||||||||||||||||||
| 4233 | uint green_first = uint(first_color.green()) << 16; | - | ||||||||||||||||||||||||||||||
| 4234 | uint blue_first = uint(first_color.blue()) << 16; | - | ||||||||||||||||||||||||||||||
| 4235 | uint alpha_first = uint(first_color.alpha()) << 16; | - | ||||||||||||||||||||||||||||||
| 4236 | - | |||||||||||||||||||||||||||||||
| 4237 | uint red_second = uint(second_color.red()) << 16; | - | ||||||||||||||||||||||||||||||
| 4238 | uint green_second = uint(second_color.green()) << 16; | - | ||||||||||||||||||||||||||||||
| 4239 | uint blue_second = uint(second_color.blue()) << 16; | - | ||||||||||||||||||||||||||||||
| 4240 | uint alpha_second = uint(second_color.alpha()) << 16; | - | ||||||||||||||||||||||||||||||
| 4241 | - | |||||||||||||||||||||||||||||||
| 4242 | int i = 0; | - | ||||||||||||||||||||||||||||||
| 4243 | for (; i <= qMin(GRADIENT_STOPTABLE_SIZE, first_index); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 4244 | if (colorInterpolation)
| 0 | ||||||||||||||||||||||||||||||
| 4245 | colorTable[i] = first_color; never executed: colorTable[i] = first_color; | 0 | ||||||||||||||||||||||||||||||
| 4246 | else | - | ||||||||||||||||||||||||||||||
| 4247 | colorTable[i] = qPremultiply(first_color); never executed: colorTable[i] = qPremultiply(first_color); | 0 | ||||||||||||||||||||||||||||||
| 4248 | } | - | ||||||||||||||||||||||||||||||
| 4249 | - | |||||||||||||||||||||||||||||||
| 4250 | if (i < second_index) {
| 0 | ||||||||||||||||||||||||||||||
| 4251 | qreal reciprocal = qreal(1) / (second_index - first_index); | - | ||||||||||||||||||||||||||||||
| 4252 | - | |||||||||||||||||||||||||||||||
| 4253 | int red_delta = qRound((qreal(red_second) - red_first) * reciprocal); | - | ||||||||||||||||||||||||||||||
| 4254 | int green_delta = qRound((qreal(green_second) - green_first) * reciprocal); | - | ||||||||||||||||||||||||||||||
| 4255 | int blue_delta = qRound((qreal(blue_second) - blue_first) * reciprocal); | - | ||||||||||||||||||||||||||||||
| 4256 | int alpha_delta = qRound((qreal(alpha_second) - alpha_first) * reciprocal); | - | ||||||||||||||||||||||||||||||
| 4257 | - | |||||||||||||||||||||||||||||||
| 4258 | // rounding | - | ||||||||||||||||||||||||||||||
| 4259 | red_first += 1 << 15; | - | ||||||||||||||||||||||||||||||
| 4260 | green_first += 1 << 15; | - | ||||||||||||||||||||||||||||||
| 4261 | blue_first += 1 << 15; | - | ||||||||||||||||||||||||||||||
| 4262 | alpha_first += 1 << 15; | - | ||||||||||||||||||||||||||||||
| 4263 | - | |||||||||||||||||||||||||||||||
| 4264 | for (; i < qMin(GRADIENT_STOPTABLE_SIZE, second_index); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 4265 | red_first += red_delta; | - | ||||||||||||||||||||||||||||||
| 4266 | green_first += green_delta; | - | ||||||||||||||||||||||||||||||
| 4267 | blue_first += blue_delta; | - | ||||||||||||||||||||||||||||||
| 4268 | alpha_first += alpha_delta; | - | ||||||||||||||||||||||||||||||
| 4269 | - | |||||||||||||||||||||||||||||||
| 4270 | const QRgba64 color = qRgba64(red_first >> 16, green_first >> 16, blue_first >> 16, alpha_first >> 16); | - | ||||||||||||||||||||||||||||||
| 4271 | - | |||||||||||||||||||||||||||||||
| 4272 | if (colorInterpolation)
| 0 | ||||||||||||||||||||||||||||||
| 4273 | colorTable[i] = color; never executed: colorTable[i] = color; | 0 | ||||||||||||||||||||||||||||||
| 4274 | else | - | ||||||||||||||||||||||||||||||
| 4275 | colorTable[i] = qPremultiply(color); never executed: colorTable[i] = qPremultiply(color); | 0 | ||||||||||||||||||||||||||||||
| 4276 | } | - | ||||||||||||||||||||||||||||||
| 4277 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4278 | - | |||||||||||||||||||||||||||||||
| 4279 | for (; i < GRADIENT_STOPTABLE_SIZE; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 4280 | if (colorInterpolation)
| 0 | ||||||||||||||||||||||||||||||
| 4281 | colorTable[i] = second_color; never executed: colorTable[i] = second_color; | 0 | ||||||||||||||||||||||||||||||
| 4282 | else | - | ||||||||||||||||||||||||||||||
| 4283 | colorTable[i] = qPremultiply(second_color); never executed: colorTable[i] = qPremultiply(second_color); | 0 | ||||||||||||||||||||||||||||||
| 4284 | } | - | ||||||||||||||||||||||||||||||
| 4285 | - | |||||||||||||||||||||||||||||||
| 4286 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 4287 | } | - | ||||||||||||||||||||||||||||||
| 4288 | - | |||||||||||||||||||||||||||||||
| 4289 | QRgba64 current_color = combineAlpha256(stops[0].second.rgba64(), opacity); | - | ||||||||||||||||||||||||||||||
| 4290 | if (stopCount == 1) {
| 0 | ||||||||||||||||||||||||||||||
| 4291 | current_color = qPremultiply(current_color); | - | ||||||||||||||||||||||||||||||
| 4292 | for (int i = 0; i < size; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 4293 | colorTable[i] = current_color; never executed: colorTable[i] = current_color; | 0 | ||||||||||||||||||||||||||||||
| 4294 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 4295 | } | - | ||||||||||||||||||||||||||||||
| 4296 | - | |||||||||||||||||||||||||||||||
| 4297 | // The position where the gradient begins and ends | - | ||||||||||||||||||||||||||||||
| 4298 | qreal begin_pos = stops[0].first; | - | ||||||||||||||||||||||||||||||
| 4299 | qreal end_pos = stops[stopCount-1].first; | - | ||||||||||||||||||||||||||||||
| 4300 | - | |||||||||||||||||||||||||||||||
| 4301 | int pos = 0; // The position in the color table. | - | ||||||||||||||||||||||||||||||
| 4302 | QRgba64 next_color; | - | ||||||||||||||||||||||||||||||
| 4303 | - | |||||||||||||||||||||||||||||||
| 4304 | qreal incr = 1 / qreal(size); // the double increment. | - | ||||||||||||||||||||||||||||||
| 4305 | qreal dpos = 1.5 * incr; // current position in gradient stop list (0 to 1) | - | ||||||||||||||||||||||||||||||
| 4306 | - | |||||||||||||||||||||||||||||||
| 4307 | // Up to first point | - | ||||||||||||||||||||||||||||||
| 4308 | colorTable[pos++] = qPremultiply(current_color); | - | ||||||||||||||||||||||||||||||
| 4309 | while (dpos <= begin_pos) {
| 0 | ||||||||||||||||||||||||||||||
| 4310 | colorTable[pos] = colorTable[pos - 1]; | - | ||||||||||||||||||||||||||||||
| 4311 | ++pos; | - | ||||||||||||||||||||||||||||||
| 4312 | dpos += incr; | - | ||||||||||||||||||||||||||||||
| 4313 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4314 | - | |||||||||||||||||||||||||||||||
| 4315 | int current_stop = 0; // We always interpolate between current and current + 1. | - | ||||||||||||||||||||||||||||||
| 4316 | - | |||||||||||||||||||||||||||||||
| 4317 | qreal t; // position between current left and right stops | - | ||||||||||||||||||||||||||||||
| 4318 | qreal t_delta; // the t increment per entry in the color table | - | ||||||||||||||||||||||||||||||
| 4319 | - | |||||||||||||||||||||||||||||||
| 4320 | if (dpos < end_pos) {
| 0 | ||||||||||||||||||||||||||||||
| 4321 | // Gradient area | - | ||||||||||||||||||||||||||||||
| 4322 | while (dpos > stops[current_stop+1].first)
| 0 | ||||||||||||||||||||||||||||||
| 4323 | ++current_stop; never executed: ++current_stop; | 0 | ||||||||||||||||||||||||||||||
| 4324 | - | |||||||||||||||||||||||||||||||
| 4325 | if (current_stop != 0)
| 0 | ||||||||||||||||||||||||||||||
| 4326 | current_color = combineAlpha256(stops[current_stop].second.rgba64(), opacity); never executed: current_color = combineAlpha256(stops[current_stop].second.rgba64(), opacity); | 0 | ||||||||||||||||||||||||||||||
| 4327 | next_color = combineAlpha256(stops[current_stop+1].second.rgba64(), opacity); | - | ||||||||||||||||||||||||||||||
| 4328 | - | |||||||||||||||||||||||||||||||
| 4329 | if (colorInterpolation) {
| 0 | ||||||||||||||||||||||||||||||
| 4330 | current_color = qPremultiply(current_color); | - | ||||||||||||||||||||||||||||||
| 4331 | next_color = qPremultiply(next_color); | - | ||||||||||||||||||||||||||||||
| 4332 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4333 | - | |||||||||||||||||||||||||||||||
| 4334 | qreal diff = stops[current_stop+1].first - stops[current_stop].first; | - | ||||||||||||||||||||||||||||||
| 4335 | qreal c = (diff == 0) ? qreal(0) : 256 / diff;
| 0 | ||||||||||||||||||||||||||||||
| 4336 | t = (dpos - stops[current_stop].first) * c; | - | ||||||||||||||||||||||||||||||
| 4337 | t_delta = incr * c; | - | ||||||||||||||||||||||||||||||
| 4338 | - | |||||||||||||||||||||||||||||||
| 4339 | while (true) { | - | ||||||||||||||||||||||||||||||
| 4340 | Q_ASSERT(current_stop < stopCount); | - | ||||||||||||||||||||||||||||||
| 4341 | - | |||||||||||||||||||||||||||||||
| 4342 | int dist = qRound(t); | - | ||||||||||||||||||||||||||||||
| 4343 | int idist = 256 - dist; | - | ||||||||||||||||||||||||||||||
| 4344 | - | |||||||||||||||||||||||||||||||
| 4345 | if (colorInterpolation)
| 0 | ||||||||||||||||||||||||||||||
| 4346 | colorTable[pos] = interpolate256(current_color, idist, next_color, dist); never executed: colorTable[pos] = interpolate256(current_color, idist, next_color, dist); | 0 | ||||||||||||||||||||||||||||||
| 4347 | else | - | ||||||||||||||||||||||||||||||
| 4348 | colorTable[pos] = qPremultiply(interpolate256(current_color, idist, next_color, dist)); never executed: colorTable[pos] = qPremultiply(interpolate256(current_color, idist, next_color, dist)); | 0 | ||||||||||||||||||||||||||||||
| 4349 | - | |||||||||||||||||||||||||||||||
| 4350 | ++pos; | - | ||||||||||||||||||||||||||||||
| 4351 | dpos += incr; | - | ||||||||||||||||||||||||||||||
| 4352 | - | |||||||||||||||||||||||||||||||
| 4353 | if (dpos >= end_pos)
| 0 | ||||||||||||||||||||||||||||||
| 4354 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4355 | - | |||||||||||||||||||||||||||||||
| 4356 | t += t_delta; | - | ||||||||||||||||||||||||||||||
| 4357 | - | |||||||||||||||||||||||||||||||
| 4358 | int skip = 0; | - | ||||||||||||||||||||||||||||||
| 4359 | while (dpos > stops[current_stop+skip+1].first)
| 0 | ||||||||||||||||||||||||||||||
| 4360 | ++skip; never executed: ++skip; | 0 | ||||||||||||||||||||||||||||||
| 4361 | - | |||||||||||||||||||||||||||||||
| 4362 | if (skip != 0) {
| 0 | ||||||||||||||||||||||||||||||
| 4363 | current_stop += skip; | - | ||||||||||||||||||||||||||||||
| 4364 | if (skip == 1)
| 0 | ||||||||||||||||||||||||||||||
| 4365 | current_color = next_color; never executed: current_color = next_color; | 0 | ||||||||||||||||||||||||||||||
| 4366 | else | - | ||||||||||||||||||||||||||||||
| 4367 | current_color = combineAlpha256(stops[current_stop].second.rgba64(), opacity); never executed: current_color = combineAlpha256(stops[current_stop].second.rgba64(), opacity); | 0 | ||||||||||||||||||||||||||||||
| 4368 | next_color = combineAlpha256(stops[current_stop+1].second.rgba64(), opacity); | - | ||||||||||||||||||||||||||||||
| 4369 | - | |||||||||||||||||||||||||||||||
| 4370 | if (colorInterpolation) {
| 0 | ||||||||||||||||||||||||||||||
| 4371 | if (skip != 1)
| 0 | ||||||||||||||||||||||||||||||
| 4372 | current_color = qPremultiply(current_color); never executed: current_color = qPremultiply(current_color); | 0 | ||||||||||||||||||||||||||||||
| 4373 | next_color = qPremultiply(next_color); | - | ||||||||||||||||||||||||||||||
| 4374 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4375 | - | |||||||||||||||||||||||||||||||
| 4376 | qreal diff = stops[current_stop+1].first - stops[current_stop].first; | - | ||||||||||||||||||||||||||||||
| 4377 | qreal c = (diff == 0) ? qreal(0) : 256 / diff;
| 0 | ||||||||||||||||||||||||||||||
| 4378 | t = (dpos - stops[current_stop].first) * c; | - | ||||||||||||||||||||||||||||||
| 4379 | t_delta = incr * c; | - | ||||||||||||||||||||||||||||||
| 4380 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4381 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4382 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4383 | - | |||||||||||||||||||||||||||||||
| 4384 | // After last point | - | ||||||||||||||||||||||||||||||
| 4385 | current_color = qPremultiply(combineAlpha256(stops[stopCount - 1].second.rgba64(), opacity)); | - | ||||||||||||||||||||||||||||||
| 4386 | while (pos < size - 1) {
| 0 | ||||||||||||||||||||||||||||||
| 4387 | colorTable[pos] = current_color; | - | ||||||||||||||||||||||||||||||
| 4388 | ++pos; | - | ||||||||||||||||||||||||||||||
| 4389 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4390 | - | |||||||||||||||||||||||||||||||
| 4391 | // Make sure the last color stop is represented at the end of the table | - | ||||||||||||||||||||||||||||||
| 4392 | colorTable[size - 1] = current_color; | - | ||||||||||||||||||||||||||||||
| 4393 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4394 | - | |||||||||||||||||||||||||||||||
| 4395 | Q_GLOBAL_STATIC(QGradientCache, qt_gradient_cache) never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||||||||||||||||||||||||||
| 4396 | - | |||||||||||||||||||||||||||||||
| 4397 | - | |||||||||||||||||||||||||||||||
| 4398 | void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe) | - | ||||||||||||||||||||||||||||||
| 4399 | { | - | ||||||||||||||||||||||||||||||
| 4400 | rasterBuffer = rb; | - | ||||||||||||||||||||||||||||||
| 4401 | type = None; | - | ||||||||||||||||||||||||||||||
| 4402 | txop = 0; | - | ||||||||||||||||||||||||||||||
| 4403 | bilinear = false; | - | ||||||||||||||||||||||||||||||
| 4404 | m11 = m22 = m33 = 1.; | - | ||||||||||||||||||||||||||||||
| 4405 | m12 = m13 = m21 = m23 = dx = dy = 0.0; | - | ||||||||||||||||||||||||||||||
| 4406 | clip = pe ? pe->d_func()->clip() : 0;
| 0 | ||||||||||||||||||||||||||||||
| 4407 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4408 | - | |||||||||||||||||||||||||||||||
| 4409 | Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); | - | ||||||||||||||||||||||||||||||
| 4410 | - | |||||||||||||||||||||||||||||||
| 4411 | void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode) | - | ||||||||||||||||||||||||||||||
| 4412 | { | - | ||||||||||||||||||||||||||||||
| 4413 | Qt::BrushStyle brushStyle = qbrush_style(brush); | - | ||||||||||||||||||||||||||||||
| 4414 | cachedGradient.reset(); | - | ||||||||||||||||||||||||||||||
| 4415 | switch (brushStyle) { | - | ||||||||||||||||||||||||||||||
| 4416 | case Qt::SolidPattern: { never executed: case Qt::SolidPattern: | 0 | ||||||||||||||||||||||||||||||
| 4417 | type = Solid; | - | ||||||||||||||||||||||||||||||
| 4418 | QColor c = qbrush_color(brush); | - | ||||||||||||||||||||||||||||||
| 4419 | solid.color = qPremultiply(combineAlpha256(c.rgba64(), alpha)); | - | ||||||||||||||||||||||||||||||
| 4420 | if (solid.color.isTransparent() && compositionMode == QPainter::CompositionMode_SourceOver)
| 0 | ||||||||||||||||||||||||||||||
| 4421 | type = None; never executed: type = None; | 0 | ||||||||||||||||||||||||||||||
| 4422 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4423 | } | - | ||||||||||||||||||||||||||||||
| 4424 | - | |||||||||||||||||||||||||||||||
| 4425 | case Qt::LinearGradientPattern: never executed: case Qt::LinearGradientPattern: | 0 | ||||||||||||||||||||||||||||||
| 4426 | { | - | ||||||||||||||||||||||||||||||
| 4427 | type = LinearGradient; | - | ||||||||||||||||||||||||||||||
| 4428 | const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient()); | - | ||||||||||||||||||||||||||||||
| 4429 | gradient.alphaColor = !brush.isOpaque() || alpha != 256;
| 0 | ||||||||||||||||||||||||||||||
| 4430 | - | |||||||||||||||||||||||||||||||
| 4431 | QSharedPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); | - | ||||||||||||||||||||||||||||||
| 4432 | cachedGradient = cacheInfo; | - | ||||||||||||||||||||||||||||||
| 4433 | gradient.colorTable32 = cacheInfo->buffer32; | - | ||||||||||||||||||||||||||||||
| 4434 | gradient.colorTable64 = cacheInfo->buffer64; | - | ||||||||||||||||||||||||||||||
| 4435 | - | |||||||||||||||||||||||||||||||
| 4436 | gradient.spread = g->spread(); | - | ||||||||||||||||||||||||||||||
| 4437 | - | |||||||||||||||||||||||||||||||
| 4438 | QLinearGradientData &linearData = gradient.linear; | - | ||||||||||||||||||||||||||||||
| 4439 | - | |||||||||||||||||||||||||||||||
| 4440 | linearData.origin.x = g->start().x(); | - | ||||||||||||||||||||||||||||||
| 4441 | linearData.origin.y = g->start().y(); | - | ||||||||||||||||||||||||||||||
| 4442 | linearData.end.x = g->finalStop().x(); | - | ||||||||||||||||||||||||||||||
| 4443 | linearData.end.y = g->finalStop().y(); | - | ||||||||||||||||||||||||||||||
| 4444 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4445 | } | - | ||||||||||||||||||||||||||||||
| 4446 | - | |||||||||||||||||||||||||||||||
| 4447 | case Qt::RadialGradientPattern: never executed: case Qt::RadialGradientPattern: | 0 | ||||||||||||||||||||||||||||||
| 4448 | { | - | ||||||||||||||||||||||||||||||
| 4449 | type = RadialGradient; | - | ||||||||||||||||||||||||||||||
| 4450 | const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient()); | - | ||||||||||||||||||||||||||||||
| 4451 | gradient.alphaColor = !brush.isOpaque() || alpha != 256;
| 0 | ||||||||||||||||||||||||||||||
| 4452 | - | |||||||||||||||||||||||||||||||
| 4453 | QSharedPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); | - | ||||||||||||||||||||||||||||||
| 4454 | cachedGradient = cacheInfo; | - | ||||||||||||||||||||||||||||||
| 4455 | gradient.colorTable32 = cacheInfo->buffer32; | - | ||||||||||||||||||||||||||||||
| 4456 | gradient.colorTable64 = cacheInfo->buffer64; | - | ||||||||||||||||||||||||||||||
| 4457 | - | |||||||||||||||||||||||||||||||
| 4458 | gradient.spread = g->spread(); | - | ||||||||||||||||||||||||||||||
| 4459 | - | |||||||||||||||||||||||||||||||
| 4460 | QRadialGradientData &radialData = gradient.radial; | - | ||||||||||||||||||||||||||||||
| 4461 | - | |||||||||||||||||||||||||||||||
| 4462 | QPointF center = g->center(); | - | ||||||||||||||||||||||||||||||
| 4463 | radialData.center.x = center.x(); | - | ||||||||||||||||||||||||||||||
| 4464 | radialData.center.y = center.y(); | - | ||||||||||||||||||||||||||||||
| 4465 | radialData.center.radius = g->centerRadius(); | - | ||||||||||||||||||||||||||||||
| 4466 | QPointF focal = g->focalPoint(); | - | ||||||||||||||||||||||||||||||
| 4467 | radialData.focal.x = focal.x(); | - | ||||||||||||||||||||||||||||||
| 4468 | radialData.focal.y = focal.y(); | - | ||||||||||||||||||||||||||||||
| 4469 | radialData.focal.radius = g->focalRadius(); | - | ||||||||||||||||||||||||||||||
| 4470 | } | - | ||||||||||||||||||||||||||||||
| 4471 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4472 | - | |||||||||||||||||||||||||||||||
| 4473 | case Qt::ConicalGradientPattern: never executed: case Qt::ConicalGradientPattern: | 0 | ||||||||||||||||||||||||||||||
| 4474 | { | - | ||||||||||||||||||||||||||||||
| 4475 | type = ConicalGradient; | - | ||||||||||||||||||||||||||||||
| 4476 | const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient()); | - | ||||||||||||||||||||||||||||||
| 4477 | gradient.alphaColor = !brush.isOpaque() || alpha != 256;
| 0 | ||||||||||||||||||||||||||||||
| 4478 | - | |||||||||||||||||||||||||||||||
| 4479 | QSharedPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); | - | ||||||||||||||||||||||||||||||
| 4480 | cachedGradient = cacheInfo; | - | ||||||||||||||||||||||||||||||
| 4481 | gradient.colorTable32 = cacheInfo->buffer32; | - | ||||||||||||||||||||||||||||||
| 4482 | gradient.colorTable64 = cacheInfo->buffer64; | - | ||||||||||||||||||||||||||||||
| 4483 | - | |||||||||||||||||||||||||||||||
| 4484 | gradient.spread = QGradient::RepeatSpread; | - | ||||||||||||||||||||||||||||||
| 4485 | - | |||||||||||||||||||||||||||||||
| 4486 | QConicalGradientData &conicalData = gradient.conical; | - | ||||||||||||||||||||||||||||||
| 4487 | - | |||||||||||||||||||||||||||||||
| 4488 | QPointF center = g->center(); | - | ||||||||||||||||||||||||||||||
| 4489 | conicalData.center.x = center.x(); | - | ||||||||||||||||||||||||||||||
| 4490 | conicalData.center.y = center.y(); | - | ||||||||||||||||||||||||||||||
| 4491 | conicalData.angle = qDegreesToRadians(g->angle()); | - | ||||||||||||||||||||||||||||||
| 4492 | } | - | ||||||||||||||||||||||||||||||
| 4493 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4494 | - | |||||||||||||||||||||||||||||||
| 4495 | case Qt::Dense1Pattern: never executed: case Qt::Dense1Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4496 | case Qt::Dense2Pattern: never executed: case Qt::Dense2Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4497 | case Qt::Dense3Pattern: never executed: case Qt::Dense3Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4498 | case Qt::Dense4Pattern: never executed: case Qt::Dense4Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4499 | case Qt::Dense5Pattern: never executed: case Qt::Dense5Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4500 | case Qt::Dense6Pattern: never executed: case Qt::Dense6Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4501 | case Qt::Dense7Pattern: never executed: case Qt::Dense7Pattern: | 0 | ||||||||||||||||||||||||||||||
| 4502 | case Qt::HorPattern: never executed: case Qt::HorPattern: | 0 | ||||||||||||||||||||||||||||||
| 4503 | case Qt::VerPattern: never executed: case Qt::VerPattern: | 0 | ||||||||||||||||||||||||||||||
| 4504 | case Qt::CrossPattern: never executed: case Qt::CrossPattern: | 0 | ||||||||||||||||||||||||||||||
| 4505 | case Qt::BDiagPattern: never executed: case Qt::BDiagPattern: | 0 | ||||||||||||||||||||||||||||||
| 4506 | case Qt::FDiagPattern: never executed: case Qt::FDiagPattern: | 0 | ||||||||||||||||||||||||||||||
| 4507 | case Qt::DiagCrossPattern: never executed: case Qt::DiagCrossPattern: | 0 | ||||||||||||||||||||||||||||||
| 4508 | type = Texture; | - | ||||||||||||||||||||||||||||||
| 4509 | if (!tempImage)
| 0 | ||||||||||||||||||||||||||||||
| 4510 | tempImage = new QImage(); never executed: tempImage = new QImage(); | 0 | ||||||||||||||||||||||||||||||
| 4511 | *tempImage = rasterBuffer->colorizeBitmap(qt_imageForBrush(brushStyle, true), brush.color()); | - | ||||||||||||||||||||||||||||||
| 4512 | initTexture(tempImage, alpha, QTextureData::Tiled); | - | ||||||||||||||||||||||||||||||
| 4513 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4514 | case Qt::TexturePattern: never executed: case Qt::TexturePattern: | 0 | ||||||||||||||||||||||||||||||
| 4515 | type = Texture; | - | ||||||||||||||||||||||||||||||
| 4516 | if (!tempImage)
| 0 | ||||||||||||||||||||||||||||||
| 4517 | tempImage = new QImage(); never executed: tempImage = new QImage(); | 0 | ||||||||||||||||||||||||||||||
| 4518 | - | |||||||||||||||||||||||||||||||
| 4519 | if (qHasPixmapTexture(brush) && brush.texture().isQBitmap())
| 0 | ||||||||||||||||||||||||||||||
| 4520 | *tempImage = rasterBuffer->colorizeBitmap(brush.textureImage(), brush.color()); never executed: *tempImage = rasterBuffer->colorizeBitmap(brush.textureImage(), brush.color()); | 0 | ||||||||||||||||||||||||||||||
| 4521 | else | - | ||||||||||||||||||||||||||||||
| 4522 | *tempImage = brush.textureImage(); never executed: *tempImage = brush.textureImage(); | 0 | ||||||||||||||||||||||||||||||
| 4523 | initTexture(tempImage, alpha, QTextureData::Tiled, tempImage->rect()); | - | ||||||||||||||||||||||||||||||
| 4524 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4525 | - | |||||||||||||||||||||||||||||||
| 4526 | case Qt::NoBrush: never executed: case Qt::NoBrush: | 0 | ||||||||||||||||||||||||||||||
| 4527 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 4528 | type = None; | - | ||||||||||||||||||||||||||||||
| 4529 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4530 | } | - | ||||||||||||||||||||||||||||||
| 4531 | adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 4532 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4533 | - | |||||||||||||||||||||||||||||||
| 4534 | void QSpanData::adjustSpanMethods() | - | ||||||||||||||||||||||||||||||
| 4535 | { | - | ||||||||||||||||||||||||||||||
| 4536 | bitmapBlit = 0; | - | ||||||||||||||||||||||||||||||
| 4537 | alphamapBlit = 0; | - | ||||||||||||||||||||||||||||||
| 4538 | alphaRGBBlit = 0; | - | ||||||||||||||||||||||||||||||
| 4539 | - | |||||||||||||||||||||||||||||||
| 4540 | fillRect = 0; | - | ||||||||||||||||||||||||||||||
| 4541 | - | |||||||||||||||||||||||||||||||
| 4542 | switch(type) { | - | ||||||||||||||||||||||||||||||
| 4543 | case None: never executed: case None: | 0 | ||||||||||||||||||||||||||||||
| 4544 | unclipped_blend = 0; | - | ||||||||||||||||||||||||||||||
| 4545 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4546 | case Solid: never executed: case Solid: | 0 | ||||||||||||||||||||||||||||||
| 4547 | unclipped_blend = rasterBuffer->drawHelper->blendColor; | - | ||||||||||||||||||||||||||||||
| 4548 | bitmapBlit = rasterBuffer->drawHelper->bitmapBlit; | - | ||||||||||||||||||||||||||||||
| 4549 | alphamapBlit = rasterBuffer->drawHelper->alphamapBlit; | - | ||||||||||||||||||||||||||||||
| 4550 | alphaRGBBlit = rasterBuffer->drawHelper->alphaRGBBlit; | - | ||||||||||||||||||||||||||||||
| 4551 | fillRect = rasterBuffer->drawHelper->fillRect; | - | ||||||||||||||||||||||||||||||
| 4552 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4553 | case LinearGradient: never executed: case LinearGradient: | 0 | ||||||||||||||||||||||||||||||
| 4554 | case RadialGradient: never executed: case RadialGradient: | 0 | ||||||||||||||||||||||||||||||
| 4555 | case ConicalGradient: never executed: case ConicalGradient: | 0 | ||||||||||||||||||||||||||||||
| 4556 | unclipped_blend = rasterBuffer->drawHelper->blendGradient; | - | ||||||||||||||||||||||||||||||
| 4557 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4558 | case Texture: never executed: case Texture: | 0 | ||||||||||||||||||||||||||||||
| 4559 | unclipped_blend = qBlendTexture; | - | ||||||||||||||||||||||||||||||
| 4560 | if (!texture.imageData)
| 0 | ||||||||||||||||||||||||||||||
| 4561 | unclipped_blend = 0; never executed: unclipped_blend = 0; | 0 | ||||||||||||||||||||||||||||||
| 4562 | - | |||||||||||||||||||||||||||||||
| 4563 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 4564 | } | - | ||||||||||||||||||||||||||||||
| 4565 | // setup clipping | - | ||||||||||||||||||||||||||||||
| 4566 | if (!unclipped_blend) {
| 0 | ||||||||||||||||||||||||||||||
| 4567 | blend = 0; | - | ||||||||||||||||||||||||||||||
| 4568 | } else if (!clip) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 4569 | blend = unclipped_blend; | - | ||||||||||||||||||||||||||||||
| 4570 | } else if (clip->hasRectClip) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 4571 | blend = clip->clipRect.isEmpty() ? 0 : qt_span_fill_clipRect;
| 0 | ||||||||||||||||||||||||||||||
| 4572 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4573 | blend = qt_span_fill_clipped; | - | ||||||||||||||||||||||||||||||
| 4574 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4575 | } | - | ||||||||||||||||||||||||||||||
| 4576 | - | |||||||||||||||||||||||||||||||
| 4577 | void QSpanData::setupMatrix(const QTransform &matrix, int bilin) | - | ||||||||||||||||||||||||||||||
| 4578 | { | - | ||||||||||||||||||||||||||||||
| 4579 | QTransform delta; | - | ||||||||||||||||||||||||||||||
| 4580 | // make sure we round off correctly in qdrawhelper.cpp | - | ||||||||||||||||||||||||||||||
| 4581 | delta.translate(1.0 / 65536, 1.0 / 65536); | - | ||||||||||||||||||||||||||||||
| 4582 | - | |||||||||||||||||||||||||||||||
| 4583 | QTransform inv = (delta * matrix).inverted(); | - | ||||||||||||||||||||||||||||||
| 4584 | m11 = inv.m11(); | - | ||||||||||||||||||||||||||||||
| 4585 | m12 = inv.m12(); | - | ||||||||||||||||||||||||||||||
| 4586 | m13 = inv.m13(); | - | ||||||||||||||||||||||||||||||
| 4587 | m21 = inv.m21(); | - | ||||||||||||||||||||||||||||||
| 4588 | m22 = inv.m22(); | - | ||||||||||||||||||||||||||||||
| 4589 | m23 = inv.m23(); | - | ||||||||||||||||||||||||||||||
| 4590 | m33 = inv.m33(); | - | ||||||||||||||||||||||||||||||
| 4591 | dx = inv.dx(); | - | ||||||||||||||||||||||||||||||
| 4592 | dy = inv.dy(); | - | ||||||||||||||||||||||||||||||
| 4593 | txop = inv.type(); | - | ||||||||||||||||||||||||||||||
| 4594 | bilinear = bilin; | - | ||||||||||||||||||||||||||||||
| 4595 | - | |||||||||||||||||||||||||||||||
| 4596 | const bool affine = inv.isAffine(); | - | ||||||||||||||||||||||||||||||
| 4597 | fast_matrix = affine
| 0 | ||||||||||||||||||||||||||||||
| 4598 | && m11 * m11 + m21 * m21 < 1e4
| 0 | ||||||||||||||||||||||||||||||
| 4599 | && m12 * m12 + m22 * m22 < 1e4
| 0 | ||||||||||||||||||||||||||||||
| 4600 | && qAbs(dx) < 1e4
| 0 | ||||||||||||||||||||||||||||||
| 4601 | && qAbs(dy) < 1e4;
| 0 | ||||||||||||||||||||||||||||||
| 4602 | - | |||||||||||||||||||||||||||||||
| 4603 | adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 4604 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4605 | - | |||||||||||||||||||||||||||||||
| 4606 | void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _type, const QRect &sourceRect) | - | ||||||||||||||||||||||||||||||
| 4607 | { | - | ||||||||||||||||||||||||||||||
| 4608 | const QImageData *d = const_cast<QImage *>(image)->data_ptr(); | - | ||||||||||||||||||||||||||||||
| 4609 | if (!d || d->height == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 4610 | texture.imageData = 0; | - | ||||||||||||||||||||||||||||||
| 4611 | texture.width = 0; | - | ||||||||||||||||||||||||||||||
| 4612 | texture.height = 0; | - | ||||||||||||||||||||||||||||||
| 4613 | texture.x1 = 0; | - | ||||||||||||||||||||||||||||||
| 4614 | texture.y1 = 0; | - | ||||||||||||||||||||||||||||||
| 4615 | texture.x2 = 0; | - | ||||||||||||||||||||||||||||||
| 4616 | texture.y2 = 0; | - | ||||||||||||||||||||||||||||||
| 4617 | texture.bytesPerLine = 0; | - | ||||||||||||||||||||||||||||||
| 4618 | texture.format = QImage::Format_Invalid; | - | ||||||||||||||||||||||||||||||
| 4619 | texture.colorTable = 0; | - | ||||||||||||||||||||||||||||||
| 4620 | texture.hasAlpha = alpha != 256; | - | ||||||||||||||||||||||||||||||
| 4621 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4622 | texture.imageData = d->data; | - | ||||||||||||||||||||||||||||||
| 4623 | texture.width = d->width; | - | ||||||||||||||||||||||||||||||
| 4624 | texture.height = d->height; | - | ||||||||||||||||||||||||||||||
| 4625 | - | |||||||||||||||||||||||||||||||
| 4626 | if (sourceRect.isNull()) {
| 0 | ||||||||||||||||||||||||||||||
| 4627 | texture.x1 = 0; | - | ||||||||||||||||||||||||||||||
| 4628 | texture.y1 = 0; | - | ||||||||||||||||||||||||||||||
| 4629 | texture.x2 = texture.width; | - | ||||||||||||||||||||||||||||||
| 4630 | texture.y2 = texture.height; | - | ||||||||||||||||||||||||||||||
| 4631 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4632 | texture.x1 = sourceRect.x(); | - | ||||||||||||||||||||||||||||||
| 4633 | texture.y1 = sourceRect.y(); | - | ||||||||||||||||||||||||||||||
| 4634 | texture.x2 = qMin(texture.x1 + sourceRect.width(), d->width); | - | ||||||||||||||||||||||||||||||
| 4635 | texture.y2 = qMin(texture.y1 + sourceRect.height(), d->height); | - | ||||||||||||||||||||||||||||||
| 4636 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4637 | - | |||||||||||||||||||||||||||||||
| 4638 | texture.bytesPerLine = d->bytes_per_line; | - | ||||||||||||||||||||||||||||||
| 4639 | - | |||||||||||||||||||||||||||||||
| 4640 | texture.format = d->format; | - | ||||||||||||||||||||||||||||||
| 4641 | texture.colorTable = (d->format <= QImage::Format_Indexed8 && !d->colortable.isEmpty()) ? &d->colortable : 0;
| 0 | ||||||||||||||||||||||||||||||
| 4642 | texture.hasAlpha = image->hasAlphaChannel() || alpha != 256;
| 0 | ||||||||||||||||||||||||||||||
| 4643 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4644 | texture.const_alpha = alpha; | - | ||||||||||||||||||||||||||||||
| 4645 | texture.type = _type; | - | ||||||||||||||||||||||||||||||
| 4646 | - | |||||||||||||||||||||||||||||||
| 4647 | adjustSpanMethods(); | - | ||||||||||||||||||||||||||||||
| 4648 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4649 | - | |||||||||||||||||||||||||||||||
| 4650 | /*! | - | ||||||||||||||||||||||||||||||
| 4651 | \internal | - | ||||||||||||||||||||||||||||||
| 4652 | \a x and \a y is relative to the midpoint of \a rect. | - | ||||||||||||||||||||||||||||||
| 4653 | */ | - | ||||||||||||||||||||||||||||||
| 4654 | static inline void drawEllipsePoints(int x, int y, int length, | - | ||||||||||||||||||||||||||||||
| 4655 | const QRect &rect, | - | ||||||||||||||||||||||||||||||
| 4656 | const QRect &clip, | - | ||||||||||||||||||||||||||||||
| 4657 | ProcessSpans pen_func, ProcessSpans brush_func, | - | ||||||||||||||||||||||||||||||
| 4658 | QSpanData *pen_data, QSpanData *brush_data) | - | ||||||||||||||||||||||||||||||
| 4659 | { | - | ||||||||||||||||||||||||||||||
| 4660 | if (length == 0)
| 0 | ||||||||||||||||||||||||||||||
| 4661 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 4662 | - | |||||||||||||||||||||||||||||||
| 4663 | QT_FT_Span outline[4]; | - | ||||||||||||||||||||||||||||||
| 4664 | const int midx = rect.x() + (rect.width() + 1) / 2; | - | ||||||||||||||||||||||||||||||
| 4665 | const int midy = rect.y() + (rect.height() + 1) / 2; | - | ||||||||||||||||||||||||||||||
| 4666 | - | |||||||||||||||||||||||||||||||
| 4667 | x = x + midx; | - | ||||||||||||||||||||||||||||||
| 4668 | y = midy - y; | - | ||||||||||||||||||||||||||||||
| 4669 | - | |||||||||||||||||||||||||||||||
| 4670 | // topleft | - | ||||||||||||||||||||||||||||||
| 4671 | outline[0].x = midx + (midx - x) - (length - 1) - (rect.width() & 0x1); | - | ||||||||||||||||||||||||||||||
| 4672 | outline[0].len = qMin(length, x - outline[0].x); | - | ||||||||||||||||||||||||||||||
| 4673 | outline[0].y = y; | - | ||||||||||||||||||||||||||||||
| 4674 | outline[0].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 4675 | - | |||||||||||||||||||||||||||||||
| 4676 | // topright | - | ||||||||||||||||||||||||||||||
| 4677 | outline[1].x = x; | - | ||||||||||||||||||||||||||||||
| 4678 | outline[1].len = length; | - | ||||||||||||||||||||||||||||||
| 4679 | outline[1].y = y; | - | ||||||||||||||||||||||||||||||
| 4680 | outline[1].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 4681 | - | |||||||||||||||||||||||||||||||
| 4682 | // bottomleft | - | ||||||||||||||||||||||||||||||
| 4683 | outline[2].x = outline[0].x; | - | ||||||||||||||||||||||||||||||
| 4684 | outline[2].len = outline[0].len; | - | ||||||||||||||||||||||||||||||
| 4685 | outline[2].y = midy + (midy - y) - (rect.height() & 0x1); | - | ||||||||||||||||||||||||||||||
| 4686 | outline[2].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 4687 | - | |||||||||||||||||||||||||||||||
| 4688 | // bottomright | - | ||||||||||||||||||||||||||||||
| 4689 | outline[3].x = x; | - | ||||||||||||||||||||||||||||||
| 4690 | outline[3].len = length; | - | ||||||||||||||||||||||||||||||
| 4691 | outline[3].y = outline[2].y; | - | ||||||||||||||||||||||||||||||
| 4692 | outline[3].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 4693 | - | |||||||||||||||||||||||||||||||
| 4694 | if (brush_func && outline[0].x + outline[0].len < outline[1].x) {
| 0 | ||||||||||||||||||||||||||||||
| 4695 | QT_FT_Span fill[2]; | - | ||||||||||||||||||||||||||||||
| 4696 | - | |||||||||||||||||||||||||||||||
| 4697 | // top fill | - | ||||||||||||||||||||||||||||||
| 4698 | fill[0].x = outline[0].x + outline[0].len - 1; | - | ||||||||||||||||||||||||||||||
| 4699 | fill[0].len = qMax(0, outline[1].x - fill[0].x); | - | ||||||||||||||||||||||||||||||
| 4700 | fill[0].y = outline[1].y; | - | ||||||||||||||||||||||||||||||
| 4701 | fill[0].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 4702 | - | |||||||||||||||||||||||||||||||
| 4703 | // bottom fill | - | ||||||||||||||||||||||||||||||
| 4704 | fill[1].x = outline[2].x + outline[2].len - 1; | - | ||||||||||||||||||||||||||||||
| 4705 | fill[1].len = qMax(0, outline[3].x - fill[1].x); | - | ||||||||||||||||||||||||||||||
| 4706 | fill[1].y = outline[3].y; | - | ||||||||||||||||||||||||||||||
| 4707 | fill[1].coverage = 255; | - | ||||||||||||||||||||||||||||||
| 4708 | - | |||||||||||||||||||||||||||||||
| 4709 | int n = (fill[0].y >= fill[1].y ? 1 : 2);
| 0 | ||||||||||||||||||||||||||||||
| 4710 | n = qt_intersect_spans(fill, n, clip); | - | ||||||||||||||||||||||||||||||
| 4711 | if (n > 0)
| 0 | ||||||||||||||||||||||||||||||
| 4712 | brush_func(n, fill, brush_data); never executed: brush_func(n, fill, brush_data); | 0 | ||||||||||||||||||||||||||||||
| 4713 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4714 | if (pen_func) {
| 0 | ||||||||||||||||||||||||||||||
| 4715 | int n = (outline[1].y >= outline[2].y ? 2 : 4);
| 0 | ||||||||||||||||||||||||||||||
| 4716 | n = qt_intersect_spans(outline, n, clip); | - | ||||||||||||||||||||||||||||||
| 4717 | if (n > 0)
| 0 | ||||||||||||||||||||||||||||||
| 4718 | pen_func(n, outline, pen_data); never executed: pen_func(n, outline, pen_data); | 0 | ||||||||||||||||||||||||||||||
| 4719 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4720 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4721 | - | |||||||||||||||||||||||||||||||
| 4722 | /*! | - | ||||||||||||||||||||||||||||||
| 4723 | \internal | - | ||||||||||||||||||||||||||||||
| 4724 | Draws an ellipse using the integer point midpoint algorithm. | - | ||||||||||||||||||||||||||||||
| 4725 | */ | - | ||||||||||||||||||||||||||||||
| 4726 | static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, | - | ||||||||||||||||||||||||||||||
| 4727 | ProcessSpans pen_func, ProcessSpans brush_func, | - | ||||||||||||||||||||||||||||||
| 4728 | QSpanData *pen_data, QSpanData *brush_data) | - | ||||||||||||||||||||||||||||||
| 4729 | { | - | ||||||||||||||||||||||||||||||
| 4730 | const qreal a = qreal(rect.width()) / 2; | - | ||||||||||||||||||||||||||||||
| 4731 | const qreal b = qreal(rect.height()) / 2; | - | ||||||||||||||||||||||||||||||
| 4732 | qreal d = b*b - (a*a*b) + 0.25*a*a; | - | ||||||||||||||||||||||||||||||
| 4733 | - | |||||||||||||||||||||||||||||||
| 4734 | int x = 0; | - | ||||||||||||||||||||||||||||||
| 4735 | int y = (rect.height() + 1) / 2; | - | ||||||||||||||||||||||||||||||
| 4736 | int startx = x; | - | ||||||||||||||||||||||||||||||
| 4737 | - | |||||||||||||||||||||||||||||||
| 4738 | // region 1 | - | ||||||||||||||||||||||||||||||
| 4739 | while (a*a*(2*y - 1) > 2*b*b*(x + 1)) {
| 0 | ||||||||||||||||||||||||||||||
| 4740 | if (d < 0) { // select E
| 0 | ||||||||||||||||||||||||||||||
| 4741 | d += b*b*(2*x + 3); | - | ||||||||||||||||||||||||||||||
| 4742 | ++x; | - | ||||||||||||||||||||||||||||||
| 4743 | } else { // select SE never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4744 | d += b*b*(2*x + 3) + a*a*(-2*y + 2); | - | ||||||||||||||||||||||||||||||
| 4745 | drawEllipsePoints(startx, y, x - startx + 1, rect, clip, | - | ||||||||||||||||||||||||||||||
| 4746 | pen_func, brush_func, pen_data, brush_data); | - | ||||||||||||||||||||||||||||||
| 4747 | startx = ++x; | - | ||||||||||||||||||||||||||||||
| 4748 | --y; | - | ||||||||||||||||||||||||||||||
| 4749 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4750 | } | - | ||||||||||||||||||||||||||||||
| 4751 | drawEllipsePoints(startx, y, x - startx + 1, rect, clip, | - | ||||||||||||||||||||||||||||||
| 4752 | pen_func, brush_func, pen_data, brush_data); | - | ||||||||||||||||||||||||||||||
| 4753 | - | |||||||||||||||||||||||||||||||
| 4754 | // region 2 | - | ||||||||||||||||||||||||||||||
| 4755 | d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b); | - | ||||||||||||||||||||||||||||||
| 4756 | const int miny = rect.height() & 0x1; | - | ||||||||||||||||||||||||||||||
| 4757 | while (y > miny) {
| 0 | ||||||||||||||||||||||||||||||
| 4758 | if (d < 0) { // select SE
| 0 | ||||||||||||||||||||||||||||||
| 4759 | d += b*b*(2*x + 2) + a*a*(-2*y + 3); | - | ||||||||||||||||||||||||||||||
| 4760 | ++x; | - | ||||||||||||||||||||||||||||||
| 4761 | } else { // select S never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4762 | d += a*a*(-2*y + 3); | - | ||||||||||||||||||||||||||||||
| 4763 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4764 | --y; | - | ||||||||||||||||||||||||||||||
| 4765 | drawEllipsePoints(x, y, 1, rect, clip, | - | ||||||||||||||||||||||||||||||
| 4766 | pen_func, brush_func, pen_data, brush_data); | - | ||||||||||||||||||||||||||||||
| 4767 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4768 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 4769 | - | |||||||||||||||||||||||||||||||
| 4770 | /*! | - | ||||||||||||||||||||||||||||||
| 4771 | \fn void QRasterPaintEngine::drawPoints(const QPoint *points, int pointCount) | - | ||||||||||||||||||||||||||||||
| 4772 | \overload | - | ||||||||||||||||||||||||||||||
| 4773 | \reimp | - | ||||||||||||||||||||||||||||||
| 4774 | */ | - | ||||||||||||||||||||||||||||||
| 4775 | - | |||||||||||||||||||||||||||||||
| 4776 | - | |||||||||||||||||||||||||||||||
| 4777 | #ifdef QT_DEBUG_DRAW | - | ||||||||||||||||||||||||||||||
| 4778 | void dumpClip(int width, int height, const QClipData *clip) | - | ||||||||||||||||||||||||||||||
| 4779 | { | - | ||||||||||||||||||||||||||||||
| 4780 | QImage clipImg(width, height, QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||||||||
| 4781 | clipImg.fill(0xffff0000); | - | ||||||||||||||||||||||||||||||
| 4782 | - | |||||||||||||||||||||||||||||||
| 4783 | int x0 = width; | - | ||||||||||||||||||||||||||||||
| 4784 | int x1 = 0; | - | ||||||||||||||||||||||||||||||
| 4785 | int y0 = height; | - | ||||||||||||||||||||||||||||||
| 4786 | int y1 = 0; | - | ||||||||||||||||||||||||||||||
| 4787 | - | |||||||||||||||||||||||||||||||
| 4788 | ((QClipData *) clip)->spans(); // Force allocation of the spans structure... | - | ||||||||||||||||||||||||||||||
| 4789 | - | |||||||||||||||||||||||||||||||
| 4790 | for (int i = 0; i < clip->count; ++i) { | - | ||||||||||||||||||||||||||||||
| 4791 | const QSpan *span = ((QClipData *) clip)->spans() + i; | - | ||||||||||||||||||||||||||||||
| 4792 | for (int j = 0; j < span->len; ++j) | - | ||||||||||||||||||||||||||||||
| 4793 | clipImg.setPixel(span->x + j, span->y, 0xffffff00); | - | ||||||||||||||||||||||||||||||
| 4794 | x0 = qMin(x0, int(span->x)); | - | ||||||||||||||||||||||||||||||
| 4795 | x1 = qMax(x1, int(span->x + span->len - 1)); | - | ||||||||||||||||||||||||||||||
| 4796 | - | |||||||||||||||||||||||||||||||
| 4797 | y0 = qMin(y0, int(span->y)); | - | ||||||||||||||||||||||||||||||
| 4798 | y1 = qMax(y1, int(span->y)); | - | ||||||||||||||||||||||||||||||
| 4799 | } | - | ||||||||||||||||||||||||||||||
| 4800 | - | |||||||||||||||||||||||||||||||
| 4801 | static int counter = 0; | - | ||||||||||||||||||||||||||||||
| 4802 | - | |||||||||||||||||||||||||||||||
| 4803 | Q_ASSERT(y0 >= 0); | - | ||||||||||||||||||||||||||||||
| 4804 | Q_ASSERT(x0 >= 0); | - | ||||||||||||||||||||||||||||||
| 4805 | Q_ASSERT(y1 >= 0); | - | ||||||||||||||||||||||||||||||
| 4806 | Q_ASSERT(x1 >= 0); | - | ||||||||||||||||||||||||||||||
| 4807 | - | |||||||||||||||||||||||||||||||
| 4808 | fprintf(stderr,"clip %d: %d %d - %d %d\n", counter, x0, y0, x1, y1); | - | ||||||||||||||||||||||||||||||
| 4809 | clipImg.save(QString::fromLatin1("clip-%0.png").arg(counter++)); | - | ||||||||||||||||||||||||||||||
| 4810 | } | - | ||||||||||||||||||||||||||||||
| 4811 | #endif | - | ||||||||||||||||||||||||||||||
| 4812 | - | |||||||||||||||||||||||||||||||
| 4813 | - | |||||||||||||||||||||||||||||||
| 4814 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |