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
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
6
8
9// Unlike our predecessor, QSGSimpleRectNode, use QSGVertexColorMaterial
10// instead of Flat in order to allow better batching in the renderer.
11
13 : m_geometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), 4)
14{
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
29
31{
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
40{
41 if (color != m_color) {
42 float r, g, b, a;
43 color.getRgbF(&r, &g, &b, &a);
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 }
52 }
53}
54
56{
57 return m_color;
58}
59
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore\reentrant
Definition qrect.h:484
void setGeometry(QSGGeometry *geometry)
Sets the geometry of this node to geometry.
Definition qsgnode.cpp:764
void setRect(const QRectF &rect) override
Sets the rectangle of this rect node to rect.
QColor color() const override
Returns the color of this rectangle.
QRectF rect() const override
Returns the rectangle that this rect node covers.
void setColor(const QColor &color) override
Sets the color of this rectangle to color.
void setMaterial(QSGMaterial *material)
Sets the material of this geometry node to material.
Definition qsgnode.cpp:927
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
ColoredPoint2D * vertexDataAsColoredPoint2D()
Convenience function to access the vertex data as a mutable array of QSGGeometry::ColoredPoint2D.
static void updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect)
Updates the geometry g with the coordinates in rect.
@ DirtyGeometry
Definition qsgnode.h:74
void markDirty(DirtyState bits)
Notifies all connected renderers that the node has dirty bits.
Definition qsgnode.cpp:624
rect
[4]
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLuint color
[2]
GLboolean GLboolean g
GLint y
void qsgnode_set_description(QSGNode *node, const QString &description)
Definition qsgnode.cpp:641
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
unsigned char uchar
Definition qtypes.h:32
The QSGGeometry::ColoredPoint2D struct is a convenience struct for accessing 2D Points with a color.
Definition qsggeometry.h:92