Clean up QSGVertexColorMaterial a bit
authorGunnar Sletta <gunnar.sletta@nokia.com>
Mon, 9 May 2011 10:41:00 +0000 (12:41 +0200)
committerGunnar Sletta <gunnar.sletta@nokia.com>
Mon, 9 May 2011 11:51:40 +0000 (13:51 +0200)
src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h

index a0220ce..b82cf28 100644 (file)
@@ -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);
index 429251a..dee64ba 100644 (file)
@@ -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
index 9f5e0ed..7f05537 100644 (file)
@@ -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