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 defined(__OBJC__) || defined(Q_QDOC)
19@protocol MTLTexture;
20#endif
21
22QT_BEGIN_NAMESPACE
23
24namespace QNativeInterface {
25
26#if QT_CONFIG(opengl) || defined(Q_QDOC)
27struct Q_QUICK_EXPORT QSGOpenGLTexture
28{
29 QT_DECLARE_NATIVE_INTERFACE(QSGOpenGLTexture, 1, QSGTexture)
30 virtual GLuint nativeTexture() const = 0;
31 static QSGTexture *fromNative(GLuint textureId,
32 QQuickWindow *window,
33 const QSize &size,
34 QQuickWindow::CreateTextureOptions options = {});
35 static QSGTexture *fromNativeExternalOES(GLuint textureId,
36 QQuickWindow *window,
37 const QSize &size,
38 QQuickWindow::CreateTextureOptions options = {});
39};
40#endif
41
42#if defined(Q_OS_WIN) || defined(Q_QDOC)
43struct Q_QUICK_EXPORT QSGD3D11Texture
44{
45 QT_DECLARE_NATIVE_INTERFACE(QSGD3D11Texture, 1, QSGTexture)
46 virtual void *nativeTexture() const = 0;
47 static QSGTexture *fromNative(void *texture,
48 QQuickWindow *window,
49 const QSize &size,
50 QQuickWindow::CreateTextureOptions options = {});
51};
52struct Q_QUICK_EXPORT QSGD3D12Texture
53{
54 QT_DECLARE_NATIVE_INTERFACE(QSGD3D12Texture, 1, QSGTexture)
55 virtual void *nativeTexture() const = 0;
56 virtual int nativeResourceState() const = 0;
57 static QSGTexture *fromNative(void *texture,
58 int resourceState,
59 QQuickWindow *window,
60 const QSize &size,
61 QQuickWindow::CreateTextureOptions options = {});
62};
63#endif
64
65#if defined(__OBJC__) || defined(Q_QDOC)
66struct Q_QUICK_EXPORT QSGMetalTexture
67{
68 QT_DECLARE_NATIVE_INTERFACE(QSGMetalTexture, 1, QSGTexture)
69 virtual id<MTLTexture> nativeTexture() const = 0;
70 static QSGTexture *fromNative(id<MTLTexture> texture,
71 QQuickWindow *window,
72 const QSize &size,
73 QQuickWindow::CreateTextureOptions options = {});
74};
75#endif
76
77#if QT_CONFIG(vulkan) || defined(Q_QDOC)
78struct Q_QUICK_EXPORT QSGVulkanTexture
79{
80 QT_DECLARE_NATIVE_INTERFACE(QSGVulkanTexture, 1, QSGTexture)
81 virtual VkImage nativeImage() const = 0;
82 virtual VkImageLayout nativeImageLayout() const = 0;
83 static QSGTexture *fromNative(VkImage image,
84 VkImageLayout layout,
85 QQuickWindow *window,
86 const QSize &size,
87 QQuickWindow::CreateTextureOptions options = {});
88};
89#endif
90
91} // QNativeInterface
92
93QT_END_NAMESPACE
94
95#endif // QSGTEXTURE_PLATFORM_H
96

source code of qtdeclarative/src/quick/scenegraph/coreapi/qsgtexture_platform.h