From: Simon Hausmann Date: Wed, 4 Jan 2012 15:32:55 +0000 (+0100) Subject: Fix QPainter::drawText with complex brushes X-Git-Tag: qt-v5.0.0-alpha1~2044 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73187281c3f88b7a709713a2b09fb43871ea6b6d;p=profile%2Fivi%2Fqtbase.git Fix QPainter::drawText with complex brushes Commit d52fd497f60a3c4456994f4f10e9451d611c9ea4 introduced a call path to QPaintEngineEx::drawStaticTextItem, which has a bug in using the pen's color instead of the entire brush. This patch replaces the use of the color with the pen's brush(). Task-number: QTBUG-23450 Change-Id: Ieb3bf352c840ff0d3fb4ac678caf7b13f4f9a8f1 Reviewed-by: Eskil Abrahamsen Blomfeldt --- diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 5c39a5f..3f19433 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1072,7 +1072,7 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) changedHints = true; } - fill(qtVectorPathForPath(path), s->pen.color()); + fill(qtVectorPathForPath(path), s->pen.brush()); if (changedHints) { s->renderHints = oldHints; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 4faecad..8451ce0 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -256,6 +256,8 @@ private slots: void drawTextOutsideGuiThread(); + void drawTextWithComplexBrush(); + private: void fillData(); void setPenColor(QPainter& p); @@ -4305,6 +4307,28 @@ void tst_QPainter::drawTextOutsideGuiThread() QCOMPARE(referenceRendering, t.rendering); } +void tst_QPainter::drawTextWithComplexBrush() +{ + QImage texture(10, 10, QImage::Format_ARGB32_Premultiplied); + texture.fill(Qt::red); + + QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); + image.fill(Qt::white); + QPainter p(&image); + QFont f = p.font(); + f.setPixelSize(70); + p.setFont(f); + + QBrush brush(Qt::white); + brush.setTextureImage(texture); + p.setPen(QPen(brush, 2)); + + p.drawText(10, 10, "Hello World"); + + int paintedPixels = getPaintedPixels(image, Qt::white); + QVERIFY(paintedPixels > 0); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc"