summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-10-19 10:17:34 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-10-19 10:31:42 (GMT)
commit8182dc12b88727c647f9bac4d9a19914e3cd8307 (patch)
treef78e8c4d0bb916eff6d91ee742ba2e596bfa656e /src/gui/image
parent62b884a0ff3d9285b2ea4e1513dfe9e49f7edc5b (diff)
downloadQt-8182dc12b88727c647f9bac4d9a19914e3cd8307.zip
Qt-8182dc12b88727c647f9bac4d9a19914e3cd8307.tar.gz
Qt-8182dc12b88727c647f9bac4d9a19914e3cd8307.tar.bz2
Fixed slow QPixmap::fill() when the pixmap is sharing data.
If the pixmap is sharing data with other pixmaps, it must be detached before it is filled. Instead of detaching by making a copy, create a new uninitialized data object since all pixels are overwritten by fill() anyway. Task-number: QTBUG-3228 Reviewed-by: Trond
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index c03a364..bf6c9ae 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -959,7 +959,17 @@ void QPixmap::fill(const QColor &color)
return;
}
- detach();
+ if (data->ref == 1) {
+ // detach() will also remove this pixmap from caches, so
+ // it has to be called even when ref == 1.
+ detach();
+ } else {
+ // Don't bother to make a copy of the data object, since
+ // it will be filled with new pixel data anyway.
+ QPixmapData *d = data->createCompatiblePixmapData();
+ d->resize(data->width(), data->height());
+ data = d;
+ }
data->fill(color);
}