Implement [QNSView isOpaque]
Re-use the QCocoaWindow implementation. This gives a small performance boost since NSWindow can skip drawing the background if it knows that the content view will fill with opaque pixels. Change-Id: I4a9a14135d890e9132dd1cb0af5a1c1a769d7e2f Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>bb10
parent
a87e8f7a10
commit
a8283fe4d9
|
|
@ -109,6 +109,7 @@ public:
|
|||
void raise();
|
||||
void lower();
|
||||
bool isExposed() const;
|
||||
bool isOpaque() const;
|
||||
void propagateSizeHints();
|
||||
void setOpacity(qreal level);
|
||||
void setMask(const QRegion ®ion);
|
||||
|
|
@ -161,8 +162,6 @@ protected:
|
|||
QCocoaWindow *parentCocoaWindow() const;
|
||||
void syncWindowState(Qt::WindowState newState);
|
||||
|
||||
void updateOpaque();
|
||||
|
||||
// private:
|
||||
public: // for QNSView
|
||||
friend class QCocoaBackingStore;
|
||||
|
|
|
|||
|
|
@ -505,6 +505,14 @@ bool QCocoaWindow::isExposed() const
|
|||
return m_isExposed;
|
||||
}
|
||||
|
||||
bool QCocoaWindow::isOpaque() const
|
||||
{
|
||||
bool translucent = (window()->format().alphaBufferSize() > 0
|
||||
|| window()->opacity() < 1
|
||||
|| (m_contentView && [m_contentView hasMask]));
|
||||
return !translucent;
|
||||
}
|
||||
|
||||
void QCocoaWindow::propagateSizeHints()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
|
@ -543,20 +551,11 @@ void QCocoaWindow::propagateSizeHints()
|
|||
}
|
||||
}
|
||||
|
||||
void QCocoaWindow::updateOpaque()
|
||||
{
|
||||
bool translucent = window()->format().alphaBufferSize() > 0
|
||||
|| window()->opacity() < 1
|
||||
|| (m_contentView && [m_contentView hasMask]);
|
||||
[m_nsWindow setOpaque:!translucent];
|
||||
}
|
||||
|
||||
|
||||
void QCocoaWindow::setOpacity(qreal level)
|
||||
{
|
||||
if (m_nsWindow) {
|
||||
[m_nsWindow setAlphaValue:level];
|
||||
updateOpaque();
|
||||
[m_nsWindow setOpaque: isOpaque()];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -566,7 +565,7 @@ void QCocoaWindow::setMask(const QRegion ®ion)
|
|||
[m_nsWindow setBackgroundColor:[NSColor clearColor]];
|
||||
|
||||
[m_qtView setMaskRegion:®ion];
|
||||
updateOpaque();
|
||||
[m_nsWindow setOpaque: isOpaque()];
|
||||
}
|
||||
|
||||
bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ QT_END_NAMESPACE
|
|||
- (BOOL)acceptsFirstResponder;
|
||||
- (BOOL)becomeFirstResponder;
|
||||
- (BOOL)hasMask;
|
||||
- (BOOL)isOpaque;
|
||||
|
||||
- (void)resetMouseButtons;
|
||||
|
||||
|
|
|
|||
|
|
@ -310,6 +310,11 @@ static QTouchDevice *touchDevice = 0;
|
|||
return m_maskData != 0;
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return m_platformWindow->isOpaque();
|
||||
}
|
||||
|
||||
- (void) setMaskRegion:(const QRegion *)region
|
||||
{
|
||||
m_shouldInvalidateWindowShadow = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue