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
qsgdefaultimagenode.cpp
Go to the documentation of this file.
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
5#include <private/qsgnode_p.h>
6
8
10 : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
11 , m_texCoordMode(QSGDefaultImageNode::NoTransform)
12 , m_isAtlasTexture(false)
13 , m_ownsTexture(false)
14{
15 setGeometry(&m_geometry);
16 setMaterial(&m_material);
17 setOpaqueMaterial(&m_opaque_material);
19 m_opaque_material.setMipmapFiltering(QSGTexture::None);
20#ifdef QSG_RUNTIME_DESCRIPTION
22#endif
23}
24
26{
27 if (m_ownsTexture)
28 delete m_material.texture();
29}
30
32{
33 if (m_material.filtering() == filtering)
34 return;
35
36 m_material.setFiltering(filtering);
37 m_opaque_material.setFiltering(filtering);
39}
40
42{
43 return m_material.filtering();
44}
45
47{
48 if (m_material.mipmapFiltering() == filtering)
49 return;
50
51 m_material.setMipmapFiltering(filtering);
52 m_opaque_material.setMipmapFiltering(filtering);
54}
55
60
70
75
77{
78 if (m_rect == r)
79 return;
80
81 m_rect = r;
82 rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
84}
85
87{
88 return m_rect;
89}
90
92{
93 if (m_sourceRect == r)
94 return;
95
96 m_sourceRect = r;
97 rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
99}
100
102{
103 return m_sourceRect;
104}
105
107{
109 if (m_ownsTexture)
110 delete m_material.texture();
111 m_material.setTexture(texture);
112 m_opaque_material.setTexture(texture);
113 rebuildGeometry(&m_geometry, texture, m_rect, m_sourceRect, m_texCoordMode);
114
115 DirtyState dirty = DirtyMaterial;
116 // It would be tempting to skip the extra bit here and instead use
117 // m_material.texture to get the old state, but that texture could
118 // have been deleted in the mean time.
119 bool wasAtlas = m_isAtlasTexture;
120 m_isAtlasTexture = texture->isAtlasTexture();
121 if (wasAtlas || m_isAtlasTexture)
122 dirty |= DirtyGeometry;
123 // The geometry has also changed if the texture size changed.
124 if (m_textureSize != texture->textureSize())
125 dirty |= DirtyGeometry;
126 m_textureSize = texture->textureSize();
127 markDirty(dirty);
128}
129
131{
132 return m_material.texture();
133}
134
136{
137 if (m_texCoordMode == mode)
138 return;
139 m_texCoordMode = mode;
140 rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
142}
143
144QSGDefaultImageNode::TextureCoordinatesTransformMode QSGDefaultImageNode::textureCoordinatesTransform() const
145{
146 return m_texCoordMode;
147}
148
150{
151 m_ownsTexture = owns;
152}
153
155{
156 return m_ownsTexture;
157}
158
\inmodule QtCore\reentrant
Definition qrect.h:484
void setGeometry(QSGGeometry *geometry)
Sets the geometry of this node to geometry.
Definition qsgnode.cpp:764
bool ownsTexture() const override
QSGTexture::Filtering filtering() const override
Returns the filtering for this image node.
QSGTexture * texture() const override
Returns the texture for this image node.
QSGTexture::Filtering mipmapFiltering() const override
Returns the mipmap filtering for this image node.
QRectF sourceRect() const override
Returns the source rect of this image node.
void setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode) override
Sets the method used to generate texture coordinates to mode.
QRectF rect() const override
Returns the target rect of this image node.
TextureCoordinatesTransformMode textureCoordinatesTransform() const override
Returns the mode used to generate texture coordinates for this node.
void setSourceRect(const QRectF &r) override
Sets the source rect of this image node to rect.
void setTexture(QSGTexture *texture) override
Sets the texture of this image node to texture.
void setAnisotropyLevel(QSGTexture::AnisotropyLevel level) override
Sets this image node's anistropy level to level.
void setMipmapFiltering(QSGTexture::Filtering filtering) override
Sets the mipmap filtering to be used for this image node to filtering.
void setFiltering(QSGTexture::Filtering filtering) override
Sets the filtering to be used for this image node to filtering.
void setRect(const QRectF &rect) override
Sets the target rect of this image node to rect.
QSGTexture::AnisotropyLevel anisotropyLevel() const override
Returns this image node's anistropy level.
void setOwnsTexture(bool owns) override
Sets whether the node takes ownership of the texture to owns.
void setMaterial(QSGMaterial *material)
Sets the material of this geometry node to material.
Definition qsgnode.cpp:927
void setOpaqueMaterial(QSGMaterial *material)
Sets the opaque material of this geometry to material.
Definition qsgnode.cpp:958
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
static void rebuildGeometry(QSGGeometry *g, QSGTexture *texture, const QRectF &rect, QRectF sourceRect, TextureCoordinatesTransformMode texCoordMode)
Updates the geometry g with the texture, the coordinates in rect, and the texture coordinates from so...
@ DirtyMaterial
Definition qsgnode.h:75
@ DirtyGeometry
Definition qsgnode.h:74
void markDirty(DirtyState bits)
Notifies all connected renderers that the node has dirty bits.
Definition qsgnode.cpp:624
QSGTexture::AnisotropyLevel anisotropyLevel() const
Returns this material's anistropy level.
void setFiltering(QSGTexture::Filtering filteringType)
Sets the filtering to filtering.
void setAnisotropyLevel(QSGTexture::AnisotropyLevel level)
Sets this material's anistropy level to level.
QSGTexture::Filtering filtering() const
Returns this material's filtering mode.
void setMipmapFiltering(QSGTexture::Filtering filteringType)
Sets the mipmap mode to filtering.
void setTexture(QSGTexture *texture)
Sets the texture of this material to texture.
QSGTexture::Filtering mipmapFiltering() const
Returns this material's mipmap filtering mode.
QSGTexture * texture() const
Returns this texture material's texture.
\inmodule QtQuick
Definition qsgtexture.h:20
Filtering
Specifies how sampling of texels should filter when texture coordinates are not pixel aligned.
Definition qsgtexture.h:34
AnisotropyLevel
Specifies the anisotropic filtering level to be used when the texture is not screen aligned.
Definition qsgtexture.h:40
Combined button and popup list for selecting options.
GLenum mode
GLenum GLuint GLint level
GLboolean r
[2]
GLenum GLuint texture
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
void qsgnode_set_description(QSGNode *node, const QString &description)
Definition qsgnode.cpp:641
QLatin1StringView QLatin1String
Definition qstringfwd.h:31