1// Copyright (C) 2016 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_P_H
5#define QSGTEXTURE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qtquickglobal_p.h>
19#include <private/qobject_p.h>
20#include "qsgtexture.h"
21
22QT_BEGIN_NAMESPACE
23
24struct QSGSamplerDescription
25{
26 QSGTexture::Filtering filtering = QSGTexture::Nearest;
27 QSGTexture::Filtering mipmapFiltering = QSGTexture::None;
28 QSGTexture::WrapMode horizontalWrap = QSGTexture::ClampToEdge;
29 QSGTexture::WrapMode verticalWrap = QSGTexture::ClampToEdge;
30 QSGTexture::AnisotropyLevel anisotropylevel = QSGTexture::AnisotropyNone;
31
32 static QSGSamplerDescription fromTexture(QSGTexture *t);
33};
34
35Q_DECLARE_TYPEINFO(QSGSamplerDescription, Q_RELOCATABLE_TYPE);
36
37bool operator==(const QSGSamplerDescription &a, const QSGSamplerDescription &b) noexcept;
38bool operator!=(const QSGSamplerDescription &a, const QSGSamplerDescription &b) noexcept;
39size_t qHash(const QSGSamplerDescription &s, size_t seed = 0) noexcept;
40
41#if QT_CONFIG(opengl)
42class Q_QUICK_PRIVATE_EXPORT QSGTexturePlatformOpenGL : public QNativeInterface::QSGOpenGLTexture
43{
44public:
45 QSGTexturePlatformOpenGL(QSGTexture *t) : m_texture(t) { }
46 QSGTexture *m_texture;
47
48 GLuint nativeTexture() const override;
49};
50#endif
51
52#ifdef Q_OS_WIN
53class Q_QUICK_PRIVATE_EXPORT QSGTexturePlatformD3D11 : public QNativeInterface::QSGD3D11Texture
54{
55public:
56 QSGTexturePlatformD3D11(QSGTexture *t) : m_texture(t) { }
57 QSGTexture *m_texture;
58
59 void *nativeTexture() const override;
60};
61class Q_QUICK_PRIVATE_EXPORT QSGTexturePlatformD3D12 : public QNativeInterface::QSGD3D12Texture
62{
63public:
64 QSGTexturePlatformD3D12(QSGTexture *t) : m_texture(t) { }
65 QSGTexture *m_texture;
66
67 int nativeResourceState() const override;
68 void *nativeTexture() const override;
69};
70#endif
71
72#if defined(__OBJC__)
73class Q_QUICK_PRIVATE_EXPORT QSGTexturePlatformMetal : public QNativeInterface::QSGMetalTexture
74{
75public:
76 QSGTexturePlatformMetal(QSGTexture *t) : m_texture(t) { }
77 QSGTexture *m_texture;
78
79 id<MTLTexture> nativeTexture() const override;
80};
81#endif
82
83#if QT_CONFIG(vulkan)
84class Q_QUICK_PRIVATE_EXPORT QSGTexturePlatformVulkan : public QNativeInterface::QSGVulkanTexture
85{
86public:
87 QSGTexturePlatformVulkan(QSGTexture *t) : m_texture(t) { }
88 QSGTexture *m_texture;
89
90 VkImage nativeImage() const override;
91 VkImageLayout nativeImageLayout() const override;
92};
93#endif
94
95class Q_QUICK_PRIVATE_EXPORT QSGTexturePrivate : public QObjectPrivate
96{
97 Q_DECLARE_PUBLIC(QSGTexture)
98public:
99 QSGTexturePrivate(QSGTexture *t);
100 static QSGTexturePrivate *get(QSGTexture *t) { return t->d_func(); }
101 void resetDirtySamplerOptions();
102 bool hasDirtySamplerOptions() const;
103
104 uint wrapChanged : 1;
105 uint filteringChanged : 1;
106 uint anisotropyChanged : 1;
107
108 uint horizontalWrap : 2;
109 uint verticalWrap : 2;
110 uint mipmapMode : 2;
111 uint filterMode : 2;
112 uint anisotropyLevel: 3;
113
114 // While we could make QSGTexturePrivate implement all the interfaces, we
115 // rather choose to use separate objects to avoid clashes in the function
116 // names and signatures.
117#if QT_CONFIG(opengl)
118 QSGTexturePlatformOpenGL m_openglTextureAccessor;
119#endif
120#ifdef Q_OS_WIN
121 QSGTexturePlatformD3D11 m_d3d11TextureAccessor;
122 QSGTexturePlatformD3D12 m_d3d12TextureAccessor;
123#endif
124#if defined(__OBJC__)
125 QSGTexturePlatformMetal m_metalTextureAccessor;
126#endif
127#if QT_CONFIG(vulkan)
128 QSGTexturePlatformVulkan m_vulkanTextureAccessor;
129#endif
130};
131
132Q_QUICK_PRIVATE_EXPORT bool qsg_safeguard_texture(QSGTexture *);
133
134QT_END_NAMESPACE
135
136#endif // QSGTEXTURE_P_H
137

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