Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgrhiinternaltextnode.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 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
6#include <private/qquadpath_p.h>
7#include <private/qsgcurvefillnode_p.h>
8#include <private/qsgcurvestrokenode_p.h>
9#include <private/qsgcurveprocessor_p.h>
10
12
13QSGRhiInternalTextNode::QSGRhiInternalTextNode(QSGRenderContext *renderContext)
14 : QSGInternalTextNode(renderContext)
15{
16}
17
18void QSGRhiInternalTextNode::addDecorationNode(const QRectF &rect, const QColor &color)
19{
20 QSGCurveStrokeNode *node = new QSGCurveStrokeNode;
21 node->setColor(color);
22 node->setStrokeWidth(rect.height());
23
24 QQuadPath path;
25 QPointF c = rect.center();
26 path.moveTo(QVector2D(rect.left(), c.y()));
27 path.lineTo(QVector2D(rect.right(), c.y()));
28
29 QSGCurveProcessor::processStroke(path, 2, rect.height(), false, Qt::MiterJoin, Qt::FlatCap,
30 [&node](const std::array<QVector2D, 3> &s,
31 const std::array<QVector2D, 3> &p,
32 const std::array<QVector2D, 3> &n,
33 const std::array<float, 3> &ex,
34 QSGCurveStrokeNode::TriangleFlags f) {
35 Q_ASSERT(f.testFlag(QSGCurveStrokeNode::TriangleFlag::Line));
36 node->appendTriangle(s, std::array<QVector2D, 2>{p.at(0), p.at(2)}, n, ex);
37 });
38 node->cookGeometry();
39 appendChildNode(node);
40}
41
42QT_END_NAMESPACE