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>bb10
parent
3df159ba17
commit
e91abaa48e
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -233,12 +233,19 @@ void tst_QImageConversion::convertGeneric_data()
|
|||
QTest::addColumn<QImage::Format>("outputFormat");
|
||||
QImage rgb32 = generateImageRgb32(1000, 1000);
|
||||
QImage argb32 = generateImageArgb32(1000, 1000);
|
||||
QImage i8 = argb32.convertToFormat(QImage::Format_Indexed8);
|
||||
QImage rgba32 = argb32.convertToFormat(QImage::Format_RGBA8888);
|
||||
QImage bgr30 = rgb32.convertToFormat(QImage::Format_BGR30);
|
||||
QImage a2rgb30 = argb32.convertToFormat(QImage::Format_A2RGB30_Premultiplied);
|
||||
QImage rgb666 = rgb32.convertToFormat(QImage::Format_RGB666);
|
||||
QImage argb4444 = argb32.convertToFormat(QImage::Format_ARGB4444_Premultiplied);
|
||||
|
||||
QTest::newRow("indexed8 -> rgb32") << i8 << QImage::Format_RGB32;
|
||||
QTest::newRow("indexed8 -> argb32") << i8 << QImage::Format_ARGB32;
|
||||
QTest::newRow("indexed8 -> argb32pm") << i8 << QImage::Format_ARGB32_Premultiplied;
|
||||
QTest::newRow("indexed8 -> rgbx8888") << i8 << QImage::Format_RGBX8888;
|
||||
QTest::newRow("indexed8 -> rgb16") << i8 << QImage::Format_RGB16;
|
||||
|
||||
QTest::newRow("rgba8888 -> rgb32") << rgba32 << QImage::Format_RGB32;
|
||||
QTest::newRow("rgba8888 -> argb32") << rgba32 << QImage::Format_ARGB32;
|
||||
QTest::newRow("rgba8888 -> argb32pm") << rgba32 << QImage::Format_ARGB32_Premultiplied;
|
||||
|
|
|
|||
Loading…
Reference in New Issue