diff options
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 127 |
1 files changed, 63 insertions, 64 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 90b6d16551..0f5c7756ad 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -873,7 +873,7 @@ void QRasterPaintEngine::updateRasterState() && s->intOpacity == 256 && (mode == QPainter::CompositionMode_Source || (mode == QPainter::CompositionMode_SourceOver - && s->penData.solid.color.isOpaque())); + && s->penData.solidColor.isOpaque())); } s->dirty = 0; @@ -1536,9 +1536,9 @@ static void fillRect_normalized(const QRect &r, QSpanData *data, if (data->fillRect && (mode == QPainter::CompositionMode_Source || (mode == QPainter::CompositionMode_SourceOver - && data->solid.color.isOpaque()))) + && data->solidColor.isOpaque()))) { - data->fillRect(data->rasterBuffer, x1, y1, width, height, data->solid.color); + data->fillRect(data->rasterBuffer, x1, y1, width, height, data->solidColor); return; } } @@ -1900,9 +1900,9 @@ void QRasterPaintEngine::fillRect(const QRectF &r, const QColor &color) Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); - d->solid_color_filler.solid.color = qPremultiply(combineAlpha256(color.rgba64(), s->intOpacity)); + d->solid_color_filler.solidColor = qPremultiply(combineAlpha256(color.rgba64(), s->intOpacity)); - if (d->solid_color_filler.solid.color.isTransparent() + if (d->solid_color_filler.solidColor.isTransparent() && s->composition_mode == QPainter::CompositionMode_SourceOver) { return; } @@ -2356,14 +2356,14 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe case QImage::Format_A2BGR30_Premultiplied: case QImage::Format_A2RGB30_Premultiplied: // Combine premultiplied color with the opacity set on the painter. - d->solid_color_filler.solid.color = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity); + d->solid_color_filler.solidColor = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity); break; default: - d->solid_color_filler.solid.color = qPremultiply(combineAlpha256(QRgba64::fromArgb32(color), s->intOpacity)); + d->solid_color_filler.solidColor = qPremultiply(combineAlpha256(QRgba64::fromArgb32(color), s->intOpacity)); break; } - if (d->solid_color_filler.solid.color.isTransparent() && s->composition_mode == QPainter::CompositionMode_SourceOver) + if (d->solid_color_filler.solidColor.isTransparent() && s->composition_mode == QPainter::CompositionMode_SourceOver) return; d->solid_color_filler.clip = d->clip(); @@ -2713,20 +2713,20 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx if (unclipped) { if (depth == 1) { if (s->penData.bitmapBlit) { - s->penData.bitmapBlit(rb, rx, ry, s->penData.solid.color, + s->penData.bitmapBlit(rb, rx, ry, s->penData.solidColor, scanline, w, h, bpl); return; } } else if (depth == 8) { if (s->penData.alphamapBlit) { - s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, + s->penData.alphamapBlit(rb, rx, ry, s->penData.solidColor, scanline, w, h, bpl, 0, useGammaCorrection); return; } } else if (depth == 32) { // (A)RGB Alpha mask where the alpha component is not used. if (s->penData.alphaRGBBlit) { - s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, + s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solidColor, (const uint *) scanline, w, h, bpl / 4, 0, useGammaCorrection); return; } @@ -2755,10 +2755,10 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx ry = ny; } if (depth == 8) - s->penData.alphamapBlit(rb, rx, ry, s->penData.solid.color, + s->penData.alphamapBlit(rb, rx, ry, s->penData.solidColor, scanline, w, h, bpl, clip, useGammaCorrection); else if (depth == 32) - s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solid.color, + s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solidColor, (const uint *) scanline, w, h, bpl / 4, clip, useGammaCorrection); return; } @@ -3835,7 +3835,6 @@ QImage::Format QRasterBuffer::prepare(QImage *image) bytes_per_line = image->bytesPerLine(); format = image->format(); - drawHelper = qDrawHelper + format; if (image->depth() == 1 && image->colorTable().size() == 2) { monoDestinationWithClut = true; const QVector<QRgb> colorTable = image->colorTable(); @@ -3883,51 +3882,15 @@ void QClipData::initialize() Q_CHECK_PTR(m_clipLines); QT_TRY { - m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan)); allocated = clipSpanHeight; - Q_CHECK_PTR(m_spans); - QT_TRY { - if (hasRectClip) { - int y = 0; - while (y < ymin) { - m_clipLines[y].spans = 0; - m_clipLines[y].count = 0; - ++y; - } - - const int len = clipRect.width(); - count = 0; - while (y < ymax) { - QSpan *span = m_spans + count; - span->x = xmin; - span->len = len; - span->y = y; - span->coverage = 255; - ++count; - - m_clipLines[y].spans = span; - m_clipLines[y].count = 1; - ++y; - } - - while (y < clipSpanHeight) { - m_clipLines[y].spans = 0; - m_clipLines[y].count = 0; - ++y; - } - } else if (hasRegionClip) { - + if (hasRegionClip) { const auto rects = clipRegion.begin(); const int numRects = clipRegion.rectCount(); - - { // resize - const int maxSpans = (ymax - ymin) * numRects; - if (maxSpans > allocated) { - m_spans = q_check_ptr((QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan))); - allocated = maxSpans; - } - } + const int maxSpans = (ymax - ymin) * numRects; + allocated = qMax(allocated, maxSpans); + m_spans = (QSpan *)malloc(allocated * sizeof(QSpan)); + Q_CHECK_PTR(m_spans); int y = 0; int firstInBand = 0; @@ -3974,6 +3937,40 @@ void QClipData::initialize() ++y; } + return; + } + + m_spans = (QSpan *)malloc(allocated * sizeof(QSpan)); + Q_CHECK_PTR(m_spans); + + if (hasRectClip) { + int y = 0; + while (y < ymin) { + m_clipLines[y].spans = 0; + m_clipLines[y].count = 0; + ++y; + } + + const int len = clipRect.width(); + count = 0; + while (y < ymax) { + QSpan *span = m_spans + count; + span->x = xmin; + span->len = len; + span->y = y; + span->coverage = 255; + ++count; + + m_clipLines[y].spans = span; + m_clipLines[y].count = 1; + ++y; + } + + while (y < clipSpanHeight) { + m_clipLines[y].spans = 0; + m_clipLines[y].count = 0; + ++y; + } } } QT_CATCH(...) { free(m_spans); // have to free m_spans again or someone might think that we were successfully initialized. @@ -4596,8 +4593,8 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode case Qt::SolidPattern: { type = Solid; QColor c = qbrush_color(brush); - solid.color = qPremultiply(combineAlpha256(c.rgba64(), alpha)); - if (solid.color.isTransparent() && compositionMode == QPainter::CompositionMode_SourceOver) + solidColor = qPremultiply(combineAlpha256(c.rgba64(), alpha)); + if (solidColor.isTransparent() && compositionMode == QPainter::CompositionMode_SourceOver) type = None; break; } @@ -4723,17 +4720,19 @@ void QSpanData::adjustSpanMethods() case None: unclipped_blend = 0; break; - case Solid: - unclipped_blend = rasterBuffer->drawHelper->blendColor; - bitmapBlit = rasterBuffer->drawHelper->bitmapBlit; - alphamapBlit = rasterBuffer->drawHelper->alphamapBlit; - alphaRGBBlit = rasterBuffer->drawHelper->alphaRGBBlit; - fillRect = rasterBuffer->drawHelper->fillRect; + case Solid: { + const DrawHelper &drawHelper = qDrawHelper[rasterBuffer->format]; + unclipped_blend = drawHelper.blendColor; + bitmapBlit = drawHelper.bitmapBlit; + alphamapBlit = drawHelper.alphamapBlit; + alphaRGBBlit = drawHelper.alphaRGBBlit; + fillRect = drawHelper.fillRect; break; + } case LinearGradient: case RadialGradient: case ConicalGradient: - unclipped_blend = rasterBuffer->drawHelper->blendGradient; + unclipped_blend = qBlendGradient; break; case Texture: unclipped_blend = qBlendTexture; |