aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-08-04 13:10:34 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-08-04 14:29:30 +0200
commit28005c0c037626d5601192e2a412633656d52b39 (patch)
treea95aef6661149a95285d18736620051b8d16ce8a /src/quick/scenegraph
parentfb96109bbc2ec5d83171a70d6c164d79695d2ddd (diff)
Switch to MTLTexture protocol in QSGTexture native access
Now only available from ObjC code. Change-Id: I88df6c8839fc660ffd2b8e88a789ca73a9d4accd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp22
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture_mac.mm17
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture_p.h6
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture_platform.h10
4 files changed, 28 insertions, 27 deletions
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<QPlatformInte
}
#endif // win
-#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) || defined(Q_CLANG_QDOC)
+#if defined(__OBJC__) || defined(Q_CLANG_QDOC)
namespace QPlatformInterface {
/*!
\class QPlatformInterface::QSGMetalTexture
@@ -867,19 +867,12 @@ namespace QPlatformInterface {
*/
/*!
- \fn MTLTexture *QPlatformInterface::QSGMetalTexture::nativeTexture() const
+ \fn id<MTLTexture> 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<MTLTexture> 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<QPlatformInterface::QSGMetalTexture>()
{
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 <private/qquickitem_p.h>
#include <private/qquickwindow_p.h>
+#include <QtGui/private/qrhi_p.h>
QT_BEGIN_NAMESPACE
+id<MTLTexture> QSGTexturePlatformMetal::nativeTexture() const
+{
+ if (auto *tex = m_texture->rhiTexture())
+ return (id<MTLTexture>) quintptr(tex->nativeTexture().object);
+ return 0;
+}
+
namespace QPlatformInterface {
-QSGTexture *QSGMetalTexture::fromNative(MTLTexture *texture,
+/*!
+ \internal
+ */
+QSGMetalTexture::~QSGMetalTexture()
+{
+}
+
+QSGTexture *QSGMetalTexture::fromNative(id<MTLTexture> 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<MTLTexture> 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 <QtGui/qvulkaninstance.h>
#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<MTLTexture> nativeTexture() const = 0;
+ static QSGTexture *fromNative(id<MTLTexture> texture,
QQuickWindow *window,
const QSize &size,
QQuickWindow::CreateTextureOptions options = {});