Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgtexture.h
Go to the documentation of this file.
1// Copyright (C) 2019 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// Qt-Security score:significant reason:default
4
5#ifndef QSGTEXTURE_H
6#define QSGTEXTURE_H
7
8#include <QtQuick/qtquickglobal.h>
9#include <QtCore/qobject.h>
10#include <QtGui/qimage.h>
11#include <QtQuick/qsgtexture_platform.h>
12
13QT_BEGIN_NAMESPACE
14
15class QSGTexturePrivate;
16class QRhi;
17class QRhiTexture;
18class QRhiResourceUpdateBatch;
19
20class Q_QUICK_EXPORT QSGTexture : public QObject
21{
22 Q_OBJECT
23 Q_DECLARE_PRIVATE(QSGTexture)
24
25public:
26 QSGTexture();
27 ~QSGTexture() override;
28
29 enum WrapMode {
30 Repeat,
31 ClampToEdge,
32 MirroredRepeat
33 };
34
35 enum Filtering {
36 None,
37 Nearest,
38 Linear
39 };
40
41 enum AnisotropyLevel {
42 AnisotropyNone,
43 Anisotropy2x,
44 Anisotropy4x,
45 Anisotropy8x,
46 Anisotropy16x
47 };
48
49 virtual qint64 comparisonKey() const = 0;
50 virtual QRhiTexture *rhiTexture() const;
51 virtual QSize textureSize() const = 0;
52 virtual bool hasAlphaChannel() const = 0;
53 virtual bool hasMipmaps() const = 0;
54
55 virtual QRectF normalizedTextureSubRect() const;
56
57 virtual bool isAtlasTexture() const;
58
59 virtual QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates = nullptr) const;
60
61 virtual void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates);
62
63 void setMipmapFiltering(Filtering filter);
64 QSGTexture::Filtering mipmapFiltering() const;
65
66 void setFiltering(Filtering filter);
67 QSGTexture::Filtering filtering() const;
68
69 void setAnisotropyLevel(AnisotropyLevel level);
70 QSGTexture::AnisotropyLevel anisotropyLevel() const;
71
72 void setHorizontalWrapMode(WrapMode hwrap);
73 QSGTexture::WrapMode horizontalWrapMode() const;
74
75 void setVerticalWrapMode(WrapMode vwrap);
76 QSGTexture::WrapMode verticalWrapMode() const;
77
78 inline QRectF convertToNormalizedSourceRect(const QRectF &rect) const;
79
80 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QSGTexture)
81
82protected:
83 QSGTexture(QSGTexturePrivate &dd);
84};
85
86QRectF QSGTexture::convertToNormalizedSourceRect(const QRectF &rect) const
87{
88 QSize s = textureSize();
89 QRectF r = normalizedTextureSubRect();
90
91 qreal sx = r.width() / s.width();
92 qreal sy = r.height() / s.height();
93
94 return QRectF(r.x() + rect.x() * sx,
95 r.y() + rect.y() * sy,
96 rect.width() * sx,
97 rect.height() * sy);
98}
99
100class Q_QUICK_EXPORT QSGDynamicTexture : public QSGTexture
101{
102 Q_OBJECT
103
104public:
105 QSGDynamicTexture() = default;
106 ~QSGDynamicTexture() override;
107
108 virtual bool updateTexture() = 0;
109
110protected:
111 QSGDynamicTexture(QSGTexturePrivate &dd);
112};
113
114QT_END_NAMESPACE
115
116#endif
The QSGDynamicTexture class serves as a baseclass for dynamically changing textures,...
Definition qsgtexture.h:101
\inmodule QtQuick
Definition qsgtexture.h:21
Combined button and popup list for selecting options.
static void qt_debug_print_texture_count()
static void qt_debug_remove_texture(QSGTexture *texture)
static void qt_debug_add_texture(QSGTexture *texture)
size_t qHash(const QSGSamplerDescription &s, size_t seed=0) noexcept
Q_DECLARE_TYPEINFO(QSGSamplerDescription, Q_RELOCATABLE_TYPE)
bool operator!=(const QSGSamplerDescription &a, const QSGSamplerDescription &b) noexcept
Q_QUICK_EXPORT bool qsg_safeguard_texture(QSGTexture *)
bool operator==(const QSGSamplerDescription &a, const QSGSamplerDescription &b) noexcept
static QSGSamplerDescription fromTexture(QSGTexture *t)