Fix regression in rotated bilinear sampling
Fix a mistake introduced recently and revealed by lancelot. Adds an auto-test for rotations to catch similar errors faster in the future. Change-Id: I028a160107d98899e723481b6201ef776f20c721 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
f41cbc2d45
commit
f2922c80a4
@ -2398,10 +2398,10 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
|
|||||||
const __m128i bl = _mm_setr_epi32(bottomData[offset0], bottomData[offset1], bottomData[offset2], bottomData[offset3]);
|
const __m128i bl = _mm_setr_epi32(bottomData[offset0], bottomData[offset1], bottomData[offset2], bottomData[offset3]);
|
||||||
const __m128i br = _mm_setr_epi32(bottomData[offset0 + 1], bottomData[offset1 + 1], bottomData[offset2 + 1], bottomData[offset3 + 1]);
|
const __m128i br = _mm_setr_epi32(bottomData[offset0 + 1], bottomData[offset1 + 1], bottomData[offset2 + 1], bottomData[offset3 + 1]);
|
||||||
|
|
||||||
__m128i v_distx = _mm_srli_epi16(v_fx, 12);
|
__m128i v_distx = _mm_srli_epi16(v_fx, 8);
|
||||||
__m128i v_disty = _mm_srli_epi16(v_fy, 12);
|
__m128i v_disty = _mm_srli_epi16(v_fy, 8);
|
||||||
v_distx = _mm_srli_epi16(_mm_add_epi32(v_fx, v_fxy_r), 4);
|
v_distx = _mm_srli_epi16(_mm_add_epi32(v_distx, v_fxy_r), 4);
|
||||||
v_disty = _mm_srli_epi16(_mm_add_epi32(v_fy, v_fxy_r), 4);
|
v_disty = _mm_srli_epi16(_mm_add_epi32(v_disty, v_fxy_r), 4);
|
||||||
v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
|
v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
|
||||||
v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
|
v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
|
||||||
v_disty = _mm_shufflehi_epi16(v_disty, _MM_SHUFFLE(2,2,0,0));
|
v_disty = _mm_shufflehi_epi16(v_disty, _MM_SHUFFLE(2,2,0,0));
|
||||||
|
@ -295,6 +295,9 @@ private slots:
|
|||||||
|
|
||||||
void QTBUG50153_drawImage_assert();
|
void QTBUG50153_drawImage_assert();
|
||||||
|
|
||||||
|
void rotateImage_data();
|
||||||
|
void rotateImage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillData();
|
void fillData();
|
||||||
void setPenColor(QPainter& p);
|
void setPenColor(QPainter& p);
|
||||||
@ -5059,6 +5062,64 @@ void tst_QPainter::QTBUG50153_drawImage_assert()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QPainter::rotateImage_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QImage>("image");
|
||||||
|
QTest::addColumn<bool>("smooth");
|
||||||
|
|
||||||
|
QImage image(128, 128, QImage::Format_RGB32);
|
||||||
|
for (int y = 0; y < 128; ++y) {
|
||||||
|
for (int x = 0; x < 128; ++x) {
|
||||||
|
image.setPixel(x, y, qRgb(x + y, x + y, x + y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTest::newRow("fast") << image << false;
|
||||||
|
QTest::newRow("smooth") << image << true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QPainter::rotateImage()
|
||||||
|
{
|
||||||
|
QFETCH(QImage, image);
|
||||||
|
QFETCH(bool, smooth);
|
||||||
|
|
||||||
|
QImage dest(184, 184, QImage::Format_ARGB32_Premultiplied);
|
||||||
|
dest.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter painter(&dest);
|
||||||
|
QTransform transform;
|
||||||
|
transform.translate(92, 0);
|
||||||
|
transform.rotate(45);
|
||||||
|
painter.setTransform(transform);
|
||||||
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, smooth);
|
||||||
|
painter.drawImage(0, 0, image);
|
||||||
|
painter.end();
|
||||||
|
|
||||||
|
QRgb lastRow = qRgba(0, 0, 0, 0);
|
||||||
|
for (int y = 0; y < 184; ++y) {
|
||||||
|
QRgb row = qRgba(0, 0, 0, 0);
|
||||||
|
for (int x = 0; x < 184; ++x) {
|
||||||
|
QRgb pixel = dest.pixel(x, y);
|
||||||
|
if (qAlpha(pixel) < 255)
|
||||||
|
continue;
|
||||||
|
if (qAlpha(row) == 0) {
|
||||||
|
row = pixel;
|
||||||
|
} else {
|
||||||
|
QCOMPARE(qRed(pixel), qGreen(pixel));
|
||||||
|
QCOMPARE(qGreen(pixel), qBlue(pixel));
|
||||||
|
QVERIFY(qAbs(qRed(row) - qRed(pixel)) <= 2);
|
||||||
|
QVERIFY(qAbs(qGreen(row) - qGreen(pixel)) <= 2);
|
||||||
|
QVERIFY(qAbs(qBlue(row) - qBlue(pixel)) <= 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (qAlpha(row) && qAlpha(lastRow))
|
||||||
|
QVERIFY(qGray(lastRow) <= qGray(row));
|
||||||
|
lastRow = row;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QPainter)
|
QTEST_MAIN(tst_QPainter)
|
||||||
|
|
||||||
#include "tst_qpainter.moc"
|
#include "tst_qpainter.moc"
|
||||||
|
Loading…
Reference in New Issue
Block a user