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>bb10
parent
1cc8ec1e78
commit
4c0c537421
|
|
@ -1433,6 +1433,10 @@ void QImage::setDevicePixelRatio(qreal scaleFactor)
|
|||
{
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
if (scaleFactor == d->devicePixelRatio)
|
||||
return;
|
||||
|
||||
detach();
|
||||
d->devicePixelRatio = scaleFactor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -682,6 +682,9 @@ void QPixmap::setDevicePixelRatio(qreal scaleFactor)
|
|||
if (isNull())
|
||||
return;
|
||||
|
||||
if (scaleFactor == data->devicePixelRatio())
|
||||
return;
|
||||
|
||||
detach();
|
||||
data->setDevicePixelRatio(scaleFactor);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue