Skip to content

Commit

Permalink
Clean up QSGVertexColorMaterial a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunnar Sletta committed May 9, 2011
1 parent 79f2d3c commit 743f8df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 36 deletions.
4 changes: 1 addition & 3 deletions src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
30 changes: 6 additions & 24 deletions src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
Expand Up @@ -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);
}


Expand All @@ -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
14 changes: 5 additions & 9 deletions src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h
Expand Up @@ -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
Expand Down

0 comments on commit 743f8df

Please sign in to comment.