aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-03-21 16:34:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-06 10:10:31 +0200
commit0b190b7114c816689eeb8478ea5151732bc7a5de (patch)
tree3d92604a6f789e1d14359cd2b2a83dfb1b94692c /src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
parentd01e595d362fcc8347f410eecdf055f80dd5423f (diff)
Fixed distance field text when using non-opaque colors.
The alpha has to be premultiplied before passing the color to the shader. Change-Id: If22f0e0892eb4330d5f7398bea2710fce18c4dcb Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp')
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index 45fc0f5c6d..86c3356d58 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -144,8 +144,8 @@ void QSGDistanceFieldTextMaterialShader::updateState(const RenderState &state, Q
if (oldMaterial == 0
|| material->color() != oldMaterial->color()
|| state.isOpacityDirty()) {
- QVector4D color(material->color().redF(), material->color().greenF(),
- material->color().blueF(), material->color().alphaF());
+ QColor c = material->color();
+ QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
color *= state.opacity();
program()->setUniformValue(m_color_id, color);
}
@@ -204,6 +204,14 @@ QSGMaterialType *QSGDistanceFieldTextMaterial::type() const
return &type;
}
+void QSGDistanceFieldTextMaterial::setColor(const QColor &color)
+{
+ m_color = QColor::fromRgbF(color.redF() * color.alphaF(),
+ color.greenF() * color.alphaF(),
+ color.blueF() * color.alphaF(),
+ color.alphaF());
+}
+
QSGMaterialShader *QSGDistanceFieldTextMaterial::createShader() const
{
return new QSGDistanceFieldTextMaterialShader;
@@ -276,8 +284,8 @@ void DistanceFieldStyledTextMaterialShader::updateState(const RenderState &state
if (oldMaterial == 0
|| material->styleColor() != oldMaterial->styleColor()
|| (state.isOpacityDirty())) {
- QVector4D color(material->styleColor().redF(), material->styleColor().greenF(),
- material->styleColor().blueF(), material->styleColor().alphaF());
+ QColor c = material->styleColor();
+ QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
color *= state.opacity();
program()->setUniformValue(m_styleColor_id, color);
}
@@ -292,6 +300,14 @@ QSGDistanceFieldStyledTextMaterial::~QSGDistanceFieldStyledTextMaterial()
{
}
+void QSGDistanceFieldStyledTextMaterial::setStyleColor(const QColor &color)
+{
+ m_styleColor = QColor::fromRgbF(color.redF() * color.alphaF(),
+ color.greenF() * color.alphaF(),
+ color.blueF() * color.alphaF(),
+ color.alphaF());
+}
+
int QSGDistanceFieldStyledTextMaterial::compare(const QSGMaterial *o) const
{
Q_ASSERT(o && type() == o->type());