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/image/qpixmapdata.cpp | |
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/image/qpixmapdata.cpp')
-rw-r--r-- | src/gui/image/qpixmapdata.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 31ca909..345e3cf 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -146,7 +146,7 @@ bool QPixmapData::fromData(const uchar *buf, uint len, const char *format, Qt::I void QPixmapData::copy(const QPixmapData *data, const QRect &rect) { - fromImage(data->toImage().copy(rect), Qt::NoOpaqueDetection); + fromImage(data->toImage(rect), Qt::NoOpaqueDetection); } bool QPixmapData::scroll(int dx, int dy, const QRect &rect) @@ -255,6 +255,14 @@ void QPixmapData::setSerialNumber(int serNo) ser_no = serNo; } +QImage QPixmapData::toImage(const QRect &rect) const +{ + if (rect.contains(QRect(0, 0, w, h))) + return toImage(); + else + return toImage().copy(rect); +} + QImage* QPixmapData::buffer() { return 0; |