From 28005c0c037626d5601192e2a412633656d52b39 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 4 Aug 2020 13:10:34 +0200 Subject: Switch to MTLTexture protocol in QSGTexture native access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now only available from ObjC code. Change-Id: I88df6c8839fc660ffd2b8e88a789ca73a9d4accd Reviewed-by: Tor Arne Vestbø --- src/quick/scenegraph/coreapi/qsgtexture.cpp | 22 ++++------------------ src/quick/scenegraph/coreapi/qsgtexture_mac.mm | 17 ++++++++++++++++- src/quick/scenegraph/coreapi/qsgtexture_p.h | 6 +++--- src/quick/scenegraph/coreapi/qsgtexture_platform.h | 10 +++++----- 4 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp index 2400095125..66ba477990 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.cpp +++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp @@ -119,7 +119,7 @@ QSGTexturePrivate::QSGTexturePrivate(QSGTexture *t) #ifdef Q_OS_WIN , m_d3d11TextureAccessor(t) #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) +#if defined(__OBJC__) , m_metalTextureAccessor(t) #endif #if QT_CONFIG(vulkan) @@ -857,7 +857,7 @@ QPlatformInterface::QSGD3D11Texture *QSGTexture::platformInterface QPlatformInterface::QSGMetalTexture::nativeTexture() const \return the Metal texture object. */ /*! - \internal - */ -QSGMetalTexture::~QSGMetalTexture() -{ -} - -/*! - \fn QSGTexture *QPlatformInterface::QSGMetalTexture::fromNative(MTLTexture *texture, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options) + \fn QSGTexture *QPlatformInterface::QSGMetalTexture::fromNative(id texture, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options) Creates a new QSGTexture wrapping an existing Metal \a texture object. @@ -907,13 +900,6 @@ QSGMetalTexture::~QSGMetalTexture() } // QPlatformInterface -MTLTexture *QSGTexturePlatformMetal::nativeTexture() const -{ - if (auto *tex = m_texture->rhiTexture()) - return (MTLTexture *) quintptr(tex->nativeTexture().object); - return 0; -} - template<> Q_QUICK_EXPORT QPlatformInterface::QSGMetalTexture *QSGTexture::platformInterface() { diff --git a/src/quick/scenegraph/coreapi/qsgtexture_mac.mm b/src/quick/scenegraph/coreapi/qsgtexture_mac.mm index 3614e5f2f3..d4b565cbfe 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture_mac.mm +++ b/src/quick/scenegraph/coreapi/qsgtexture_mac.mm @@ -41,12 +41,27 @@ #include "qsgtexture_platform.h" #include #include +#include QT_BEGIN_NAMESPACE +id QSGTexturePlatformMetal::nativeTexture() const +{ + if (auto *tex = m_texture->rhiTexture()) + return (id) quintptr(tex->nativeTexture().object); + return 0; +} + namespace QPlatformInterface { -QSGTexture *QSGMetalTexture::fromNative(MTLTexture *texture, +/*! + \internal + */ +QSGMetalTexture::~QSGMetalTexture() +{ +} + +QSGTexture *QSGMetalTexture::fromNative(id texture, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options) diff --git a/src/quick/scenegraph/coreapi/qsgtexture_p.h b/src/quick/scenegraph/coreapi/qsgtexture_p.h index a003049099..594cd223f7 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture_p.h +++ b/src/quick/scenegraph/coreapi/qsgtexture_p.h @@ -96,14 +96,14 @@ public: }; #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) +#if defined(__OBJC__) class Q_QUICK_PRIVATE_EXPORT QSGTexturePlatformMetal : public QPlatformInterface::QSGMetalTexture { public: QSGTexturePlatformMetal(QSGTexture *t) : m_texture(t) { } QSGTexture *m_texture; - MTLTexture *nativeTexture() const override; + id nativeTexture() const override; }; #endif @@ -147,7 +147,7 @@ public: #ifdef Q_OS_WIN QSGTexturePlatformD3D11 m_d3d11TextureAccessor; #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) +#if defined(__OBJC__) QSGTexturePlatformMetal m_metalTextureAccessor; #endif #if QT_CONFIG(vulkan) diff --git a/src/quick/scenegraph/coreapi/qsgtexture_platform.h b/src/quick/scenegraph/coreapi/qsgtexture_platform.h index f7e1591765..234f050bfc 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture_platform.h +++ b/src/quick/scenegraph/coreapi/qsgtexture_platform.h @@ -50,8 +50,8 @@ #include #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) || defined(Q_CLANG_QDOC) -Q_FORWARD_DECLARE_OBJC_CLASS(MTLTexture); +#if defined(__OBJC__) || defined(Q_CLANG_QDOC) +@protocol MTLTexture; #endif QT_BEGIN_NAMESPACE @@ -84,13 +84,13 @@ public: }; #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) || defined(Q_CLANG_QDOC) +#if defined(__OBJC__) || defined(Q_CLANG_QDOC) class Q_QUICK_EXPORT QSGMetalTexture { public: virtual ~QSGMetalTexture(); - virtual MTLTexture *nativeTexture() const = 0; - static QSGTexture *fromNative(MTLTexture *texture, + virtual id nativeTexture() const = 0; + static QSGTexture *fromNative(id texture, QQuickWindow *window, const QSize &size, QQuickWindow::CreateTextureOptions options = {}); -- cgit v1.2.3