aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-11-22 11:01:19 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-11-27 20:18:42 +0100
commit3acc52f3d5eefdb17264c06aa6311b65e230d932 (patch)
tree6454300201bc7c4a2543ee78338dd8fb3d2a596f
parente53d9ed11520adbe022f03076029e3385ba3f741 (diff)
Fix text decoration on software backend
This amends d0cb311e0d3cd84c933bd993e6003f45be2ebdd8. In said change, text decoration was implemented using the curve renderer shaders, but neglected to consider that the QSGInternalTextNode is used on all backends. This caused decorations to disappear when using the software backend. This patch slightly refactors it, so that the shader-based approach is only used on the default RHI-based backend, and the software backend will still use a rectangle node, since this works well with that backend, even on fractional scaling displays. Task-number: QTBUG-86977 Change-Id: I08a595b1a794c5b41a0f239328dc6f5f2fce70c0 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/quick/CMakeLists.txt1
-rw-r--r--src/quick/items/qsginternaltextnode.cpp24
-rw-r--r--src/quick/items/qsginternaltextnode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext.cpp6
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext_p.h1
-rw-r--r--src/quick/scenegraph/qsgrhiinternaltextnode.cpp41
-rw-r--r--src/quick/scenegraph/qsgrhiinternaltextnode_p.h31
7 files changed, 82 insertions, 24 deletions
diff --git a/src/quick/CMakeLists.txt b/src/quick/CMakeLists.txt
index 2c2604edab..deac45631b 100644
--- a/src/quick/CMakeLists.txt
+++ b/src/quick/CMakeLists.txt
@@ -154,6 +154,7 @@ qt_internal_add_qml_module(Quick
scenegraph/qsgdistancefieldglyphnode_p_p.h
scenegraph/qsgrenderloop.cpp scenegraph/qsgrenderloop_p.h
scenegraph/qsgrhidistancefieldglyphcache.cpp scenegraph/qsgrhidistancefieldglyphcache_p.h
+ scenegraph/qsgrhiinternaltextnode.cpp scenegraph/qsgrhiinternaltextnode_p.h
scenegraph/qsgrhilayer.cpp scenegraph/qsgrhilayer_p.h
scenegraph/qsgrhishadereffectnode.cpp scenegraph/qsgrhishadereffectnode_p.h
scenegraph/qsgrhisupport.cpp scenegraph/qsgrhisupport_p.h
diff --git a/src/quick/items/qsginternaltextnode.cpp b/src/quick/items/qsginternaltextnode.cpp
index 7a82f24a29..ca0e8b0cfc 100644
--- a/src/quick/items/qsginternaltextnode.cpp
+++ b/src/quick/items/qsginternaltextnode.cpp
@@ -23,10 +23,6 @@
#include <private/qtextdocumentlayout_p.h>
#include <qhash.h>
-#include <private/qsgcurvefillnode_p.h>
-#include <private/qsgcurvestrokenode_p.h>
-#include <private/qsgcurveprocessor_p.h>
-
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcVP)
@@ -129,25 +125,7 @@ void QSGInternalTextNode::clearCursor()
void QSGInternalTextNode::addDecorationNode(const QRectF &rect, const QColor &color)
{
- QSGCurveStrokeNode *node = new QSGCurveStrokeNode;
- node->setColor(color);
- node->setStrokeWidth(rect.height());
-
- QQuadPath path;
- QPointF c = rect.center();
- path.moveTo(QVector2D(rect.left(), c.y()));
- path.lineTo(QVector2D(rect.right(), c.y()));
-
- QSGCurveProcessor::processStroke(path, 2, rect.height(), Qt::MiterJoin, Qt::FlatCap,
- [&node](const std::array<QVector2D, 3> &s,
- const std::array<QVector2D, 3> &p,
- const std::array<QVector2D, 3> &n,
- bool isLine) {
- Q_ASSERT(isLine);
- node->appendTriangle(s, std::array<QVector2D, 2>{p.at(0), p.at(2)}, n);
- });
- node->cookGeometry();
- appendChildNode(node);
+ addRectangleNode(rect, color);
}
void QSGInternalTextNode::addRectangleNode(const QRectF &rect, const QColor &color)
diff --git a/src/quick/items/qsginternaltextnode_p.h b/src/quick/items/qsginternaltextnode_p.h
index d0bf52d09c..eaece9087d 100644
--- a/src/quick/items/qsginternaltextnode_p.h
+++ b/src/quick/items/qsginternaltextnode_p.h
@@ -156,7 +156,7 @@ public:
void clearCursor();
void addRectangleNode(const QRectF &rect, const QColor &color);
- void addDecorationNode(const QRectF &rect, const QColor &color);
+ virtual void addDecorationNode(const QRectF &rect, const QColor &color);
void addImage(const QRectF &rect, const QImage &image);
void deleteContent();
QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp
index 379debfe82..7d1daa1716 100644
--- a/src/quick/scenegraph/qsgdefaultcontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultcontext.cpp
@@ -21,6 +21,7 @@
#endif
#include <QtQuick/private/qsgrhishadereffectnode_p.h>
#include <QtQuick/private/qsginternaltextnode_p.h>
+#include <QtQuick/private/qsgrhiinternaltextnode_p.h>
#include <QOpenGLContext>
@@ -146,6 +147,11 @@ QSGPainterNode *QSGDefaultContext::createPainterNode(QQuickPaintedItem *item)
return new QSGDefaultPainterNode(item);
}
+QSGInternalTextNode *QSGDefaultContext::createInternalTextNode(QSGRenderContext *renderContext)
+{
+ return new QSGRhiInternalTextNode(renderContext);
+}
+
QSGGlyphNode *QSGDefaultContext::createGlyphNode(QSGRenderContext *rc,
QSGTextNode::RenderType renderType,
int renderTypeQuality)
diff --git a/src/quick/scenegraph/qsgdefaultcontext_p.h b/src/quick/scenegraph/qsgdefaultcontext_p.h
index 9250224f50..922d340d1e 100644
--- a/src/quick/scenegraph/qsgdefaultcontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultcontext_p.h
@@ -34,6 +34,7 @@ public:
QSGInternalImageNode *createInternalImageNode(QSGRenderContext *renderContext) override;
QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override;
QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality) override;
+ QSGInternalTextNode *createInternalTextNode(QSGRenderContext *renderContext) override;
QSGLayer *createLayer(QSGRenderContext *renderContext) override;
QSurfaceFormat defaultSurfaceFormat() const override;
QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override;
diff --git a/src/quick/scenegraph/qsgrhiinternaltextnode.cpp b/src/quick/scenegraph/qsgrhiinternaltextnode.cpp
new file mode 100644
index 0000000000..6108ff7044
--- /dev/null
+++ b/src/quick/scenegraph/qsgrhiinternaltextnode.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qsgrhiinternaltextnode_p.h"
+
+#include <private/qquadpath_p.h>
+#include <private/qsgcurvefillnode_p.h>
+#include <private/qsgcurvestrokenode_p.h>
+#include <private/qsgcurveprocessor_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QSGRhiInternalTextNode::QSGRhiInternalTextNode(QSGRenderContext *renderContext)
+ : QSGInternalTextNode(renderContext)
+{
+}
+
+void QSGRhiInternalTextNode::addDecorationNode(const QRectF &rect, const QColor &color)
+{
+ QSGCurveStrokeNode *node = new QSGCurveStrokeNode;
+ node->setColor(color);
+ node->setStrokeWidth(rect.height());
+
+ QQuadPath path;
+ QPointF c = rect.center();
+ path.moveTo(QVector2D(rect.left(), c.y()));
+ path.lineTo(QVector2D(rect.right(), c.y()));
+
+ QSGCurveProcessor::processStroke(path, 2, rect.height(), Qt::MiterJoin, Qt::FlatCap,
+ [&node](const std::array<QVector2D, 3> &s,
+ const std::array<QVector2D, 3> &p,
+ const std::array<QVector2D, 3> &n,
+ bool isLine) {
+ Q_ASSERT(isLine);
+ node->appendTriangle(s, std::array<QVector2D, 2>{p.at(0), p.at(2)}, n);
+ });
+ node->cookGeometry();
+ appendChildNode(node);
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhiinternaltextnode_p.h b/src/quick/scenegraph/qsgrhiinternaltextnode_p.h
new file mode 100644
index 0000000000..88980773b3
--- /dev/null
+++ b/src/quick/scenegraph/qsgrhiinternaltextnode_p.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QSGRHIINTERNALTEXTNODE_P_H
+#define QSGRHIINTERNALTEXTNODE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qsginternaltextnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGRhiInternalTextNode : public QSGInternalTextNode
+{
+public:
+ QSGRhiInternalTextNode(QSGRenderContext *renderContext);
+ void addDecorationNode(const QRectF &rect, const QColor &color) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGRHIINTERNALTEXTNODE_P_H