Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QSGTEXTURE_H
5#define QSGTEXTURE_H
6
7#include <QtQuick/qtquickglobal.h>
8#include <QtCore/qobject.h>
9#include <QtGui/qimage.h>
10#include <QtQuick/qsgtexture_platform.h>
11
13
15class QRhi;
16class QRhiTexture;
18
19class Q_QUICK_EXPORT QSGTexture : public QObject
20{
22 Q_DECLARE_PRIVATE(QSGTexture)
23
24public:
25 QSGTexture();
26 ~QSGTexture() override;
27
33
39
47
48 virtual qint64 comparisonKey() const = 0;
49 virtual QRhiTexture *rhiTexture() const;
50 virtual QSize textureSize() const = 0;
51 virtual bool hasAlphaChannel() const = 0;
52 virtual bool hasMipmaps() const = 0;
53
54 virtual QRectF normalizedTextureSubRect() const;
55
56 virtual bool isAtlasTexture() const;
57
58 virtual QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates = nullptr) const;
59
60 virtual void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates);
61
62 void setMipmapFiltering(Filtering filter);
63 QSGTexture::Filtering mipmapFiltering() const;
64
65 void setFiltering(Filtering filter);
66 QSGTexture::Filtering filtering() const;
67
68 void setAnisotropyLevel(AnisotropyLevel level);
69 QSGTexture::AnisotropyLevel anisotropyLevel() const;
70
71 void setHorizontalWrapMode(WrapMode hwrap);
72 QSGTexture::WrapMode horizontalWrapMode() const;
73
74 void setVerticalWrapMode(WrapMode vwrap);
75 QSGTexture::WrapMode verticalWrapMode() const;
76
77 inline QRectF convertToNormalizedSourceRect(const QRectF &rect) const;
78
80
81protected:
83};
84
86{
89
90 qreal sx = r.width() / s.width();
91 qreal sy = r.height() / s.height();
92
93 return QRectF(r.x() + rect.x() * sx,
94 r.y() + rect.y() * sy,
95 rect.width() * sx,
96 rect.height() * sy);
97}
98
99class Q_QUICK_EXPORT QSGDynamicTexture : public QSGTexture
100{
102
103public:
104 QSGDynamicTexture() = default;
106
107 virtual bool updateTexture() = 0;
108
109protected:
111};
112
114
115#endif
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtGui
Definition qrhi.h:1731
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
The QSGDynamicTexture class serves as a baseclass for dynamically changing textures,...
Definition qsgtexture.h:100
virtual bool updateTexture()=0
Call this function to explicitly update the dynamic texture.
~QSGDynamicTexture() override
QSGDynamicTexture()=default
\inmodule QtQuick
Definition qsgtexture.h:20
virtual bool hasMipmaps() const =0
Returns true if the texture data contains mipmap levels.
virtual QRectF normalizedTextureSubRect() const
Returns the rectangle inside textureSize() that this texture represents in normalized coordinates.
virtual bool hasAlphaChannel() const =0
Returns true if the texture data contains an alpha channel.
virtual QSize textureSize() const =0
Returns the size of the texture in pixels.
QRectF convertToNormalizedSourceRect(const QRectF &rect) const
Returns rect converted to normalized coordinates.
Definition qsgtexture.h:85
Filtering
Specifies how sampling of texels should filter when texture coordinates are not pixel aligned.
Definition qsgtexture.h:34
WrapMode
Specifies how the sampler should treat texture coordinates.
Definition qsgtexture.h:28
AnisotropyLevel
Specifies the anisotropic filtering level to be used when the texture is not screen aligned.
Definition qsgtexture.h:40
virtual qint64 comparisonKey() const =0
Returns a key suitable for comparing textures.
\inmodule QtCore
Definition qsize.h:25
rect
[4]
Combined button and popup list for selecting options.
#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T)
GLenum GLuint GLint level
GLboolean r
[2]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLdouble s
[6]
Definition qopenglext.h:235
#define Q_OBJECT
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187