mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
avoid image copy in QRasterPixmapData::fromImage()
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
159ce748e8
commit
9c85f796af
2 changed files with 5 additions and 15 deletions
|
@ -101,15 +101,14 @@ bool QRasterPixmapData::fromData(const uchar *buffer, uint len, const char *form
|
|||
if (image.isNull())
|
||||
return false;
|
||||
|
||||
createPixmapForImage(image, flags, /* inplace = */true);
|
||||
createPixmapForImage(image, flags);
|
||||
return !isNull();
|
||||
}
|
||||
|
||||
void QRasterPixmapData::fromImage(const QImage &sourceImage,
|
||||
Qt::ImageConversionFlags flags)
|
||||
{
|
||||
QImage image = sourceImage;
|
||||
createPixmapForImage(image, flags, /* inplace = */false);
|
||||
createPixmapForImage(sourceImage, flags);
|
||||
}
|
||||
|
||||
void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
|
||||
|
@ -119,7 +118,7 @@ void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
|
|||
if (image.isNull())
|
||||
return;
|
||||
|
||||
createPixmapForImage(image, flags, /* inplace = */true);
|
||||
createPixmapForImage(image, flags);
|
||||
}
|
||||
|
||||
// from qwindowsurface.cpp
|
||||
|
@ -270,7 +269,7 @@ int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
void QRasterPixmapData::createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace)
|
||||
void QRasterPixmapData::createPixmapForImage(const QImage &sourceImage, Qt::ImageConversionFlags flags)
|
||||
{
|
||||
QImage::Format format;
|
||||
if (flags & Qt::NoFormatConversion) {
|
||||
|
@ -296,15 +295,6 @@ void QRasterPixmapData::createPixmapForImage(QImage &sourceImage, Qt::ImageConve
|
|||
} else if ((flags & Qt::NoOpaqueDetection) == 0
|
||||
&& !sourceImage.data_ptr()->checkForAlphaPixels())
|
||||
{
|
||||
// image has alpha format but is really opaque, so try to do a
|
||||
// more efficient conversion
|
||||
if (sourceImage.format() == QImage::Format_ARGB32
|
||||
|| sourceImage.format() == QImage::Format_ARGB32_Premultiplied)
|
||||
{
|
||||
if (!inPlace)
|
||||
sourceImage.detach();
|
||||
sourceImage.d->format = QImage::Format_RGB32;
|
||||
}
|
||||
format = opaqueFormat;
|
||||
} else {
|
||||
format = alphaFormat;
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
protected:
|
||||
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
||||
void createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace);
|
||||
void createPixmapForImage(const QImage &sourceImage, Qt::ImageConversionFlags flags);
|
||||
void setImage(const QImage &image);
|
||||
QImage image;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue