| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSGTEXTURE_PLATFORM_H |
| 5 | #define QSGTEXTURE_PLATFORM_H |
| 6 | |
| 7 | #include <QtCore/qnativeinterface.h> |
| 8 | #include <QtQuick/qquickwindow.h> |
| 9 | |
| 10 | #if QT_CONFIG(opengl) |
| 11 | #include <QtGui/qopengl.h> |
| 12 | #endif |
| 13 | |
| 14 | #if QT_CONFIG(vulkan) |
| 15 | #include <QtGui/qvulkaninstance.h> |
| 16 | #endif |
| 17 | |
| 18 | #if QT_CONFIG(metal) || defined(Q_QDOC) |
| 19 | # if defined(__OBJC__) || defined(Q_QDOC) |
| 20 | @protocol MTLTexture; |
| 21 | # define QT_OBJC_PROTOCOL(protocol) id<protocol> |
| 22 | # else |
| 23 | typedef struct objc_object *id; |
| 24 | # define QT_OBJC_PROTOCOL(protocol) id |
| 25 | # endif |
| 26 | #endif |
| 27 | |
| 28 | QT_BEGIN_NAMESPACE |
| 29 | |
| 30 | namespace QNativeInterface { |
| 31 | |
| 32 | #if QT_CONFIG(opengl) || defined(Q_QDOC) |
| 33 | struct Q_QUICK_EXPORT QSGOpenGLTexture |
| 34 | { |
| 35 | QT_DECLARE_NATIVE_INTERFACE(QSGOpenGLTexture, 1, QSGTexture) |
| 36 | virtual GLuint nativeTexture() const = 0; |
| 37 | static QSGTexture *fromNative(GLuint textureId, |
| 38 | QQuickWindow *window, |
| 39 | const QSize &size, |
| 40 | QQuickWindow::CreateTextureOptions options = {}); |
| 41 | static QSGTexture *fromNativeExternalOES(GLuint textureId, |
| 42 | QQuickWindow *window, |
| 43 | const QSize &size, |
| 44 | QQuickWindow::CreateTextureOptions options = {}); |
| 45 | }; |
| 46 | #endif |
| 47 | |
| 48 | #if defined(Q_OS_WIN) || defined(Q_QDOC) |
| 49 | struct Q_QUICK_EXPORT QSGD3D11Texture |
| 50 | { |
| 51 | QT_DECLARE_NATIVE_INTERFACE(QSGD3D11Texture, 1, QSGTexture) |
| 52 | virtual void *nativeTexture() const = 0; |
| 53 | static QSGTexture *fromNative(void *texture, |
| 54 | QQuickWindow *window, |
| 55 | const QSize &size, |
| 56 | QQuickWindow::CreateTextureOptions options = {}); |
| 57 | }; |
| 58 | struct Q_QUICK_EXPORT QSGD3D12Texture |
| 59 | { |
| 60 | QT_DECLARE_NATIVE_INTERFACE(QSGD3D12Texture, 1, QSGTexture) |
| 61 | virtual void *nativeTexture() const = 0; |
| 62 | virtual int nativeResourceState() const = 0; |
| 63 | static QSGTexture *fromNative(void *texture, |
| 64 | int resourceState, |
| 65 | QQuickWindow *window, |
| 66 | const QSize &size, |
| 67 | QQuickWindow::CreateTextureOptions options = {}); |
| 68 | }; |
| 69 | #endif |
| 70 | |
| 71 | #if QT_CONFIG(metal) || defined(Q_QDOC) |
| 72 | struct Q_QUICK_EXPORT QSGMetalTexture |
| 73 | { |
| 74 | QT_DECLARE_NATIVE_INTERFACE(QSGMetalTexture, 1, QSGTexture) |
| 75 | virtual QT_OBJC_PROTOCOL(MTLTexture) nativeTexture() const = 0; |
| 76 | static QSGTexture *fromNative(QT_OBJC_PROTOCOL(MTLTexture) texture, |
| 77 | QQuickWindow *window, |
| 78 | const QSize &size, |
| 79 | QQuickWindow::CreateTextureOptions options = {}); |
| 80 | }; |
| 81 | #endif |
| 82 | |
| 83 | #if QT_CONFIG(vulkan) || defined(Q_QDOC) |
| 84 | struct Q_QUICK_EXPORT QSGVulkanTexture |
| 85 | { |
| 86 | QT_DECLARE_NATIVE_INTERFACE(QSGVulkanTexture, 1, QSGTexture) |
| 87 | virtual VkImage nativeImage() const = 0; |
| 88 | virtual VkImageLayout nativeImageLayout() const = 0; |
| 89 | static QSGTexture *fromNative(VkImage image, |
| 90 | VkImageLayout layout, |
| 91 | QQuickWindow *window, |
| 92 | const QSize &size, |
| 93 | QQuickWindow::CreateTextureOptions options = {}); |
| 94 | }; |
| 95 | #endif |
| 96 | |
| 97 | } // QNativeInterface |
| 98 | |
| 99 | QT_END_NAMESPACE |
| 100 | |
| 101 | #endif // QSGTEXTURE_PLATFORM_H |
| 102 | |