Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
4
#
include
"qsgdefaultimagenode_p.h"
5
#
include
<
private
/
qsgnode_p
.
h
>
6
7
QT_BEGIN_NAMESPACE
8
9
QSGDefaultImageNode::QSGDefaultImageNode()
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);
18
m_material.setMipmapFiltering(QSGTexture::None);
19
m_opaque_material.setMipmapFiltering(QSGTexture::None);
20
#
ifdef
QSG_RUNTIME_DESCRIPTION
21
qsgnode_set_description(
this
, QLatin1String(
"image"
));
22
#
endif
23
}
24
25
QSGDefaultImageNode::~QSGDefaultImageNode()
26
{
27
if
(m_ownsTexture)
28
delete
m_material.texture();
29
}
30
31
void
QSGDefaultImageNode::setFiltering(QSGTexture::Filtering filtering)
32
{
33
if
(m_material.filtering() == filtering)
34
return
;
35
36
m_material.setFiltering(filtering);
37
m_opaque_material.setFiltering(filtering);
38
markDirty(DirtyMaterial);
39
}
40
41
QSGTexture::Filtering QSGDefaultImageNode::filtering()
const
42
{
43
return
m_material.filtering();
44
}
45
46
void
QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
47
{
48
if
(m_material.mipmapFiltering() == filtering)
49
return
;
50
51
m_material.setMipmapFiltering(filtering);
52
m_opaque_material.setMipmapFiltering(filtering);
53
markDirty(DirtyMaterial);
54
}
55
56
QSGTexture::Filtering QSGDefaultImageNode::mipmapFiltering()
const
57
{
58
return
m_material.mipmapFiltering();
59
}
60
61
void
QSGDefaultImageNode::setAnisotropyLevel(QSGTexture::AnisotropyLevel level)
62
{
63
if
(m_material.anisotropyLevel() == level)
64
return
;
65
66
m_material.setAnisotropyLevel(level);
67
m_opaque_material.setAnisotropyLevel(level);
68
markDirty(DirtyMaterial);
69
}
70
71
QSGTexture::AnisotropyLevel QSGDefaultImageNode::anisotropyLevel()
const
72
{
73
return
m_material.anisotropyLevel();
74
}
75
76
void
QSGDefaultImageNode::setRect(
const
QRectF &r)
77
{
78
if
(m_rect == r)
79
return
;
80
81
m_rect = r;
82
rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
83
markDirty(DirtyGeometry);
84
}
85
86
QRectF QSGDefaultImageNode::rect()
const
87
{
88
return
m_rect;
89
}
90
91
void
QSGDefaultImageNode::setSourceRect(
const
QRectF &r)
92
{
93
if
(m_sourceRect == r)
94
return
;
95
96
m_sourceRect = r;
97
rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
98
markDirty(DirtyGeometry);
99
}
100
101
QRectF QSGDefaultImageNode::sourceRect()
const
102
{
103
return
m_sourceRect;
104
}
105
106
void
QSGDefaultImageNode::setTexture(QSGTexture *texture)
107
{
108
Q_ASSERT(texture);
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
130
QSGTexture *QSGDefaultImageNode::texture()
const
131
{
132
return
m_material.texture();
133
}
134
135
void
QSGDefaultImageNode::setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode)
136
{
137
if
(m_texCoordMode == mode)
138
return
;
139
m_texCoordMode = mode;
140
rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
141
markDirty(DirtyMaterial);
142
}
143
144
QSGDefaultImageNode::TextureCoordinatesTransformMode QSGDefaultImageNode::textureCoordinatesTransform()
const
145
{
146
return
m_texCoordMode;
147
}
148
149
void
QSGDefaultImageNode::setOwnsTexture(
bool
owns)
150
{
151
m_ownsTexture = owns;
152
}
153
154
bool
QSGDefaultImageNode::ownsTexture()
const
155
{
156
return
m_ownsTexture;
157
}
158
159
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quick
scenegraph
util
qsgdefaultimagenode.cpp
Generated on
for Qt by
1.18.0