Forward devicePixelRatio in QPixmap::mask()
Also add a test checking that devicePixelRatio is forwarded to derivatives of QPixmap. Change-Id: Idb2b3f033ccc0fd49bf54b11f5dffbce5a19b006 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
954b73445c
commit
685b8db13a
@ -178,6 +178,7 @@ QBitmap QPlatformPixmap::mask() const
|
||||
if (mask.isNull()) // allocation failed
|
||||
return QBitmap();
|
||||
|
||||
mask.setDevicePixelRatio(devicePixelRatio());
|
||||
mask.setColorCount(2);
|
||||
mask.setColor(0, QColor(Qt::color0).rgba());
|
||||
mask.setColor(1, QColor(Qt::color1).rgba());
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user