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
qsgdefaultrectanglenode.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
"qsgdefaultrectanglenode_p.h"
5
#
include
"qsgflatcolormaterial.h"
6
7
QT_BEGIN_NAMESPACE
8
9
// Unlike our predecessor, QSGSimpleRectNode, use QSGVertexColorMaterial
10
// instead of Flat in order to allow better batching in the renderer.
11
12
QSGDefaultRectangleNode::QSGDefaultRectangleNode()
13
: m_geometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), 4)
14
{
15
QSGGeometry::updateColoredRectGeometry(&m_geometry, QRectF());
16
setMaterial(&m_material);
17
setGeometry(&m_geometry);
18
setColor(QColor(255, 255, 255));
19
#
ifdef
QSG_RUNTIME_DESCRIPTION
20
qsgnode_set_description(
this
, QLatin1String(
"rectangle"
));
21
#
endif
22
}
23
24
void
QSGDefaultRectangleNode::setRect(
const
QRectF &rect)
25
{
26
QSGGeometry::updateColoredRectGeometry(&m_geometry, rect);
27
markDirty(QSGNode::DirtyGeometry);
28
}
29
30
QRectF QSGDefaultRectangleNode::rect()
const
31
{
32
const
QSGGeometry::ColoredPoint2D *pts = m_geometry.vertexDataAsColoredPoint2D();
33
return
QRectF(pts[0].x,
34
pts[0].y,
35
pts[3].x - pts[0].x,
36
pts[3].y - pts[0].y);
37
}
38
39
void
QSGDefaultRectangleNode::setColor(
const
QColor &color)
40
{
41
if
(color != m_color) {
42
float
r, g, b, a;
43
color.getRgbF(&r, &g, &b, &a);
44
QSGGeometry::ColoredPoint2D *pts = m_geometry.vertexDataAsColoredPoint2D();
45
for
(
int
i = 0; i < 4; ++i) {
46
pts[i].r = uchar(qRound(r * a * 255));
47
pts[i].g = uchar(qRound(g * a * 255));
48
pts[i].b = uchar(qRound(b * a * 255));
49
pts[i].a = uchar(qRound(a * 255));
50
}
51
markDirty(QSGNode::DirtyGeometry);
52
m_color = color;
53
}
54
}
55
56
QColor QSGDefaultRectangleNode::color()
const
57
{
58
return
m_color;
59
}
60
61
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quick
scenegraph
util
qsgdefaultrectanglenode.cpp
Generated on
for Qt by
1.18.0