diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-02-07 16:52:00 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-26 14:18:21 +0100 |
commit | b1a882f178d71d1462b5ee7e7ffde142928b5086 (patch) | |
tree | ea756d8029fa0e148ef296e63bcbe4c1c74b28e2 /tests/auto/gui | |
parent | 08cbbde61778276ccdda73d89fd64d02c623779f (diff) |
Fix drawCachedGlyphs on RGBA8888
drawCachedGlyphs draws with the wrong color on RGBA8888. The issue
is that the draw routines bitmapblit_quint32 and alphamapblit_quint32
while safe to use on rgba formats, needs to have the input color
converted.
This patch adds small wrapper functions for bitmapblit and alphamapblit
that converts the formats. Two tests are extended to ensure we have
test coverage.
Change-Id: I5f99f3795eba46a69d4df5b167e6099024e9a060
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 46f97840af..4ae70fe137 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -87,6 +87,7 @@ private slots: void plainTextVsRichText(); + void setPenPlainText_data(); void setPenPlainText(); void setPenRichText(); void richTextOverridesPen(); @@ -106,6 +107,8 @@ private: QImage const m_whiteSquare; }; +Q_DECLARE_METATYPE(QImage::Format); + void tst_QStaticText::initTestCase() { // a "blank" square; we compare against in our testfunctions to verify @@ -615,30 +618,41 @@ void tst_QStaticText::plainTextVsRichText() QCOMPARE(imagePlainText, imageRichText); } +void tst_QStaticText::setPenPlainText_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("rgb32") << QImage::Format_RGB32; + QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; + QTest::newRow("rgbx8888") << QImage::Format_RGBX8888; +} + void tst_QStaticText::setPenPlainText() { + QFETCH(QImage::Format, format); + QFont font = QGuiApplication::font(); font.setStyleStrategy(QFont::NoAntialias); QFontMetricsF fm(font); - QPixmap image(qCeil(fm.width("XXXXX")), qCeil(fm.height())); + QImage image(qCeil(fm.width("XXXXX")), qCeil(fm.height()), format); image.fill(Qt::white); { QPainter p(&image); p.setFont(font); - p.setPen(Qt::green); + p.setPen(Qt::yellow); QStaticText staticText("XXXXX"); staticText.setTextFormat(Qt::PlainText); p.drawStaticText(0, 0, staticText); } - QImage img = image.toImage(); - for (int x=0; x<img.width(); ++x) { - for (int y=0; y<img.height(); ++y) { - QRgb pixel = img.pixel(x, y); + for (int x=0; x<image.width(); ++x) { + for (int y=0; y<image.height(); ++y) { + QRgb pixel = image.pixel(x, y); QVERIFY(pixel == QColor(Qt::white).rgba() - || pixel == QColor(Qt::green).rgba()); + || pixel == QColor(Qt::yellow).rgba()); } } } |