summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-03-26 10:53:44 +0100
committerMarc Mutz <marc.mutz@kdab.com>2020-04-23 08:38:49 +0000
commit5c1446e3faf7684dfa559edc49611b92ea825776 (patch)
tree2a505d25a3eba48d7e14f87c040deb01a26fdbfd
parent871e2981dde9836311bbc560f58805c4b0d61839 (diff)
QImage: optimize convertWithPalette()
The old code got a QMap serialized as a QString and parsed it to re-create the same map. Just copy the map. Change-Id: Ic71b9fa9d822eab53fe37dfb4d76223cd69ac057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/gui/image/qimage.cpp7
-rw-r--r--src/gui/image/qimage.h1
-rw-r--r--src/gui/image/qimage_p.h3
3 files changed, 5 insertions, 6 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 2646d298e9..499c527cfc 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2149,12 +2149,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
QImage dest(src.size(), format);
dest.setColorTable(clut);
- QString textsKeys = src.text();
- const auto textKeyList = textsKeys.splitRef(QLatin1Char('\n'), Qt::SkipEmptyParts);
- for (const auto &textKey : textKeyList) {
- const auto textKeySplitted = textKey.split(QLatin1String(": "));
- dest.setText(textKeySplitted[0].toString(), textKeySplitted[1].toString());
- }
+ QImageData::get(dest)->text = QImageData::get(src)->text;
int h = src.height();
int w = src.width();
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 56824e5ee7..b11aa9d9d0 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -385,6 +385,7 @@ private:
friend class QRasterPlatformPixmap;
friend class QBlittablePlatformPixmap;
friend class QPixmapCacheEntry;
+ friend struct QImageData;
public:
typedef QImageData * DataPtr;
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 0930955f5a..03ec43eaf7 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -69,6 +69,9 @@ struct Q_GUI_EXPORT QImageData { // internal image data
static QImageData *create(const QSize &size, QImage::Format format);
static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
+ static QImageData *get(QImage &img) noexcept { return img.d; }
+ static const QImageData *get(const QImage &img) noexcept { return img.d; }
+
QAtomicInt ref;
int width;