aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-06-30 09:08:35 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-06-30 09:08:35 +0200
commit5112821a37ab749f758e354e84703df2d09d5471 (patch)
tree8f19ba6e7661109675b5e1e9b0ddae94b4c96d4f /src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
parent5d2ea1d5e9d6e29a16d0e9333cfc2dc8e7c5b677 (diff)
parenta3f686cf7cc14ff481b972b1170a7ff76d0e0fd0 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: .qmake.conf src/qml/qml/qqmlengine.cpp src/quick/items/qquickitemsmodule.cpp tools/qml/main.cpp Change-Id: Ida8daf6b4d7e675385f2f5514c446e52dedaf136
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 9f1a44154c..14bc0fad07 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -267,6 +267,30 @@ void QSG24BitTextMaskShader::updateState(const RenderState &state, QSGMaterial *
}
}
+class QSG32BitColorTextShader : public QSGTextMaskShader
+{
+public:
+ QSG32BitColorTextShader(QFontEngine::GlyphFormat glyphFormat)
+ : QSGTextMaskShader(glyphFormat)
+ {
+ setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/32bitcolortext.frag"));
+ }
+
+ void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) Q_DECL_OVERRIDE;
+};
+
+void QSG32BitColorTextShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
+{
+ QSGTextMaskShader::updateState(state, newEffect, oldEffect);
+ QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect);
+ QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect);
+
+ if (oldMaterial == Q_NULLPTR || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
+ float opacity = material->color().w() * state.opacity();
+ program()->setUniformValue(m_color_id, opacity);
+ }
+}
+
class QSGStyledTextShader : public QSG8BitTextMaskShader
{
public:
@@ -497,8 +521,16 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
QSGMaterialType *QSGTextMaskMaterial::type() const
{
- static QSGMaterialType rgb, gray;
- return glyphCache()->glyphFormat() == QFontEngine::Format_A32 ? &rgb : &gray;
+ static QSGMaterialType argb, rgb, gray;
+ switch (glyphCache()->glyphFormat()) {
+ case QFontEngine::Format_ARGB:
+ return &argb;
+ case QFontEngine::Format_A32:
+ return &rgb;
+ case QFontEngine::Format_A8:
+ default:
+ return &gray;
+ }
}
QOpenGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const
@@ -508,10 +540,15 @@ QOpenGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const
QSGMaterialShader *QSGTextMaskMaterial::createShader() const
{
- QFontEngine::GlyphFormat glyphFormat = glyphCache()->glyphFormat();
- return glyphFormat == QFontEngine::Format_A32
- ? (QSGMaterialShader *) new QSG24BitTextMaskShader(glyphFormat)
- : (QSGMaterialShader *) new QSG8BitTextMaskShader(glyphFormat);
+ switch (QFontEngine::GlyphFormat glyphFormat = glyphCache()->glyphFormat()) {
+ case QFontEngine::Format_ARGB:
+ return new QSG32BitColorTextShader(glyphFormat);
+ case QFontEngine::Format_A32:
+ return new QSG24BitTextMaskShader(glyphFormat);
+ case QFontEngine::Format_A8:
+ default:
+ return new QSG8BitTextMaskShader(glyphFormat);
+ }
}
static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)