summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2015-03-09 19:18:27 +0100
committerDavid Edmundson <davidedmundson@kde.org>2015-03-09 21:14:16 +0000
commit4c0c53742140ef6f35a5258e79f62a202fe9832e (patch)
tree51496b78031a5686a047a7bfdb4ef31cf0279d86 /src/gui/image
parent1cc8ec1e78cedcf4600b216978b3b08bf08ddf66 (diff)
Avoid detaching pixmaps when it has not changed
setDevicePixelRatio is often called unconditionally even when the devicePixelRatio matches the pixmap or image. This causes a lot of unncessary detaches wasting some memory. Change-Id: I27535b2b22312ec0edc9bdc00c99d322afb727c1 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qimage.cpp4
-rw-r--r--src/gui/image/qpixmap.cpp3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index e33ab24243..dba42d4698 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1433,6 +1433,10 @@ void QImage::setDevicePixelRatio(qreal scaleFactor)
{
if (!d)
return;
+
+ if (scaleFactor == d->devicePixelRatio)
+ return;
+
detach();
d->devicePixelRatio = scaleFactor;
}
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 0a9b55ed24..db6ae54d26 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -682,6 +682,9 @@ void QPixmap::setDevicePixelRatio(qreal scaleFactor)
if (isNull())
return;
+ if (scaleFactor == data->devicePixelRatio())
+ return;
+
detach();
data->setDevicePixelRatio(scaleFactor);
}