Fix transparent toplevels on Mac OS X again..
We're using QWindow::format() to decide opacity or not in a few places, but this used to resolve to QPlatformFormat::format() which would in turn return a default format without alpha set. Instead, return the format requested by the user. Masked windows were always broken as converting a 32-bit image to an Indexed8, doesn't give a grayscale image, but rather a randomly spreadout set of indices based on the colortable generated by the converToFormat function. Task-number: QTBUG-28531 Change-Id: I537288f85c70b1e6194785b9ebcb5ea1f9581cee Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>bb10
parent
9fdb9b269b
commit
7f1ad7c7c9
|
|
@ -118,6 +118,7 @@ public:
|
|||
bool setKeyboardGrabEnabled(bool grab);
|
||||
bool setMouseGrabEnabled(bool grab);
|
||||
QMargins frameMargins() const;
|
||||
QSurfaceFormat format() const;
|
||||
|
||||
void requestActivateWindow();
|
||||
|
||||
|
|
|
|||
|
|
@ -253,6 +253,11 @@ QCocoaWindow::~QCocoaWindow()
|
|||
[m_nsWindowDelegate release];
|
||||
}
|
||||
|
||||
QSurfaceFormat QCocoaWindow::format() const
|
||||
{
|
||||
return window()->requestedFormat();
|
||||
}
|
||||
|
||||
void QCocoaWindow::setGeometry(const QRect &rect)
|
||||
{
|
||||
if (geometry() == rect)
|
||||
|
|
|
|||
|
|
@ -340,15 +340,20 @@ static QTouchDevice *touchDevice = 0;
|
|||
}
|
||||
|
||||
const QRect &rect = region->boundingRect();
|
||||
QImage maskImage(rect.size(), QImage::Format_RGB888);
|
||||
maskImage.fill(Qt::white);
|
||||
QPainter p(&maskImage);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
QImage tmp(rect.size(), QImage::Format_RGB32);
|
||||
tmp.fill(Qt::white);
|
||||
QPainter p(&tmp);
|
||||
p.setClipRegion(*region);
|
||||
p.fillRect(rect, QBrush(Qt::black));
|
||||
p.fillRect(rect, Qt::black);
|
||||
p.end();
|
||||
|
||||
maskImage = maskImage.convertToFormat(QImage::Format_Indexed8);
|
||||
QImage maskImage = QImage(rect.size(), QImage::Format_Indexed8);
|
||||
for (int y=0; y<rect.height(); ++y) {
|
||||
const uint *src = (const uint *) tmp.constScanLine(y);
|
||||
uchar *dst = maskImage.scanLine(y);
|
||||
for (int x=0; x<rect.width(); ++x) {
|
||||
dst[x] = src[x] & 0xff;
|
||||
}
|
||||
}
|
||||
m_maskImage = qt_mac_toCGImage(maskImage, true, &m_maskData);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue