summaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgtextnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/items/qsgtextnode.cpp')
-rw-r--r--src/declarative/items/qsgtextnode.cpp71
1 files changed, 39 insertions, 32 deletions
diff --git a/src/declarative/items/qsgtextnode.cpp b/src/declarative/items/qsgtextnode.cpp
index 527dd2b2e2..3bbe0d2832 100644
--- a/src/declarative/items/qsgtextnode.cpp
+++ b/src/declarative/items/qsgtextnode.cpp
@@ -40,21 +40,23 @@
****************************************************************************/
#include "qsgtextnode_p.h"
-#include "solidrectnode.h"
-#include "adaptationlayer.h"
-#include "distancefieldglyphcache_p.h"
-#include "distancefield_glyphnode.h"
+#include "qsgsimplerectnode.h"
+#include <private/qsgadaptationlayer_p.h>
+#include <private/qsgdistancefieldglyphcache_p.h>
+#include <private/qsgdistancefieldglyphnode_p.h>
-#include "qsgcontext.h"
+#include <private/qsgcontext_p.h>
#include <qmath.h>
#include <qtextdocument.h>
#include <qtextlayout.h>
#include <qabstracttextdocumentlayout.h>
#include <qxmlstream.h>
+#include <qrawfont.h>
#include <private/qdeclarativestyledtext_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
+#include <private/qrawfont_p.h>
QT_BEGIN_NAMESPACE
@@ -80,13 +82,13 @@ void QSGTextNode::setColor(const QColor &color)
setUpdateFlag(UpdateNodes);
} else {
for (int i=0; i<childCount(); ++i) {
- Node *childNode = childAtIndex(i);
+ QSGNode *childNode = childAtIndex(i);
if (childNode->subType() == GlyphNodeSubType) {
- GlyphNodeInterface *glyphNode = static_cast<GlyphNodeInterface *>(childNode);
+ QSGGlyphNode *glyphNode = static_cast<QSGGlyphNode *>(childNode);
if (glyphNode->color() == m_color)
glyphNode->setColor(color);
} else if (childNode->subType() == SolidRectNodeSubType) {
- SolidRectNode *solidRectNode = static_cast<SolidRectNode *>(childNode);
+ QSGSimpleRectNode *solidRectNode = static_cast<QSGSimpleRectNode *>(childNode);
if (solidRectNode->color() == m_color)
solidRectNode->setColor(color);
}
@@ -102,13 +104,13 @@ void QSGTextNode::setStyleColor(const QColor &styleColor)
setUpdateFlag(UpdateNodes);
} else {
for (int i=0; i<childCount(); ++i) {
- Node *childNode = childAtIndex(i);
+ QSGNode *childNode = childAtIndex(i);
if (childNode->subType() == GlyphNodeSubType) {
- GlyphNodeInterface *glyphNode = static_cast<GlyphNodeInterface *>(childNode);
+ QSGGlyphNode *glyphNode = static_cast<QSGGlyphNode *>(childNode);
if (glyphNode->color() == m_styleColor)
glyphNode->setColor(styleColor);
} else if (childNode->subType() == SolidRectNodeSubType) {
- SolidRectNode *solidRectNode = static_cast<SolidRectNode *>(childNode);
+ QSGSimpleRectNode *solidRectNode = static_cast<QSGSimpleRectNode *>(childNode);
if (solidRectNode->color() == m_styleColor)
solidRectNode->setColor(styleColor);
}
@@ -119,43 +121,44 @@ void QSGTextNode::setStyleColor(const QColor &styleColor)
}
#endif
-void QSGTextNode::addTextDecorations(const QPointF &position, const QFont &font, const QColor &color,
- qreal width)
+void QSGTextNode::addTextDecorations(const QPointF &position, const QRawFont &font, const QColor &color,
+ qreal width, bool hasOverline, bool hasStrikeOut, bool hasUnderline)
{
- QFontPrivate *dptrFont = QFontPrivate::get(font);
- QFontEngine *fontEngine = dptrFont->engineForScript(QUnicodeTables::Common);
+ Q_ASSERT(font.isValid());
+ QRawFontPrivate *dptrFont = QRawFontPrivate::get(font);
+ QFontEngine *fontEngine = dptrFont->fontEngine;
qreal lineThickness = fontEngine->lineThickness().toReal();
QRectF line(position.x(), position.y() - lineThickness / 2.0, width, lineThickness);
- if (font.underline()) {
+ if (hasUnderline) {
int underlinePosition = fontEngine->underlinePosition().ceil().toInt();
QRectF underline(line);
underline.translate(0.0, underlinePosition);
- appendChildNode(new SolidRectNode(underline, color));
+ appendChildNode(new QSGSimpleRectNode(underline, color));
}
- qreal ascent = fontEngine->ascent().toReal();
- if (font.overline()) {
+ qreal ascent = font.ascent();
+ if (hasOverline) {
QRectF overline(line);
overline.translate(0.0, -ascent);
- appendChildNode(new SolidRectNode(overline, color));
+ appendChildNode(new QSGSimpleRectNode(overline, color));
}
- if (font.strikeOut()) {
+ if (hasStrikeOut) {
QRectF strikeOut(line);
strikeOut.translate(0.0, ascent / -3.0);
- appendChildNode(new SolidRectNode(strikeOut, color));
+ appendChildNode(new QSGSimpleRectNode(strikeOut, color));
}
}
-GlyphNodeInterface *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphs &glyphs, const QColor &color,
+QSGGlyphNode *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphs &glyphs, const QColor &color,
QSGText::TextStyle style, const QColor &styleColor)
{
- GlyphNodeInterface *node = m_context->createGlyphNode();
- if (DistanceFieldGlyphCache::distanceFieldEnabled()) {
- DistanceFieldGlyphNode *dfNode = static_cast<DistanceFieldGlyphNode *>(node);
+ QSGGlyphNode *node = m_context->createGlyphNode();
+ if (QSGDistanceFieldGlyphCache::distanceFieldEnabled()) {
+ QSGDistanceFieldGlyphNode *dfNode = static_cast<QSGDistanceFieldGlyphNode *>(node);
dfNode->setStyle(style);
dfNode->setStyleColor(styleColor);
}
@@ -189,8 +192,11 @@ void QSGTextNode::addTextLayout(const QPointF &position, QTextLayout *textLayout
addGlyphs(position, glyphsList.at(i), color, style, styleColor);
QFont font = textLayout->font();
- if (font.strikeOut() || font.underline() || font.overline())
- addTextDecorations(position, font, color, textLayout->boundingRect().width());
+ QRawFont rawFont = QRawFont::fromFont(font);
+ if (font.strikeOut() || font.underline() || font.overline()) {
+ addTextDecorations(position, rawFont, color, textLayout->boundingRect().width(),
+ font.overline(), font.strikeOut(), font.underline());
+ }
}
@@ -353,13 +359,14 @@ void QSGTextNode::addTextBlock(const QPointF &position, QTextDocument *textDocum
QList<QGlyphs> glyphsList = fragment.glyphs();
for (int i=0; i<glyphsList.size(); ++i) {
QGlyphs glyphs = glyphsList.at(i);
- GlyphNodeInterface *glyphNode = addGlyphs(position + blockPosition + ascent, glyphs,
+ QSGGlyphNode *glyphNode = addGlyphs(position + blockPosition + ascent, glyphs,
color, style, styleColor);
- QFont font = glyphs.font();
+ QRawFont font = glyphs.font();
QPointF baseLine = glyphNode->baseLine();
qreal width = glyphNode->boundingRect().width();
- addTextDecorations(baseLine, font, color, width);
+ addTextDecorations(baseLine, font, color, width,
+ glyphs.overline(), glyphs.strikeOut(), glyphs.underline());
}
}
@@ -387,7 +394,7 @@ void QSGTextNode::updateNodes()
// if (pixmap.isNull())
// return;
-// TextureNodeInterface *pixmapNode = m_context->createTextureNode();
+// QSGImageNode *pixmapNode = m_context->createImageNode();
// pixmapNode->setRect(pixmap.rect());
// pixmapNode->setSourceRect(pixmap.rect());
// pixmapNode->setOpacity(m_opacity);