diff options
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 161ced5..89202ac 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -875,9 +875,10 @@ void QRasterPaintEngine::updateState() if (s->dirty & DirtyTransform) updateMatrix(s->matrix); - if (s->dirty & (DirtyPen|DirtyCompositionMode)) { + if (s->dirty & (DirtyPen|DirtyCompositionMode|DirtyOpacity)) { const QPainter::CompositionMode mode = s->composition_mode; s->flags.fast_text = (s->penData.type == QSpanData::Solid) + && s->intOpacity == 256 && (mode == QPainter::CompositionMode_Source || (mode == QPainter::CompositionMode_SourceOver && qAlpha(s->penData.solid.color) == 255)); @@ -901,6 +902,7 @@ void QRasterPaintEngine::opacityChanged() s->fillFlags |= DirtyOpacity; s->strokeFlags |= DirtyOpacity; s->pixmapFlags |= DirtyOpacity; + s->dirty |= DirtyOpacity; s->intOpacity = (int) (s->opacity * 256); } diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index ff9bf1c..83ff9a9 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -256,6 +256,7 @@ private slots: void drawPointScaled(); void QTBUG14614_gradientCacheRaceCondition(); + void drawTextOpacity(); private: void fillData(); @@ -4576,6 +4577,30 @@ void tst_QPainter::QTBUG14614_gradientCacheRaceCondition() producers[i].wait(); } +void tst_QPainter::drawTextOpacity() +{ + QImage image(32, 32, QImage::Format_RGB32); + image.fill(0xffffffff); + + QPainter p(&image); + p.setPen(QColor("#6F6F6F")); + p.setOpacity(0.5); + p.drawText(5, 30, QLatin1String("Qt")); + p.end(); + + QImage copy = image; + image.fill(0xffffffff); + + p.begin(&image); + p.setPen(QColor("#6F6F6F")); + p.drawLine(-10, -10, -1, -1); + p.setOpacity(0.5); + p.drawText(5, 30, QLatin1String("Qt")); + p.end(); + + QCOMPARE(image, copy); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |