summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2010-04-06 14:08:20 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2010-04-06 14:19:23 (GMT)
commitce0af99f47c1728a6d8145ea89f41b1c9207104a (patch)
tree974919a7c185894f6d8c1da6c5ddf120f7c54ee9 /src
parent0d4e512c2dd9a13aa19cbd6d28209f2dc00a0cf8 (diff)
downloadQt-ce0af99f47c1728a6d8145ea89f41b1c9207104a.zip
Qt-ce0af99f47c1728a6d8145ea89f41b1c9207104a.tar.gz
Qt-ce0af99f47c1728a6d8145ea89f41b1c9207104a.tar.bz2
Prevented unnecessary copy in QImage::setAlphaChannel().
If the formats don't match the detch is unnecessary as operator= will anyways destroy the detached QImageData and substitute it with the newly created QImageData from convertToFormat. Task-number: QTBUG-9640 Reviewed-by: Trond
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qimage.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 233c58d..ce1d6d3 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -5704,9 +5704,10 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
return;
}
- detach();
-
- *this = convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ if (d->format == QImage::Format_ARGB32_Premultiplied)
+ detach();
+ else
+ *this = convertToFormat(QImage::Format_ARGB32_Premultiplied);
// Slight optimization since alphachannels are returned as 8-bit grays.
if (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale()) {