| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | class QRectVectorPath : public QVectorPath { | - |
| 17 | public: | - |
| 18 | inline void set(const QRect &r) { | - |
| 19 | qreal left = r.x(); | - |
| 20 | qreal right = r.x() + r.width(); | - |
| 21 | qreal top = r.y(); | - |
| 22 | qreal bottom = r.y() + r.height(); | - |
| 23 | pts[0] = left; | - |
| 24 | pts[1] = top; | - |
| 25 | pts[2] = right; | - |
| 26 | pts[3] = top; | - |
| 27 | pts[4] = right; | - |
| 28 | pts[5] = bottom; | - |
| 29 | pts[6] = left; | - |
| 30 | pts[7] = bottom; | - |
| 31 | } | - |
| 32 | | - |
| 33 | inline void set(const QRectF &r) { | - |
| 34 | qreal left = r.x(); | - |
| 35 | qreal right = r.x() + r.width(); | - |
| 36 | qreal top = r.y(); | - |
| 37 | qreal bottom = r.y() + r.height(); | - |
| 38 | pts[0] = left; | - |
| 39 | pts[1] = top; | - |
| 40 | pts[2] = right; | - |
| 41 | pts[3] = top; | - |
| 42 | pts[4] = right; | - |
| 43 | pts[5] = bottom; | - |
| 44 | pts[6] = left; | - |
| 45 | pts[7] = bottom; | - |
| 46 | } | - |
| 47 | inline QRectVectorPath(const QRect &r) | - |
| 48 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) | - |
| 49 | { | - |
| 50 | set(r); | - |
| 51 | } | - |
| 52 | inline QRectVectorPath(const QRectF &r) | - |
| 53 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) | - |
| 54 | { | - |
| 55 | set(r); | - |
| 56 | } | - |
| 57 | inline QRectVectorPath() | - |
| 58 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) | - |
| 59 | { } | - |
| 60 | | - |
| 61 | qreal pts[8]; | - |
| 62 | }; | - |
| 63 | | - |
| 64 | __attribute__((visibility("default"))) extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); | - |
| 65 | static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; | - |
| 66 | static void qt_span_fill_clipRect(int count, const QSpan *spans, void *userData); | - |
| 67 | static void qt_span_fill_clipped(int count, const QSpan *spans, void *userData); | - |
| 68 | static void qt_span_clip(int count, const QSpan *spans, void *userData); | - |
| 69 | | - |
| 70 | struct ClipData | - |
| 71 | { | - |
| 72 | QClipData *oldClip; | - |
| 73 | QClipData *newClip; | - |
| 74 | Qt::ClipOperation operation; | - |
| 75 | }; | - |
| 76 | | - |
| 77 | enum LineDrawMode { | - |
| 78 | LineDrawClipped, | - |
| 79 | LineDrawNormal, | - |
| 80 | LineDrawIncludeLastPixel | - |
| 81 | }; | - |
| 82 | | - |
| 83 | static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, | - |
| 84 | ProcessSpans pen_func, ProcessSpans brush_func, | - |
| 85 | QSpanData *pen_data, QSpanData *brush_data); | - |
| 86 | | - |
| 87 | struct QRasterFloatPoint { | - |
| 88 | qreal x; | - |
| 89 | qreal y; | - |
| 90 | }; | - |
| 91 | template <typename T> static inline bool isRect(const T *pts, int elementCount) { | - |
| 92 | return (elementCount == 5 | - |
| 93 | && pts[0] == pts[8] && pts[1] == pts[9] | - |
| 94 | && pts[0] == pts[6] && pts[2] == pts[4] | - |
| 95 | && pts[1] == pts[3] && pts[5] == pts[7] | - |
| 96 | && pts[0] < pts[4] && pts[1] < pts[5] | - |
| 97 | ) || | - |
| 98 | (elementCount == 4 | - |
| 99 | && pts[0] == pts[6] && pts[2] == pts[4] | - |
| 100 | && pts[1] == pts[3] && pts[5] == pts[7] | - |
| 101 | && pts[0] < pts[4] && pts[1] < pts[5] | - |
| 102 | ); | - |
| 103 | } | - |
| 104 | | - |
| 105 | | - |
| 106 | static void qt_ft_outline_move_to(qfixed x, qfixed y, void *data) | - |
| 107 | { | - |
| 108 | ((QOutlineMapper *) data)->moveTo(QPointF(x, y)); | - |
| 109 | } | - |
| 110 | | - |
| 111 | static void qt_ft_outline_line_to(qfixed x, qfixed y, void *data) | - |
| 112 | { | - |
| 113 | ((QOutlineMapper *) data)->lineTo(QPointF(x, y)); | - |
| 114 | } | - |
| 115 | | - |
| 116 | static void qt_ft_outline_cubic_to(qfixed c1x, qfixed c1y, | - |
| 117 | qfixed c2x, qfixed c2y, | - |
| 118 | qfixed ex, qfixed ey, | - |
| 119 | void *data) | - |
| 120 | { | - |
| 121 | ((QOutlineMapper *) data)->curveTo(QPointF(c1x, c1y), | - |
| 122 | QPointF(c2x, c2y), | - |
| 123 | QPointF(ex, ey)); | - |
| 124 | } | - |
| 125 | QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() : | - |
| 126 | QPaintEngineExPrivate(), | - |
| 127 | cachedLines(0) | - |
| 128 | { | - |
| 129 | } | - |
| 130 | QRasterPaintEngine::QRasterPaintEngine(QPaintDevice *device) | - |
| 131 | : QPaintEngineEx(*(new QRasterPaintEnginePrivate)) | - |
| 132 | { | - |
| 133 | d_func()->device = device; | - |
| 134 | init(); | - |
| 135 | } | - |
| 136 | | - |
| 137 | | - |
| 138 | | - |
| 139 | | - |
| 140 | QRasterPaintEngine::QRasterPaintEngine(QRasterPaintEnginePrivate &dd, QPaintDevice *device) | - |
| 141 | : QPaintEngineEx(dd) | - |
| 142 | { | - |
| 143 | d_func()->device = device; | - |
| 144 | init(); | - |
| 145 | } | - |
| 146 | | - |
| 147 | void QRasterPaintEngine::init() | - |
| 148 | { | - |
| 149 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 150 | | - |
| 151 | | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | d->grayRaster.reset(new QT_FT_Raster); | - |
| 158 | qt_noop(); | - |
| 159 | if (qt_ft_grays_raster.raster_new(d->grayRaster.data())) | - |
| 160 | qt_noop(); | - |
| 161 | | - |
| 162 | | - |
| 163 | d->rasterizer.reset(new QRasterizer); | - |
| 164 | d->rasterBuffer.reset(new QRasterBuffer()); | - |
| 165 | d->outlineMapper.reset(new QOutlineMapper); | - |
| 166 | d->outlinemapper_xform_dirty = true; | - |
| 167 | | - |
| 168 | d->basicStroker.setMoveToHook(qt_ft_outline_move_to); | - |
| 169 | d->basicStroker.setLineToHook(qt_ft_outline_line_to); | - |
| 170 | d->basicStroker.setCubicToHook(qt_ft_outline_cubic_to); | - |
| 171 | | - |
| 172 | d->baseClip.reset(new QClipData(d->device->height())); | - |
| 173 | d->baseClip->setClipRect(QRect(0, 0, d->device->width(), d->device->height())); | - |
| 174 | | - |
| 175 | d->image_filler.init(d->rasterBuffer.data(), this); | - |
| 176 | d->image_filler.type = QSpanData::Texture; | - |
| 177 | | - |
| 178 | d->image_filler_xform.init(d->rasterBuffer.data(), this); | - |
| 179 | d->image_filler_xform.type = QSpanData::Texture; | - |
| 180 | | - |
| 181 | d->solid_color_filler.init(d->rasterBuffer.data(), this); | - |
| 182 | d->solid_color_filler.type = QSpanData::Solid; | - |
| 183 | | - |
| 184 | d->deviceDepth = d->device->depth(); | - |
| 185 | | - |
| 186 | d->mono_surface = false; | - |
| 187 | gccaps &= ~PorterDuff; | - |
| 188 | | - |
| 189 | QImage::Format format = QImage::Format_Invalid; | - |
| 190 | | - |
| 191 | switch (d->device->devType()) { | - |
| 192 | case QInternal::Pixmap: | - |
| 193 | QMessageLogger("painting/qpaintengine_raster.cpp", 415416, __PRETTY_FUNCTION__).warning("QRasterPaintEngine: unsupported for pixmaps..."); | - |
| 194 | break; | - |
| 195 | case QInternal::Image: | - |
| 196 | format = d->rasterBuffer->prepare(static_cast<QImage *>(d->device)); | - |
| 197 | break; | - |
| 198 | default: | - |
| 199 | QMessageLogger("painting/qpaintengine_raster.cpp", 421422, __PRETTY_FUNCTION__).warning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType()); | - |
| 200 | d->device = 0; | - |
| 201 | return; | - |
| 202 | } | - |
| 203 | | - |
| 204 | switch (format) { | - |
| 205 | case QImage::Format_MonoLSB: | - |
| 206 | case QImage::Format_Mono: | - |
| 207 | d->mono_surface = true; | - |
| 208 | break; | - |
| 209 | case QImage::Format_ARGB8565_Premultiplied: | - |
| 210 | case QImage::Format_ARGB8555_Premultiplied: | - |
| 211 | case QImage::Format_ARGB6666_Premultiplied: | - |
| 212 | case QImage::Format_ARGB4444_Premultiplied: | - |
| 213 | case QImage::Format_ARGB32_Premultiplied: | - |
| 214 | case QImage::Format_ARGB32: | - |
| 215 | gccaps |= PorterDuff; | - |
| 216 | break; | - |
| 217 | case QImage::Format_RGB32: | - |
| 218 | case QImage::Format_RGB444: | - |
| 219 | case QImage::Format_RGB555: | - |
| 220 | case QImage::Format_RGB666: | - |
| 221 | case QImage::Format_RGB888: | - |
| 222 | case QImage::Format_RGB16: | - |
| 223 | break; | - |
| 224 | default: | - |
| 225 | break; | - |
| 226 | } | - |
| 227 | } | - |
| 228 | | - |
| 229 | | - |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | | - |
| 234 | | - |
| 235 | QRasterPaintEngine::~QRasterPaintEngine() | - |
| 236 | { | - |
| 237 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 238 | | - |
| 239 | qt_ft_grays_raster.raster_done(*d->grayRaster.data()); | - |
| 240 | } | - |
| 241 | | - |
| 242 | | - |
| 243 | | - |
| 244 | | - |
| 245 | bool QRasterPaintEngine::begin(QPaintDevice *device) | - |
| 246 | { | - |
| 247 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 248 | | - |
| 249 | if (device->devType() == QInternal::Pixmap) { | - |
| 250 | QPixmap *pixmap = static_cast<QPixmap *>(device); | - |
| 251 | QPlatformPixmap *pd = pixmap->handle(); | - |
| 252 | if (pd->classId() == QPlatformPixmap::RasterClass || pd->classId() == QPlatformPixmap::BlitterClass) | - |
| 253 | d->device = pd->buffer(); | - |
| 254 | } else { | - |
| 255 | d->device = device; | - |
| 256 | } | - |
| 257 | | - |
| 258 | | - |
| 259 | d->pdev = d->device; | - |
| 260 | | - |
| 261 | qt_noop(); | - |
| 262 | | - |
| 263 | | - |
| 264 | d->systemStateChanged(); | - |
| 265 | | - |
| 266 | QRasterPaintEngineState *s = state(); | - |
| 267 | ensureOutlineMapper(); | - |
| 268 | d->outlineMapper->m_clip_rect = d->deviceRect; | - |
| 269 | | - |
| 270 | if (d->outlineMapper->m_clip_rect.width() > QT_RASTER_COORD_LIMIT) | - |
| 271 | d->outlineMapper->m_clip_rect.setWidth(QT_RASTER_COORD_LIMIT); | - |
| 272 | if (d->outlineMapper->m_clip_rect.height() > QT_RASTER_COORD_LIMIT) | - |
| 273 | d->outlineMapper->m_clip_rect.setHeight(QT_RASTER_COORD_LIMIT); | - |
| 274 | | - |
| 275 | d->rasterizer->setClipRect(d->deviceRect); | - |
| 276 | | - |
| 277 | s->penData.init(d->rasterBuffer.data(), this); | - |
| 278 | s->penData.setup(s->pen.brush(), s->intOpacity, s->composition_mode); | - |
| 279 | s->stroker = &d->basicStroker; | - |
| 280 | d->basicStroker.setClipRect(d->deviceRect); | - |
| 281 | | - |
| 282 | s->brushData.init(d->rasterBuffer.data(), this); | - |
| 283 | s->brushData.setup(s->brush, s->intOpacity, s->composition_mode); | - |
| 284 | | - |
| 285 | d->rasterBuffer->compositionMode = QPainter::CompositionMode_SourceOver; | - |
| 286 | | - |
| 287 | setDirty(DirtyBrushOrigin); | - |
| 288 | if (d->mono_surface) | - |
| 289 | d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono; | - |
| 290 | | - |
| 291 | | - |
| 292 | | - |
| 293 | else if (false) | - |
| 294 | | - |
| 295 | { | - |
| 296 | QImage::Format format = static_cast<QImage *>(d->device)->format(); | - |
| 297 | if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) | - |
| 298 | d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; | - |
| 299 | else | - |
| 300 | d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; | - |
| 301 | } else | - |
| 302 | d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; | - |
| 303 | | - |
| 304 | setActive(true); | - |
| 305 | return true; | - |
| 306 | } | - |
| 307 | | - |
| 308 | | - |
| 309 | | - |
| 310 | | - |
| 311 | bool QRasterPaintEngine::end() | - |
| 312 | { | - |
| 313 | return true; | - |
| 314 | } | - |
| 315 | | - |
| 316 | | - |
| 317 | | - |
| 318 | | - |
| 319 | void QRasterPaintEngine::releaseBuffer() | - |
| 320 | { | - |
| 321 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 322 | d->rasterBuffer.reset(new QRasterBuffer); | - |
| 323 | } | - |
| 324 | | - |
| 325 | | - |
| 326 | | - |
| 327 | | - |
| 328 | QSize QRasterPaintEngine::size() const | - |
| 329 | { | - |
| 330 | const QRasterPaintEnginePrivate * const d = d_func(); | - |
| 331 | return QSize(d->rasterBuffer->width(), d->rasterBuffer->height()); | - |
| 332 | } | - |
| 333 | void QRasterPaintEngine::updateMatrix(const QTransform &matrix) | - |
| 334 | { | - |
| 335 | QRasterPaintEngineState *s = state(); | - |
| 336 | | - |
| 337 | s->matrix = matrix; | - |
| 338 | QTransform::TransformationType txop = s->matrix.type(); | - |
| 339 | | - |
| 340 | switch (txop) { | - |
| 341 | | - |
| 342 | case QTransform::TxNone: | - |
| 343 | s->flags.int_xform = true; | - |
| 344 | break; | - |
| 345 | | - |
| 346 | case QTransform::TxTranslate: | - |
| 347 | s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx() | - |
| 348 | && qreal(int(s->matrix.dy())) == s->matrix.dy(); | - |
| 349 | break; | - |
| 350 | | - |
| 351 | case QTransform::TxScale: | - |
| 352 | s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx() | - |
| 353 | && qreal(int(s->matrix.dy())) == s->matrix.dy() | - |
| 354 | && qreal(int(s->matrix.m11())) == s->matrix.m11() | - |
| 355 | && qreal(int(s->matrix.m22())) == s->matrix.m22(); | - |
| 356 | break; | - |
| 357 | | - |
| 358 | default: | - |
| 359 | s->flags.int_xform = false; | - |
| 360 | break; | - |
| 361 | } | - |
| 362 | | - |
| 363 | s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale); | - |
| 364 | | - |
| 365 | ensureOutlineMapper(); | - |
| 366 | } | - |
| 367 | | - |
| 368 | | - |
| 369 | | - |
| 370 | QRasterPaintEngineState::~QRasterPaintEngineState() | - |
| 371 | { | - |
| 372 | if (flags.has_clip_ownership) | - |
| 373 | delete clip; | - |
| 374 | } | - |
| 375 | | - |
| 376 | | - |
| 377 | QRasterPaintEngineState::QRasterPaintEngineState() | - |
| 378 | { | - |
| 379 | stroker = 0; | - |
| 380 | | - |
| 381 | fillFlags = 0; | - |
| 382 | strokeFlags = 0; | - |
| 383 | pixmapFlags = 0; | - |
| 384 | | - |
| 385 | intOpacity = 256; | - |
| 386 | | - |
| 387 | txscale = 1.; | - |
| 388 | | - |
| 389 | flags.fast_pen = true; | - |
| 390 | flags.antialiased = false; | - |
| 391 | flags.bilinear = false; | - |
| 392 | flags.legacy_rounding = false; | - |
| 393 | flags.fast_text = true; | - |
| 394 | flags.int_xform = true; | - |
| 395 | flags.tx_noshear = true; | - |
| 396 | flags.fast_images = true; | - |
| 397 | | - |
| 398 | clip = 0; | - |
| 399 | flags.has_clip_ownership = false; | - |
| 400 | | - |
| 401 | dirty = 0; | - |
| 402 | } | - |
| 403 | | - |
| 404 | QRasterPaintEngineState::QRasterPaintEngineState(QRasterPaintEngineState &s) | - |
| 405 | : QPainterState(s) | - |
| 406 | , lastPen(s.lastPen) | - |
| 407 | , penData(s.penData) | - |
| 408 | , stroker(s.stroker) | - |
| 409 | , strokeFlags(s.strokeFlags) | - |
| 410 | , lastBrush(s.lastBrush) | - |
| 411 | , brushData(s.brushData) | - |
| 412 | , fillFlags(s.fillFlags) | - |
| 413 | , pixmapFlags(s.pixmapFlags) | - |
| 414 | , intOpacity(s.intOpacity) | - |
| 415 | , txscale(s.txscale) | - |
| 416 | , clip(s.clip) | - |
| 417 | , dirty(s.dirty) | - |
| 418 | , flag_bits(s.flag_bits) | - |
| 419 | { | - |
| 420 | brushData.tempImage = 0; | - |
| 421 | penData.tempImage = 0; | - |
| 422 | flags.has_clip_ownership = false; | - |
| 423 | } | - |
| 424 | | - |
| 425 | | - |
| 426 | | - |
| 427 | | - |
| 428 | QPainterState *QRasterPaintEngine::createState(QPainterState *orig) const | - |
| 429 | { | - |
| 430 | QRasterPaintEngineState *s; | - |
| 431 | if (!orig) | - |
| 432 | s = new QRasterPaintEngineState(); | - |
| 433 | else | - |
| 434 | s = new QRasterPaintEngineState(*static_cast<QRasterPaintEngineState *>(orig)); | - |
| 435 | | - |
| 436 | return s; | - |
| 437 | } | - |
| 438 | | - |
| 439 | | - |
| 440 | | - |
| 441 | | - |
| 442 | void QRasterPaintEngine::setState(QPainterState *s) | - |
| 443 | { | - |
| 444 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 445 | QPaintEngineEx::setState(s); | - |
| 446 | d->rasterBuffer->compositionMode = s->composition_mode; | - |
| 447 | } | - |
| 448 | void QRasterPaintEngine::penChanged() | - |
| 449 | { | - |
| 450 | | - |
| 451 | | - |
| 452 | | - |
| 453 | QRasterPaintEngineState *s = state(); | - |
| 454 | s->strokeFlags |= DirtyPen; | - |
| 455 | s->dirty |= DirtyPen; | - |
| 456 | } | - |
| 457 | | - |
| 458 | | - |
| 459 | | - |
| 460 | | - |
| 461 | void QRasterPaintEngine::updatePen(const QPen &pen) | - |
| 462 | { | - |
| 463 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 464 | QRasterPaintEngineState *s = state(); | - |
| 465 | | - |
| 466 | | - |
| 467 | | - |
| 468 | | - |
| 469 | Qt::PenStyle pen_style = qpen_style(pen); | - |
| 470 | | - |
| 471 | s->lastPen = pen; | - |
| 472 | s->strokeFlags = 0; | - |
| 473 | | - |
| 474 | s->penData.clip = d->clip(); | - |
| 475 | s->penData.setup(pen_style == Qt::NoPen ? QBrush() : pen.brush(), s->intOpacity, s->composition_mode); | - |
| 476 | | - |
| 477 | if (s->strokeFlags & QRasterPaintEngine::DirtyTransform | - |
| 478 | || pen.brush().transform().type() >= QTransform::TxNone) { | - |
| 479 | d->updateMatrixData(&s->penData, pen.brush(), s->matrix); | - |
| 480 | } | - |
| 481 | | - |
| 482 | | - |
| 483 | | - |
| 484 | | - |
| 485 | if (pen_style == Qt::CustomDashLine && pen.dashPattern().size() == 0) { | - |
| 486 | pen_style = Qt::SolidLine; | - |
| 487 | s->lastPen.setStyle(Qt::SolidLine); | - |
| 488 | } | - |
| 489 | | - |
| 490 | d->basicStroker.setJoinStyle(qpen_joinStyle(pen)); | - |
| 491 | d->basicStroker.setCapStyle(qpen_capStyle(pen)); | - |
| 492 | d->basicStroker.setMiterLimit(pen.miterLimit()); | - |
| 493 | | - |
| 494 | qreal penWidth = qpen_widthf(pen); | - |
| 495 | if (penWidth == 0) | - |
| 496 | d->basicStroker.setStrokeWidth(1); | - |
| 497 | else | - |
| 498 | d->basicStroker.setStrokeWidth(penWidth); | - |
| 499 | | - |
| 500 | if(pen_style == Qt::SolidLine) { | - |
| 501 | s->stroker = &d->basicStroker; | - |
| 502 | } else if (pen_style != Qt::NoPen) { | - |
| 503 | if (!d->dashStroker) | - |
| 504 | d->dashStroker.reset(new QDashStroker(&d->basicStroker)); | - |
| 505 | if (qt_pen_is_cosmetic(pen, s->renderHints)) { | - |
| 506 | d->dashStroker->setClipRect(d->deviceRect); | - |
| 507 | } else { | - |
| 508 | | - |
| 509 | QRectF clipRect = s->matrix.inverted().mapRect(QRectF(d->deviceRect)); | - |
| 510 | d->dashStroker->setClipRect(clipRect); | - |
| 511 | } | - |
| 512 | d->dashStroker->setDashPattern(pen.dashPattern()); | - |
| 513 | d->dashStroker->setDashOffset(pen.dashOffset()); | - |
| 514 | s->stroker = d->dashStroker.data(); | - |
| 515 | } else { | - |
| 516 | s->stroker = 0; | - |
| 517 | } | - |
| 518 | | - |
| 519 | ensureRasterState(); | - |
| 520 | bool cosmetic = qt_pen_is_cosmetic(pen, s->renderHints); | - |
| 521 | s->flags.fast_pen = pen_style > Qt::NoPen | - |
| 522 | && s->penData.blend | - |
| 523 | && ((cosmetic && penWidth <= 1) | - |
| 524 | || (!cosmetic && s->flags.tx_noshear && penWidth * s->txscale <= 1)); | - |
| 525 | | - |
| 526 | s->flags.non_complex_pen = qpen_capStyle(s->lastPen) <= Qt::SquareCap && s->flags.tx_noshear; | - |
| 527 | | - |
| 528 | s->strokeFlags = 0; | - |
| 529 | } | - |
| 530 | | - |
| 531 | | - |
| 532 | | - |
| 533 | | - |
| 534 | | - |
| 535 | | - |
| 536 | void QRasterPaintEngine::brushOriginChanged() | - |
| 537 | { | - |
| 538 | QRasterPaintEngineState *s = state(); | - |
| 539 | | - |
| 540 | | - |
| 541 | | - |
| 542 | | - |
| 543 | s->fillFlags |= DirtyBrushOrigin; | - |
| 544 | } | - |
| 545 | | - |
| 546 | | - |
| 547 | | - |
| 548 | | - |
| 549 | | - |
| 550 | void QRasterPaintEngine::brushChanged() | - |
| 551 | { | - |
| 552 | QRasterPaintEngineState *s = state(); | - |
| 553 | | - |
| 554 | | - |
| 555 | | - |
| 556 | s->fillFlags |= DirtyBrush; | - |
| 557 | } | - |
| 558 | | - |
| 559 | | - |
| 560 | | - |
| 561 | | - |
| 562 | | - |
| 563 | | - |
| 564 | | - |
| 565 | void QRasterPaintEngine::updateBrush(const QBrush &brush) | - |
| 566 | { | - |
| 567 | | - |
| 568 | | - |
| 569 | | - |
| 570 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 571 | QRasterPaintEngineState *s = state(); | - |
| 572 | | - |
| 573 | s->brushData.clip = d->clip(); | - |
| 574 | s->brushData.setup(brush, s->intOpacity, s->composition_mode); | - |
| 575 | if (s->fillFlags & DirtyTransform | - |
| 576 | || brush.transform().type() >= QTransform::TxNone) | - |
| 577 | d_func()->updateMatrixData(&s->brushData, brush, d->brushMatrix()); | - |
| 578 | s->lastBrush = brush; | - |
| 579 | s->fillFlags = 0; | - |
| 580 | } | - |
| 581 | | - |
| 582 | void QRasterPaintEngine::updateOutlineMapper() | - |
| 583 | { | - |
| 584 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 585 | d->outlineMapper->setMatrix(state()->matrix); | - |
| 586 | } | - |
| 587 | | - |
| 588 | void QRasterPaintEngine::updateRasterState() | - |
| 589 | { | - |
| 590 | QRasterPaintEngineState *s = state(); | - |
| 591 | | - |
| 592 | if (s->dirty & DirtyTransform) | - |
| 593 | updateMatrix(s->matrix); | - |
| 594 | | - |
| 595 | if (s->dirty & (DirtyPen|DirtyCompositionMode|DirtyOpacity)) { | - |
| 596 | const QPainter::CompositionMode mode = s->composition_mode; | - |
| 597 | s->flags.fast_text = (s->penData.type == QSpanData::Solid) | - |
| 598 | && s->intOpacity == 256 | - |
| 599 | && (mode == QPainter::CompositionMode_Source | - |
| 600 | || (mode == QPainter::CompositionMode_SourceOver | - |
| 601 | && qAlpha(s->penData.solid.color) == 255)); | - |
| 602 | } | - |
| 603 | | - |
| 604 | s->dirty = 0; | - |
| 605 | } | - |
| 606 | | - |
| 607 | | - |
| 608 | | - |
| 609 | | - |
| 610 | | - |
| 611 | void QRasterPaintEngine::opacityChanged() | - |
| 612 | { | - |
| 613 | QRasterPaintEngineState *s = state(); | - |
| 614 | | - |
| 615 | | - |
| 616 | | - |
| 617 | | - |
| 618 | | - |
| 619 | s->fillFlags |= DirtyOpacity; | - |
| 620 | s->strokeFlags |= DirtyOpacity; | - |
| 621 | s->pixmapFlags |= DirtyOpacity; | - |
| 622 | s->dirty |= DirtyOpacity; | - |
| 623 | s->intOpacity = (int) (s->opacity * 256); | - |
| 624 | } | - |
| 625 | | - |
| 626 | | - |
| 627 | | - |
| 628 | | - |
| 629 | void QRasterPaintEngine::compositionModeChanged() | - |
| 630 | { | - |
| 631 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 632 | QRasterPaintEngineState *s = state(); | - |
| 633 | | - |
| 634 | | - |
| 635 | | - |
| 636 | | - |
| 637 | | - |
| 638 | s->fillFlags |= DirtyCompositionMode; | - |
| 639 | s->dirty |= DirtyCompositionMode; | - |
| 640 | | - |
| 641 | s->strokeFlags |= DirtyCompositionMode; | - |
| 642 | d->rasterBuffer->compositionMode = s->composition_mode; | - |
| 643 | | - |
| 644 | d->recalculateFastImages(); | - |
| 645 | } | - |
| 646 | | - |
| 647 | | - |
| 648 | | - |
| 649 | | - |
| 650 | void QRasterPaintEngine::renderHintsChanged() | - |
| 651 | { | - |
| 652 | QRasterPaintEngineState *s = state(); | - |
| 653 | | - |
| 654 | | - |
| 655 | | - |
| 656 | | - |
| 657 | | - |
| 658 | bool was_aa = s->flags.antialiased; | - |
| 659 | bool was_bilinear = s->flags.bilinear; | - |
| 660 | | - |
| 661 | s->flags.antialiased = bool(s->renderHints & QPainter::Antialiasing); | - |
| 662 | s->flags.bilinear = bool(s->renderHints & QPainter::SmoothPixmapTransform); | - |
| 663 | s->flags.legacy_rounding = !bool(s->renderHints & QPainter::Antialiasing) && bool(s->renderHints & QPainter::Qt4CompatiblePainting); | - |
| 664 | | - |
| 665 | if (was_aa != s->flags.antialiased) | - |
| 666 | s->strokeFlags |= DirtyHints; | - |
| 667 | | - |
| 668 | if (was_bilinear != s->flags.bilinear) { | - |
| 669 | s->strokeFlags |= DirtyPen; | - |
| 670 | s->fillFlags |= DirtyBrush; | - |
| 671 | } | - |
| 672 | | - |
| 673 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 674 | d->recalculateFastImages(); | - |
| 675 | } | - |
| 676 | | - |
| 677 | | - |
| 678 | | - |
| 679 | | - |
| 680 | void QRasterPaintEngine::transformChanged() | - |
| 681 | { | - |
| 682 | QRasterPaintEngineState *s = state(); | - |
| 683 | | - |
| 684 | | - |
| 685 | | - |
| 686 | | - |
| 687 | | - |
| 688 | s->fillFlags |= DirtyTransform; | - |
| 689 | s->strokeFlags |= DirtyTransform; | - |
| 690 | | - |
| 691 | s->dirty |= DirtyTransform; | - |
| 692 | | - |
| 693 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 694 | d->recalculateFastImages(); | - |
| 695 | } | - |
| 696 | | - |
| 697 | | - |
| 698 | | - |
| 699 | | - |
| 700 | void QRasterPaintEngine::clipEnabledChanged() | - |
| 701 | { | - |
| 702 | QRasterPaintEngineState *s = state(); | - |
| 703 | | - |
| 704 | | - |
| 705 | | - |
| 706 | | - |
| 707 | | - |
| 708 | if (s->clip) { | - |
| 709 | s->clip->enabled = s->clipEnabled; | - |
| 710 | s->fillFlags |= DirtyClipEnabled; | - |
| 711 | s->strokeFlags |= DirtyClipEnabled; | - |
| 712 | s->pixmapFlags |= DirtyClipEnabled; | - |
| 713 | } | - |
| 714 | } | - |
| 715 | | - |
| 716 | void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, | - |
| 717 | const QImage &img, | - |
| 718 | SrcOverBlendFunc func, | - |
| 719 | const QRect &clip, | - |
| 720 | int alpha, | - |
| 721 | const QRect &sr) | - |
| 722 | { | - |
| 723 | if (alpha == 0 || !clip.isValid()) | - |
| 724 | return; | - |
| 725 | | - |
| 726 | qt_noop(); | - |
| 727 | | - |
| 728 | int srcBPL = img.bytesPerLine(); | - |
| 729 | const uchar *srcBits = img.bits(); | - |
| 730 | int srcSize = img.depth() >> 3; | - |
| 731 | int iw = img.width(); | - |
| 732 | int ih = img.height(); | - |
| 733 | | - |
| 734 | if (!sr.isEmpty()) { | - |
| 735 | iw = sr.width(); | - |
| 736 | ih = sr.height(); | - |
| 737 | | - |
| 738 | srcBits += ((sr.y() * srcBPL) + sr.x() * srcSize); | - |
| 739 | } | - |
| 740 | | - |
| 741 | | - |
| 742 | int x = qRound(pt.x()); | - |
| 743 | int cx1 = clip.x(); | - |
| 744 | int cx2 = clip.x() + clip.width(); | - |
| 745 | if (x < cx1) { | - |
| 746 | int d = cx1 - x; | - |
| 747 | srcBits += srcSize * d; | - |
| 748 | iw -= d; | - |
| 749 | x = cx1; | - |
| 750 | } | - |
| 751 | if (x + iw > cx2) { | - |
| 752 | int d = x + iw - cx2; | - |
| 753 | iw -= d; | - |
| 754 | } | - |
| 755 | if (iw <= 0) | - |
| 756 | return; | - |
| 757 | | - |
| 758 | | - |
| 759 | int cy1 = clip.y(); | - |
| 760 | int cy2 = clip.y() + clip.height(); | - |
| 761 | int y = qRound(pt.y()); | - |
| 762 | if (y < cy1) { | - |
| 763 | int d = cy1 - y; | - |
| 764 | srcBits += srcBPL * d; | - |
| 765 | ih -= d; | - |
| 766 | y = cy1; | - |
| 767 | } | - |
| 768 | if (y + ih > cy2) { | - |
| 769 | int d = y + ih - cy2; | - |
| 770 | ih -= d; | - |
| 771 | } | - |
| 772 | if (ih <= 0) | - |
| 773 | return; | - |
| 774 | | - |
| 775 | | - |
| 776 | int dstSize = rasterBuffer->bytesPerPixel(); | - |
| 777 | int dstBPL = rasterBuffer->bytesPerLine(); | - |
| 778 | func(rasterBuffer->buffer() + x * dstSize + y * dstBPL, dstBPL, | - |
| 779 | srcBits, srcBPL, | - |
| 780 | iw, ih, | - |
| 781 | alpha); | - |
| 782 | } | - |
| 783 | | - |
| 784 | | - |
| 785 | void QRasterPaintEnginePrivate::systemStateChanged() | - |
| 786 | { | - |
| 787 | deviceRectUnclipped = QRectclipRect(0, 0, | - |
| 788 | qMin(QT_RASTER_COORD_LIMIT, device->width()), | - |
| 789 | qMin(QT_RASTER_COORD_LIMIT, device->height())); | - |
| 790 | | - |
| 791 | if (!systemClip.isEmpty()) { evaluated: !systemClip.isEmpty()| yes Evaluation Count:14829 | yes Evaluation Count:13971 |
| 13971-14829 |
| 792 | QRegion clippedDeviceRgn = systemClip & clipRectdeviceRectUnclipped; | - |
| 793 | deviceRect = clippedDeviceRgn.boundingRect(); | - |
| 794 | baseClip->setClipRegion(clippedDeviceRgn); | - |
| 795 | } else { executed: }Execution Count:14829 | 14829 |
| 796 | deviceRect = clipRectdeviceRectUnclipped; | - |
| 797 | baseClip->setClipRect(deviceRect); | - |
| 798 | } executed: }Execution Count:13971 | 13971 |
| 799 | | - |
| 800 | | - |
| 801 | | - |
| 802 | | - |
| 803 | exDeviceRect = deviceRect; | - |
| 804 | | - |
| 805 | QRasterPaintEngine * const q = q_func(); | - |
| 806 | if (q->state()) { partially evaluated: q->state()| yes Evaluation Count:28800 | no Evaluation Count:0 |
| 0-28800 |
| 807 | q->state()->strokeFlags |= QPaintEngine::DirtyClipRegion; | - |
| 808 | q->state()->fillFlags |= QPaintEngine::DirtyClipRegion; | - |
| 809 | q->state()->pixmapFlags |= QPaintEngine::DirtyClipRegion; | - |
| 810 | } executed: }Execution Count:28800 | 28800 |
| 811 | } executed: }Execution Count:28800 | 28800 |
| 812 | | - |
| 813 | void QRasterPaintEnginePrivate::updateMatrixData(QSpanData *spanData, const QBrush &b, const QTransform &m) | - |
| 814 | { | - |
| 815 | if (b.d->style == Qt::NoBrush || b.d->style == Qt::SolidPattern) | - |
| 816 | return; | - |
| 817 | | - |
| 818 | QRasterPaintEngine * const q = q_func(); | - |
| 819 | bool bilinear = q->state()->flags.bilinear; | - |
| 820 | | - |
| 821 | if (b.d->transform.type() > QTransform::TxNone) { | - |
| 822 | spanData->setupMatrix(b.transform() * m, bilinear); | - |
| 823 | } else { | - |
| 824 | if (m.type() <= QTransform::TxTranslate) { | - |
| 825 | | - |
| 826 | | - |
| 827 | spanData->m11 = 1; | - |
| 828 | spanData->m12 = 0; | - |
| 829 | spanData->m13 = 0; | - |
| 830 | spanData->m21 = 0; | - |
| 831 | spanData->m22 = 1; | - |
| 832 | spanData->m23 = 0; | - |
| 833 | spanData->m33 = 1; | - |
| 834 | spanData->dx = -m.dx(); | - |
| 835 | spanData->dy = -m.dy(); | - |
| 836 | spanData->txop = m.type(); | - |
| 837 | spanData->bilinear = bilinear; | - |
| 838 | spanData->fast_matrix = qAbs(m.dx()) < 1e4 && qAbs(m.dy()) < 1e4; | - |
| 839 | spanData->adjustSpanMethods(); | - |
| 840 | } else { | - |
| 841 | spanData->setupMatrix(m, bilinear); | - |
| 842 | } | - |
| 843 | } | - |
| 844 | } | - |
| 845 | static void qrasterpaintengine_state_setNoClip(QRasterPaintEngineState *s) | - |
| 846 | { | - |
| 847 | if (s->flags.has_clip_ownership) | - |
| 848 | delete s->clip; | - |
| 849 | s->clip = 0; | - |
| 850 | s->flags.has_clip_ownership = false; | - |
| 851 | } | - |
| 852 | | - |
| 853 | static void qrasterpaintengine_dirty_clip(QRasterPaintEnginePrivate *d, QRasterPaintEngineState *s) | - |
| 854 | { | - |
| 855 | s->fillFlags |= QPaintEngine::DirtyClipPath; | - |
| 856 | s->strokeFlags |= QPaintEngine::DirtyClipPath; | - |
| 857 | s->pixmapFlags |= QPaintEngine::DirtyClipPath; | - |
| 858 | | - |
| 859 | d->solid_color_filler.clip = d->clip(); | - |
| 860 | d->solid_color_filler.adjustSpanMethods(); | - |
| 861 | | - |
| 862 | | - |
| 863 | | - |
| 864 | | - |
| 865 | | - |
| 866 | } | - |
| 867 | | - |
| 868 | | - |
| 869 | | - |
| 870 | | - |
| 871 | | - |
| 872 | void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) | - |
| 873 | { | - |
| 874 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 875 | QRasterPaintEngineState *s = state(); | - |
| 876 | | - |
| 877 | const qreal *points = path.points(); | - |
| 878 | const QPainterPath::ElementType *types = path.elements(); | - |
| 879 | | - |
| 880 | | - |
| 881 | if (op != Qt::IntersectClip || !s->clip || s->clip->hasRectClip || s->clip->hasRegionClip) { | - |
| 882 | if (s->matrix.type() <= QTransform::TxScale | - |
| 883 | && ((path.shape() == QVectorPath::RectangleHint) | - |
| 884 | || (isRect(points, path.elementCount()) | - |
| 885 | && (!types || (types[0] == QPainterPath::MoveToElement | - |
| 886 | && types[1] == QPainterPath::LineToElement | - |
| 887 | && types[2] == QPainterPath::LineToElement | - |
| 888 | && types[3] == QPainterPath::LineToElement))))) { | - |
| 889 | | - |
| 890 | | - |
| 891 | | - |
| 892 | | - |
| 893 | QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]); | - |
| 894 | if (setClipRectInDeviceCoords(s->matrix.mapRect(r).toRect(), op)) | - |
| 895 | return; | - |
| 896 | } | - |
| 897 | } | - |
| 898 | | - |
| 899 | if (op == Qt::NoClip) { | - |
| 900 | qrasterpaintengine_state_setNoClip(s); | - |
| 901 | | - |
| 902 | } else { | - |
| 903 | QClipData *base = d->baseClip.data(); | - |
| 904 | | - |
| 905 | | - |
| 906 | if (op == Qt::IntersectClip && s->clip) | - |
| 907 | base = s->clip; | - |
| 908 | | - |
| 909 | | - |
| 910 | | - |
| 911 | | - |
| 912 | Qt::ClipOperation isectOp = Qt::IntersectClip; | - |
| 913 | if (base == 0) | - |
| 914 | isectOp = Qt::ReplaceClip; | - |
| 915 | | - |
| 916 | QClipData *newClip = new QClipData(d->rasterBuffer->height()); | - |
| 917 | newClip->initialize(); | - |
| 918 | ClipData clipData = { base, newClip, isectOp }; | - |
| 919 | ensureOutlineMapper(); | - |
| 920 | d->rasterize(d->outlineMapper->convertPath(path), qt_span_clip, &clipData, 0); | - |
| 921 | | - |
| 922 | newClip->fixup(); | - |
| 923 | | - |
| 924 | if (s->flags.has_clip_ownership) | - |
| 925 | delete s->clip; | - |
| 926 | | - |
| 927 | s->clip = newClip; | - |
| 928 | s->flags.has_clip_ownership = true; | - |
| 929 | } | - |
| 930 | qrasterpaintengine_dirty_clip(d, s); | - |
| 931 | } | - |
| 932 | | - |
| 933 | | - |
| 934 | | - |
| 935 | | - |
| 936 | | - |
| 937 | | - |
| 938 | void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) | - |
| 939 | { | - |
| 940 | | - |
| 941 | | - |
| 942 | | - |
| 943 | | - |
| 944 | QRasterPaintEngineState *s = state(); | - |
| 945 | | - |
| 946 | if (op == Qt::NoClip) { | - |
| 947 | qrasterpaintengine_state_setNoClip(s); | - |
| 948 | | - |
| 949 | } else if (s->matrix.type() > QTransform::TxScale) { | - |
| 950 | QPaintEngineEx::clip(rect, op); | - |
| 951 | return; | - |
| 952 | | - |
| 953 | } else if (!setClipRectInDeviceCoords(s->matrix.mapRect(rect), op)) { | - |
| 954 | QPaintEngineEx::clip(rect, op); | - |
| 955 | return; | - |
| 956 | } | - |
| 957 | } | - |
| 958 | | - |
| 959 | | - |
| 960 | bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op) | - |
| 961 | { | - |
| 962 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 963 | QRect clipRect = r & d->deviceRect; | - |
| 964 | QRasterPaintEngineState *s = state(); | - |
| 965 | | - |
| 966 | if (op == Qt::ReplaceClip || s->clip == 0) { | - |
| 967 | | - |
| 968 | | - |
| 969 | | - |
| 970 | QRegion clipRegion = systemClip(); | - |
| 971 | QClipData *clip = new QClipData(d->rasterBuffer->height()); | - |
| 972 | | - |
| 973 | if (clipRegion.isEmpty()) | - |
| 974 | clip->setClipRect(clipRect); | - |
| 975 | else | - |
| 976 | clip->setClipRegion(clipRegion & clipRect); | - |
| 977 | | - |
| 978 | if (s->flags.has_clip_ownership) | - |
| 979 | delete s->clip; | - |
| 980 | | - |
| 981 | s->clip = clip; | - |
| 982 | s->clip->enabled = true; | - |
| 983 | s->flags.has_clip_ownership = true; | - |
| 984 | | - |
| 985 | } else if (op == Qt::IntersectClip){ | - |
| 986 | QClipData *base = s->clip; | - |
| 987 | | - |
| 988 | qt_noop(); | - |
| 989 | if (base->hasRectClip || base->hasRegionClip) { | - |
| 990 | if (!s->flags.has_clip_ownership) { | - |
| 991 | s->clip = new QClipData(d->rasterBuffer->height()); | - |
| 992 | s->flags.has_clip_ownership = true; | - |
| 993 | } | - |
| 994 | if (base->hasRectClip) | - |
| 995 | s->clip->setClipRect(base->clipRect & clipRect); | - |
| 996 | else | - |
| 997 | s->clip->setClipRegion(base->clipRegion & clipRect); | - |
| 998 | s->clip->enabled = true; | - |
| 999 | } else { | - |
| 1000 | return false; | - |
| 1001 | } | - |
| 1002 | } else { | - |
| 1003 | return false; | - |
| 1004 | } | - |
| 1005 | | - |
| 1006 | qrasterpaintengine_dirty_clip(d, s); | - |
| 1007 | return true; | - |
| 1008 | } | - |
| 1009 | | - |
| 1010 | | - |
| 1011 | | - |
| 1012 | | - |
| 1013 | | - |
| 1014 | void QRasterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) | - |
| 1015 | { | - |
| 1016 | | - |
| 1017 | | - |
| 1018 | | - |
| 1019 | | - |
| 1020 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1021 | | - |
| 1022 | if (region.rectCount() == 1) { | - |
| 1023 | clip(region.boundingRect(), op); | - |
| 1024 | return; | - |
| 1025 | } | - |
| 1026 | | - |
| 1027 | QRasterPaintEngineState *s = state(); | - |
| 1028 | const QClipData *clip = d->clip(); | - |
| 1029 | const QClipData *baseClip = d->baseClip.data(); | - |
| 1030 | | - |
| 1031 | if (op == Qt::NoClip) { | - |
| 1032 | qrasterpaintengine_state_setNoClip(s); | - |
| 1033 | } else if (s->matrix.type() > QTransform::TxScale | - |
| 1034 | || (op == Qt::IntersectClip && !clip->hasRectClip && !clip->hasRegionClip) | - |
| 1035 | || (op == Qt::ReplaceClip && !baseClip->hasRectClip && !baseClip->hasRegionClip)) { | - |
| 1036 | QPaintEngineEx::clip(region, op); | - |
| 1037 | } else { | - |
| 1038 | const QClipData *curClip; | - |
| 1039 | QClipData *newClip; | - |
| 1040 | | - |
| 1041 | if (op == Qt::IntersectClip) | - |
| 1042 | curClip = clip; | - |
| 1043 | else | - |
| 1044 | curClip = baseClip; | - |
| 1045 | | - |
| 1046 | if (s->flags.has_clip_ownership) { | - |
| 1047 | newClip = s->clip; | - |
| 1048 | qt_noop(); | - |
| 1049 | } else { | - |
| 1050 | newClip = new QClipData(d->rasterBuffer->height()); | - |
| 1051 | s->clip = newClip; | - |
| 1052 | s->flags.has_clip_ownership = true; | - |
| 1053 | } | - |
| 1054 | | - |
| 1055 | QRegion r = s->matrix.map(region); | - |
| 1056 | if (curClip->hasRectClip) | - |
| 1057 | newClip->setClipRegion(r & curClip->clipRect); | - |
| 1058 | else if (curClip->hasRegionClip) | - |
| 1059 | newClip->setClipRegion(r & curClip->clipRegion); | - |
| 1060 | | - |
| 1061 | qrasterpaintengine_dirty_clip(d, s); | - |
| 1062 | } | - |
| 1063 | } | - |
| 1064 | void QRasterPaintEngine::fillPath(const QPainterPath &path, QSpanData *fillData) | - |
| 1065 | { | - |
| 1066 | | - |
| 1067 | | - |
| 1068 | | - |
| 1069 | | - |
| 1070 | if (!fillData->blend) | - |
| 1071 | return; | - |
| 1072 | | - |
| 1073 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1074 | | - |
| 1075 | const QRectF controlPointRect = path.controlPointRect(); | - |
| 1076 | | - |
| 1077 | QRasterPaintEngineState *s = state(); | - |
| 1078 | const QRect deviceRect = s->matrix.mapRect(controlPointRect).toRect(); | - |
| 1079 | ProcessSpans blend = d->getBrushFunc(deviceRect, fillData); | - |
| 1080 | const bool do_clip = (deviceRect.left() < -QT_RASTER_COORD_LIMIT | - |
| 1081 | || deviceRect.right() > QT_RASTER_COORD_LIMIT | - |
| 1082 | || deviceRect.top() < -QT_RASTER_COORD_LIMIT | - |
| 1083 | || deviceRect.bottom() > QT_RASTER_COORD_LIMIT); | - |
| 1084 | | - |
| 1085 | if (!s->flags.antialiased && !do_clip) { | - |
| 1086 | d->initializeRasterizer(fillData); | - |
| 1087 | d->rasterizer->rasterize(path * s->matrix, path.fillRule()); | - |
| 1088 | return; | - |
| 1089 | } | - |
| 1090 | | - |
| 1091 | ensureOutlineMapper(); | - |
| 1092 | d->rasterize(d->outlineMapper->convertPath(path), blend, fillData, d->rasterBuffer.data()); | - |
| 1093 | } | - |
| 1094 | | - |
| 1095 | static void fillRect_normalized(const QRect &r, QSpanData *data, | - |
| 1096 | QRasterPaintEnginePrivate *pe) | - |
| 1097 | { | - |
| 1098 | int x1, x2, y1, y2; | - |
| 1099 | | - |
| 1100 | bool rectClipped = true; | - |
| 1101 | | - |
| 1102 | if (data->clip) { | - |
| 1103 | x1 = qMax(r.x(), data->clip->xmin); | - |
| 1104 | x2 = qMin(r.x() + r.width(), data->clip->xmax); | - |
| 1105 | y1 = qMax(r.y(), data->clip->ymin); | - |
| 1106 | y2 = qMin(r.y() + r.height(), data->clip->ymax); | - |
| 1107 | rectClipped = data->clip->hasRectClip; | - |
| 1108 | | - |
| 1109 | } else if (pe) { | - |
| 1110 | x1 = qMax(r.x(), pe->deviceRect.x()); | - |
| 1111 | x2 = qMin(r.x() + r.width(), pe->deviceRect.x() + pe->deviceRect.width()); | - |
| 1112 | y1 = qMax(r.y(), pe->deviceRect.y()); | - |
| 1113 | y2 = qMin(r.y() + r.height(), pe->deviceRect.y() + pe->deviceRect.height()); | - |
| 1114 | } else { | - |
| 1115 | x1 = qMax(r.x(), 0); | - |
| 1116 | x2 = qMin(r.x() + r.width(), data->rasterBuffer->width()); | - |
| 1117 | y1 = qMax(r.y(), 0); | - |
| 1118 | y2 = qMin(r.y() + r.height(), data->rasterBuffer->height()); | - |
| 1119 | } | - |
| 1120 | | - |
| 1121 | if (x2 <= x1 || y2 <= y1) | - |
| 1122 | return; | - |
| 1123 | | - |
| 1124 | const int width = x2 - x1; | - |
| 1125 | const int height = y2 - y1; | - |
| 1126 | | - |
| 1127 | bool isUnclipped = rectClipped | - |
| 1128 | || (pe && pe->isUnclipped_normalized(QRect(x1, y1, width, height))); | - |
| 1129 | | - |
| 1130 | if (pe && isUnclipped) { | - |
| 1131 | const QPainter::CompositionMode mode = pe->rasterBuffer->compositionMode; | - |
| 1132 | | - |
| 1133 | if (data->fillRect && (mode == QPainter::CompositionMode_Source | - |
| 1134 | || (mode == QPainter::CompositionMode_SourceOver | - |
| 1135 | && qAlpha(data->solid.color) == 255))) | - |
| 1136 | { | - |
| 1137 | data->fillRect(data->rasterBuffer, x1, y1, width, height, | - |
| 1138 | data->solid.color); | - |
| 1139 | return; | - |
| 1140 | } | - |
| 1141 | } | - |
| 1142 | | - |
| 1143 | ProcessSpans blend = isUnclipped ? data->unclipped_blend : data->blend; | - |
| 1144 | | - |
| 1145 | const int nspans = 256; | - |
| 1146 | QT_FT_Span spans[nspans]; | - |
| 1147 | | - |
| 1148 | qt_noop(); | - |
| 1149 | int y = y1; | - |
| 1150 | while (y < y2) { | - |
| 1151 | int n = qMin(nspans, y2 - y); | - |
| 1152 | int i = 0; | - |
| 1153 | while (i < n) { | - |
| 1154 | spans[i].x = x1; | - |
| 1155 | spans[i].len = width; | - |
| 1156 | spans[i].y = y + i; | - |
| 1157 | spans[i].coverage = 255; | - |
| 1158 | ++i; | - |
| 1159 | } | - |
| 1160 | | - |
| 1161 | blend(n, spans, data); | - |
| 1162 | y += n; | - |
| 1163 | } | - |
| 1164 | } | - |
| 1165 | | - |
| 1166 | | - |
| 1167 | | - |
| 1168 | | - |
| 1169 | void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) | - |
| 1170 | { | - |
| 1171 | | - |
| 1172 | | - |
| 1173 | | - |
| 1174 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1175 | ensureRasterState(); | - |
| 1176 | QRasterPaintEngineState *s = state(); | - |
| 1177 | | - |
| 1178 | | - |
| 1179 | ensureBrush(); | - |
| 1180 | if (s->brushData.blend) { evaluated: s->brushData.blend| yes Evaluation Count:6418 | yes Evaluation Count:2013 |
| 2013-6418 |
| 1181 | if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxTranslate) { evaluated: !s->flags.antialiased| yes Evaluation Count:6408 | yes Evaluation Count:10 |
evaluated: s->matrix.type() <= QTransform::TxTranslate| yes Evaluation Count:6405 | yes Evaluation Count:3 |
| 3-6408 |
| 1182 | const QRect *r = rects; | - |
| 1183 | const QRect *lastRect = rects + rectCount; | - |
| 1184 | | - |
| 1185 | int offset_x = int(s->matrix.dx()); | - |
| 1186 | int offset_y = int(s->matrix.dy()); | - |
| 1187 | while (r < lastRect) { evaluated: r < lastRect| yes Evaluation Count:6405 | yes Evaluation Count:6405 |
| 6405 |
| 1188 | QRect rect = r->normalized(); | - |
| 1189 | QRect rr = rect.translated(offset_x, offset_y); | - |
| 1190 | fillRect_normalized(rr, &s->brushData, d); | - |
| 1191 | ++r; | - |
| 1192 | } executed: }Execution Count:6405 | 6405 |
| 1193 | } else { executed: }Execution Count:6405 | 6405 |
| 1194 | QRectVectorPath path; | - |
| 1195 | for (int i=0; i<rectCount; ++i) { evaluated: i<rectCount| yes Evaluation Count:13 | yes Evaluation Count:13 |
| 13 |
| 1196 | path.set(rects[i]); | - |
| 1197 | fill(path, s->brush); | - |
| 1198 | } executed: }Execution Count:13 | 13 |
| 1199 | } executed: }Execution Count:13 | 13 |
| 1200 | } | - |
| 1201 | | - |
| 1202 | ensurePen(); | - |
| 1203 | if (s->penData.blend) { evaluated: s->penData.blend| yes Evaluation Count:2384 | yes Evaluation Count:6047 |
| 2384-6047 |
| 1204 | QRectVectorPath path; | - |
| 1205 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:2378 | yes Evaluation Count:6 |
| 6-2378 |
| 1206 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 1207 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 1208 | for (int i = 0; i < rectCount; ++i) { evaluated: i < rectCount| yes Evaluation Count:2378 | yes Evaluation Count:2378 |
| 2378 |
| 1209 | path.set(rects[i]); | - |
| 1210 | stroker.drawPath(path); | - |
| 1211 | } executed: }Execution Count:2378 | 2378 |
| 1212 | } else { executed: }Execution Count:2378 | 2378 |
| 1213 | for (int i = 0; i < rectCount; ++i) { evaluated: i < rectCount| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
| 1214 | path.set(rects[i]); | - |
| 1215 | stroke(path, s->pen); | - |
| 1216 | } executed: }Execution Count:6 | 6 |
| 1217 | } executed: }Execution Count:6 | 6 |
| 1218 | } | - |
| 1219 | } executed: }Execution Count:8431 | 8431 |
| 1220 | | - |
| 1221 | | - |
| 1222 | | - |
| 1223 | | - |
| 1224 | void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount) | - |
| 1225 | { | - |
| 1226 | | - |
| 1227 | | - |
| 1228 | | - |
| 1229 | | - |
| 1230 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1231 | ensureRasterState(); | - |
| 1232 | QRasterPaintEngineState *s = state(); | - |
| 1233 | | - |
| 1234 | | - |
| 1235 | if (s->flags.tx_noshear) { evaluated: s->flags.tx_noshear| yes Evaluation Count:616 | yes Evaluation Count:8 |
| 8-616 |
| 1236 | ensureBrush(); | - |
| 1237 | if (s->brushData.blend) { evaluated: s->brushData.blend| yes Evaluation Count:313 | yes Evaluation Count:303 |
| 303-313 |
| 1238 | d->initializeRasterizer(&s->brushData); | - |
| 1239 | for (int i = 0; i < rectCount; ++i) { evaluated: i < rectCount| yes Evaluation Count:313 | yes Evaluation Count:313 |
| 313 |
| 1240 | const QRectF &rect = rects[i].normalized(); | - |
| 1241 | if (rect.isEmpty()) evaluated: rect.isEmpty()| yes Evaluation Count:2 | yes Evaluation Count:311 |
| 2-311 |
| 1242 | continue; executed: continue;Execution Count:2 | 2 |
| 1243 | const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); | - |
| 1244 | const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f); | - |
| 1245 | d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); | - |
| 1246 | } executed: }Execution Count:311 | 311 |
| 1247 | } executed: }Execution Count:313 | 313 |
| 1248 | | - |
| 1249 | ensurePen(); | - |
| 1250 | if (s->penData.blend) { evaluated: s->penData.blend| yes Evaluation Count:361 | yes Evaluation Count:255 |
| 255-361 |
| 1251 | QRectVectorPath path; | - |
| 1252 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:337 | yes Evaluation Count:24 |
| 24-337 |
| 1253 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 1254 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 1255 | for (int i = 0; i < rectCount; ++i) { evaluated: i < rectCount| yes Evaluation Count:337 | yes Evaluation Count:337 |
| 337 |
| 1256 | path.set(rects[i]); | - |
| 1257 | stroker.drawPath(path); | - |
| 1258 | } executed: }Execution Count:337 | 337 |
| 1259 | } else { executed: }Execution Count:337 | 337 |
| 1260 | for (int i = 0; i < rectCount; ++i) { evaluated: i < rectCount| yes Evaluation Count:24 | yes Evaluation Count:24 |
| 24 |
| 1261 | path.set(rects[i]); | - |
| 1262 | QPaintEngineEx::stroke(path, s->lastPen); | - |
| 1263 | } executed: }Execution Count:24 | 24 |
| 1264 | } executed: }Execution Count:24 | 24 |
| 1265 | } | - |
| 1266 | | - |
| 1267 | return; executed: return;Execution Count:616 | 616 |
| 1268 | } | - |
| 1269 | | - |
| 1270 | QPaintEngineEx::drawRects(rects, rectCount); | - |
| 1271 | } executed: }Execution Count:8 | 8 |
| 1272 | | - |
| 1273 | | - |
| 1274 | | - |
| 1275 | | - |
| 1276 | | - |
| 1277 | void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) | - |
| 1278 | { | - |
| 1279 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1280 | QRasterPaintEngineState *s = state(); | - |
| 1281 | | - |
| 1282 | ensurePen(pen); | - |
| 1283 | if (!s->penData.blend) evaluated: !s->penData.blend| yes Evaluation Count:13 | yes Evaluation Count:13272 |
| 13-13272 |
| 1284 | return; executed: return;Execution Count:13 | 13 |
| 1285 | | - |
| 1286 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:11507 | yes Evaluation Count:1765 |
| 1765-11507 |
| 1287 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 1288 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 1289 | stroker.drawPath(path); | - |
| 1290 | } else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) { evaluated: s->flags.non_complex_pen| yes Evaluation Count:1545 | yes Evaluation Count:220 |
evaluated: path.shape() == QVectorPath::LinesHint| yes Evaluation Count:875 | yes Evaluation Count:670 |
executed: }Execution Count:11507 | 220-11507 |
| 1291 | qreal width = qt_pen_is_cosmetic(s->lastPen, s->renderHints) partially evaluated: qt_pen_is_cosmetic(s->lastPen, s->renderHints)| no Evaluation Count:0 | yes Evaluation Count:875 |
| 0-875 |
| 1292 | ? (qpen_widthf(s->lastPen) == 0 ? 1 : qpen_widthf(s->lastPen)) | - |
| 1293 | : qpen_widthf(s->lastPen) * s->txscale; | - |
| 1294 | int dashIndex = 0; | - |
| 1295 | qreal dashOffset = s->lastPen.dashOffset(); | - |
| 1296 | bool inDash = true; | - |
| 1297 | qreal patternLength = 0; | - |
| 1298 | const QVector<qreal> pattern = s->lastPen.dashPattern(); | - |
| 1299 | for (int i = 0; i < pattern.size(); ++i) evaluated: i < pattern.size()| yes Evaluation Count:6 | yes Evaluation Count:875 |
| 6-875 |
| 1300 | patternLength += pattern.at(i); executed: patternLength += pattern.at(i);Execution Count:6 | 6 |
| 1301 | | - |
| 1302 | if (patternLength > 0) { evaluated: patternLength > 0| yes Evaluation Count:1 | yes Evaluation Count:874 |
| 1-874 |
| 1303 | int n = qFloor(dashOffset / patternLength); | - |
| 1304 | dashOffset -= n * patternLength; | - |
| 1305 | while (dashOffset >= pattern.at(dashIndex)) { partially evaluated: dashOffset >= pattern.at(dashIndex)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1306 | dashOffset -= pattern.at(dashIndex); | - |
| 1307 | if (++dashIndex >= pattern.size()) never evaluated: ++dashIndex >= pattern.size() | 0 |
| 1308 | dashIndex = 0; never executed: dashIndex = 0; | 0 |
| 1309 | inDash = !inDash; | - |
| 1310 | } | 0 |
| 1311 | } executed: }Execution Count:1 | 1 |
| 1312 | | - |
| 1313 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1314 | d->initializeRasterizer(&s->penData); | - |
| 1315 | int lineCount = path.elementCount() / 2; | - |
| 1316 | const QLineF *lines = reinterpret_cast<const QLineF *>(path.points()); | - |
| 1317 | | - |
| 1318 | for (int i = 0; i < lineCount; ++i) { evaluated: i < lineCount| yes Evaluation Count:876 | yes Evaluation Count:875 |
| 875-876 |
| 1319 | if (lines[i].p1() == lines[i].p2()) { evaluated: lines[i].p1() == lines[i].p2()| yes Evaluation Count:1 | yes Evaluation Count:875 |
| 1-875 |
| 1320 | if (s->lastPen.capStyle() != Qt::FlatCap) { partially evaluated: s->lastPen.capStyle() != Qt::FlatCap| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1321 | QPointF p = lines[i].p1(); | - |
| 1322 | QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()), | - |
| 1323 | QPointF(p.x() + width*0.5, p.y()))); | - |
| 1324 | d->rasterizer->rasterizeLine(line.p1(), line.p2(), 1); | - |
| 1325 | } executed: }Execution Count:1 | 1 |
| 1326 | continue; executed: continue;Execution Count:1 | 1 |
| 1327 | } | - |
| 1328 | | - |
| 1329 | const QLineF line = s->matrix.map(lines[i]); | - |
| 1330 | if (qpen_style(s->lastPen) == Qt::SolidLine) { evaluated: qpen_style(s->lastPen) == Qt::SolidLine| yes Evaluation Count:872 | yes Evaluation Count:3 |
| 3-872 |
| 1331 | d->rasterizer->rasterizeLine(line.p1(), line.p2(), | - |
| 1332 | width / line.length(), | - |
| 1333 | s->lastPen.capStyle() == Qt::SquareCap); | - |
| 1334 | } else { executed: }Execution Count:872 | 872 |
| 1335 | d->rasterizeLine_dashed(line, width, | - |
| 1336 | &dashIndex, &dashOffset, &inDash); | - |
| 1337 | } executed: }Execution Count:3 | 3 |
| 1338 | } | - |
| 1339 | } executed: }Execution Count:875 | 875 |
| 1340 | else | - |
| 1341 | QPaintEngineEx::stroke(path, pen); executed: QPaintEngineEx::stroke(path, pen);Execution Count:890 | 890 |
| 1342 | } | - |
| 1343 | | - |
| 1344 | QRect QRasterPaintEngine::toNormalizedFillRect(const QRectF &rect) | - |
| 1345 | { | - |
| 1346 | QRasterPaintEngineState *s = state(); | - |
| 1347 | | - |
| 1348 | qreal delta = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0); | - |
| 1349 | | - |
| 1350 | int x1 = qRound(rect.x() + delta); | - |
| 1351 | int y1 = qRound(rect.y() + delta); | - |
| 1352 | int x2 = qRound(rect.right() + delta); | - |
| 1353 | int y2 = qRound(rect.bottom() + delta); | - |
| 1354 | | - |
| 1355 | if (x2 < x1) | - |
| 1356 | qSwap(x1, x2); | - |
| 1357 | if (y2 < y1) | - |
| 1358 | qSwap(y1, y2); | - |
| 1359 | | - |
| 1360 | return QRect(x1, y1, x2 - x1, y2 - y1); | - |
| 1361 | } | - |
| 1362 | | - |
| 1363 | | - |
| 1364 | | - |
| 1365 | | - |
| 1366 | void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) | - |
| 1367 | { | - |
| 1368 | if (path.isEmpty()) | - |
| 1369 | return; | - |
| 1370 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1371 | QRasterPaintEngineState *s = state(); | - |
| 1372 | | - |
| 1373 | ensureBrush(brush); | - |
| 1374 | if (!s->brushData.blend) | - |
| 1375 | return; | - |
| 1376 | | - |
| 1377 | if (path.shape() == QVectorPath::RectangleHint) { | - |
| 1378 | if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxScale) { | - |
| 1379 | const qreal *p = path.points(); | - |
| 1380 | QPointF tl = QPointF(p[0], p[1]) * s->matrix; | - |
| 1381 | QPointF br = QPointF(p[4], p[5]) * s->matrix; | - |
| 1382 | fillRect_normalized(toNormalizedFillRect(QRectF(tl, br)), &s->brushData, d); | - |
| 1383 | return; | - |
| 1384 | } | - |
| 1385 | ensureRasterState(); | - |
| 1386 | if (s->flags.tx_noshear) { | - |
| 1387 | d->initializeRasterizer(&s->brushData); | - |
| 1388 | | - |
| 1389 | const qreal *p = path.points(); | - |
| 1390 | QRectF r = QRectF(p[0], p[1], p[2] - p[0], p[7] - p[1]).normalized(); | - |
| 1391 | if (!r.isEmpty()) { | - |
| 1392 | const QPointF a = s->matrix.map((r.topLeft() + r.bottomLeft()) * 0.5f); | - |
| 1393 | const QPointF b = s->matrix.map((r.topRight() + r.bottomRight()) * 0.5f); | - |
| 1394 | d->rasterizer->rasterizeLine(a, b, r.height() / r.width()); | - |
| 1395 | } | - |
| 1396 | return; | - |
| 1397 | } | - |
| 1398 | } | - |
| 1399 | | - |
| 1400 | | - |
| 1401 | QRectF cpRect = path.controlPointRect(); | - |
| 1402 | const QRect deviceRect = s->matrix.mapRect(cpRect).toRect(); | - |
| 1403 | ProcessSpans blend = d->getBrushFunc(deviceRect, &s->brushData); | - |
| 1404 | ensureOutlineMapper(); | - |
| 1405 | d->rasterize(d->outlineMapper->convertPath(path), blend, &s->brushData, d->rasterBuffer.data()); | - |
| 1406 | } | - |
| 1407 | | - |
| 1408 | void QRasterPaintEngine::fillRect(const QRectF &r, QSpanData *data) | - |
| 1409 | { | - |
| 1410 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1411 | QRasterPaintEngineState *s = state(); | - |
| 1412 | | - |
| 1413 | if (!s->flags.antialiased) { | - |
| 1414 | uint txop = s->matrix.type(); | - |
| 1415 | if (txop == QTransform::TxNone) { | - |
| 1416 | fillRect_normalized(toNormalizedFillRect(r), data, d); | - |
| 1417 | return; | - |
| 1418 | } else if (txop == QTransform::TxTranslate) { | - |
| 1419 | const QRect rr = toNormalizedFillRect(r.translated(s->matrix.dx(), s->matrix.dy())); | - |
| 1420 | fillRect_normalized(rr, data, d); | - |
| 1421 | return; | - |
| 1422 | } else if (txop == QTransform::TxScale) { | - |
| 1423 | const QRect rr = toNormalizedFillRect(s->matrix.mapRect(r)); | - |
| 1424 | fillRect_normalized(rr, data, d); | - |
| 1425 | return; | - |
| 1426 | } | - |
| 1427 | } | - |
| 1428 | ensureRasterState(); | - |
| 1429 | if (s->flags.tx_noshear) { | - |
| 1430 | d->initializeRasterizer(data); | - |
| 1431 | QRectF nr = r.normalized(); | - |
| 1432 | if (!nr.isEmpty()) { | - |
| 1433 | const QPointF a = s->matrix.map((nr.topLeft() + nr.bottomLeft()) * 0.5f); | - |
| 1434 | const QPointF b = s->matrix.map((nr.topRight() + nr.bottomRight()) * 0.5f); | - |
| 1435 | d->rasterizer->rasterizeLine(a, b, nr.height() / nr.width()); | - |
| 1436 | } | - |
| 1437 | return; | - |
| 1438 | } | - |
| 1439 | | - |
| 1440 | QPainterPath path; | - |
| 1441 | path.addRect(r); | - |
| 1442 | ensureOutlineMapper(); | - |
| 1443 | fillPath(path, data); | - |
| 1444 | } | - |
| 1445 | | - |
| 1446 | | - |
| 1447 | | - |
| 1448 | | - |
| 1449 | void QRasterPaintEngine::fillRect(const QRectF &r, const QBrush &brush) | - |
| 1450 | { | - |
| 1451 | | - |
| 1452 | | - |
| 1453 | | - |
| 1454 | QRasterPaintEngineState *s = state(); | - |
| 1455 | | - |
| 1456 | ensureBrush(brush); | - |
| 1457 | if (!s->brushData.blend) | - |
| 1458 | return; | - |
| 1459 | | - |
| 1460 | fillRect(r, &s->brushData); | - |
| 1461 | } | - |
| 1462 | | - |
| 1463 | | - |
| 1464 | | - |
| 1465 | | - |
| 1466 | void QRasterPaintEngine::fillRect(const QRectF &r, const QColor &color) | - |
| 1467 | { | - |
| 1468 | | - |
| 1469 | | - |
| 1470 | | - |
| 1471 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1472 | QRasterPaintEngineState *s = state(); | - |
| 1473 | | - |
| 1474 | d->solid_color_filler.solid.color = PREMUL(((((color.rgba() >> 24) * s->intOpacity) >> 8) << 24) | (color.rgba() & 0x00ffffff)); | - |
| 1475 | if ((d->solid_color_filler.solid.color & 0xff000000) == 0 | - |
| 1476 | && s->composition_mode == QPainter::CompositionMode_SourceOver) { | - |
| 1477 | return; | - |
| 1478 | } | - |
| 1479 | d->solid_color_filler.clip = d->clip(); | - |
| 1480 | d->solid_color_filler.adjustSpanMethods(); | - |
| 1481 | fillRect(r, &d->solid_color_filler); | - |
| 1482 | } | - |
| 1483 | | - |
| 1484 | static inline bool isAbove(const QPointF *a, const QPointF *b) | - |
| 1485 | { | - |
| 1486 | return a->y() < b->y(); | - |
| 1487 | } | - |
| 1488 | | - |
| 1489 | static bool splitPolygon(const QPointF *points, int pointCount, QVector<QPointF> *upper, QVector<QPointF> *lower) | - |
| 1490 | { | - |
| 1491 | qt_noop(); | - |
| 1492 | qt_noop(); | - |
| 1493 | | - |
| 1494 | qt_noop(); | - |
| 1495 | | - |
| 1496 | QVector<const QPointF *> sorted; | - |
| 1497 | sorted.reserve(pointCount); | - |
| 1498 | | - |
| 1499 | upper->reserve(pointCount * 3 / 4); | - |
| 1500 | lower->reserve(pointCount * 3 / 4); | - |
| 1501 | | - |
| 1502 | for (int i = 0; i < pointCount; ++i) | - |
| 1503 | sorted << points + i; | - |
| 1504 | | - |
| 1505 | qSort(sorted.begin(), sorted.end(), isAbove); | - |
| 1506 | | - |
| 1507 | qreal splitY = sorted.at(sorted.size() / 2)->y(); | - |
| 1508 | | - |
| 1509 | const QPointF *end = points + pointCount; | - |
| 1510 | const QPointF *last = end - 1; | - |
| 1511 | | - |
| 1512 | QVector<QPointF> *bin[2] = { upper, lower }; | - |
| 1513 | | - |
| 1514 | for (const QPointF *p = points; p < end; ++p) { | - |
| 1515 | int side = p->y() < splitY; | - |
| 1516 | int lastSide = last->y() < splitY; | - |
| 1517 | | - |
| 1518 | if (side != lastSide) { | - |
| 1519 | if (qFuzzyCompare(p->y(), splitY)) { | - |
| 1520 | bin[!side]->append(*p); | - |
| 1521 | } else if (qFuzzyCompare(last->y(), splitY)) { | - |
| 1522 | bin[side]->append(*last); | - |
| 1523 | } else { | - |
| 1524 | QPointF delta = *p - *last; | - |
| 1525 | QPointF intersection(p->x() + delta.x() * (splitY - p->y()) / delta.y(), splitY); | - |
| 1526 | | - |
| 1527 | bin[0]->append(intersection); | - |
| 1528 | bin[1]->append(intersection); | - |
| 1529 | } | - |
| 1530 | } | - |
| 1531 | | - |
| 1532 | bin[side]->append(*p); | - |
| 1533 | | - |
| 1534 | last = p; | - |
| 1535 | } | - |
| 1536 | | - |
| 1537 | | - |
| 1538 | return upper->size() < pointCount && lower->size() < pointCount; | - |
| 1539 | } | - |
| 1540 | | - |
| 1541 | | - |
| 1542 | | - |
| 1543 | | - |
| 1544 | void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) | - |
| 1545 | { | - |
| 1546 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1547 | QRasterPaintEngineState *s = state(); | - |
| 1548 | | - |
| 1549 | const int maxPoints = 0xffff; | - |
| 1550 | | - |
| 1551 | | - |
| 1552 | if (pointCount > maxPoints) { | - |
| 1553 | QVector<QPointF> upper, lower; | - |
| 1554 | | - |
| 1555 | if (splitPolygon(points, pointCount, &upper, &lower)) { | - |
| 1556 | fillPolygon(upper.constData(), upper.size(), mode); | - |
| 1557 | fillPolygon(lower.constData(), lower.size(), mode); | - |
| 1558 | } else | - |
| 1559 | QMessageLogger("painting/qpaintengine_raster.cpp", 19061907, __PRETTY_FUNCTION__).warning("Polygon too complex for filling."); | - |
| 1560 | | - |
| 1561 | return; | - |
| 1562 | } | - |
| 1563 | | - |
| 1564 | | - |
| 1565 | QVectorPath vp((qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); | - |
| 1566 | ensureOutlineMapper(); | - |
| 1567 | QT_FT_Outline *outline = d->outlineMapper->convertPath(vp); | - |
| 1568 | | - |
| 1569 | | - |
| 1570 | ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect, | - |
| 1571 | &s->brushData); | - |
| 1572 | d->rasterize(outline, brushBlend, &s->brushData, d->rasterBuffer.data()); | - |
| 1573 | } | - |
| 1574 | | - |
| 1575 | | - |
| 1576 | | - |
| 1577 | | - |
| 1578 | void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) | - |
| 1579 | { | - |
| 1580 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1581 | QRasterPaintEngineState *s = state(); | - |
| 1582 | | - |
| 1583 | | - |
| 1584 | | - |
| 1585 | | - |
| 1586 | | - |
| 1587 | | - |
| 1588 | qt_noop(); | - |
| 1589 | | - |
| 1590 | if (mode != PolylineMode && isRect((qreal *) points, pointCount)) { partially evaluated: mode != PolylineMode| yes Evaluation Count:447 | no Evaluation Count:0 |
evaluated: isRect((qreal *) points, pointCount)| yes Evaluation Count:20 | yes Evaluation Count:427 |
| 0-447 |
| 1591 | QRectF r(points[0], points[2]); | - |
| 1592 | drawRects(&r, 1); | - |
| 1593 | return; executed: return;Execution Count:20 | 20 |
| 1594 | } | - |
| 1595 | | - |
| 1596 | ensurePen(); | - |
| 1597 | if (mode != PolylineMode) { partially evaluated: mode != PolylineMode| yes Evaluation Count:427 | no Evaluation Count:0 |
| 0-427 |
| 1598 | | - |
| 1599 | ensureBrush(); | - |
| 1600 | if (s->brushData.blend) evaluated: s->brushData.blend| yes Evaluation Count:391 | yes Evaluation Count:36 |
| 36-391 |
| 1601 | fillPolygon(points, pointCount, mode); executed: fillPolygon(points, pointCount, mode);Execution Count:391 | 391 |
| 1602 | } executed: }Execution Count:427 | 427 |
| 1603 | | - |
| 1604 | | - |
| 1605 | if (s->penData.blend) { evaluated: s->penData.blend| yes Evaluation Count:408 | yes Evaluation Count:19 |
| 19-408 |
| 1606 | QVectorPath vp((qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); | - |
| 1607 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:396 | yes Evaluation Count:12 |
| 12-396 |
| 1608 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 1609 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 1610 | stroker.drawPath(vp); | - |
| 1611 | } else { executed: }Execution Count:396 | 396 |
| 1612 | QPaintEngineEx::stroke(vp, s->lastPen); | - |
| 1613 | } executed: }Execution Count:12 | 12 |
| 1614 | } | - |
| 1615 | } executed: }Execution Count:427 | 427 |
| 1616 | | - |
| 1617 | | - |
| 1618 | | - |
| 1619 | | - |
| 1620 | void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) | - |
| 1621 | { | - |
| 1622 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1623 | QRasterPaintEngineState *s = state(); | - |
| 1624 | | - |
| 1625 | | - |
| 1626 | | - |
| 1627 | | - |
| 1628 | | - |
| 1629 | | - |
| 1630 | qt_noop(); | - |
| 1631 | if (mode != PolylineMode && isRect((int *) points, pointCount)) { evaluated: mode != PolylineMode| yes Evaluation Count:906 | yes Evaluation Count:50052 |
evaluated: isRect((int *) points, pointCount)| yes Evaluation Count:20 | yes Evaluation Count:886 |
| 20-50052 |
| 1632 | QRect r(points[0].x(), | - |
| 1633 | points[0].y(), | - |
| 1634 | points[2].x() - points[0].x(), | - |
| 1635 | points[2].y() - points[0].y()); | - |
| 1636 | drawRects(&r, 1); | - |
| 1637 | return; executed: return;Execution Count:20 | 20 |
| 1638 | } | - |
| 1639 | | - |
| 1640 | ensurePen(); | - |
| 1641 | | - |
| 1642 | | - |
| 1643 | if (mode != PolylineMode) { evaluated: mode != PolylineMode| yes Evaluation Count:886 | yes Evaluation Count:50052 |
| 886-50052 |
| 1644 | ensureBrush(); | - |
| 1645 | if (s->brushData.blend) { evaluated: s->brushData.blend| yes Evaluation Count:850 | yes Evaluation Count:36 |
| 36-850 |
| 1646 | | - |
| 1647 | ensureOutlineMapper(); | - |
| 1648 | d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill); | - |
| 1649 | d->outlineMapper->moveTo(*points); | - |
| 1650 | const QPoint *p = points; | - |
| 1651 | const QPoint *ep = points + pointCount - 1; | - |
| 1652 | do { | - |
| 1653 | d->outlineMapper->lineTo(*(++p)); | - |
| 1654 | } while (p < ep); executed: }Execution Count:2317 evaluated: p < ep| yes Evaluation Count:1467 | yes Evaluation Count:850 |
| 850-2317 |
| 1655 | d->outlineMapper->endOutline(); | - |
| 1656 | | - |
| 1657 | | - |
| 1658 | ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect, | - |
| 1659 | &s->brushData); | - |
| 1660 | d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer.data()); | - |
| 1661 | } executed: }Execution Count:850 | 850 |
| 1662 | } executed: }Execution Count:886 | 886 |
| 1663 | | - |
| 1664 | | - |
| 1665 | if (s->penData.blend) { evaluated: s->penData.blend| yes Evaluation Count:50920 | yes Evaluation Count:18 |
| 18-50920 |
| 1666 | int count = pointCount * 2; | - |
| 1667 | QVarLengthArray<qreal> fpoints(count); | - |
| 1668 | for (int i=0; i<count; ++i) evaluated: i<count| yes Evaluation Count:309350 | yes Evaluation Count:50920 |
| 50920-309350 |
| 1669 | fpoints[i] = ((int *) points)[i]; executed: fpoints[i] = ((int *) points)[i];Execution Count:309350 | 309350 |
| 1670 | QVectorPath vp((qreal *) fpoints.data(), pointCount, 0, QVectorPath::polygonFlags(mode)); | - |
| 1671 | | - |
| 1672 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:50908 | yes Evaluation Count:12 |
| 12-50908 |
| 1673 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 1674 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 1675 | stroker.drawPath(vp); | - |
| 1676 | } else { executed: }Execution Count:50908 | 50908 |
| 1677 | QPaintEngineEx::stroke(vp, s->lastPen); | - |
| 1678 | } executed: }Execution Count:12 | 12 |
| 1679 | } | - |
| 1680 | } executed: }Execution Count:50938 | 50938 |
| 1681 | | - |
| 1682 | | - |
| 1683 | | - |
| 1684 | | - |
| 1685 | void QRasterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pixmap) | - |
| 1686 | { | - |
| 1687 | | - |
| 1688 | | - |
| 1689 | | - |
| 1690 | | - |
| 1691 | QPlatformPixmap *pd = pixmap.handle(); | - |
| 1692 | if (pd->classId() == QPlatformPixmap::RasterClass) { | - |
| 1693 | const QImage &image = static_cast<QRasterPlatformPixmap *>(pd)->image; | - |
| 1694 | if (image.depth() == 1) { | - |
| 1695 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1696 | QRasterPaintEngineState *s = state(); | - |
| 1697 | if (s->matrix.type() <= QTransform::TxTranslate) { | - |
| 1698 | ensurePen(); | - |
| 1699 | drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - |
| 1700 | } else { | - |
| 1701 | drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color())); | - |
| 1702 | } | - |
| 1703 | } else { | - |
| 1704 | QRasterPaintEngine::drawImage(pos, image); | - |
| 1705 | } | - |
| 1706 | } else { | - |
| 1707 | const QImage image = pixmap.toImage(); | - |
| 1708 | if (pixmap.depth() == 1) { | - |
| 1709 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1710 | QRasterPaintEngineState *s = state(); | - |
| 1711 | if (s->matrix.type() <= QTransform::TxTranslate) { | - |
| 1712 | ensurePen(); | - |
| 1713 | drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - |
| 1714 | } else { | - |
| 1715 | drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color())); | - |
| 1716 | } | - |
| 1717 | } else { | - |
| 1718 | QRasterPaintEngine::drawImage(pos, image); | - |
| 1719 | } | - |
| 1720 | } | - |
| 1721 | } | - |
| 1722 | | - |
| 1723 | | - |
| 1724 | | - |
| 1725 | | - |
| 1726 | void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr) | - |
| 1727 | { | - |
| 1728 | | - |
| 1729 | | - |
| 1730 | | - |
| 1731 | | - |
| 1732 | QPlatformPixmap* pd = pixmap.handle(); | - |
| 1733 | if (pd->classId() == QPlatformPixmap::RasterClass) { | - |
| 1734 | const QImage &image = static_cast<QRasterPlatformPixmap *>(pd)->image; | - |
| 1735 | if (image.depth() == 1) { | - |
| 1736 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1737 | QRasterPaintEngineState *s = state(); | - |
| 1738 | if (s->matrix.type() <= QTransform::TxTranslate | - |
| 1739 | && r.size() == sr.size() | - |
| 1740 | && r.size() == pixmap.size()) { | - |
| 1741 | ensurePen(); | - |
| 1742 | drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - |
| 1743 | return; | - |
| 1744 | } else { | - |
| 1745 | drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr); | - |
| 1746 | } | - |
| 1747 | } else { | - |
| 1748 | drawImage(r, image, sr); | - |
| 1749 | } | - |
| 1750 | } else { | - |
| 1751 | QRect clippedSource = sr.toAlignedRect().intersected(pixmap.rect()); | - |
| 1752 | const QImage image = pd->toImage(clippedSource); | - |
| 1753 | QRectF translatedSource = sr.translated(-clippedSource.topLeft()); | - |
| 1754 | if (image.depth() == 1) { | - |
| 1755 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1756 | QRasterPaintEngineState *s = state(); | - |
| 1757 | if (s->matrix.type() <= QTransform::TxTranslate | - |
| 1758 | && r.size() == sr.size() | - |
| 1759 | && r.size() == pixmap.size()) { | - |
| 1760 | ensurePen(); | - |
| 1761 | drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); | - |
| 1762 | return; | - |
| 1763 | } else { | - |
| 1764 | drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), translatedSource); | - |
| 1765 | } | - |
| 1766 | } else { | - |
| 1767 | drawImage(r, image, translatedSource); | - |
| 1768 | } | - |
| 1769 | } | - |
| 1770 | } | - |
| 1771 | | - |
| 1772 | static inline int fast_ceil_positive(const qreal &v) | - |
| 1773 | { | - |
| 1774 | const int iv = int(v); | - |
| 1775 | if (v - iv == 0) | - |
| 1776 | return iv; | - |
| 1777 | else | - |
| 1778 | return iv + 1; | - |
| 1779 | } | - |
| 1780 | | - |
| 1781 | static inline const QRect toAlignedRect_positive(const QRectF &rect) | - |
| 1782 | { | - |
| 1783 | const int xmin = int(rect.x()); | - |
| 1784 | const int xmax = int(fast_ceil_positive(rect.right())); | - |
| 1785 | const int ymin = int(rect.y()); | - |
| 1786 | const int ymax = int(fast_ceil_positive(rect.bottom())); | - |
| 1787 | return QRect(xmin, ymin, xmax - xmin, ymax - ymin); | - |
| 1788 | } | - |
| 1789 | | - |
| 1790 | | - |
| 1791 | | - |
| 1792 | | - |
| 1793 | void QRasterPaintEngine::drawImage(const QPointF &p, const QImage &img) | - |
| 1794 | { | - |
| 1795 | | - |
| 1796 | | - |
| 1797 | | - |
| 1798 | | - |
| 1799 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1800 | QRasterPaintEngineState *s = state(); | - |
| 1801 | qreal scale = img.devicePixelRatio(); | - |
| 1802 | | - |
| 1803 | if (scale > 1.0 || s->matrix.type() > QTransform::TxTranslate) { | - |
| 1804 | drawImage(QRectF(p.x(), p.y(), img.width() / scale, img.height() / scale), | - |
| 1805 | img, | - |
| 1806 | QRectF(0, 0, img.width(), img.height())); | - |
| 1807 | } else { | - |
| 1808 | | - |
| 1809 | const QClipData *clip = d->clip(); | - |
| 1810 | QPointF pt(p.x() + s->matrix.dx(), p.y() + s->matrix.dy()); | - |
| 1811 | | - |
| 1812 | if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { | - |
| 1813 | SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; | - |
| 1814 | if (func) { | - |
| 1815 | if (!clip) { | - |
| 1816 | d->drawImage(pt, img, func, d->deviceRect, s->intOpacity); | - |
| 1817 | return; | - |
| 1818 | } else if (clip->hasRectClip) { | - |
| 1819 | d->drawImage(pt, img, func, clip->clipRect, s->intOpacity); | - |
| 1820 | return; | - |
| 1821 | } | - |
| 1822 | } | - |
| 1823 | } | - |
| 1824 | | - |
| 1825 | | - |
| 1826 | | - |
| 1827 | d->image_filler.clip = clip; | - |
| 1828 | d->image_filler.initTexture(&img, s->intOpacity, QTextureData::Plain, img.rect()); | - |
| 1829 | if (!d->image_filler.blend) | - |
| 1830 | return; | - |
| 1831 | d->image_filler.dx = -pt.x(); | - |
| 1832 | d->image_filler.dy = -pt.y(); | - |
| 1833 | QRect rr = img.rect().translated(qRound(pt.x()), qRound(pt.y())); | - |
| 1834 | | - |
| 1835 | fillRect_normalized(rr, &d->image_filler, d); | - |
| 1836 | } | - |
| 1837 | | - |
| 1838 | } | - |
| 1839 | | - |
| 1840 | QRectF qt_mapRect_non_normalizing(const QRectF &r, const QTransform &t) | - |
| 1841 | { | - |
| 1842 | return QRectF(r.topLeft() * t, r.bottomRight() * t); | - |
| 1843 | } | - |
| 1844 | | - |
| 1845 | namespace { | - |
| 1846 | enum RotationType { | - |
| 1847 | Rotation90, | - |
| 1848 | Rotation180, | - |
| 1849 | Rotation270, | - |
| 1850 | NoRotation | - |
| 1851 | }; | - |
| 1852 | | - |
| 1853 | inline RotationType qRotationType(const QTransform &transform) | - |
| 1854 | { | - |
| 1855 | QTransform::TransformationType type = transform.type(); | - |
| 1856 | | - |
| 1857 | if (type > QTransform::TxRotate) | - |
| 1858 | return NoRotation; | - |
| 1859 | | - |
| 1860 | if (type == QTransform::TxRotate && qFuzzyIsNull(transform.m11()) && qFuzzyCompare(transform.m12(), qreal(-1)) | - |
| 1861 | && qFuzzyCompare(transform.m21(), qreal(1)) && qFuzzyIsNull(transform.m22())) | - |
| 1862 | return Rotation90; | - |
| 1863 | | - |
| 1864 | if (type == QTransform::TxScale && qFuzzyCompare(transform.m11(), qreal(-1)) && qFuzzyIsNull(transform.m12()) | - |
| 1865 | && qFuzzyIsNull(transform.m21()) && qFuzzyCompare(transform.m22(), qreal(-1))) | - |
| 1866 | return Rotation180; | - |
| 1867 | | - |
| 1868 | if (type == QTransform::TxRotate && qFuzzyIsNull(transform.m11()) && qFuzzyCompare(transform.m12(), qreal(1)) | - |
| 1869 | && qFuzzyCompare(transform.m21(), qreal(-1)) && qFuzzyIsNull(transform.m22())) | - |
| 1870 | return Rotation270; | - |
| 1871 | | - |
| 1872 | return NoRotation; | - |
| 1873 | } | - |
| 1874 | | - |
| 1875 | inline bool isPixelAligned(const QRectF &rect) { | - |
| 1876 | return QRectF(rect.toRect()) == rect; | - |
| 1877 | } | - |
| 1878 | } | - |
| 1879 | | - |
| 1880 | | - |
| 1881 | | - |
| 1882 | | - |
| 1883 | void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRectF &sr, | - |
| 1884 | Qt::ImageConversionFlags) | - |
| 1885 | { | - |
| 1886 | | - |
| 1887 | | - |
| 1888 | | - |
| 1889 | | - |
| 1890 | if (r.isEmpty()) | - |
| 1891 | return; | - |
| 1892 | | - |
| 1893 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 1894 | QRasterPaintEngineState *s = state(); | - |
| 1895 | int sr_l = qFloor(sr.left()); | - |
| 1896 | int sr_r = qCeil(sr.right()) - 1; | - |
| 1897 | int sr_t = qFloor(sr.top()); | - |
| 1898 | int sr_b = qCeil(sr.bottom()) - 1; | - |
| 1899 | | - |
| 1900 | if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) { | - |
| 1901 | | - |
| 1902 | | - |
| 1903 | QTransform old = s->matrix; | - |
| 1904 | | - |
| 1905 | if (s->flags.legacy_rounding) | - |
| 1906 | s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); | - |
| 1907 | | - |
| 1908 | | - |
| 1909 | QRgb color = img.pixel(sr_l, sr_t); | - |
| 1910 | switch (img.format()) { | - |
| 1911 | case QImage::Format_ARGB32_Premultiplied: | - |
| 1912 | case QImage::Format_ARGB8565_Premultiplied: | - |
| 1913 | case QImage::Format_ARGB6666_Premultiplied: | - |
| 1914 | case QImage::Format_ARGB8555_Premultiplied: | - |
| 1915 | case QImage::Format_ARGB4444_Premultiplied: | - |
| 1916 | | - |
| 1917 | d->solid_color_filler.solid.color = | - |
| 1918 | ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff) | - |
| 1919 | | ((((color & 0xff00ff00) >> 8) * s->intOpacity) & 0xff00ff00); | - |
| 1920 | break; | - |
| 1921 | default: | - |
| 1922 | d->solid_color_filler.solid.color = PREMUL(((((color >> 24) * s->intOpacity) >> 8) << 24) | (color & 0x00ffffff)); | - |
| 1923 | break; | - |
| 1924 | } | - |
| 1925 | | - |
| 1926 | if ((d->solid_color_filler.solid.color & 0xff000000) == 0 | - |
| 1927 | && s->composition_mode == QPainter::CompositionMode_SourceOver) { | - |
| 1928 | return; | - |
| 1929 | } | - |
| 1930 | | - |
| 1931 | d->solid_color_filler.clip = d->clip(); | - |
| 1932 | d->solid_color_filler.adjustSpanMethods(); | - |
| 1933 | fillRect(r, &d->solid_color_filler); | - |
| 1934 | | - |
| 1935 | s->matrix = old; | - |
| 1936 | return; | - |
| 1937 | } | - |
| 1938 | | - |
| 1939 | bool stretch_sr = r.width() != sr.width() || r.height() != sr.height(); | - |
| 1940 | | - |
| 1941 | const QClipData *clip = d->clip(); | - |
| 1942 | | - |
| 1943 | if (s->matrix.type() > QTransform::TxTranslate | - |
| 1944 | && !stretch_sr | - |
| 1945 | && (!clip || clip->hasRectClip) | - |
| 1946 | && s->intOpacity == 256 | - |
| 1947 | && (d->rasterBuffer->compositionMode == QPainter::CompositionMode_SourceOver | - |
| 1948 | || d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source) | - |
| 1949 | && d->rasterBuffer->format == img.format() | - |
| 1950 | && (d->rasterBuffer->format == QImage::Format_RGB16 | - |
| 1951 | || d->rasterBuffer->format == QImage::Format_RGB32 | - |
| 1952 | || (d->rasterBuffer->format == QImage::Format_ARGB32_Premultiplied | - |
| 1953 | && d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source))) | - |
| 1954 | { | - |
| 1955 | RotationType rotationType = qRotationType(s->matrix); | - |
| 1956 | | - |
| 1957 | if (rotationType != NoRotation && qMemRotateFunctions[d->rasterBuffer->format][rotationType] && img.rect().contains(sr.toAlignedRect())) { | - |
| 1958 | QRectF transformedTargetRect = s->matrix.mapRect(r); | - |
| 1959 | | - |
| 1960 | if ((!(s->renderHints & QPainter::SmoothPixmapTransform) && !(s->renderHints & QPainter::Antialiasing)) | - |
| 1961 | || (isPixelAligned(transformedTargetRect) && isPixelAligned(sr))) | - |
| 1962 | { | - |
| 1963 | QRect clippedTransformedTargetRect = transformedTargetRect.toRect().intersected(clip ? clip->clipRect : d->deviceRect); | - |
| 1964 | if (clippedTransformedTargetRect.isNull()) | - |
| 1965 | return; | - |
| 1966 | | - |
| 1967 | QRectF clippedTargetRect = s->matrix.inverted().mapRect(QRectF(clippedTransformedTargetRect)); | - |
| 1968 | | - |
| 1969 | QRect clippedSourceRect | - |
| 1970 | = QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(), | - |
| 1971 | clippedTargetRect.width(), clippedTargetRect.height()).toRect(); | - |
| 1972 | | - |
| 1973 | uint dbpl = d->rasterBuffer->bytesPerLine(); | - |
| 1974 | uint sbpl = img.bytesPerLine(); | - |
| 1975 | | - |
| 1976 | uchar *dst = d->rasterBuffer->buffer(); | - |
| 1977 | uint bpp = img.depth() >> 3; | - |
| 1978 | | - |
| 1979 | const uchar *srcBase = img.bits() + clippedSourceRect.y() * sbpl + clippedSourceRect.x() * bpp; | - |
| 1980 | uchar *dstBase = dst + clippedTransformedTargetRect.y() * dbpl + clippedTransformedTargetRect.x() * bpp; | - |
| 1981 | | - |
| 1982 | uint cw = clippedSourceRect.width(); | - |
| 1983 | uint ch = clippedSourceRect.height(); | - |
| 1984 | | - |
| 1985 | qMemRotateFunctions[d->rasterBuffer->format][rotationType](srcBase, cw, ch, sbpl, dstBase, dbpl); | - |
| 1986 | | - |
| 1987 | return; | - |
| 1988 | } | - |
| 1989 | } | - |
| 1990 | } | - |
| 1991 | | - |
| 1992 | if (s->matrix.type() > QTransform::TxTranslate || stretch_sr) { | - |
| 1993 | | - |
| 1994 | QRectF targetBounds = s->matrix.mapRect(r); | - |
| 1995 | bool exceedsPrecision = targetBounds.width() > 0xffff | - |
| 1996 | || targetBounds.height() > 0xffff; | - |
| 1997 | | - |
| 1998 | if (!exceedsPrecision && d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { | - |
| 1999 | if (s->matrix.type() > QTransform::TxScale) { | - |
| 2000 | SrcOverTransformFunc func = qTransformFunctions[d->rasterBuffer->format][img.format()]; | - |
| 2001 | if (func && (!clip || clip->hasRectClip)) { | - |
| 2002 | func(d->rasterBuffer->buffer(), d->rasterBuffer->bytesPerLine(), img.bits(), | - |
| 2003 | img.bytesPerLine(), r, sr, !clip ? d->deviceRect : clip->clipRect, | - |
| 2004 | s->matrix, s->intOpacity); | - |
| 2005 | return; | - |
| 2006 | } | - |
| 2007 | } else { | - |
| 2008 | | - |
| 2009 | bool sourceRect2x = r.width() * 2 == sr.width() && r.height() * 2 == sr.height(); | - |
| 2010 | bool scale2x = (s->matrix.m11() == qreal(2)) && (s->matrix.m22() == qreal(2)); | - |
| 2011 | if (s->matrix.type() == QTransform::TxScale && sourceRect2x && scale2x) { | - |
| 2012 | SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; | - |
| 2013 | if (func) { | - |
| 2014 | QPointF pt(r.x() * 2 + s->matrix.dx(), r.y() * 2 + s->matrix.dy()); | - |
| 2015 | if (!clip) { | - |
| 2016 | d->drawImage(pt, img, func, d->deviceRect, s->intOpacity, sr.toRect()); | - |
| 2017 | return; | - |
| 2018 | } else if (clip->hasRectClip) { | - |
| 2019 | d->drawImage(pt, img, func, clip->clipRect, s->intOpacity, sr.toRect()); | - |
| 2020 | return; | - |
| 2021 | } | - |
| 2022 | } | - |
| 2023 | } | - |
| 2024 | SrcOverScaleFunc func = qScaleFunctions[d->rasterBuffer->format][img.format()]; | - |
| 2025 | if (func && (!clip || clip->hasRectClip)) { | - |
| 2026 | func(d->rasterBuffer->buffer(), d->rasterBuffer->bytesPerLine(), | - |
| 2027 | img.bits(), img.bytesPerLine(), | - |
| 2028 | qt_mapRect_non_normalizing(r, s->matrix), sr, | - |
| 2029 | !clip ? d->deviceRect : clip->clipRect, | - |
| 2030 | s->intOpacity); | - |
| 2031 | return; | - |
| 2032 | } | - |
| 2033 | } | - |
| 2034 | } | - |
| 2035 | | - |
| 2036 | QTransform copy = s->matrix; | - |
| 2037 | copy.translate(r.x(), r.y()); | - |
| 2038 | if (stretch_sr) | - |
| 2039 | copy.scale(r.width() / sr.width(), r.height() / sr.height()); | - |
| 2040 | copy.translate(-sr.x(), -sr.y()); | - |
| 2041 | | - |
| 2042 | d->image_filler_xform.clip = clip; | - |
| 2043 | d->image_filler_xform.initTexture(&img, s->intOpacity, QTextureData::Plain, toAlignedRect_positive(sr)); | - |
| 2044 | if (!d->image_filler_xform.blend) | - |
| 2045 | return; | - |
| 2046 | d->image_filler_xform.setupMatrix(copy, s->flags.bilinear); | - |
| 2047 | | - |
| 2048 | if (!s->flags.antialiased && s->matrix.type() == QTransform::TxScale) { | - |
| 2049 | QRectF rr = s->matrix.mapRect(r); | - |
| 2050 | | - |
| 2051 | const int x1 = qRound(rr.x()); | - |
| 2052 | const int y1 = qRound(rr.y()); | - |
| 2053 | const int x2 = qRound(rr.right()); | - |
| 2054 | const int y2 = qRound(rr.bottom()); | - |
| 2055 | | - |
| 2056 | fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler_xform, d); | - |
| 2057 | return; | - |
| 2058 | } | - |
| 2059 | | - |
| 2060 | | - |
| 2061 | ensureRasterState(); | - |
| 2062 | if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { | - |
| 2063 | d->initializeRasterizer(&d->image_filler_xform); | - |
| 2064 | d->rasterizer->setAntialiased(s->flags.antialiased); | - |
| 2065 | d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 2066 | | - |
| 2067 | const QPointF offs = s->flags.legacy_rounding ? QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta) : QPointF(); | - |
| 2068 | | - |
| 2069 | const QRectF &rect = r.normalized(); | - |
| 2070 | const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs; | - |
| 2071 | const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f) - offs; | - |
| 2072 | | - |
| 2073 | if (s->flags.tx_noshear) | - |
| 2074 | d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); | - |
| 2075 | else | - |
| 2076 | d->rasterizer->rasterizeLine(a, b, qAbs((s->matrix.m22() * rect.height()) / (s->matrix.m11() * rect.width()))); | - |
| 2077 | return; | - |
| 2078 | } | - |
| 2079 | | - |
| 2080 | const qreal offs = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0); | - |
| 2081 | QPainterPath path; | - |
| 2082 | path.addRect(r); | - |
| 2083 | QTransform m = s->matrix; | - |
| 2084 | s->matrix = QTransform(m.m11(), m.m12(), m.m13(), | - |
| 2085 | m.m21(), m.m22(), m.m23(), | - |
| 2086 | m.m31() - offs, m.m32() - offs, m.m33()); | - |
| 2087 | fillPath(path, &d->image_filler_xform); | - |
| 2088 | s->matrix = m; | - |
| 2089 | } else { | - |
| 2090 | if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { | - |
| 2091 | SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; | - |
| 2092 | if (func) { | - |
| 2093 | QPointF pt(r.x() + s->matrix.dx(), r.y() + s->matrix.dy()); | - |
| 2094 | if (!clip) { | - |
| 2095 | d->drawImage(pt, img, func, d->deviceRect, s->intOpacity, sr.toRect()); | - |
| 2096 | return; | - |
| 2097 | } else if (clip->hasRectClip) { | - |
| 2098 | d->drawImage(pt, img, func, clip->clipRect, s->intOpacity, sr.toRect()); | - |
| 2099 | return; | - |
| 2100 | } | - |
| 2101 | } | - |
| 2102 | } | - |
| 2103 | | - |
| 2104 | d->image_filler.clip = clip; | - |
| 2105 | d->image_filler.initTexture(&img, s->intOpacity, QTextureData::Plain, toAlignedRect_positive(sr)); | - |
| 2106 | if (!d->image_filler.blend) | - |
| 2107 | return; | - |
| 2108 | d->image_filler.dx = -(r.x() + s->matrix.dx()) + sr.x(); | - |
| 2109 | d->image_filler.dy = -(r.y() + s->matrix.dy()) + sr.y(); | - |
| 2110 | | - |
| 2111 | QRectF rr = r; | - |
| 2112 | rr.translate(s->matrix.dx(), s->matrix.dy()); | - |
| 2113 | | - |
| 2114 | const int x1 = qRound(rr.x()); | - |
| 2115 | const int y1 = qRound(rr.y()); | - |
| 2116 | const int x2 = qRound(rr.right()); | - |
| 2117 | const int y2 = qRound(rr.bottom()); | - |
| 2118 | | - |
| 2119 | fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler, d); | - |
| 2120 | } | - |
| 2121 | } | - |
| 2122 | | - |
| 2123 | | - |
| 2124 | | - |
| 2125 | | - |
| 2126 | void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &sr) | - |
| 2127 | { | - |
| 2128 | | - |
| 2129 | | - |
| 2130 | | - |
| 2131 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2132 | QRasterPaintEngineState *s = state(); | - |
| 2133 | | - |
| 2134 | QImage image; | - |
| 2135 | | - |
| 2136 | QPlatformPixmap *pd = pixmap.handle(); | - |
| 2137 | if (pd->classId() == QPlatformPixmap::RasterClass) { | - |
| 2138 | image = static_cast<QRasterPlatformPixmap *>(pd)->image; | - |
| 2139 | } else { | - |
| 2140 | image = pixmap.toImage(); | - |
| 2141 | } | - |
| 2142 | | - |
| 2143 | if (image.depth() == 1) | - |
| 2144 | image = d->rasterBuffer->colorizeBitmap(image, s->pen.color()); | - |
| 2145 | | - |
| 2146 | if (s->matrix.type() > QTransform::TxTranslate) { | - |
| 2147 | QTransform copy = s->matrix; | - |
| 2148 | copy.translate(r.x(), r.y()); | - |
| 2149 | copy.translate(-sr.x(), -sr.y()); | - |
| 2150 | d->image_filler_xform.clip = d->clip(); | - |
| 2151 | d->image_filler_xform.initTexture(&image, s->intOpacity, QTextureData::Tiled); | - |
| 2152 | if (!d->image_filler_xform.blend) | - |
| 2153 | return; | - |
| 2154 | d->image_filler_xform.setupMatrix(copy, s->flags.bilinear); | - |
| 2155 | | - |
| 2156 | | - |
| 2157 | ensureRasterState(); | - |
| 2158 | if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { | - |
| 2159 | d->initializeRasterizer(&d->image_filler_xform); | - |
| 2160 | d->rasterizer->setAntialiased(s->flags.antialiased); | - |
| 2161 | d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 2162 | | - |
| 2163 | const QRectF &rect = r.normalized(); | - |
| 2164 | const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); | - |
| 2165 | const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f); | - |
| 2166 | if (s->flags.tx_noshear) | - |
| 2167 | d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); | - |
| 2168 | else | - |
| 2169 | d->rasterizer->rasterizeLine(a, b, qAbs((s->matrix.m22() * rect.height()) / (s->matrix.m11() * rect.width()))); | - |
| 2170 | return; | - |
| 2171 | } | - |
| 2172 | | - |
| 2173 | QPainterPath path; | - |
| 2174 | path.addRect(r); | - |
| 2175 | fillPath(path, &d->image_filler_xform); | - |
| 2176 | } else { | - |
| 2177 | d->image_filler.clip = d->clip(); | - |
| 2178 | | - |
| 2179 | d->image_filler.initTexture(&image, s->intOpacity, QTextureData::Tiled); | - |
| 2180 | if (!d->image_filler.blend) | - |
| 2181 | return; | - |
| 2182 | d->image_filler.dx = -(r.x() + s->matrix.dx()) + sr.x(); | - |
| 2183 | d->image_filler.dy = -(r.y() + s->matrix.dy()) + sr.y(); | - |
| 2184 | | - |
| 2185 | QRectF rr = r; | - |
| 2186 | rr.translate(s->matrix.dx(), s->matrix.dy()); | - |
| 2187 | fillRect_normalized(rr.toRect().normalized(), &d->image_filler, d); | - |
| 2188 | } | - |
| 2189 | } | - |
| 2190 | | - |
| 2191 | | - |
| 2192 | | - |
| 2193 | static inline bool monoVal(const uchar* s, int x) | - |
| 2194 | { | - |
| 2195 | return (s[x>>3] << (x&7)) & 0x80; | - |
| 2196 | } | - |
| 2197 | | - |
| 2198 | | - |
| 2199 | | - |
| 2200 | | - |
| 2201 | QRasterBuffer *QRasterPaintEngine::rasterBuffer() | - |
| 2202 | { | - |
| 2203 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2204 | return d->rasterBuffer.data(); | - |
| 2205 | } | - |
| 2206 | | - |
| 2207 | | - |
| 2208 | | - |
| 2209 | | - |
| 2210 | void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx,int ry,int w,int h) | - |
| 2211 | { | - |
| 2212 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2213 | QRasterPaintEngineState *s = state(); | - |
| 2214 | | - |
| 2215 | if (!s->penData.blend) | - |
| 2216 | return; | - |
| 2217 | | - |
| 2218 | QRasterBuffer *rb = d->rasterBuffer.data(); | - |
| 2219 | | - |
| 2220 | const QRect rect(rx, ry, w, h); | - |
| 2221 | const QClipData *clip = d->clip(); | - |
| 2222 | bool unclipped = false; | - |
| 2223 | if (clip) { | - |
| 2224 | | - |
| 2225 | const bool intersects = qMax(clip->xmin, rect.left()) <= qMin(clip->xmax - 1, rect.right()) | - |
| 2226 | && qMax(clip->ymin, rect.top()) <= qMin(clip->ymax - 1, rect.bottom()); | - |
| 2227 | | - |
| 2228 | if (clip->hasRectClip) { | - |
| 2229 | unclipped = rx > clip->xmin | - |
| 2230 | && rx + w < clip->xmax | - |
| 2231 | && ry > clip->ymin | - |
| 2232 | && ry + h < clip->ymax; | - |
| 2233 | } | - |
| 2234 | | - |
| 2235 | if (!intersects) | - |
| 2236 | return; | - |
| 2237 | } else { | - |
| 2238 | | - |
| 2239 | const bool intersects = qMax(0, rect.left()) <= qMin(rb->width() - 1, rect.right()) | - |
| 2240 | && qMax(0, rect.top()) <= qMin(rb->height() - 1, rect.bottom()); | - |
| 2241 | if (!intersects) | - |
| 2242 | return; | - |
| 2243 | | - |
| 2244 | | - |
| 2245 | const bool contains = rect.left() >= 0 && rect.right() < rb->width() | - |
| 2246 | && rect.top() >= 0 && rect.bottom() < rb->height(); | - |
| 2247 | | - |
| 2248 | unclipped = contains && d->isUnclipped_normalized(rect); | - |
| 2249 | } | - |
| 2250 | | - |
| 2251 | ProcessSpans blend = unclipped ? s->penData.unclipped_blend : s->penData.blend; | - |
| 2252 | const uchar * scanline = static_cast<const uchar *>(src); | - |
| 2253 | | - |
| 2254 | if (s->flags.fast_text) { | - |
| 2255 | if (unclipped) { | - |
| 2256 | if (depth == 1) { | - |
| 2257 | if (s->penData.bitmapBlit) { | - |
| 2258 | s->penData.bitmapBlit(rb, rx, ry, s->penData.solid.color, | - |
| 2259 | scanline, w, h, bpl); | - |
| 2260 | return; | - |
| 2261 | } | - |
| 2262 | } else if (depth == 8) { | - |
| 2263 | if (s->penData.alphamapBlit) { | - |
| 2264 | s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, | - |
| 2265 | scanline, w, h, bpl, 0); | - |
| 2266 | return; | - |
| 2267 | } | - |
| 2268 | } else if (depth == 32) { | - |
| 2269 | | - |
| 2270 | if (s->penData.alphaRGBBlit) { | - |
| 2271 | s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, | - |
| 2272 | (const uint *) scanline, w, h, bpl / 4, 0); | - |
| 2273 | return; | - |
| 2274 | } | - |
| 2275 | } | - |
| 2276 | } else if (d->deviceDepth == 32 && (depth == 8 || depth == 32)) { | - |
| 2277 | | - |
| 2278 | if (!clip) { | - |
| 2279 | int nx = qMax(0, rx); | - |
| 2280 | int ny = qMax(0, ry); | - |
| 2281 | | - |
| 2282 | | - |
| 2283 | int xdiff = nx - rx; | - |
| 2284 | int ydiff = ny - ry; | - |
| 2285 | scanline += ydiff * bpl; | - |
| 2286 | scanline += xdiff * (depth == 32 ? 4 : 1); | - |
| 2287 | | - |
| 2288 | w -= xdiff; | - |
| 2289 | h -= ydiff; | - |
| 2290 | | - |
| 2291 | if (nx + w > d->rasterBuffer->width()) | - |
| 2292 | w = d->rasterBuffer->width() - nx; | - |
| 2293 | if (ny + h > d->rasterBuffer->height()) | - |
| 2294 | h = d->rasterBuffer->height() - ny; | - |
| 2295 | | - |
| 2296 | rx = nx; | - |
| 2297 | ry = ny; | - |
| 2298 | } | - |
| 2299 | if (depth == 8 && s->penData.alphamapBlit) { | - |
| 2300 | s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, | - |
| 2301 | scanline, w, h, bpl, clip); | - |
| 2302 | } else if (depth == 32 && s->penData.alphaRGBBlit) { | - |
| 2303 | s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, | - |
| 2304 | (const uint *) scanline, w, h, bpl / 4, clip); | - |
| 2305 | } | - |
| 2306 | return; | - |
| 2307 | } | - |
| 2308 | } | - |
| 2309 | | - |
| 2310 | int x0 = 0; | - |
| 2311 | if (rx < 0) { | - |
| 2312 | x0 = -rx; | - |
| 2313 | w -= x0; | - |
| 2314 | } | - |
| 2315 | | - |
| 2316 | int y0 = 0; | - |
| 2317 | if (ry < 0) { | - |
| 2318 | y0 = -ry; | - |
| 2319 | scanline += bpl * y0; | - |
| 2320 | h -= y0; | - |
| 2321 | } | - |
| 2322 | | - |
| 2323 | w = qMin(w, rb->width() - qMax(0, rx)); | - |
| 2324 | h = qMin(h, rb->height() - qMax(0, ry)); | - |
| 2325 | | - |
| 2326 | if (w <= 0 || h <= 0) | - |
| 2327 | return; | - |
| 2328 | | - |
| 2329 | const int NSPANS = 256; | - |
| 2330 | QSpan spans[NSPANS]; | - |
| 2331 | int current = 0; | - |
| 2332 | | - |
| 2333 | const int x1 = x0 + w; | - |
| 2334 | const int y1 = y0 + h; | - |
| 2335 | | - |
| 2336 | if (depth == 1) { | - |
| 2337 | for (int y = y0; y < y1; ++y) { | - |
| 2338 | for (int x = x0; x < x1; ) { | - |
| 2339 | if (!monoVal(scanline, x)) { | - |
| 2340 | ++x; | - |
| 2341 | continue; | - |
| 2342 | } | - |
| 2343 | | - |
| 2344 | if (current == NSPANS) { | - |
| 2345 | blend(current, spans, &s->penData); | - |
| 2346 | current = 0; | - |
| 2347 | } | - |
| 2348 | spans[current].x = x + rx; | - |
| 2349 | spans[current].y = y + ry; | - |
| 2350 | spans[current].coverage = 255; | - |
| 2351 | int len = 1; | - |
| 2352 | ++x; | - |
| 2353 | | - |
| 2354 | while (x < x1 && monoVal(scanline, x)) { | - |
| 2355 | ++x; | - |
| 2356 | ++len; | - |
| 2357 | } | - |
| 2358 | spans[current].len = len; | - |
| 2359 | ++current; | - |
| 2360 | } | - |
| 2361 | scanline += bpl; | - |
| 2362 | } | - |
| 2363 | } else if (depth == 8) { | - |
| 2364 | for (int y = y0; y < y1; ++y) { | - |
| 2365 | for (int x = x0; x < x1; ) { | - |
| 2366 | | - |
| 2367 | if (scanline[x] == 0) { | - |
| 2368 | ++x; | - |
| 2369 | continue; | - |
| 2370 | } | - |
| 2371 | | - |
| 2372 | if (current == NSPANS) { | - |
| 2373 | blend(current, spans, &s->penData); | - |
| 2374 | current = 0; | - |
| 2375 | } | - |
| 2376 | int coverage = scanline[x]; | - |
| 2377 | spans[current].x = x + rx; | - |
| 2378 | spans[current].y = y + ry; | - |
| 2379 | spans[current].coverage = coverage; | - |
| 2380 | int len = 1; | - |
| 2381 | ++x; | - |
| 2382 | | - |
| 2383 | | - |
| 2384 | while (x < x1 && scanline[x] == coverage) { | - |
| 2385 | ++x; | - |
| 2386 | ++len; | - |
| 2387 | } | - |
| 2388 | spans[current].len = len; | - |
| 2389 | ++current; | - |
| 2390 | } | - |
| 2391 | scanline += bpl; | - |
| 2392 | } | - |
| 2393 | } else { | - |
| 2394 | uint *sl = (uint *) src; | - |
| 2395 | for (int y = y0; y < y1; ++y) { | - |
| 2396 | for (int x = x0; x < x1; ) { | - |
| 2397 | | - |
| 2398 | if ((sl[x] & 0x00ffffff) == 0) { | - |
| 2399 | ++x; | - |
| 2400 | continue; | - |
| 2401 | } | - |
| 2402 | | - |
| 2403 | if (current == NSPANS) { | - |
| 2404 | blend(current, spans, &s->penData); | - |
| 2405 | current = 0; | - |
| 2406 | } | - |
| 2407 | uint rgbCoverage = sl[x]; | - |
| 2408 | int coverage = qGreen(rgbCoverage); | - |
| 2409 | spans[current].x = x + rx; | - |
| 2410 | spans[current].y = y + ry; | - |
| 2411 | spans[current].coverage = coverage; | - |
| 2412 | int len = 1; | - |
| 2413 | ++x; | - |
| 2414 | | - |
| 2415 | | - |
| 2416 | while (x < x1 && sl[x] == rgbCoverage) { | - |
| 2417 | ++x; | - |
| 2418 | ++len; | - |
| 2419 | } | - |
| 2420 | spans[current].len = len; | - |
| 2421 | ++current; | - |
| 2422 | } | - |
| 2423 | sl += bpl / sizeof(uint); | - |
| 2424 | } | - |
| 2425 | } | - |
| 2426 | | - |
| 2427 | | - |
| 2428 | | - |
| 2429 | if (current != 0) | - |
| 2430 | blend(current, spans, &s->penData); | - |
| 2431 | } | - |
| 2432 | | - |
| 2433 | | - |
| 2434 | | - |
| 2435 | | - |
| 2436 | bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, | - |
| 2437 | const QFixedPoint *positions, QFontEngine *fontEngine) | - |
| 2438 | { | - |
| 2439 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2440 | QRasterPaintEngineState *s = state(); | - |
| 2441 | | - |
| 2442 | if (fontEngine->hasInternalCaching()) { | - |
| 2443 | QFontEngine::GlyphFormat neededFormat = | - |
| 2444 | painter()->device()->devType() == QInternal::Widget | - |
| 2445 | ? QFontEngine::Format_None | - |
| 2446 | : QFontEngine::Format_A8; | - |
| 2447 | | - |
| 2448 | if (d_func()->mono_surface) | - |
| 2449 | neededFormat = QFontEngine::Format_Mono; | - |
| 2450 | | - |
| 2451 | for (int i = 0; i < numGlyphs; i++) { | - |
| 2452 | QFixed spp = fontEngine->subPixelPositionForX(positions[i].x); | - |
| 2453 | | - |
| 2454 | QPoint offset; | - |
| 2455 | QImage *alphaMap = fontEngine->lockedAlphaMapForGlyph(glyphs[i], spp, neededFormat, s->matrix, | - |
| 2456 | &offset); | - |
| 2457 | if (alphaMap == 0 || alphaMap->isNull()) | - |
| 2458 | continue; | - |
| 2459 | | - |
| 2460 | alphaPenBlt(alphaMap->bits(), alphaMap->bytesPerLine(), alphaMap->depth(), | - |
| 2461 | qFloor(positions[i].x) + offset.x(), | - |
| 2462 | qRound(positions[i].y) + offset.y(), | - |
| 2463 | alphaMap->width(), alphaMap->height()); | - |
| 2464 | | - |
| 2465 | fontEngine->unlockAlphaMapForGlyph(); | - |
| 2466 | } | - |
| 2467 | | - |
| 2468 | } else { | - |
| 2469 | QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType; | - |
| 2470 | | - |
| 2471 | QImageTextureGlyphCache *cache = | - |
| 2472 | static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix)); | - |
| 2473 | if (!cache) { | - |
| 2474 | cache = new QImageTextureGlyphCache(glyphType, s->matrix); | - |
| 2475 | fontEngine->setGlyphCache(0, cache); | - |
| 2476 | } | - |
| 2477 | | - |
| 2478 | cache->populate(fontEngine, numGlyphs, glyphs, positions); | - |
| 2479 | cache->fillInPendingGlyphs(); | - |
| 2480 | | - |
| 2481 | const QImage &image = cache->image(); | - |
| 2482 | int bpl = image.bytesPerLine(); | - |
| 2483 | | - |
| 2484 | int depth = image.depth(); | - |
| 2485 | int rightShift = 0; | - |
| 2486 | int leftShift = 0; | - |
| 2487 | if (depth == 32) | - |
| 2488 | leftShift = 2; | - |
| 2489 | else if (depth == 1) | - |
| 2490 | rightShift = 3; | - |
| 2491 | | - |
| 2492 | int margin = fontEngine->glyphMargin(glyphType); | - |
| 2493 | const uchar *bits = image.bits(); | - |
| 2494 | for (int i=0; i<numGlyphs; ++i) { | - |
| 2495 | | - |
| 2496 | QFixed subPixelPosition = fontEngine->subPixelPositionForX(positions[i].x); | - |
| 2497 | QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphs[i], subPixelPosition); | - |
| 2498 | const QTextureGlyphCache::Coord &c = cache->coords[glyph]; | - |
| 2499 | if (c.isNull()) | - |
| 2500 | continue; | - |
| 2501 | | - |
| 2502 | int x = qFloor(positions[i].x) + c.baseLineX - margin; | - |
| 2503 | int y = qRound(positions[i].y) - c.baseLineY - margin; | - |
| 2504 | alphaPenBlt(bits + ((c.x << leftShift) >> rightShift) + c.y * bpl, bpl, depth, x, y, c.w, c.h); | - |
| 2505 | } | - |
| 2506 | } | - |
| 2507 | return true; | - |
| 2508 | } | - |
| 2509 | | - |
| 2510 | | - |
| 2511 | | - |
| 2512 | | - |
| 2513 | | - |
| 2514 | | - |
| 2515 | bool QRasterPaintEnginePrivate::isUnclipped_normalized(const QRect &r) const | - |
| 2516 | { | - |
| 2517 | const QClipData *cl = clip(); | - |
| 2518 | if (!cl) { | - |
| 2519 | | - |
| 2520 | const QRect &r1 = deviceRect; | - |
| 2521 | return (r.left() >= r1.left() && r.right() <= r1.right() | - |
| 2522 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); | - |
| 2523 | } | - |
| 2524 | | - |
| 2525 | | - |
| 2526 | if (cl->hasRectClip) { | - |
| 2527 | | - |
| 2528 | if (cl->clipRect == deviceRect) | - |
| 2529 | return true; | - |
| 2530 | | - |
| 2531 | | - |
| 2532 | const QRect &r1 = cl->clipRect; | - |
| 2533 | return (r.left() >= r1.left() && r.right() <= r1.right() | - |
| 2534 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); | - |
| 2535 | } else { | - |
| 2536 | return qt_region_strictContains(cl->clipRegion, r); | - |
| 2537 | } | - |
| 2538 | } | - |
| 2539 | | - |
| 2540 | bool QRasterPaintEnginePrivate::isUnclipped(const QRect &rect, | - |
| 2541 | int penWidth) const | - |
| 2542 | { | - |
| 2543 | const QRasterPaintEngine * const q = q_func(); | - |
| 2544 | const QRasterPaintEngineState *s = q->state(); | - |
| 2545 | const QClipData *cl = clip(); | - |
| 2546 | if (!cl) { | - |
| 2547 | QRect r = rect.normalized(); | - |
| 2548 | | - |
| 2549 | const QRect &r1 = deviceRect; | - |
| 2550 | return (r.left() >= r1.left() && r.right() <= r1.right() | - |
| 2551 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); | - |
| 2552 | } | - |
| 2553 | | - |
| 2554 | | - |
| 2555 | | - |
| 2556 | if (cl->hasRectClip && cl->clipRect == deviceRect) | - |
| 2557 | return true; | - |
| 2558 | | - |
| 2559 | if (s->flags.antialiased) | - |
| 2560 | ++penWidth; | - |
| 2561 | | - |
| 2562 | QRect r = rect.normalized(); | - |
| 2563 | if (penWidth > 0) { | - |
| 2564 | r.setX(r.x() - penWidth); | - |
| 2565 | r.setY(r.y() - penWidth); | - |
| 2566 | r.setWidth(r.width() + 2 * penWidth); | - |
| 2567 | r.setHeight(r.height() + 2 * penWidth); | - |
| 2568 | } | - |
| 2569 | | - |
| 2570 | if (cl->hasRectClip) { | - |
| 2571 | | - |
| 2572 | const QRect &r1 = cl->clipRect; | - |
| 2573 | return (r.left() >= r1.left() && r.right() <= r1.right() | - |
| 2574 | && r.top() >= r1.top() && r.bottom() <= r1.bottom()); | - |
| 2575 | } else { | - |
| 2576 | return qt_region_strictContains(cl->clipRegion, r); | - |
| 2577 | } | - |
| 2578 | } | - |
| 2579 | | - |
| 2580 | inline bool QRasterPaintEnginePrivate::isUnclipped(const QRectF &rect, | - |
| 2581 | int penWidth) const | - |
| 2582 | { | - |
| 2583 | return isUnclipped(rect.normalized().toAlignedRect(), penWidth); | - |
| 2584 | } | - |
| 2585 | | - |
| 2586 | inline ProcessSpans | - |
| 2587 | QRasterPaintEnginePrivate::getBrushFunc(const QRect &rect, | - |
| 2588 | const QSpanData *data) const | - |
| 2589 | { | - |
| 2590 | return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend; | - |
| 2591 | } | - |
| 2592 | | - |
| 2593 | inline ProcessSpans | - |
| 2594 | QRasterPaintEnginePrivate::getBrushFunc(const QRectF &rect, | - |
| 2595 | const QSpanData *data) const | - |
| 2596 | { | - |
| 2597 | return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend; | - |
| 2598 | } | - |
| 2599 | | - |
| 2600 | inline ProcessSpans | - |
| 2601 | QRasterPaintEnginePrivate::getPenFunc(const QRectF &rect, | - |
| 2602 | const QSpanData *data) const | - |
| 2603 | { | - |
| 2604 | const QRasterPaintEngine * const q = q_func(); | - |
| 2605 | const QRasterPaintEngineState *s = q->state(); | - |
| 2606 | | - |
| 2607 | if (!s->flags.fast_pen && s->matrix.type() > QTransform::TxTranslate) | - |
| 2608 | return data->blend; | - |
| 2609 | const int penWidth = s->flags.fast_pen ? 1 : qCeil(s->lastPen.widthF()); | - |
| 2610 | return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend; | - |
| 2611 | } | - |
| 2612 | | - |
| 2613 | static QPair<int, int> visibleGlyphRange(const QRectF &clip, QFontEngine *fontEngine, | - |
| 2614 | glyph_t *glyphs, QFixedPoint *positions, int numGlyphs) | - |
| 2615 | { | - |
| 2616 | QFixed clipLeft = QFixed::fromReal(clip.left()); | - |
| 2617 | QFixed clipRight = QFixed::fromReal(clip.right()); | - |
| 2618 | QFixed clipTop = QFixed::fromReal(clip.top()); | - |
| 2619 | QFixed clipBottom = QFixed::fromReal(clip.bottom()); | - |
| 2620 | | - |
| 2621 | int first = 0; | - |
| 2622 | while (first < numGlyphs) { | - |
| 2623 | glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[first]); | - |
| 2624 | QFixed left = metrics.x + positions[first].x; | - |
| 2625 | QFixed top = metrics.y + positions[first].y; | - |
| 2626 | QFixed right = left + metrics.width; | - |
| 2627 | QFixed bottom = top + metrics.height; | - |
| 2628 | if (left < clipRight && right > clipLeft && top < clipBottom && bottom > clipTop) | - |
| 2629 | break; | - |
| 2630 | ++first; | - |
| 2631 | } | - |
| 2632 | int last = numGlyphs - 1; | - |
| 2633 | while (last > first) { | - |
| 2634 | glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[last]); | - |
| 2635 | QFixed left = metrics.x + positions[last].x; | - |
| 2636 | QFixed top = metrics.y + positions[last].y; | - |
| 2637 | QFixed right = left + metrics.width; | - |
| 2638 | QFixed bottom = top + metrics.height; | - |
| 2639 | if (left < clipRight && right > clipLeft && top < clipBottom && bottom > clipTop) | - |
| 2640 | break; | - |
| 2641 | --last; | - |
| 2642 | } | - |
| 2643 | return QPair<int, int>(first, last + 1); | - |
| 2644 | } | - |
| 2645 | | - |
| 2646 | | - |
| 2647 | | - |
| 2648 | | - |
| 2649 | void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) | - |
| 2650 | { | - |
| 2651 | if (textItem->numGlyphs == 0) | - |
| 2652 | return; | - |
| 2653 | | - |
| 2654 | ensurePen(); | - |
| 2655 | ensureRasterState(); | - |
| 2656 | | - |
| 2657 | QFontEngine *fontEngine = textItem->fontEngine(); | - |
| 2658 | if (!supportsTransformations(fontEngine)) { | - |
| 2659 | drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, | - |
| 2660 | fontEngine); | - |
| 2661 | } else if (state()->matrix.type() < QTransform::TxProject) { | - |
| 2662 | bool invertible; | - |
| 2663 | QTransform invMat = state()->matrix.inverted(&invertible); | - |
| 2664 | if (!invertible) | - |
| 2665 | return; | - |
| 2666 | | - |
| 2667 | QPair<int, int> range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()), | - |
| 2668 | textItem->fontEngine(), textItem->glyphs, | - |
| 2669 | textItem->glyphPositions, textItem->numGlyphs); | - |
| 2670 | QStaticTextItem copy = *textItem; | - |
| 2671 | copy.glyphs += range.first; | - |
| 2672 | copy.glyphPositions += range.first; | - |
| 2673 | copy.numGlyphs = range.second - range.first; | - |
| 2674 | QPaintEngineEx::drawStaticTextItem(©); | - |
| 2675 | } else { | - |
| 2676 | QPaintEngineEx::drawStaticTextItem(textItem); | - |
| 2677 | } | - |
| 2678 | } | - |
| 2679 | | - |
| 2680 | | - |
| 2681 | | - |
| 2682 | | - |
| 2683 | void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) | - |
| 2684 | { | - |
| 2685 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - |
| 2686 | if (ti.glyphs.numGlyphs == 0) | - |
| 2687 | return; | - |
| 2688 | ensurePen(); | - |
| 2689 | ensureRasterState(); | - |
| 2690 | | - |
| 2691 | QRasterPaintEngineState *s = state(); | - |
| 2692 | QTransform matrix = s->matrix; | - |
| 2693 | | - |
| 2694 | if (!supportsTransformations(ti.fontEngine)) { | - |
| 2695 | QVarLengthArray<QFixedPoint> positions; | - |
| 2696 | QVarLengthArray<glyph_t> glyphs; | - |
| 2697 | | - |
| 2698 | matrix.translate(p.x(), p.y()); | - |
| 2699 | ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); | - |
| 2700 | | - |
| 2701 | drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), ti.fontEngine); | - |
| 2702 | } else if (matrix.type() < QTransform::TxProject) { | - |
| 2703 | bool invertible; | - |
| 2704 | QTransform invMat = matrix.inverted(&invertible); | - |
| 2705 | if (!invertible) | - |
| 2706 | return; | - |
| 2707 | | - |
| 2708 | QVarLengthArray<QFixedPoint> positions; | - |
| 2709 | QVarLengthArray<glyph_t> glyphs; | - |
| 2710 | | - |
| 2711 | ti.fontEngine->getGlyphPositions(ti.glyphs, QTransform::fromTranslate(p.x(), p.y()), | - |
| 2712 | ti.flags, glyphs, positions); | - |
| 2713 | QPair<int, int> range = visibleGlyphRange(invMat.mapRect(clipBoundingRect()), | - |
| 2714 | ti.fontEngine, glyphs.data(), positions.data(), | - |
| 2715 | glyphs.size()); | - |
| 2716 | | - |
| 2717 | if (range.first >= range.second) | - |
| 2718 | return; | - |
| 2719 | | - |
| 2720 | QStaticTextItem staticTextItem; | - |
| 2721 | staticTextItem.color = s->pen.color(); | - |
| 2722 | staticTextItem.font = s->font; | - |
| 2723 | staticTextItem.setFontEngine(ti.fontEngine); | - |
| 2724 | staticTextItem.numGlyphs = range.second - range.first; | - |
| 2725 | staticTextItem.glyphs = glyphs.data() + range.first; | - |
| 2726 | staticTextItem.glyphPositions = positions.data() + range.first; | - |
| 2727 | QPaintEngineEx::drawStaticTextItem(&staticTextItem); | - |
| 2728 | } else { | - |
| 2729 | QPaintEngineEx::drawTextItem(p, ti); | - |
| 2730 | } | - |
| 2731 | } | - |
| 2732 | | - |
| 2733 | | - |
| 2734 | | - |
| 2735 | | - |
| 2736 | void QRasterPaintEngine::drawPoints(const QPointF *points, int pointCount) | - |
| 2737 | { | - |
| 2738 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2739 | QRasterPaintEngineState *s = state(); | - |
| 2740 | | - |
| 2741 | ensurePen(); | - |
| 2742 | if (!s->penData.blend) never evaluated: !s->penData.blend | 0 |
| 2743 | return; | 0 |
| 2744 | | - |
| 2745 | if (!s->flags.fast_pen) { never evaluated: !s->flags.fast_pen | 0 |
| 2746 | QPaintEngineEx::drawPoints(points, pointCount); | - |
| 2747 | return; | 0 |
| 2748 | } | - |
| 2749 | | - |
| 2750 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 2751 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 2752 | stroker.drawPoints(points, pointCount); | - |
| 2753 | } | 0 |
| 2754 | | - |
| 2755 | | - |
| 2756 | void QRasterPaintEngine::drawPoints(const QPoint *points, int pointCount) | - |
| 2757 | { | - |
| 2758 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2759 | QRasterPaintEngineState *s = state(); | - |
| 2760 | | - |
| 2761 | ensurePen(); | - |
| 2762 | if (!s->penData.blend) partially evaluated: !s->penData.blend| no Evaluation Count:0 | yes Evaluation Count:136 |
| 0-136 |
| 2763 | return; | 0 |
| 2764 | | - |
| 2765 | if (!s->flags.fast_pen) { evaluated: !s->flags.fast_pen| yes Evaluation Count:1 | yes Evaluation Count:135 |
| 1-135 |
| 2766 | QPaintEngineEx::drawPoints(points, pointCount); | - |
| 2767 | return; executed: return;Execution Count:1 | 1 |
| 2768 | } | - |
| 2769 | | - |
| 2770 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 2771 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 2772 | stroker.drawPoints(points, pointCount); | - |
| 2773 | } executed: }Execution Count:135 | 135 |
| 2774 | | - |
| 2775 | | - |
| 2776 | | - |
| 2777 | | - |
| 2778 | void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount) | - |
| 2779 | { | - |
| 2780 | | - |
| 2781 | | - |
| 2782 | | - |
| 2783 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2784 | QRasterPaintEngineState *s = state(); | - |
| 2785 | | - |
| 2786 | ensurePen(); | - |
| 2787 | if (!s->penData.blend) evaluated: !s->penData.blend| yes Evaluation Count:48 | yes Evaluation Count:4988 |
| 48-4988 |
| 2788 | return; executed: return;Execution Count:48 | 48 |
| 2789 | | - |
| 2790 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:4933 | yes Evaluation Count:55 |
| 55-4933 |
| 2791 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 2792 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 2793 | for (int i=0; i<lineCount; ++i) { evaluated: i<lineCount| yes Evaluation Count:4933 | yes Evaluation Count:4933 |
| 4933 |
| 2794 | const QLine &l = lines[i]; | - |
| 2795 | stroker.drawLine(l.p1(), l.p2()); | - |
| 2796 | } executed: }Execution Count:4933 | 4933 |
| 2797 | } else { executed: }Execution Count:4933 | 4933 |
| 2798 | QPaintEngineEx::drawLines(lines, lineCount); | - |
| 2799 | } executed: }Execution Count:55 | 55 |
| 2800 | } | - |
| 2801 | | - |
| 2802 | void QRasterPaintEnginePrivate::rasterizeLine_dashed(QLineF line, | - |
| 2803 | qreal width, | - |
| 2804 | int *dashIndex, | - |
| 2805 | qreal *dashOffset, | - |
| 2806 | bool *inDash) | - |
| 2807 | { | - |
| 2808 | QRasterPaintEngine * const q = q_func(); | - |
| 2809 | QRasterPaintEngineState *s = q->state(); | - |
| 2810 | | - |
| 2811 | const QPen &pen = s->lastPen; | - |
| 2812 | const bool squareCap = (pen.capStyle() == Qt::SquareCap); | - |
| 2813 | const QVector<qreal> pattern = pen.dashPattern(); | - |
| 2814 | | - |
| 2815 | qreal patternLength = 0; | - |
| 2816 | for (int i = 0; i < pattern.size(); ++i) | - |
| 2817 | patternLength += pattern.at(i); | - |
| 2818 | | - |
| 2819 | if (patternLength <= 0) | - |
| 2820 | return; | - |
| 2821 | | - |
| 2822 | qreal length = line.length(); | - |
| 2823 | qt_noop(); | - |
| 2824 | while (length > 0) { | - |
| 2825 | const bool rasterize = *inDash; | - |
| 2826 | qreal dash = (pattern.at(*dashIndex) - *dashOffset) * width; | - |
| 2827 | QLineF l = line; | - |
| 2828 | | - |
| 2829 | if (dash >= length) { | - |
| 2830 | dash = length; | - |
| 2831 | *dashOffset += dash / width; | - |
| 2832 | length = 0; | - |
| 2833 | } else { | - |
| 2834 | *dashOffset = 0; | - |
| 2835 | *inDash = !(*inDash); | - |
| 2836 | if (++*dashIndex >= pattern.size()) | - |
| 2837 | *dashIndex = 0; | - |
| 2838 | length -= dash; | - |
| 2839 | l.setLength(dash); | - |
| 2840 | line.setP1(l.p2()); | - |
| 2841 | } | - |
| 2842 | | - |
| 2843 | if (rasterize && dash > 0) | - |
| 2844 | rasterizer->rasterizeLine(l.p1(), l.p2(), width / dash, squareCap); | - |
| 2845 | } | - |
| 2846 | } | - |
| 2847 | | - |
| 2848 | | - |
| 2849 | | - |
| 2850 | | - |
| 2851 | void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) | - |
| 2852 | { | - |
| 2853 | | - |
| 2854 | | - |
| 2855 | | - |
| 2856 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2857 | QRasterPaintEngineState *s = state(); | - |
| 2858 | | - |
| 2859 | ensurePen(); | - |
| 2860 | if (!s->penData.blend) evaluated: !s->penData.blend| yes Evaluation Count:48 | yes Evaluation Count:1925 |
| 48-1925 |
| 2861 | return; executed: return;Execution Count:48 | 48 |
| 2862 | if (s->flags.fast_pen) { evaluated: s->flags.fast_pen| yes Evaluation Count:1106 | yes Evaluation Count:819 |
| 819-1106 |
| 2863 | QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); | - |
| 2864 | stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 2865 | for (int i=0; i<lineCount; ++i) { evaluated: i<lineCount| yes Evaluation Count:1595 | yes Evaluation Count:1106 |
| 1106-1595 |
| 2866 | QLineF line = lines[i]; | - |
| 2867 | stroker.drawLine(line.p1(), line.p2()); | - |
| 2868 | } executed: }Execution Count:1595 | 1595 |
| 2869 | } else { executed: }Execution Count:1106 | 1106 |
| 2870 | QPaintEngineEx::drawLines(lines, lineCount); | - |
| 2871 | } executed: }Execution Count:819 | 819 |
| 2872 | } | - |
| 2873 | | - |
| 2874 | | - |
| 2875 | | - |
| 2876 | | - |
| 2877 | | - |
| 2878 | void QRasterPaintEngine::drawEllipse(const QRectF &rect) | - |
| 2879 | { | - |
| 2880 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2881 | QRasterPaintEngineState *s = state(); | - |
| 2882 | | - |
| 2883 | ensurePen(); | - |
| 2884 | if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen) | - |
| 2885 | || (qpen_style(s->lastPen) == Qt::NoPen)) | - |
| 2886 | && !s->flags.antialiased | - |
| 2887 | && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT | - |
| 2888 | && !rect.isEmpty() | - |
| 2889 | && s->matrix.type() <= QTransform::TxScale) | - |
| 2890 | { | - |
| 2891 | ensureBrush(); | - |
| 2892 | const QRectF r = s->matrix.mapRect(rect); | - |
| 2893 | ProcessSpans penBlend = d->getPenFunc(r, &s->penData); | - |
| 2894 | ProcessSpans brushBlend = d->getBrushFunc(r, &s->brushData); | - |
| 2895 | const QRect brect = QRect(int(r.x()), int(r.y()), | - |
| 2896 | (int(r.x()+r.width()) - int(r.x())), | - |
| 2897 | (int(r.y()+r.height()) - int(r.y()))); | - |
| 2898 | if (brect == r) { | - |
| 2899 | drawEllipse_midpoint_i(brect, d->deviceRect, penBlend, brushBlend, | - |
| 2900 | &s->penData, &s->brushData); | - |
| 2901 | return; | - |
| 2902 | } | - |
| 2903 | } | - |
| 2904 | QPaintEngineEx::drawEllipse(rect); | - |
| 2905 | } | - |
| 2906 | bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine) const | - |
| 2907 | { | - |
| 2908 | const QTransform &m = state()->matrix; | - |
| 2909 | return supportsTransformations(fontEngine, m); | - |
| 2910 | } | - |
| 2911 | | - |
| 2912 | | - |
| 2913 | | - |
| 2914 | | - |
| 2915 | bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const | - |
| 2916 | { | - |
| 2917 | if (fontEngine->supportsTransformations(m)) | - |
| 2918 | return true; | - |
| 2919 | | - |
| 2920 | return !shouldDrawCachedGlyphs(fontEngine, m); | - |
| 2921 | } | - |
| 2922 | | - |
| 2923 | | - |
| 2924 | | - |
| 2925 | | - |
| 2926 | QPoint QRasterPaintEngine::coordinateOffset() const | - |
| 2927 | { | - |
| 2928 | return QPoint(0, 0); | - |
| 2929 | } | - |
| 2930 | | - |
| 2931 | void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg) | - |
| 2932 | { | - |
| 2933 | qt_noop(); | - |
| 2934 | if (!fg->blend) | - |
| 2935 | return; | - |
| 2936 | QRasterPaintEnginePrivate * const d = d_func(); | - |
| 2937 | | - |
| 2938 | qt_noop(); | - |
| 2939 | | - |
| 2940 | const int spanCount = 256; | - |
| 2941 | QT_FT_Span spans[spanCount]; | - |
| 2942 | int n = 0; | - |
| 2943 | | - |
| 2944 | | - |
| 2945 | int w = image.width(); | - |
| 2946 | int h = image.height(); | - |
| 2947 | int ymax = qMin(qRound(pos.y() + h), d->rasterBuffer->height()); | - |
| 2948 | int ymin = qMax(qRound(pos.y()), 0); | - |
| 2949 | int xmax = qMin(qRound(pos.x() + w), d->rasterBuffer->width()); | - |
| 2950 | int xmin = qMax(qRound(pos.x()), 0); | - |
| 2951 | | - |
| 2952 | int x_offset = xmin - qRound(pos.x()); | - |
| 2953 | | - |
| 2954 | QImage::Format format = image.format(); | - |
| 2955 | for (int y = ymin; y < ymax; ++y) { | - |
| 2956 | const uchar *src = image.scanLine(y - qRound(pos.y())); | - |
| 2957 | if (format == QImage::Format_MonoLSB) { | - |
| 2958 | for (int x = 0; x < xmax - xmin; ++x) { | - |
| 2959 | int src_x = x + x_offset; | - |
| 2960 | uchar pixel = src[src_x >> 3]; | - |
| 2961 | if (!pixel) { | - |
| 2962 | x += 7 - (src_x%8); | - |
| 2963 | continue; | - |
| 2964 | } | - |
| 2965 | if (pixel & (0x1 << (src_x & 7))) { | - |
| 2966 | spans[n].x = xmin + x; | - |
| 2967 | spans[n].y = y; | - |
| 2968 | spans[n].coverage = 255; | - |
| 2969 | int len = 1; | - |
| 2970 | while (src_x+1 < w && src[(src_x+1) >> 3] & (0x1 << ((src_x+1) & 7))) { | - |
| 2971 | ++src_x; | - |
| 2972 | ++len; | - |
| 2973 | } | - |
| 2974 | spans[n].len = ((len + spans[n].x) > xmax) ? (xmax - spans[n].x) : len; | - |
| 2975 | x += len; | - |
| 2976 | ++n; | - |
| 2977 | if (n == spanCount) { | - |
| 2978 | fg->blend(n, spans, fg); | - |
| 2979 | n = 0; | - |
| 2980 | } | - |
| 2981 | } | - |
| 2982 | } | - |
| 2983 | } else { | - |
| 2984 | for (int x = 0; x < xmax - xmin; ++x) { | - |
| 2985 | int src_x = x + x_offset; | - |
| 2986 | uchar pixel = src[src_x >> 3]; | - |
| 2987 | if (!pixel) { | - |
| 2988 | x += 7 - (src_x%8); | - |
| 2989 | continue; | - |
| 2990 | } | - |
| 2991 | if (pixel & (0x80 >> (x & 7))) { | - |
| 2992 | spans[n].x = xmin + x; | - |
| 2993 | spans[n].y = y; | - |
| 2994 | spans[n].coverage = 255; | - |
| 2995 | int len = 1; | - |
| 2996 | while (src_x+1 < w && src[(src_x+1) >> 3] & (0x80 >> ((src_x+1) & 7))) { | - |
| 2997 | ++src_x; | - |
| 2998 | ++len; | - |
| 2999 | } | - |
| 3000 | spans[n].len = ((len + spans[n].x) > xmax) ? (xmax - spans[n].x) : len; | - |
| 3001 | x += len; | - |
| 3002 | ++n; | - |
| 3003 | if (n == spanCount) { | - |
| 3004 | fg->blend(n, spans, fg); | - |
| 3005 | n = 0; | - |
| 3006 | } | - |
| 3007 | } | - |
| 3008 | } | - |
| 3009 | } | - |
| 3010 | } | - |
| 3011 | if (n) { | - |
| 3012 | fg->blend(n, spans, fg); | - |
| 3013 | n = 0; | - |
| 3014 | } | - |
| 3015 | } | - |
| 3016 | QRasterPaintEngine::ClipType QRasterPaintEngine::clipType() const | - |
| 3017 | { | - |
| 3018 | const QRasterPaintEnginePrivate * const d = d_func(); | - |
| 3019 | | - |
| 3020 | const QClipData *clip = d->clip(); | - |
| 3021 | if (!clip || clip->hasRectClip) | - |
| 3022 | return RectClip; | - |
| 3023 | else | - |
| 3024 | return ComplexClip; | - |
| 3025 | } | - |
| 3026 | | - |
| 3027 | | - |
| 3028 | | - |
| 3029 | | - |
| 3030 | | - |
| 3031 | QRect QRasterPaintEngine::clipBoundingRect() const | - |
| 3032 | { | - |
| 3033 | const QRasterPaintEnginePrivate * const d = d_func(); | - |
| 3034 | | - |
| 3035 | const QClipData *clip = d->clip(); | - |
| 3036 | | - |
| 3037 | if (!clip) | - |
| 3038 | return d->deviceRect; | - |
| 3039 | | - |
| 3040 | if (clip->hasRectClip) | - |
| 3041 | return clip->clipRect; | - |
| 3042 | | - |
| 3043 | return QRect(clip->xmin, clip->ymin, clip->xmax - clip->xmin, clip->ymax - clip->ymin); | - |
| 3044 | } | - |
| 3045 | | - |
| 3046 | void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data) | - |
| 3047 | { | - |
| 3048 | QRasterPaintEngine * const q = q_func(); | - |
| 3049 | QRasterPaintEngineState *s = q->state(); | - |
| 3050 | | - |
| 3051 | rasterizer->setAntialiased(s->flags.antialiased); | - |
| 3052 | rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 3053 | | - |
| 3054 | QRect clipRect(deviceRect); | - |
| 3055 | ProcessSpans blend; | - |
| 3056 | | - |
| 3057 | | - |
| 3058 | const QClipData *c = clip(); | - |
| 3059 | if (c) { | - |
| 3060 | const QRect r(QPoint(c->xmin, c->ymin), | - |
| 3061 | QSize(c->xmax - c->xmin, c->ymax - c->ymin)); | - |
| 3062 | clipRect = clipRect.intersected(r); | - |
| 3063 | blend = data->blend; | - |
| 3064 | } else { | - |
| 3065 | blend = data->unclipped_blend; | - |
| 3066 | } | - |
| 3067 | | - |
| 3068 | rasterizer->setClipRect(clipRect); | - |
| 3069 | rasterizer->initialize(blend, data); | - |
| 3070 | } | - |
| 3071 | | - |
| 3072 | void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, | - |
| 3073 | ProcessSpans callback, | - |
| 3074 | QSpanData *spanData, QRasterBuffer *rasterBuffer) | - |
| 3075 | { | - |
| 3076 | if (!callback || !outline) | - |
| 3077 | return; | - |
| 3078 | | - |
| 3079 | QRasterPaintEngine * const q = q_func(); | - |
| 3080 | QRasterPaintEngineState *s = q->state(); | - |
| 3081 | | - |
| 3082 | if (!s->flags.antialiased) { | - |
| 3083 | initializeRasterizer(spanData); | - |
| 3084 | | - |
| 3085 | const Qt::FillRule fillRule = outline->flags == 0x0 | - |
| 3086 | ? Qt::WindingFill | - |
| 3087 | : Qt::OddEvenFill; | - |
| 3088 | | - |
| 3089 | rasterizer->rasterize(outline, fillRule); | - |
| 3090 | return; | - |
| 3091 | } | - |
| 3092 | | - |
| 3093 | rasterize(outline, callback, (void *)spanData, rasterBuffer); | - |
| 3094 | } | - |
| 3095 | | - |
| 3096 | extern "C" { | - |
| 3097 | int q_gray_rendered_spans(QT_FT_Raster raster); | - |
| 3098 | } | - |
| 3099 | | - |
| 3100 | static inline uchar *alignAddress(uchar *address, quintptr alignmentMask) | - |
| 3101 | { | - |
| 3102 | return (uchar *)(((quintptr)address + alignmentMask) & ~alignmentMask); | - |
| 3103 | } | - |
| 3104 | | - |
| 3105 | void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, | - |
| 3106 | ProcessSpans callback, | - |
| 3107 | void *userData, QRasterBuffer *) | - |
| 3108 | { | - |
| 3109 | if (!callback || !outline) | - |
| 3110 | return; | - |
| 3111 | | - |
| 3112 | QRasterPaintEngine * const q = q_func(); | - |
| 3113 | QRasterPaintEngineState *s = q->state(); | - |
| 3114 | | - |
| 3115 | if (!s->flags.antialiased) { | - |
| 3116 | rasterizer->setAntialiased(s->flags.antialiased); | - |
| 3117 | rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); | - |
| 3118 | rasterizer->setClipRect(deviceRect); | - |
| 3119 | rasterizer->initialize(callback, userData); | - |
| 3120 | | - |
| 3121 | const Qt::FillRule fillRule = outline->flags == 0x0 | - |
| 3122 | ? Qt::WindingFill | - |
| 3123 | : Qt::OddEvenFill; | - |
| 3124 | | - |
| 3125 | rasterizer->rasterize(outline, fillRule); | - |
| 3126 | return; | - |
| 3127 | } | - |
| 3128 | | - |
| 3129 | | - |
| 3130 | | - |
| 3131 | | - |
| 3132 | | - |
| 3133 | int rasterPoolSize = 8192; | - |
| 3134 | uchar rasterPoolOnStack[8192 + 0xf]; | - |
| 3135 | uchar *rasterPoolBase = alignAddress(rasterPoolOnStack, 0xf); | - |
| 3136 | uchar *rasterPoolOnHeap = 0; | - |
| 3137 | | - |
| 3138 | qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); | - |
| 3139 | | - |
| 3140 | void *data = userData; | - |
| 3141 | | - |
| 3142 | QT_FT_BBox clip_box = { deviceRect.x(), | - |
| 3143 | deviceRect.y(), | - |
| 3144 | deviceRect.x() + deviceRect.width(), | - |
| 3145 | deviceRect.y() + deviceRect.height() }; | - |
| 3146 | | - |
| 3147 | QT_FT_Raster_Params rasterParams; | - |
| 3148 | rasterParams.target = 0; | - |
| 3149 | rasterParams.source = outline; | - |
| 3150 | rasterParams.flags = 0x4; | - |
| 3151 | rasterParams.gray_spans = 0; | - |
| 3152 | rasterParams.black_spans = 0; | - |
| 3153 | rasterParams.bit_test = 0; | - |
| 3154 | rasterParams.bit_set = 0; | - |
| 3155 | rasterParams.user = data; | - |
| 3156 | rasterParams.clip_box = clip_box; | - |
| 3157 | | - |
| 3158 | bool done = false; | - |
| 3159 | int error; | - |
| 3160 | | - |
| 3161 | int rendered_spans = 0; | - |
| 3162 | | - |
| 3163 | while (!done) { | - |
| 3164 | | - |
| 3165 | rasterParams.flags |= (0x1 | 0x2); | - |
| 3166 | rasterParams.gray_spans = callback; | - |
| 3167 | rasterParams.skip_spans = rendered_spans; | - |
| 3168 | error = qt_ft_grays_raster.raster_render(*grayRaster.data(), &rasterParams); | - |
| 3169 | | - |
| 3170 | | - |
| 3171 | if (error == -6) { | - |
| 3172 | rasterPoolSize *= 2; | - |
| 3173 | if (rasterPoolSize > 1024 * 1024) { | - |
| 3174 | QMessageLogger("painting/qpaintengine_raster.cpp", 35833584, __PRETTY_FUNCTION__).warning("QPainter: Rasterization of primitive failed"); | - |
| 3175 | break; | - |
| 3176 | } | - |
| 3177 | | - |
| 3178 | rendered_spans += q_gray_rendered_spans(*grayRaster.data()); | - |
| 3179 | | - |
| 3180 | free(rasterPoolOnHeap); | - |
| 3181 | rasterPoolOnHeap = (uchar *)malloc(rasterPoolSize + 0xf); | - |
| 3182 | | - |
| 3183 | qt_noop(); | - |
| 3184 | | - |
| 3185 | rasterPoolBase = alignAddress(rasterPoolOnHeap, 0xf); | - |
| 3186 | | - |
| 3187 | qt_ft_grays_raster.raster_done(*grayRaster.data()); | - |
| 3188 | qt_ft_grays_raster.raster_new(grayRaster.data()); | - |
| 3189 | qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); | - |
| 3190 | } else { | - |
| 3191 | done = true; | - |
| 3192 | } | - |
| 3193 | } | - |
| 3194 | | - |
| 3195 | free(rasterPoolOnHeap); | - |
| 3196 | } | - |
| 3197 | | - |
| 3198 | void QRasterPaintEnginePrivate::recalculateFastImages() | - |
| 3199 | { | - |
| 3200 | QRasterPaintEngine * const q = q_func(); | - |
| 3201 | QRasterPaintEngineState *s = q->state(); | - |
| 3202 | | - |
| 3203 | s->flags.fast_images = !(s->renderHints & QPainter::SmoothPixmapTransform) | - |
| 3204 | && s->matrix.type() <= QTransform::TxShear; | - |
| 3205 | } | - |
| 3206 | | - |
| 3207 | bool QRasterPaintEnginePrivate::canUseFastImageBlending(QPainter::CompositionMode mode, const QImage &image) const | - |
| 3208 | { | - |
| 3209 | const QRasterPaintEngine * const q = q_func(); | - |
| 3210 | const QRasterPaintEngineState *s = q->state(); | - |
| 3211 | | - |
| 3212 | return s->flags.fast_images | - |
| 3213 | && (mode == QPainter::CompositionMode_SourceOver | - |
| 3214 | || (mode == QPainter::CompositionMode_Source | - |
| 3215 | && !image.hasAlphaChannel())); | - |
| 3216 | } | - |
| 3217 | | - |
| 3218 | QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color) | - |
| 3219 | { | - |
| 3220 | qt_noop(); | - |
| 3221 | | - |
| 3222 | QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB); | - |
| 3223 | QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied); | - |
| 3224 | | - |
| 3225 | QRgb fg = PREMUL(color.rgba()); | - |
| 3226 | QRgb bg = 0; | - |
| 3227 | | - |
| 3228 | int height = sourceImage.height(); | - |
| 3229 | int width = sourceImage.width(); | - |
| 3230 | for (int y=0; y<height; ++y) { | - |
| 3231 | uchar *source = sourceImage.scanLine(y); | - |
| 3232 | QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y)); | - |
| 3233 | if (!source || !target) | - |
| 3234 | qt_noop(); | - |
| 3235 | for (int x=0; x < width; ++x) | - |
| 3236 | target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg; | - |
| 3237 | } | - |
| 3238 | return dest; | - |
| 3239 | } | - |
| 3240 | | - |
| 3241 | QRasterBuffer::~QRasterBuffer() | - |
| 3242 | { | - |
| 3243 | } | - |
| 3244 | | - |
| 3245 | void QRasterBuffer::init() | - |
| 3246 | { | - |
| 3247 | compositionMode = QPainter::CompositionMode_SourceOver; | - |
| 3248 | monoDestinationWithClut = false; | - |
| 3249 | destColor0 = 0; | - |
| 3250 | destColor1 = 0; | - |
| 3251 | } | - |
| 3252 | | - |
| 3253 | QImage::Format QRasterBuffer::prepare(QImage *image) | - |
| 3254 | { | - |
| 3255 | m_buffer = (uchar *)image->bits(); | - |
| 3256 | m_width = qMin(QT_RASTER_COORD_LIMIT, image->width()); | - |
| 3257 | m_height = qMin(QT_RASTER_COORD_LIMIT, image->height()); | - |
| 3258 | bytes_per_pixel = image->depth()/8; | - |
| 3259 | bytes_per_line = image->bytesPerLine(); | - |
| 3260 | | - |
| 3261 | format = image->format(); | - |
| 3262 | drawHelper = qDrawHelper + format; | - |
| 3263 | if (image->depth() == 1 && image->colorTable().size() == 2) { | - |
| 3264 | monoDestinationWithClut = true; | - |
| 3265 | destColor0 = PREMUL(image->colorTable()[0]); | - |
| 3266 | destColor1 = PREMUL(image->colorTable()[1]); | - |
| 3267 | } | - |
| 3268 | | - |
| 3269 | return format; | - |
| 3270 | } | - |
| 3271 | | - |
| 3272 | void QRasterBuffer::resetBuffer(int val) | - |
| 3273 | { | - |
| 3274 | memset(m_buffer, val, m_height*bytes_per_line); | - |
| 3275 | } | - |
| 3276 | | - |
| 3277 | QClipData::QClipData(int height) | - |
| 3278 | { | - |
| 3279 | clipSpanHeight = height; | - |
| 3280 | m_clipLines = 0; | - |
| 3281 | | - |
| 3282 | allocated = 0; | - |
| 3283 | m_spans = 0; | - |
| 3284 | xmin = xmax = ymin = ymax = 0; | - |
| 3285 | count = 0; | - |
| 3286 | | - |
| 3287 | enabled = true; | - |
| 3288 | hasRectClip = hasRegionClip = false; | - |
| 3289 | } | - |
| 3290 | | - |
| 3291 | QClipData::~QClipData() | - |
| 3292 | { | - |
| 3293 | if (m_clipLines) | - |
| 3294 | free(m_clipLines); | - |
| 3295 | if (m_spans) | - |
| 3296 | free(m_spans); | - |
| 3297 | } | - |
| 3298 | | - |
| 3299 | void QClipData::initialize() | - |
| 3300 | { | - |
| 3301 | if (m_spans) | - |
| 3302 | return; | - |
| 3303 | | - |
| 3304 | if (!m_clipLines) | - |
| 3305 | m_clipLines = (ClipLine *)calloc(sizeof(ClipLine), clipSpanHeight); | - |
| 3306 | | - |
| 3307 | qt_noop(); | - |
| 3308 | if (true) { | - |
| 3309 | m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan)); | - |
| 3310 | allocated = clipSpanHeight; | - |
| 3311 | qt_noop(); | - |
| 3312 | | - |
| 3313 | if (true) { | - |
| 3314 | if (hasRectClip) { | - |
| 3315 | int y = 0; | - |
| 3316 | while (y < ymin) { | - |
| 3317 | m_clipLines[y].spans = 0; | - |
| 3318 | m_clipLines[y].count = 0; | - |
| 3319 | ++y; | - |
| 3320 | } | - |
| 3321 | | - |
| 3322 | const int len = clipRect.width(); | - |
| 3323 | count = 0; | - |
| 3324 | while (y < ymax) { | - |
| 3325 | QSpan *span = m_spans + count; | - |
| 3326 | span->x = xmin; | - |
| 3327 | span->len = len; | - |
| 3328 | span->y = y; | - |
| 3329 | span->coverage = 255; | - |
| 3330 | ++count; | - |
| 3331 | | - |
| 3332 | m_clipLines[y].spans = span; | - |
| 3333 | m_clipLines[y].count = 1; | - |
| 3334 | ++y; | - |
| 3335 | } | - |
| 3336 | | - |
| 3337 | while (y < clipSpanHeight) { | - |
| 3338 | m_clipLines[y].spans = 0; | - |
| 3339 | m_clipLines[y].count = 0; | - |
| 3340 | ++y; | - |
| 3341 | } | - |
| 3342 | } else if (hasRegionClip) { | - |
| 3343 | | - |
| 3344 | const QVector<QRect> rects = clipRegion.rects(); | - |
| 3345 | const int numRects = rects.size(); | - |
| 3346 | | - |
| 3347 | { | - |
| 3348 | const int maxSpans = (ymax - ymin) * numRects; | - |
| 3349 | if (maxSpans > allocated) { | - |
| 3350 | m_spans = q_check_ptr((QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan))); | - |
| 3351 | allocated = maxSpans; | - |
| 3352 | } | - |
| 3353 | } | - |
| 3354 | | - |
| 3355 | int y = 0; | - |
| 3356 | int firstInBand = 0; | - |
| 3357 | count = 0; | - |
| 3358 | while (firstInBand < numRects) { | - |
| 3359 | const int currMinY = rects.at(firstInBand).y(); | - |
| 3360 | const int currMaxY = currMinY + rects.at(firstInBand).height(); | - |
| 3361 | | - |
| 3362 | while (y < currMinY) { | - |
| 3363 | m_clipLines[y].spans = 0; | - |
| 3364 | m_clipLines[y].count = 0; | - |
| 3365 | ++y; | - |
| 3366 | } | - |
| 3367 | | - |
| 3368 | int lastInBand = firstInBand; | - |
| 3369 | while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y) | - |
| 3370 | ++lastInBand; | - |
| 3371 | | - |
| 3372 | while (y < currMaxY) { | - |
| 3373 | | - |
| 3374 | m_clipLines[y].spans = m_spans + count; | - |
| 3375 | m_clipLines[y].count = lastInBand - firstInBand + 1; | - |
| 3376 | | - |
| 3377 | for (int r = firstInBand; r <= lastInBand; ++r) { | - |
| 3378 | const QRect &currRect = rects.at(r); | - |
| 3379 | QSpan *span = m_spans + count; | - |
| 3380 | span->x = currRect.x(); | - |
| 3381 | span->len = currRect.width(); | - |
| 3382 | span->y = y; | - |
| 3383 | span->coverage = 255; | - |
| 3384 | ++count; | - |
| 3385 | } | - |
| 3386 | ++y; | - |
| 3387 | } | - |
| 3388 | | - |
| 3389 | firstInBand = lastInBand + 1; | - |
| 3390 | } | - |
| 3391 | | - |
| 3392 | qt_noop(); | - |
| 3393 | | - |
| 3394 | while (y < clipSpanHeight) { | - |
| 3395 | m_clipLines[y].spans = 0; | - |
| 3396 | m_clipLines[y].count = 0; | - |
| 3397 | ++y; | - |
| 3398 | } | - |
| 3399 | | - |
| 3400 | } | - |
| 3401 | } else { | - |
| 3402 | free(m_spans); | - |
| 3403 | m_spans = 0; | - |
| 3404 | qt_noop(); | - |
| 3405 | } | - |
| 3406 | } else { | - |
| 3407 | free(m_clipLines); | - |
| 3408 | m_clipLines = 0; | - |
| 3409 | qt_noop(); | - |
| 3410 | } | - |
| 3411 | } | - |
| 3412 | | - |
| 3413 | void QClipData::fixup() | - |
| 3414 | { | - |
| 3415 | qt_noop(); | - |
| 3416 | | - |
| 3417 | if (count == 0) { | - |
| 3418 | ymin = ymax = xmin = xmax = 0; | - |
| 3419 | return; | - |
| 3420 | } | - |
| 3421 | | - |
| 3422 | int y = -1; | - |
| 3423 | ymin = m_spans[0].y; | - |
| 3424 | ymax = m_spans[count-1].y + 1; | - |
| 3425 | xmin = 2147483647; | - |
| 3426 | xmax = 0; | - |
| 3427 | | - |
| 3428 | const int firstLeft = m_spans[0].x; | - |
| 3429 | const int firstRight = m_spans[0].x + m_spans[0].len; | - |
| 3430 | bool isRect = true; | - |
| 3431 | | - |
| 3432 | for (int i = 0; i < count; ++i) { | - |
| 3433 | QT_FT_Span_& span = m_spans[i]; | - |
| 3434 | | - |
| 3435 | if (span.y != y) { | - |
| 3436 | if (span.y != y + 1 && y != -1) | - |
| 3437 | isRect = false; | - |
| 3438 | y = span.y; | - |
| 3439 | m_clipLines[y].spans = &span; | - |
| 3440 | m_clipLines[y].count = 1; | - |
| 3441 | } else | - |
| 3442 | ++m_clipLines[y].count; | - |
| 3443 | | - |
| 3444 | const int spanLeft = span.x; | - |
| 3445 | const int spanRight = spanLeft + span.len; | - |
| 3446 | | - |
| 3447 | if (spanLeft < xmin) | - |
| 3448 | xmin = spanLeft; | - |
| 3449 | | - |
| 3450 | if (spanRight > xmax) | - |
| 3451 | xmax = spanRight; | - |
| 3452 | | - |
| 3453 | if (spanLeft != firstLeft || spanRight != firstRight) | - |
| 3454 | isRect = false; | - |
| 3455 | } | - |
| 3456 | | - |
| 3457 | if (isRect) { | - |
| 3458 | hasRectClip = true; | - |
| 3459 | clipRect.setRect(xmin, ymin, xmax - xmin, ymax - ymin); | - |
| 3460 | } | - |
| 3461 | } | - |
| 3462 | | - |
| 3463 | | - |
| 3464 | | - |
| 3465 | | - |
| 3466 | void QClipData::setClipRect(const QRect &rect) | - |
| 3467 | { | - |
| 3468 | if (hasRectClip && rect == clipRect) | - |
| 3469 | return; | - |
| 3470 | | - |
| 3471 | | - |
| 3472 | hasRectClip = true; | - |
| 3473 | hasRegionClip = false; | - |
| 3474 | clipRect = rect; | - |
| 3475 | | - |
| 3476 | xmin = rect.x(); | - |
| 3477 | xmax = rect.x() + rect.width(); | - |
| 3478 | ymin = qMin(rect.y(), clipSpanHeight); | - |
| 3479 | ymax = qMin(rect.y() + rect.height(), clipSpanHeight); | - |
| 3480 | | - |
| 3481 | if (m_spans) { | - |
| 3482 | free(m_spans); | - |
| 3483 | m_spans = 0; | - |
| 3484 | } | - |
| 3485 | | - |
| 3486 | | - |
| 3487 | } | - |
| 3488 | | - |
| 3489 | | - |
| 3490 | | - |
| 3491 | | - |
| 3492 | void QClipData::setClipRegion(const QRegion ®ion) | - |
| 3493 | { | - |
| 3494 | if (region.rectCount() == 1) { | - |
| 3495 | setClipRect(region.rects().at(0)); | - |
| 3496 | return; | - |
| 3497 | } | - |
| 3498 | | - |
| 3499 | hasRegionClip = true; | - |
| 3500 | hasRectClip = false; | - |
| 3501 | clipRegion = region; | - |
| 3502 | | - |
| 3503 | { | - |
| 3504 | const QRect rect = region.boundingRect(); | - |
| 3505 | xmin = rect.x(); | - |
| 3506 | xmax = rect.x() + rect.width(); | - |
| 3507 | ymin = rect.y(); | - |
| 3508 | ymax = rect.y() + rect.height(); | - |
| 3509 | } | - |
| 3510 | | - |
| 3511 | if (m_spans) { | - |
| 3512 | free(m_spans); | - |
| 3513 | m_spans = 0; | - |
| 3514 | } | - |
| 3515 | | - |
| 3516 | } | - |
| 3517 | | - |
| 3518 | | - |
| 3519 | | - |
| 3520 | | - |
| 3521 | | - |
| 3522 | static const QSpan *qt_intersect_spans(const QClipData *clip, int *currentClip, | - |
| 3523 | const QSpan *spans, const QSpan *end, | - |
| 3524 | QSpan **outSpans, int available) | - |
| 3525 | { | - |
| 3526 | const_cast<QClipData *>(clip)->initialize(); | - |
| 3527 | | - |
| 3528 | QSpan *out = *outSpans; | - |
| 3529 | | - |
| 3530 | const QSpan *clipSpans = clip->m_spans + *currentClip; | - |
| 3531 | const QSpan *clipEnd = clip->m_spans + clip->count; | - |
| 3532 | | - |
| 3533 | while (available && spans < end ) { | - |
| 3534 | if (clipSpans >= clipEnd) { | - |
| 3535 | spans = end; | - |
| 3536 | break; | - |
| 3537 | } | - |
| 3538 | if (clipSpans->y > spans->y) { | - |
| 3539 | ++spans; | - |
| 3540 | continue; | - |
| 3541 | } | - |
| 3542 | if (spans->y != clipSpans->y) { | - |
| 3543 | if (spans->y < clip->count && clip->m_clipLines[spans->y].spans) | - |
| 3544 | clipSpans = clip->m_clipLines[spans->y].spans; | - |
| 3545 | else | - |
| 3546 | ++clipSpans; | - |
| 3547 | continue; | - |
| 3548 | } | - |
| 3549 | qt_noop(); | - |
| 3550 | | - |
| 3551 | int sx1 = spans->x; | - |
| 3552 | int sx2 = sx1 + spans->len; | - |
| 3553 | int cx1 = clipSpans->x; | - |
| 3554 | int cx2 = cx1 + clipSpans->len; | - |
| 3555 | | - |
| 3556 | if (cx1 < sx1 && cx2 < sx1) { | - |
| 3557 | ++clipSpans; | - |
| 3558 | continue; | - |
| 3559 | } else if (sx1 < cx1 && sx2 < cx1) { | - |
| 3560 | ++spans; | - |
| 3561 | continue; | - |
| 3562 | } | - |
| 3563 | int x = qMax(sx1, cx1); | - |
| 3564 | int len = qMin(sx2, cx2) - x; | - |
| 3565 | if (len) { | - |
| 3566 | out->x = qMax(sx1, cx1); | - |
| 3567 | out->len = qMin(sx2, cx2) - out->x; | - |
| 3568 | out->y = spans->y; | - |
| 3569 | out->coverage = qt_div_255(spans->coverage * clipSpans->coverage); | - |
| 3570 | ++out; | - |
| 3571 | --available; | - |
| 3572 | } | - |
| 3573 | if (sx2 < cx2) { | - |
| 3574 | ++spans; | - |
| 3575 | } else { | - |
| 3576 | ++clipSpans; | - |
| 3577 | } | - |
| 3578 | } | - |
| 3579 | | - |
| 3580 | *outSpans = out; | - |
| 3581 | *currentClip = clipSpans - clip->m_spans; | - |
| 3582 | return spans; | - |
| 3583 | } | - |
| 3584 | | - |
| 3585 | static void qt_span_fill_clipped(int spanCount, const QSpan *spans, void *userData) | - |
| 3586 | { | - |
| 3587 | | - |
| 3588 | QSpanData *fillData = reinterpret_cast<QSpanData *>(userData); | - |
| 3589 | | - |
| 3590 | qt_noop(); | - |
| 3591 | | - |
| 3592 | const int NSPANS = 256; | - |
| 3593 | QSpan cspans[NSPANS]; | - |
| 3594 | int currentClip = 0; | - |
| 3595 | const QSpan *end = spans + spanCount; | - |
| 3596 | while (spans < end) { | - |
| 3597 | QSpan *clipped = cspans; | - |
| 3598 | spans = qt_intersect_spans(fillData->clip, ¤tClip, spans, end, &clipped, NSPANS); | - |
| 3599 | | - |
| 3600 | | - |
| 3601 | | - |
| 3602 | if (clipped - cspans) | - |
| 3603 | fillData->unclipped_blend(clipped - cspans, cspans, fillData); | - |
| 3604 | } | - |
| 3605 | } | - |
| 3606 | | - |
| 3607 | | - |
| 3608 | | - |
| 3609 | | - |
| 3610 | | - |
| 3611 | | - |
| 3612 | static int qt_intersect_spans(QT_FT_Span *spans, int numSpans, | - |
| 3613 | const QRect &clip) | - |
| 3614 | { | - |
| 3615 | const short minx = clip.left(); | - |
| 3616 | const short miny = clip.top(); | - |
| 3617 | const short maxx = clip.right(); | - |
| 3618 | const short maxy = clip.bottom(); | - |
| 3619 | | - |
| 3620 | int n = 0; | - |
| 3621 | for (int i = 0; i < numSpans; ++i) { | - |
| 3622 | if (spans[i].y > maxy) | - |
| 3623 | break; | - |
| 3624 | if (spans[i].y < miny | - |
| 3625 | || spans[i].x > maxx | - |
| 3626 | || spans[i].x + spans[i].len <= minx) { | - |
| 3627 | continue; | - |
| 3628 | } | - |
| 3629 | if (spans[i].x < minx) { | - |
| 3630 | spans[n].len = qMin(spans[i].len - (minx - spans[i].x), maxx - minx + 1); | - |
| 3631 | spans[n].x = minx; | - |
| 3632 | } else { | - |
| 3633 | spans[n].x = spans[i].x; | - |
| 3634 | spans[n].len = qMin(spans[i].len, ushort(maxx - spans[n].x + 1)); | - |
| 3635 | } | - |
| 3636 | if (spans[n].len == 0) | - |
| 3637 | continue; | - |
| 3638 | spans[n].y = spans[i].y; | - |
| 3639 | spans[n].coverage = spans[i].coverage; | - |
| 3640 | ++n; | - |
| 3641 | } | - |
| 3642 | return n; | - |
| 3643 | } | - |
| 3644 | | - |
| 3645 | | - |
| 3646 | static void qt_span_fill_clipRect(int count, const QSpan *spans, | - |
| 3647 | void *userData) | - |
| 3648 | { | - |
| 3649 | QSpanData *fillData = reinterpret_cast<QSpanData *>(userData); | - |
| 3650 | qt_noop(); | - |
| 3651 | | - |
| 3652 | qt_noop(); | - |
| 3653 | qt_noop(); | - |
| 3654 | | - |
| 3655 | | - |
| 3656 | count = qt_intersect_spans(const_cast<QSpan*>(spans), count, | - |
| 3657 | fillData->clip->clipRect); | - |
| 3658 | if (count > 0) | - |
| 3659 | fillData->unclipped_blend(count, spans, fillData); | - |
| 3660 | } | - |
| 3661 | | - |
| 3662 | static void qt_span_clip(int count, const QSpan *spans, void *userData) | - |
| 3663 | { | - |
| 3664 | ClipData *clipData = reinterpret_cast<ClipData *>(userData); | - |
| 3665 | | - |
| 3666 | | - |
| 3667 | | - |
| 3668 | | - |
| 3669 | | - |
| 3670 | | - |
| 3671 | switch (clipData->operation) { | - |
| 3672 | | - |
| 3673 | case Qt::IntersectClip: | - |
| 3674 | { | - |
| 3675 | QClipData *newClip = clipData->newClip; | - |
| 3676 | newClip->initialize(); | - |
| 3677 | | - |
| 3678 | int currentClip = 0; | - |
| 3679 | const QSpan *end = spans + count; | - |
| 3680 | while (spans < end) { | - |
| 3681 | QSpan *newspans = newClip->m_spans + newClip->count; | - |
| 3682 | spans = qt_intersect_spans(clipData->oldClip, ¤tClip, spans, end, | - |
| 3683 | &newspans, newClip->allocated - newClip->count); | - |
| 3684 | newClip->count = newspans - newClip->m_spans; | - |
| 3685 | if (spans < end) { | - |
| 3686 | newClip->m_spans = q_check_ptr((QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan))); | - |
| 3687 | newClip->allocated *= 2; | - |
| 3688 | } | - |
| 3689 | } | - |
| 3690 | } | - |
| 3691 | break; | - |
| 3692 | | - |
| 3693 | case Qt::ReplaceClip: | - |
| 3694 | clipData->newClip->appendSpans(spans, count); | - |
| 3695 | break; | - |
| 3696 | case Qt::NoClip: | - |
| 3697 | break; | - |
| 3698 | } | - |
| 3699 | } | - |
| 3700 | void QRasterBuffer::flushToARGBImage(QImage *target) const | - |
| 3701 | { | - |
| 3702 | int w = qMin(m_width, target->width()); | - |
| 3703 | int h = qMin(m_height, target->height()); | - |
| 3704 | | - |
| 3705 | for (int y=0; y<h; ++y) { | - |
| 3706 | uint *sourceLine = (uint *)const_cast<QRasterBuffer *>(this)->scanLine(y); | - |
| 3707 | QRgb *dest = (QRgb *) target->scanLine(y); | - |
| 3708 | for (int x=0; x<w; ++x) { | - |
| 3709 | QRgb pixel = sourceLine[x]; | - |
| 3710 | int alpha = qAlpha(pixel); | - |
| 3711 | if (!alpha) { | - |
| 3712 | dest[x] = 0; | - |
| 3713 | } else { | - |
| 3714 | dest[x] = (alpha << 24) | - |
| 3715 | | ((255*qRed(pixel)/alpha) << 16) | - |
| 3716 | | ((255*qGreen(pixel)/alpha) << 8) | - |
| 3717 | | ((255*qBlue(pixel)/alpha) << 0); | - |
| 3718 | } | - |
| 3719 | } | - |
| 3720 | } | - |
| 3721 | } | - |
| 3722 | | - |
| 3723 | | - |
| 3724 | class QGradientCache | - |
| 3725 | { | - |
| 3726 | struct CacheInfo | - |
| 3727 | { | - |
| 3728 | inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : | - |
| 3729 | stops(s), opacity(op), interpolationMode(mode) {} | - |
| 3730 | uint buffer[1024]; | - |
| 3731 | QGradientStops stops; | - |
| 3732 | int opacity; | - |
| 3733 | QGradient::InterpolationMode interpolationMode; | - |
| 3734 | }; | - |
| 3735 | | - |
| 3736 | typedef QMultiHash<quint64, CacheInfo> QGradientColorTableHash; | - |
| 3737 | | - |
| 3738 | public: | - |
| 3739 | inline const uint *getBuffer(const QGradient &gradient, int opacity) { | - |
| 3740 | quint64 hash_val = 0; | - |
| 3741 | | - |
| 3742 | QGradientStops stops = gradient.stops(); | - |
| 3743 | for (int i = 0; i < stops.size() && i <= 2; i++) | - |
| 3744 | hash_val += stops[i].second.rgba(); | - |
| 3745 | | - |
| 3746 | QMutexLocker lock(&mutex); | - |
| 3747 | QGradientColorTableHash::const_iterator it = cache.constFind(hash_val); | - |
| 3748 | | - |
| 3749 | if (it == cache.constEnd()) | - |
| 3750 | return addCacheElement(hash_val, gradient, opacity); | - |
| 3751 | else { | - |
| 3752 | do { | - |
| 3753 | const CacheInfo &cache_info = it.value(); | - |
| 3754 | if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode()) | - |
| 3755 | return cache_info.buffer; | - |
| 3756 | ++it; | - |
| 3757 | } while (it != cache.constEnd() && it.key() == hash_val); | - |
| 3758 | | - |
| 3759 | return addCacheElement(hash_val, gradient, opacity); | - |
| 3760 | } | - |
| 3761 | } | - |
| 3762 | | - |
| 3763 | inline int paletteSize() const { return 1024; } | - |
| 3764 | protected: | - |
| 3765 | inline int maxCacheSize() const { return 60; } | - |
| 3766 | inline void generateGradientColorTable(const QGradient& g, | - |
| 3767 | uint *colorTable, | - |
| 3768 | int size, int opacity) const; | - |
| 3769 | uint *addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { | - |
| 3770 | if (cache.size() == maxCacheSize()) { | - |
| 3771 | | - |
| 3772 | cache.erase(cache.begin() + (qrand() % maxCacheSize())); | - |
| 3773 | } | - |
| 3774 | CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode()); | - |
| 3775 | generateGradientColorTable(gradient, cache_entry.buffer, paletteSize(), opacity); | - |
| 3776 | return cache.insert(hash_val, cache_entry).value().buffer; | - |
| 3777 | } | - |
| 3778 | | - |
| 3779 | QGradientColorTableHash cache; | - |
| 3780 | QMutex mutex; | - |
| 3781 | }; | - |
| 3782 | | - |
| 3783 | void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, int opacity) const | - |
| 3784 | { | - |
| 3785 | QGradientStops stops = gradient.stops(); | - |
| 3786 | int stopCount = stops.count(); | - |
| 3787 | qt_noop(); | - |
| 3788 | | - |
| 3789 | bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation); | - |
| 3790 | | - |
| 3791 | if (stopCount == 2) { | - |
| 3792 | uint first_color = ((((stops[0].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[0].second.rgba() & 0x00ffffff); | - |
| 3793 | uint second_color = ((((stops[1].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[1].second.rgba() & 0x00ffffff); | - |
| 3794 | | - |
| 3795 | qreal first_stop = stops[0].first; | - |
| 3796 | qreal second_stop = stops[1].first; | - |
| 3797 | | - |
| 3798 | if (second_stop < first_stop) { | - |
| 3799 | qSwap(first_color, second_color); | - |
| 3800 | qSwap(first_stop, second_stop); | - |
| 3801 | } | - |
| 3802 | | - |
| 3803 | if (colorInterpolation) { | - |
| 3804 | first_color = PREMUL(first_color); | - |
| 3805 | second_color = PREMUL(second_color); | - |
| 3806 | } | - |
| 3807 | | - |
| 3808 | int first_index = qRound(first_stop * (1024 -1)); | - |
| 3809 | int second_index = qRound(second_stop * (1024 -1)); | - |
| 3810 | | - |
| 3811 | uint red_first = qRed(first_color) << 16; | - |
| 3812 | uint green_first = qGreen(first_color) << 16; | - |
| 3813 | uint blue_first = qBlue(first_color) << 16; | - |
| 3814 | uint alpha_first = qAlpha(first_color) << 16; | - |
| 3815 | | - |
| 3816 | uint red_second = qRed(second_color) << 16; | - |
| 3817 | uint green_second = qGreen(second_color) << 16; | - |
| 3818 | uint blue_second = qBlue(second_color) << 16; | - |
| 3819 | uint alpha_second = qAlpha(second_color) << 16; | - |
| 3820 | | - |
| 3821 | int i = 0; | - |
| 3822 | for (; i <= qMin(1024, first_index); ++i) { | - |
| 3823 | if (colorInterpolation) | - |
| 3824 | colorTable[i] = first_color; | - |
| 3825 | else | - |
| 3826 | colorTable[i] = PREMUL(first_color); | - |
| 3827 | } | - |
| 3828 | | - |
| 3829 | if (i < second_index) { | - |
| 3830 | qreal reciprocal = qreal(1) / (second_index - first_index); | - |
| 3831 | | - |
| 3832 | int red_delta = qRound(int(red_second - red_first) * reciprocal); | - |
| 3833 | int green_delta = qRound(int(green_second - green_first) * reciprocal); | - |
| 3834 | int blue_delta = qRound(int(blue_second - blue_first) * reciprocal); | - |
| 3835 | int alpha_delta = qRound(int(alpha_second - alpha_first) * reciprocal); | - |
| 3836 | | - |
| 3837 | | - |
| 3838 | red_first += 1 << 15; | - |
| 3839 | green_first += 1 << 15; | - |
| 3840 | blue_first += 1 << 15; | - |
| 3841 | alpha_first += 1 << 15; | - |
| 3842 | | - |
| 3843 | for (; i < qMin(1024, second_index); ++i) { | - |
| 3844 | red_first += red_delta; | - |
| 3845 | green_first += green_delta; | - |
| 3846 | blue_first += blue_delta; | - |
| 3847 | alpha_first += alpha_delta; | - |
| 3848 | | - |
| 3849 | const uint color = ((alpha_first << 8) & 0xff000000) | (red_first & 0xff0000) | - |
| 3850 | | ((green_first >> 8) & 0xff00) | (blue_first >> 16); | - |
| 3851 | | - |
| 3852 | if (colorInterpolation) | - |
| 3853 | colorTable[i] = color; | - |
| 3854 | else | - |
| 3855 | colorTable[i] = PREMUL(color); | - |
| 3856 | } | - |
| 3857 | } | - |
| 3858 | | - |
| 3859 | for (; i < 1024; ++i) { | - |
| 3860 | if (colorInterpolation) | - |
| 3861 | colorTable[i] = second_color; | - |
| 3862 | else | - |
| 3863 | colorTable[i] = PREMUL(second_color); | - |
| 3864 | } | - |
| 3865 | | - |
| 3866 | return; | - |
| 3867 | } | - |
| 3868 | | - |
| 3869 | uint current_color = ((((stops[0].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[0].second.rgba() & 0x00ffffff); | - |
| 3870 | if (stopCount == 1) { | - |
| 3871 | current_color = PREMUL(current_color); | - |
| 3872 | for (int i = 0; i < size; ++i) | - |
| 3873 | colorTable[i] = current_color; | - |
| 3874 | return; | - |
| 3875 | } | - |
| 3876 | | - |
| 3877 | | - |
| 3878 | qreal begin_pos = stops[0].first; | - |
| 3879 | qreal end_pos = stops[stopCount-1].first; | - |
| 3880 | | - |
| 3881 | int pos = 0; | - |
| 3882 | uint next_color; | - |
| 3883 | | - |
| 3884 | qreal incr = 1 / qreal(size); | - |
| 3885 | qreal dpos = 1.5 * incr; | - |
| 3886 | | - |
| 3887 | | - |
| 3888 | colorTable[pos++] = PREMUL(current_color); | - |
| 3889 | while (dpos <= begin_pos) { | - |
| 3890 | colorTable[pos] = colorTable[pos - 1]; | - |
| 3891 | ++pos; | - |
| 3892 | dpos += incr; | - |
| 3893 | } | - |
| 3894 | | - |
| 3895 | int current_stop = 0; | - |
| 3896 | | - |
| 3897 | qreal t; | - |
| 3898 | qreal t_delta; | - |
| 3899 | | - |
| 3900 | if (dpos < end_pos) { | - |
| 3901 | | - |
| 3902 | while (dpos > stops[current_stop+1].first) | - |
| 3903 | ++current_stop; | - |
| 3904 | | - |
| 3905 | if (current_stop != 0) | - |
| 3906 | current_color = ((((stops[current_stop].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[current_stop].second.rgba() & 0x00ffffff); | - |
| 3907 | next_color = ((((stops[current_stop+1].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[current_stop+1].second.rgba() & 0x00ffffff); | - |
| 3908 | | - |
| 3909 | if (colorInterpolation) { | - |
| 3910 | current_color = PREMUL(current_color); | - |
| 3911 | next_color = PREMUL(next_color); | - |
| 3912 | } | - |
| 3913 | | - |
| 3914 | qreal diff = stops[current_stop+1].first - stops[current_stop].first; | - |
| 3915 | qreal c = (diff == 0) ? qreal(0) : 256 / diff; | - |
| 3916 | t = (dpos - stops[current_stop].first) * c; | - |
| 3917 | t_delta = incr * c; | - |
| 3918 | | - |
| 3919 | while (true) { | - |
| 3920 | qt_noop(); | - |
| 3921 | | - |
| 3922 | int dist = qRound(t); | - |
| 3923 | int idist = 256 - dist; | - |
| 3924 | | - |
| 3925 | if (colorInterpolation) | - |
| 3926 | colorTable[pos] = INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist); | - |
| 3927 | else | - |
| 3928 | colorTable[pos] = PREMUL(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)); | - |
| 3929 | | - |
| 3930 | ++pos; | - |
| 3931 | dpos += incr; | - |
| 3932 | | - |
| 3933 | if (dpos >= end_pos) | - |
| 3934 | break; | - |
| 3935 | | - |
| 3936 | t += t_delta; | - |
| 3937 | | - |
| 3938 | int skip = 0; | - |
| 3939 | while (dpos > stops[current_stop+skip+1].first) | - |
| 3940 | ++skip; | - |
| 3941 | | - |
| 3942 | if (skip != 0) { | - |
| 3943 | current_stop += skip; | - |
| 3944 | if (skip == 1) | - |
| 3945 | current_color = next_color; | - |
| 3946 | else | - |
| 3947 | current_color = ((((stops[current_stop].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[current_stop].second.rgba() & 0x00ffffff); | - |
| 3948 | next_color = ((((stops[current_stop+1].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[current_stop+1].second.rgba() & 0x00ffffff); | - |
| 3949 | | - |
| 3950 | if (colorInterpolation) { | - |
| 3951 | if (skip != 1) | - |
| 3952 | current_color = PREMUL(current_color); | - |
| 3953 | next_color = PREMUL(next_color); | - |
| 3954 | } | - |
| 3955 | | - |
| 3956 | qreal diff = stops[current_stop+1].first - stops[current_stop].first; | - |
| 3957 | qreal c = (diff == 0) ? qreal(0) : 256 / diff; | - |
| 3958 | t = (dpos - stops[current_stop].first) * c; | - |
| 3959 | t_delta = incr * c; | - |
| 3960 | } | - |
| 3961 | } | - |
| 3962 | } | - |
| 3963 | | - |
| 3964 | | - |
| 3965 | current_color = PREMUL(((((stops[stopCount - 1].second.rgba() >> 24) * opacity) >> 8) << 24) | (stops[stopCount - 1].second.rgba() & 0x00ffffff)); | - |
| 3966 | while (pos < size - 1) { | - |
| 3967 | colorTable[pos] = current_color; | - |
| 3968 | ++pos; | - |
| 3969 | } | - |
| 3970 | | - |
| 3971 | | - |
| 3972 | colorTable[size - 1] = current_color; | - |
| 3973 | } | - |
| 3974 | | - |
| 3975 | static QGradientCache *qt_gradient_cache() { static QGlobalStatic<QGradientCache > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QGradientCache *x = new QGradientCache; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QGradientCache > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } | - |
| 3976 | | - |
| 3977 | | - |
| 3978 | void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe) | - |
| 3979 | { | - |
| 3980 | rasterBuffer = rb; | - |
| 3981 | type = None; | - |
| 3982 | txop = 0; | - |
| 3983 | bilinear = false; | - |
| 3984 | m11 = m22 = m33 = 1.; | - |
| 3985 | m12 = m13 = m21 = m23 = dx = dy = 0.0; | - |
| 3986 | clip = pe ? pe->d_func()->clip() : 0; | - |
| 3987 | } | - |
| 3988 | | - |
| 3989 | __attribute__((visibility("default"))) extern QImage qt_imageForBrush(int brushStyle, bool invert); | - |
| 3990 | | - |
| 3991 | void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode) | - |
| 3992 | { | - |
| 3993 | Qt::BrushStyle brushStyle = qbrush_style(brush); | - |
| 3994 | switch (brushStyle) { | - |
| 3995 | case Qt::SolidPattern: { | - |
| 3996 | type = Solid; | - |
| 3997 | QColor c = qbrush_color(brush); | - |
| 3998 | QRgb rgba = c.rgba(); | - |
| 3999 | solid.color = PREMUL(((((rgba >> 24) * alpha) >> 8) << 24) | (rgba & 0x00ffffff)); | - |
| 4000 | if ((solid.color & 0xff000000) == 0 | - |
| 4001 | && compositionMode == QPainter::CompositionMode_SourceOver) { | - |
| 4002 | type = None; | - |
| 4003 | } | - |
| 4004 | break; | - |
| 4005 | } | - |
| 4006 | | - |
| 4007 | case Qt::LinearGradientPattern: | - |
| 4008 | { | - |
| 4009 | type = LinearGradient; | - |
| 4010 | const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient()); | - |
| 4011 | gradient.alphaColor = !brush.isOpaque() || alpha != 256; | - |
| 4012 | gradient.colorTable = const_cast<uint*>(qt_gradient_cache()->getBuffer(*g, alpha)); | - |
| 4013 | gradient.spread = g->spread(); | - |
| 4014 | | - |
| 4015 | QLinearGradientData &linearData = gradient.linear; | - |
| 4016 | | - |
| 4017 | linearData.origin.x = g->start().x(); | - |
| 4018 | linearData.origin.y = g->start().y(); | - |
| 4019 | linearData.end.x = g->finalStop().x(); | - |
| 4020 | linearData.end.y = g->finalStop().y(); | - |
| 4021 | break; | - |
| 4022 | } | - |
| 4023 | | - |
| 4024 | case Qt::RadialGradientPattern: | - |
| 4025 | { | - |
| 4026 | type = RadialGradient; | - |
| 4027 | const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient()); | - |
| 4028 | gradient.alphaColor = !brush.isOpaque() || alpha != 256; | - |
| 4029 | gradient.colorTable = const_cast<uint*>(qt_gradient_cache()->getBuffer(*g, alpha)); | - |
| 4030 | gradient.spread = g->spread(); | - |
| 4031 | | - |
| 4032 | QRadialGradientData &radialData = gradient.radial; | - |
| 4033 | | - |
| 4034 | QPointF center = g->center(); | - |
| 4035 | radialData.center.x = center.x(); | - |
| 4036 | radialData.center.y = center.y(); | - |
| 4037 | radialData.center.radius = g->centerRadius(); | - |
| 4038 | QPointF focal = g->focalPoint(); | - |
| 4039 | radialData.focal.x = focal.x(); | - |
| 4040 | radialData.focal.y = focal.y(); | - |
| 4041 | radialData.focal.radius = g->focalRadius(); | - |
| 4042 | } | - |
| 4043 | break; | - |
| 4044 | | - |
| 4045 | case Qt::ConicalGradientPattern: | - |
| 4046 | { | - |
| 4047 | type = ConicalGradient; | - |
| 4048 | const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient()); | - |
| 4049 | gradient.alphaColor = !brush.isOpaque() || alpha != 256; | - |
| 4050 | gradient.colorTable = const_cast<uint*>(qt_gradient_cache()->getBuffer(*g, alpha)); | - |
| 4051 | gradient.spread = QGradient::RepeatSpread; | - |
| 4052 | | - |
| 4053 | QConicalGradientData &conicalData = gradient.conical; | - |
| 4054 | | - |
| 4055 | QPointF center = g->center(); | - |
| 4056 | conicalData.center.x = center.x(); | - |
| 4057 | conicalData.center.y = center.y(); | - |
| 4058 | conicalData.angle = g->angle() * 2 * Q_PI / 360.0; | - |
| 4059 | } | - |
| 4060 | break; | - |
| 4061 | | - |
| 4062 | case Qt::Dense1Pattern: | - |
| 4063 | case Qt::Dense2Pattern: | - |
| 4064 | case Qt::Dense3Pattern: | - |
| 4065 | case Qt::Dense4Pattern: | - |
| 4066 | case Qt::Dense5Pattern: | - |
| 4067 | case Qt::Dense6Pattern: | - |
| 4068 | case Qt::Dense7Pattern: | - |
| 4069 | case Qt::HorPattern: | - |
| 4070 | case Qt::VerPattern: | - |
| 4071 | case Qt::CrossPattern: | - |
| 4072 | case Qt::BDiagPattern: | - |
| 4073 | case Qt::FDiagPattern: | - |
| 4074 | case Qt::DiagCrossPattern: | - |
| 4075 | type = Texture; | - |
| 4076 | if (!tempImage) | - |
| 4077 | tempImage = new QImage(); | - |
| 4078 | *tempImage = rasterBuffer->colorizeBitmap(qt_imageForBrush(brushStyle, true), brush.color()); | - |
| 4079 | initTexture(tempImage, alpha, QTextureData::Tiled); | - |
| 4080 | break; | - |
| 4081 | case Qt::TexturePattern: | - |
| 4082 | type = Texture; | - |
| 4083 | if (!tempImage) | - |
| 4084 | tempImage = new QImage(); | - |
| 4085 | | - |
| 4086 | if (qHasPixmapTexture(brush) && brush.texture().isQBitmap()) | - |
| 4087 | *tempImage = rasterBuffer->colorizeBitmap(brush.textureImage(), brush.color()); | - |
| 4088 | else | - |
| 4089 | *tempImage = brush.textureImage(); | - |
| 4090 | initTexture(tempImage, alpha, QTextureData::Tiled, tempImage->rect()); | - |
| 4091 | break; | - |
| 4092 | | - |
| 4093 | case Qt::NoBrush: | - |
| 4094 | default: | - |
| 4095 | type = None; | - |
| 4096 | break; | - |
| 4097 | } | - |
| 4098 | adjustSpanMethods(); | - |
| 4099 | } | - |
| 4100 | | - |
| 4101 | void QSpanData::adjustSpanMethods() | - |
| 4102 | { | - |
| 4103 | bitmapBlit = 0; | - |
| 4104 | alphamapBlit = 0; | - |
| 4105 | alphaRGBBlit = 0; | - |
| 4106 | | - |
| 4107 | fillRect = 0; | - |
| 4108 | | - |
| 4109 | switch(type) { | - |
| 4110 | case None: | - |
| 4111 | unclipped_blend = 0; | - |
| 4112 | break; | - |
| 4113 | case Solid: | - |
| 4114 | unclipped_blend = rasterBuffer->drawHelper->blendColor; | - |
| 4115 | bitmapBlit = rasterBuffer->drawHelper->bitmapBlit; | - |
| 4116 | alphamapBlit = rasterBuffer->drawHelper->alphamapBlit; | - |
| 4117 | alphaRGBBlit = rasterBuffer->drawHelper->alphaRGBBlit; | - |
| 4118 | fillRect = rasterBuffer->drawHelper->fillRect; | - |
| 4119 | break; | - |
| 4120 | case LinearGradient: | - |
| 4121 | case RadialGradient: | - |
| 4122 | case ConicalGradient: | - |
| 4123 | unclipped_blend = rasterBuffer->drawHelper->blendGradient; | - |
| 4124 | break; | - |
| 4125 | case Texture: | - |
| 4126 | unclipped_blend = qBlendTexture; | - |
| 4127 | if (!texture.imageData) | - |
| 4128 | unclipped_blend = 0; | - |
| 4129 | | - |
| 4130 | break; | - |
| 4131 | } | - |
| 4132 | | - |
| 4133 | if (!unclipped_blend) { | - |
| 4134 | blend = 0; | - |
| 4135 | } else if (!clip) { | - |
| 4136 | blend = unclipped_blend; | - |
| 4137 | } else if (clip->hasRectClip) { | - |
| 4138 | blend = clip->clipRect.isEmpty() ? 0 : qt_span_fill_clipRect; | - |
| 4139 | } else { | - |
| 4140 | blend = qt_span_fill_clipped; | - |
| 4141 | } | - |
| 4142 | } | - |
| 4143 | | - |
| 4144 | void QSpanData::setupMatrix(const QTransform &matrix, int bilin) | - |
| 4145 | { | - |
| 4146 | QTransform delta; | - |
| 4147 | | - |
| 4148 | delta.translate(1.0 / 65536, 1.0 / 65536); | - |
| 4149 | | - |
| 4150 | QTransform inv = (delta * matrix).inverted(); | - |
| 4151 | m11 = inv.m11(); | - |
| 4152 | m12 = inv.m12(); | - |
| 4153 | m13 = inv.m13(); | - |
| 4154 | m21 = inv.m21(); | - |
| 4155 | m22 = inv.m22(); | - |
| 4156 | m23 = inv.m23(); | - |
| 4157 | m33 = inv.m33(); | - |
| 4158 | dx = inv.dx(); | - |
| 4159 | dy = inv.dy(); | - |
| 4160 | txop = inv.type(); | - |
| 4161 | bilinear = bilin; | - |
| 4162 | | - |
| 4163 | const bool affine = inv.isAffine(); | - |
| 4164 | fast_matrix = affine | - |
| 4165 | && m11 * m11 + m21 * m21 < 1e4 | - |
| 4166 | && m12 * m12 + m22 * m22 < 1e4 | - |
| 4167 | && qAbs(dx) < 1e4 | - |
| 4168 | && qAbs(dy) < 1e4; | - |
| 4169 | | - |
| 4170 | adjustSpanMethods(); | - |
| 4171 | } | - |
| 4172 | | - |
| 4173 | void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _type, const QRect &sourceRect) | - |
| 4174 | { | - |
| 4175 | const QImageData *d = const_cast<QImage *>(image)->data_ptr(); | - |
| 4176 | if (!d || d->height == 0) { | - |
| 4177 | texture.imageData = 0; | - |
| 4178 | texture.width = 0; | - |
| 4179 | texture.height = 0; | - |
| 4180 | texture.x1 = 0; | - |
| 4181 | texture.y1 = 0; | - |
| 4182 | texture.x2 = 0; | - |
| 4183 | texture.y2 = 0; | - |
| 4184 | texture.bytesPerLine = 0; | - |
| 4185 | texture.format = QImage::Format_Invalid; | - |
| 4186 | texture.colorTable = 0; | - |
| 4187 | texture.hasAlpha = alpha != 256; | - |
| 4188 | } else { | - |
| 4189 | texture.imageData = d->data; | - |
| 4190 | texture.width = d->width; | - |
| 4191 | texture.height = d->height; | - |
| 4192 | | - |
| 4193 | if (sourceRect.isNull()) { | - |
| 4194 | texture.x1 = 0; | - |
| 4195 | texture.y1 = 0; | - |
| 4196 | texture.x2 = texture.width; | - |
| 4197 | texture.y2 = texture.height; | - |
| 4198 | } else { | - |
| 4199 | texture.x1 = sourceRect.x(); | - |
| 4200 | texture.y1 = sourceRect.y(); | - |
| 4201 | texture.x2 = qMin(texture.x1 + sourceRect.width(), d->width); | - |
| 4202 | texture.y2 = qMin(texture.y1 + sourceRect.height(), d->height); | - |
| 4203 | } | - |
| 4204 | | - |
| 4205 | texture.bytesPerLine = d->bytes_per_line; | - |
| 4206 | | - |
| 4207 | texture.format = d->format; | - |
| 4208 | texture.colorTable = (d->format <= QImage::Format_Indexed8 && !d->colortable.isEmpty()) ? &d->colortable : 0; | - |
| 4209 | texture.hasAlpha = image->hasAlphaChannel() || alpha != 256; | - |
| 4210 | } | - |
| 4211 | texture.const_alpha = alpha; | - |
| 4212 | texture.type = _type; | - |
| 4213 | | - |
| 4214 | adjustSpanMethods(); | - |
| 4215 | } | - |
| 4216 | | - |
| 4217 | | - |
| 4218 | | - |
| 4219 | | - |
| 4220 | | - |
| 4221 | static inline void drawEllipsePoints(int x, int y, int length, | - |
| 4222 | const QRect &rect, | - |
| 4223 | const QRect &clip, | - |
| 4224 | ProcessSpans pen_func, ProcessSpans brush_func, | - |
| 4225 | QSpanData *pen_data, QSpanData *brush_data) | - |
| 4226 | { | - |
| 4227 | if (length == 0) | - |
| 4228 | return; | - |
| 4229 | | - |
| 4230 | QT_FT_Span outline[4]; | - |
| 4231 | const int midx = rect.x() + (rect.width() + 1) / 2; | - |
| 4232 | const int midy = rect.y() + (rect.height() + 1) / 2; | - |
| 4233 | | - |
| 4234 | x = x + midx; | - |
| 4235 | y = midy - y; | - |
| 4236 | | - |
| 4237 | | - |
| 4238 | outline[0].x = midx + (midx - x) - (length - 1) - (rect.width() & 0x1); | - |
| 4239 | outline[0].len = qMin(length, x - outline[0].x); | - |
| 4240 | outline[0].y = y; | - |
| 4241 | outline[0].coverage = 255; | - |
| 4242 | | - |
| 4243 | | - |
| 4244 | outline[1].x = x; | - |
| 4245 | outline[1].len = length; | - |
| 4246 | outline[1].y = y; | - |
| 4247 | outline[1].coverage = 255; | - |
| 4248 | | - |
| 4249 | | - |
| 4250 | outline[2].x = outline[0].x; | - |
| 4251 | outline[2].len = outline[0].len; | - |
| 4252 | outline[2].y = midy + (midy - y) - (rect.height() & 0x1); | - |
| 4253 | outline[2].coverage = 255; | - |
| 4254 | | - |
| 4255 | | - |
| 4256 | outline[3].x = x; | - |
| 4257 | outline[3].len = length; | - |
| 4258 | outline[3].y = outline[2].y; | - |
| 4259 | outline[3].coverage = 255; | - |
| 4260 | | - |
| 4261 | if (brush_func && outline[0].x + outline[0].len < outline[1].x) { | - |
| 4262 | QT_FT_Span fill[2]; | - |
| 4263 | | - |
| 4264 | | - |
| 4265 | fill[0].x = outline[0].x + outline[0].len - 1; | - |
| 4266 | fill[0].len = qMax(0, outline[1].x - fill[0].x); | - |
| 4267 | fill[0].y = outline[1].y; | - |
| 4268 | fill[0].coverage = 255; | - |
| 4269 | | - |
| 4270 | | - |
| 4271 | fill[1].x = outline[2].x + outline[2].len - 1; | - |
| 4272 | fill[1].len = qMax(0, outline[3].x - fill[1].x); | - |
| 4273 | fill[1].y = outline[3].y; | - |
| 4274 | fill[1].coverage = 255; | - |
| 4275 | | - |
| 4276 | int n = (fill[0].y >= fill[1].y ? 1 : 2); | - |
| 4277 | n = qt_intersect_spans(fill, n, clip); | - |
| 4278 | if (n > 0) | - |
| 4279 | brush_func(n, fill, brush_data); | - |
| 4280 | } | - |
| 4281 | if (pen_func) { | - |
| 4282 | int n = (outline[1].y >= outline[2].y ? 2 : 4); | - |
| 4283 | n = qt_intersect_spans(outline, n, clip); | - |
| 4284 | if (n > 0) | - |
| 4285 | pen_func(n, outline, pen_data); | - |
| 4286 | } | - |
| 4287 | } | - |
| 4288 | | - |
| 4289 | | - |
| 4290 | | - |
| 4291 | | - |
| 4292 | | - |
| 4293 | static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, | - |
| 4294 | ProcessSpans pen_func, ProcessSpans brush_func, | - |
| 4295 | QSpanData *pen_data, QSpanData *brush_data) | - |
| 4296 | { | - |
| 4297 | const qreal a = qreal(rect.width()) / 2; | - |
| 4298 | const qreal b = qreal(rect.height()) / 2; | - |
| 4299 | qreal d = b*b - (a*a*b) + 0.25*a*a; | - |
| 4300 | | - |
| 4301 | int x = 0; | - |
| 4302 | int y = (rect.height() + 1) / 2; | - |
| 4303 | int startx = x; | - |
| 4304 | | - |
| 4305 | | - |
| 4306 | while (a*a*(2*y - 1) > 2*b*b*(x + 1)) { | - |
| 4307 | if (d < 0) { | - |
| 4308 | d += b*b*(2*x + 3); | - |
| 4309 | ++x; | - |
| 4310 | } else { | - |
| 4311 | d += b*b*(2*x + 3) + a*a*(-2*y + 2); | - |
| 4312 | drawEllipsePoints(startx, y, x - startx + 1, rect, clip, | - |
| 4313 | pen_func, brush_func, pen_data, brush_data); | - |
| 4314 | startx = ++x; | - |
| 4315 | --y; | - |
| 4316 | } | - |
| 4317 | } | - |
| 4318 | drawEllipsePoints(startx, y, x - startx + 1, rect, clip, | - |
| 4319 | pen_func, brush_func, pen_data, brush_data); | - |
| 4320 | | - |
| 4321 | | - |
| 4322 | d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b); | - |
| 4323 | const int miny = rect.height() & 0x1; | - |
| 4324 | while (y > miny) { | - |
| 4325 | if (d < 0) { | - |
| 4326 | d += b*b*(2*x + 2) + a*a*(-2*y + 3); | - |
| 4327 | ++x; | - |
| 4328 | } else { | - |
| 4329 | d += a*a*(-2*y + 3); | - |
| 4330 | } | - |
| 4331 | --y; | - |
| 4332 | drawEllipsePoints(x, y, 1, rect, clip, | - |
| 4333 | pen_func, brush_func, pen_data, brush_data); | - |
| 4334 | } | - |
| 4335 | } | - |
| 4336 | | - |
| 4337 | | - |
| | |