Use RGB64 qdrawhelper routines for unpremultiplied formats

The ARGB32PM code-path doesn't have enough precision to accurately
render ARGB32 images, but the RGB64 code-path does. Since this is
already a slow configuration and the most costly part is the conversion
we can switch to the more accurate code-path for little cost.

Task-number: QTBUG-55720
Change-Id: Ifa0afba8d8cc0c2f699bb91f51726f4ee5228f3e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2016-12-01 12:33:29 +01:00
parent 713cc6f3a8
commit a30fca8711
3 changed files with 28 additions and 1 deletions

View File

@ -5268,6 +5268,8 @@ void qBlendTexture(int count, const QSpan *spans, void *userData)
case QImage::Format_RGB16:
proc = processTextureSpansRGB16[blendType];
break;
case QImage::Format_ARGB32:
case QImage::Format_RGBA8888:
case QImage::Format_BGR30:
case QImage::Format_A2BGR30_Premultiplied:
case QImage::Format_RGB30:

View File

@ -4840,6 +4840,18 @@ void tst_QPainter::blendARGBonRGB_data()
<< QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 127;
QTest::newRow("ARGB_PM source-in RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 127;
QTest::newRow("ARGB over RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32
<< QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127;
QTest::newRow("ARGB_PM over RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 127;
QTest::newRow("ARGB source RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32
<< QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 255;
QTest::newRow("ARGB_PM source RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 255;
QTest::newRow("ARGB source-in RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32
<< QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 255;
QTest::newRow("ARGB_PM source-in RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 255;
QTest::newRow("ARGB over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32
<< QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 123;
QTest::newRow("ARGB_PM over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32_Premultiplied
@ -4902,7 +4914,7 @@ void tst_QPainter::blendARGBonRGB()
painter.drawImage(0, 0, imageArgb);
painter.end();
QCOMPARE(qRed(imageRgb.pixel(0,0)), expected_red);
QCOMPARE(imageRgb.pixelColor(0,0).red(), expected_red);
}
enum CosmeticStrokerPaint

View File

@ -69,6 +69,8 @@ private slots:
void testRasterARGB32PM();
void testRasterRGB32_data();
void testRasterRGB32();
void testRasterARGB32_data();
void testRasterARGB32();
void testRasterRGB16_data();
void testRasterRGB16();
void testRasterA2RGB30PM_data();
@ -134,6 +136,17 @@ void tst_Lancelot::testRasterARGB32PM()
}
void tst_Lancelot::testRasterARGB32_data()
{
setupTestSuite();
}
void tst_Lancelot::testRasterARGB32()
{
runTestSuite(Raster, QImage::Format_ARGB32);
}
void tst_Lancelot::testRasterRGB32_data()
{
setupTestSuite();