From a53e579a388c6bca6374b56328622bc8c1e0f138 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 12 Jan 2011 10:47:29 +0100 Subject: Mac: pixmaps dont treat alpha exactly the same as other platforms From fixing qwidget autotest, it seems to be the case that filling a pixmap with a solid color on mac changes the hasAlpha status. This is different from X11 (and raster engine). That is, the following code will produce different result: QPixmap pixmap(100, 100); pixmap.setAlphaChannel(QPixmap(100, 100)); qDebug() << "Has alpha after setting channel?" << pixmap.hasAlpha(); pixmap.fill(Qt::red); qDebug() << "Has alpha after fill?" << pixmap.hasAlpha(); So, this patch remove the possibility of converting an already alpha supporting pixmap to non-alpha upon fill. NB: somewhat related, the following code works the same on both x11, raster and mac (prints 'false'), but still seems wrong: QPixmap pixmap2(pixmap); qDebug() << "pixmap2 has alpha initially?" << pixmap2.hasAlpha(); Rev-By: Fabien Freling --- src/gui/image/qpixmap_mac.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 31aa192..f152718 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -413,7 +413,11 @@ void QMacPixmapData::fill(const QColor &fillColor) *(dptr + i) = colr; } } - macSetHasAlpha(fillColor.alpha() != 255); + + // If we had an alpha channel from before, don't + // switch it off. Only go from no alpha to alpha: + if (fillColor.alpha() != 255) + macSetHasAlpha(true); } QPixmap QMacPixmapData::alphaChannel() const -- cgit v0.12