diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-04-13 17:19:56 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-04-27 22:01:32 +0000 |
commit | e91abaa48eb3c6269a0f34301b58d2c194cb6141 (patch) | |
tree | 6d86624f4f75b18046c117639c9d2c5c1cd02c4e /src | |
parent | 3df159ba174c1775a0e77d2305a639eeab1ea71d (diff) |
Optimize convert_Indexed8_to_X32
Basic optimization of conversion from indexed8.
Task-number: QTBUG-35747
Change-Id: Ic9d32789769eadb05fbecfebf2d2f2c87d66610b
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 4f8e88adda..3c80b070e3 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -1734,24 +1734,30 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: Q_ASSERT(src->width == dest->width); Q_ASSERT(src->height == dest->height); - QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); + QVector<QRgb> colorTable = src->has_alpha_clut ? fix_color_table(src->colortable, dest->format) : src->colortable; if (colorTable.size() == 0) { colorTable.resize(256); for (int i=0; i<256; ++i) colorTable[i] = qRgb(i, i, i); } + if (colorTable.size() < 256) { + int tableSize = colorTable.size(); + colorTable.resize(256); + for (int i=tableSize; i<256; ++i) + colorTable[i] = 0; + } int w = src->width; const uchar *src_data = src->data; uchar *dest_data = dest->data; - int tableSize = colorTable.size() - 1; + const QRgb *colorTablePtr = colorTable.constData(); for (int y = 0; y < src->height; y++) { - uint *p = (uint *)dest_data; + uint *p = reinterpret_cast<uint *>(dest_data); const uchar *b = src_data; uint *end = p + w; while (p < end) - *p++ = colorTable.at(qMin<int>(tableSize, *b++)); + *p++ = colorTablePtr[*b++]; src_data += src->bytes_per_line; dest_data += dest->bytes_per_line; |