diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-06-22 11:24:26 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-06-23 08:45:11 (GMT) |
commit | fb76a872e20bd0df8e7bbe9c039b7f20423c6f12 (patch) | |
tree | c01d5f47cad65a056eb6edc1cab11c628b11e2f8 /src/gui/painting | |
parent | eaf886318568bfbd9aa1722586264c8fdf90df12 (diff) | |
download | Qt-fb76a872e20bd0df8e7bbe9c039b7f20423c6f12.zip Qt-fb76a872e20bd0df8e7bbe9c039b7f20423c6f12.tar.gz Qt-fb76a872e20bd0df8e7bbe9c039b7f20423c6f12.tar.bz2 |
Optimized sub-rect copying / painting of QPixmaps.
Prevented downloading of the whole XImage by introducing new
QPixmapData::toImage() overload taking a sub-rect. Also avoid an
additional copy by simply taking ownership of the XImage data when
the XImage format matches the QImage format.
Reviewed-by: Trond
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 94e5cbc..84b36c7 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2419,7 +2419,9 @@ void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, cons drawImage(r, image, sr); } } else { - const QImage image = pixmap.toImage(); + QRect clippedSource = sr.toAlignedRect().intersected(pixmap.rect()); + const QImage image = pd->toImage(clippedSource); + QRectF translatedSource = sr.translated(-clippedSource.topLeft()); if (image.depth() == 1) { Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); @@ -2430,10 +2432,10 @@ void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, cons drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData); return; } else { - drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr); + drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), translatedSource); } } else { - drawImage(r, image, sr); + drawImage(r, image, translatedSource); } } } |