aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-05-09 12:41:00 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-05-09 13:51:40 +0200
commit743f8df88ae2e40506ec8e006b14f6f415c4e1be (patch)
treed50d3868cb82b7c28c6a0ca0363adaf85338897c /src
parent79f2d3c2e95a19c7302f2612f0fbf7176e4f25d1 (diff)
Clean up QSGVertexColorMaterial a bit
Diffstat (limited to 'src')
-rw-r--r--src/declarative/scenegraph/qsgdefaultrectanglenode.cpp4
-rw-r--r--src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp30
-rw-r--r--src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h14
3 files changed, 12 insertions, 36 deletions
diff --git a/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp b/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
index a0220cef1f..b82cf283d9 100644
--- a/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
@@ -172,7 +172,7 @@ void QSGDefaultRectangleNode::setGradientStops(const QGradientStops &stops)
setGeometry(g);
setFlag(OwnsGeometry);
}
- static_cast<QSGVertexColorMaterial *>(material())->setOpaque(m_gradient_is_opaque);
+ static_cast<QSGVertexColorMaterial *>(material())->setColorsAreOpaque(m_gradient_is_opaque);
}
m_dirty_geometry = true;
@@ -348,7 +348,6 @@ void QSGDefaultRectangleNode::updateGeometry()
borderIndexData.append(borderVertexCount - 2);
}
- Q_ASSERT(QSGVertexColorMaterial::is(material()));
ColorVertex *vertices = (ColorVertex *)fillVertices;
fillColor = colorToColor4ub(stops.at(nextGradientStop).second);
@@ -460,7 +459,6 @@ void QSGDefaultRectangleNode::updateGeometry()
qreal gy = (innerRect.top() - halfPenWidth) + stops.at(nextGradientStop).first * m_rect.height();
Q_ASSERT(fillVertexCount >= 2);
- Q_ASSERT(QSGVertexColorMaterial::is(material()));
ColorVertex *vertices = (ColorVertex *)fillVertices;
fillColor = colorToColor4ub(stops.at(nextGradientStop).second);
diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
index 429251a02a..dee64ba9dd 100644
--- a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -128,35 +128,22 @@ const char *QSGVertexColorMaterialShader::fragmentShader() const {
*/
-QSGVertexColorMaterial::QSGVertexColorMaterial(bool opaque) : m_opaque(opaque)
+QSGVertexColorMaterial::QSGVertexColorMaterial()
{
- setFlag(Blending, !opaque);
+ setFlag(Blending, true);
}
/*!
- \fn bool QSGVertexColorMaterial::opaque() const
+ Sets if the renderer should treat colors as opaque.
- Returns if the vertex color material should interpret all colors
- as opaque.
+ Setting this flag can in some cases improve performance.
*/
-
-
-/*!
- Sets wether the material should interpret all colors in the
- geometry as \a opaque.
-
- This is an optimization hint. Setting opaque to true for geometry that only
- contains opaque colors, can lead to better performance.
-
- */
-
-void QSGVertexColorMaterial::setOpaque(bool opaque)
+void QSGVertexColorMaterial::setColorsAreOpaque(bool opaqueHint)
{
- setFlag(Blending, !opaque);
- m_opaque = opaque;
+ setFlag(Blending, !opaqueHint);
}
@@ -181,9 +168,4 @@ QSGMaterialShader *QSGVertexColorMaterial::createShader() const
return new QSGVertexColorMaterialShader;
}
-bool QSGVertexColorMaterial::is(const QSGMaterial *effect)
-{
- return effect->type() == &QSGVertexColorMaterialShader::type;
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h b/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h
index 9f5e0ed1db..7f05537986 100644
--- a/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h
+++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h
@@ -53,17 +53,13 @@ QT_MODULE(Declarative)
class QSGVertexColorMaterial : public QSGMaterial
{
public:
- QSGVertexColorMaterial(bool opaque = false);
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
-
- void setOpaque(bool opaque);
- bool opaque() const { return m_opaque; }
+ QSGVertexColorMaterial();
- static bool is(const QSGMaterial *effect);
+ void setColorsAreOpaque(bool opaqueHint);
-private:
- bool m_opaque;
+protected:
+ virtual QSGMaterialType *type() const;
+ virtual QSGMaterialShader *createShader() const;
};
QT_END_NAMESPACE