iOS: Implement QPlatformWindow::setMask() for masking rendering and input
Same implementation as for macOS. [ChangeLog][iOS] QWindow::setMask() is now supported for masking the rendering and touch input of child windows. Change-Id: I2f9429f0f8fa278fdd8edc15c7b242c7c6bc0ff0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit ed7c7a1458a0d903cea250e8b7272c6b5bf9c624) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1b583f39d3
commit
99d0f997aa
@ -56,6 +56,8 @@ public:
|
|||||||
|
|
||||||
void requestUpdate() override;
|
void requestUpdate() override;
|
||||||
|
|
||||||
|
void setMask(const QRegion ®ion) override;
|
||||||
|
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
CAEAGLLayer *eaglLayer() const;
|
CAEAGLLayer *eaglLayer() const;
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
#include "quiview.h"
|
#include "quiview.h"
|
||||||
#include "qiosinputcontext.h"
|
#include "qiosinputcontext.h"
|
||||||
|
|
||||||
|
#include <QtCore/private/qcore_mac_p.h>
|
||||||
|
|
||||||
#include <QtGui/private/qwindow_p.h>
|
#include <QtGui/private/qwindow_p.h>
|
||||||
|
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||||
#include <qpa/qplatformintegration.h>
|
#include <qpa/qplatformintegration.h>
|
||||||
|
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
@ -54,6 +57,7 @@ QIOSWindow::QIOSWindow(QWindow *window)
|
|||||||
|
|
||||||
setWindowState(window->windowStates());
|
setWindowState(window->windowStates());
|
||||||
setOpacity(window->opacity());
|
setOpacity(window->opacity());
|
||||||
|
setMask(QHighDpi::toNativeLocalRegion(window->mask(), window));
|
||||||
|
|
||||||
Qt::ScreenOrientation initialOrientation = window->contentOrientation();
|
Qt::ScreenOrientation initialOrientation = window->contentOrientation();
|
||||||
if (initialOrientation != Qt::PrimaryOrientation) {
|
if (initialOrientation != Qt::PrimaryOrientation) {
|
||||||
@ -355,6 +359,20 @@ void QIOSWindow::requestUpdate()
|
|||||||
static_cast<QIOSScreen *>(screen())->setUpdatesPaused(false);
|
static_cast<QIOSScreen *>(screen())->setUpdatesPaused(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QIOSWindow::setMask(const QRegion ®ion)
|
||||||
|
{
|
||||||
|
if (!region.isEmpty()) {
|
||||||
|
QCFType<CGMutablePathRef> maskPath = CGPathCreateMutable();
|
||||||
|
for (const QRect &r : region)
|
||||||
|
CGPathAddRect(maskPath, nullptr, r.toCGRect());
|
||||||
|
CAShapeLayer *maskLayer = [CAShapeLayer layer];
|
||||||
|
maskLayer.path = maskPath;
|
||||||
|
m_view.layer.mask = maskLayer;
|
||||||
|
} else {
|
||||||
|
m_view.layer.mask = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
CAEAGLLayer *QIOSWindow::eaglLayer() const
|
CAEAGLLayer *QIOSWindow::eaglLayer() const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user