From 685b8db13aa19e734f239678bae23607fcededbd Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 28 Mar 2019 16:49:57 +0300 Subject: Forward devicePixelRatio in QPixmap::mask() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add a test checking that devicePixelRatio is forwarded to derivatives of QPixmap. Change-Id: Idb2b3f033ccc0fd49bf54b11f5dffbce5a19b006 Reviewed-by: Morten Johan Sørvig --- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/auto/gui/image/qpixmap/tst_qpixmap.cpp') diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 9a338ad55a..4d31d80246 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -121,6 +121,7 @@ private slots: void copy(); void deepCopyPreservesDpr(); + void dprPassthrough(); void depthOfNullObjects(); void transformed(); @@ -1169,6 +1170,39 @@ void tst_QPixmap::deepCopyPreservesDpr() QCOMPARE(dest.devicePixelRatio(), dpr); } +void tst_QPixmap::dprPassthrough() +{ + const qreal dpr = 2; + QPixmap src(32, 32); + src.setDevicePixelRatio(dpr); + src.fill(Qt::transparent); + QCOMPARE(src.devicePixelRatio(), dpr); + + QImage img = src.toImage(); + QCOMPARE(img.devicePixelRatio(), dpr); + + QPixmap pm(1, 1); + pm.convertFromImage(img); + QCOMPARE(pm.devicePixelRatio(), dpr); + + QBitmap heuristicMask = src.createHeuristicMask(); + QCOMPARE(heuristicMask.devicePixelRatio(), dpr); + + QBitmap maskFromColor = src.createMaskFromColor(Qt::white); + QCOMPARE(maskFromColor.devicePixelRatio(), dpr); + + QBitmap mask = src.mask(); + QCOMPARE(mask.devicePixelRatio(), dpr); + + QPixmap scaled = src.scaled(16, 16); + QCOMPARE(scaled.devicePixelRatio(), dpr); + + QTransform t; + t.rotate(90); + QPixmap transformed = src.transformed(t); + QCOMPARE(transformed.devicePixelRatio(), dpr); +} + void tst_QPixmap::depthOfNullObjects() { QBitmap b1; -- cgit v1.2.3