Make drawing to and from RGBA8888 images faster
After profiling drawing with RGBA8888 images most of the time appears to be spend in converting to and from ARGB32PM. This patch adds four small converters that are 3-4 times faster than the generic converter. Change-Id: I3c7498756f440ca3ea9c1417b26dd8e1953b9d06 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
parent
5dd94b75e3
commit
34ff885bff
@ -118,6 +118,22 @@ static const uint *QT_FASTCALL convertARGB32ToARGB32PM(uint *buffer, const uint
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const uint *src, int count,
|
||||||
|
const QPixelLayout *, const QRgb *)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
buffer[i] = RGBA2ARGB(src[i]);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uint *QT_FASTCALL convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count,
|
||||||
|
const QPixelLayout *, const QRgb *)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
buffer[i] = PREMUL(RGBA2ARGB(src[i]));
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count,
|
static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count,
|
||||||
const QPixelLayout *layout, const QRgb *)
|
const QPixelLayout *layout, const QRgb *)
|
||||||
{
|
{
|
||||||
@ -222,6 +238,22 @@ static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uin
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const uint *src, int count,
|
||||||
|
const QPixelLayout *, const QRgb *)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
buffer[i] = ARGB2RGBA(src[i]);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const uint *src, int count,
|
||||||
|
const QPixelLayout *, const QRgb *)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
buffer[i] = ARGB2RGBA(INV_PREMUL(src[i]));
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src, int count,
|
static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src, int count,
|
||||||
const QPixelLayout *layout, const QRgb *)
|
const QPixelLayout *layout, const QRgb *)
|
||||||
{
|
{
|
||||||
@ -415,13 +447,13 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
|
|||||||
{ 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, convertFromARGB32PM }, // Format_RGB444
|
{ 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, convertFromARGB32PM }, // Format_RGB444
|
||||||
{ 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM }, // Format_ARGB4444_Premultiplied
|
{ 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM }, // Format_ARGB4444_Premultiplied
|
||||||
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
||||||
{ 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertToRGB32, convertRGBFromARGB32PM }, // Format_RGBX8888
|
{ 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBFromARGB32PM }, // Format_RGBX8888
|
||||||
{ 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888
|
{ 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM }, // Format_RGBA8888
|
||||||
{ 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888_Premultiplied
|
{ 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM }, // Format_RGBA8888_Premultiplied
|
||||||
#else
|
#else
|
||||||
{ 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertToRGB32, convertRGBFromARGB32PM }, // Format_RGBX8888
|
{ 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBFromARGB32PM }, // Format_RGBX8888
|
||||||
{ 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888 (ABGR32)
|
{ 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM }, // Format_RGBA8888 (ABGR32)
|
||||||
{ 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM } // Format_RGBA8888_Premultiplied
|
{ 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM } // Format_RGBA8888_Premultiplied
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user