Renamed of texture material classes to be more intuitivly named
authorGunnar Sletta <gunnar.sletta@nokia.com>
Mon, 9 May 2011 10:56:50 +0000 (12:56 +0200)
committerGunnar Sletta <gunnar.sletta@nokia.com>
Mon, 9 May 2011 11:51:40 +0000 (13:51 +0200)
The assumption is that most people will use QSGTextureMaterial
so this should be the one that works for both transparent
and opaque textures. QSGOpaqueTextureMaterial is an optimization

src/declarative/items/qsgninepatchnode_p.h
src/declarative/scenegraph/qsgdefaultimagenode_p.h
src/declarative/scenegraph/util/qsgpainternode_p.h
src/declarative/scenegraph/util/qsgsimpletexturenode.h
src/declarative/scenegraph/util/qsgtexturematerial.cpp
src/declarative/scenegraph/util/qsgtexturematerial.h
src/declarative/scenegraph/util/qsgtexturematerial_p.h

index 533495d..ac927bc 100644 (file)
@@ -81,8 +81,8 @@ private:
     void fillRow(QSGGeometry::TexturedPoint2D *&v, float y, float ty, int xChunkCount, float xChunkSize);
     QRectF m_targetRect;
     QRectF m_innerRect;
-    QSGTextureMaterial m_material;
-    QSGTextureMaterialWithOpacity m_materialO;
+    QSGOpaqueTextureMaterial m_material;
+    QSGTextureMaterial m_materialO;
     QSGGeometry m_geometry;
 
     uint m_horizontalTileMode : 2;
index 8eb2c89..36ae51b 100644 (file)
@@ -75,8 +75,8 @@ private:
     QRectF m_targetRect;
     QRectF m_sourceRect;
 
-    QSGTextureMaterial m_material;
-    QSGTextureMaterialWithOpacity m_materialO;
+    QSGOpaqueTextureMaterial m_material;
+    QSGTextureMaterial m_materialO;
 
     uint m_dirtyGeometry : 1;
 
index 4174eb2..f2fdbe5 100644 (file)
@@ -118,8 +118,8 @@ private:
     QGLFramebufferObject *m_multisampledFbo;
     QImage m_image;
 
-    QSGTextureMaterial m_material;
-    QSGTextureMaterialWithOpacity m_materialO;
+    QSGOpaqueTextureMaterial m_material;
+    QSGTextureMaterial m_materialO;
     QSGGeometry m_geometry;
     QSGPainterTexture *m_texture;
 
index b4d8b71..44925be 100644 (file)
@@ -69,8 +69,8 @@ public:
 
 private:
     QSGGeometry m_geometry;
-    QSGTextureMaterial m_opaque_material;
-    QSGTextureMaterialWithOpacity m_material;
+    QSGOpaqueTextureMaterial m_opaque_material;
+    QSGTextureMaterial m_material;
 
     QRectF m_rect;
 };
index 717bf82..ae8edb5 100644 (file)
@@ -63,34 +63,34 @@ const char qt_scenegraph_texture_material_fragment[] =
     "}";
 
 
-const char *QSGTextureMaterialShader::vertexShader() const
+const char *QSGOpaqueTextureMaterialShader::vertexShader() const
 {
     return qt_scenegraph_texture_material_vertex_code;
 }
 
-const char *QSGTextureMaterialShader::fragmentShader() const
+const char *QSGOpaqueTextureMaterialShader::fragmentShader() const
 {
     return qt_scenegraph_texture_material_fragment;
 }
 
-QSGMaterialType QSGTextureMaterialShader::type;
+QSGMaterialType QSGOpaqueTextureMaterialShader::type;
 
-char const *const *QSGTextureMaterialShader::attributeNames() const
+char const *const *QSGOpaqueTextureMaterialShader::attributeNames() const
 {
     static char const *const attr[] = { "qt_VertexPosition", "qt_VertexTexCoord", 0 };
     return attr;
 }
 
-void QSGTextureMaterialShader::initialize()
+void QSGOpaqueTextureMaterialShader::initialize()
 {
     m_matrix_id = m_program.uniformLocation("qt_Matrix");
 }
 
-void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
+void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
 {
     Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());
-    QSGTextureMaterial *tx = static_cast<QSGTextureMaterial *>(newEffect);
-    QSGTextureMaterial *oldTx = static_cast<QSGTextureMaterial *>(oldEffect);
+    QSGOpaqueTextureMaterial *tx = static_cast<QSGOpaqueTextureMaterial *>(newEffect);
+    QSGOpaqueTextureMaterial *oldTx = static_cast<QSGOpaqueTextureMaterial *>(oldEffect);
 
     QSGTexture *t = tx->texture();
 
@@ -109,7 +109,7 @@ void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial
 }
 
 
-QSGTextureMaterial::QSGTextureMaterial()
+QSGOpaqueTextureMaterial::QSGOpaqueTextureMaterial()
     : m_texture(0)
     , m_filtering(QSGTexture::Nearest)
     , m_mipmap_filtering(QSGTexture::Nearest)
@@ -120,34 +120,34 @@ QSGTextureMaterial::QSGTextureMaterial()
 
 
 
-QSGMaterialType *QSGTextureMaterial::type() const
+QSGMaterialType *QSGOpaqueTextureMaterial::type() const
 {
-    return &QSGTextureMaterialShader::type;
+    return &QSGOpaqueTextureMaterialShader::type;
 }
 
-QSGMaterialShader *QSGTextureMaterial::createShader() const
+QSGMaterialShader *QSGOpaqueTextureMaterial::createShader() const
 {
-    return new QSGTextureMaterialShader;
+    return new QSGOpaqueTextureMaterialShader;
 }
 
 
-void QSGTextureMaterial::setTexture(QSGTexture *texture)
+void QSGOpaqueTextureMaterial::setTexture(QSGTexture *texture)
 {
     m_texture = texture;
     setFlag(Blending, m_texture ? m_texture->hasAlphaChannel() : false);
 }
 
 
-int QSGTextureMaterial::compare(const QSGMaterial *o) const
+int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const
 {
     Q_ASSERT(o && type() == o->type());
-    const QSGTextureMaterial *other = static_cast<const QSGTextureMaterial *>(o);
+    const QSGOpaqueTextureMaterial *other = static_cast<const QSGOpaqueTextureMaterial *>(o);
     if (int diff = m_texture->textureId() - other->texture()->textureId())
         return diff;
     return int(m_filtering) - int(other->m_filtering);
 }
 
-// QSGTextureMaterialWithOpacity
+// QSGTextureMaterial
 
 static const char qt_scenegraph_texture_material_opacity_fragment[] =
     "varying highp vec2 qt_TexCoord;                       \n"
@@ -157,7 +157,7 @@ static const char qt_scenegraph_texture_material_opacity_fragment[] =
     "    gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * opacity; \n"
     "}";
 
-class TextureMaterialWithOpacityShader : public QSGTextureMaterialShader
+class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader
 {
 public:
     virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
@@ -170,30 +170,30 @@ protected:
 
     int m_opacity_id;
 };
-QSGMaterialType TextureMaterialWithOpacityShader::type;
+QSGMaterialType QSGTextureMaterialShader::type;
 
-QSGMaterialType *QSGTextureMaterialWithOpacity::type() const
+QSGMaterialType *QSGTextureMaterial::type() const
 {
-    return &TextureMaterialWithOpacityShader::type;
+    return &QSGTextureMaterialShader::type;
 }
 
-QSGMaterialShader *QSGTextureMaterialWithOpacity::createShader() const
+QSGMaterialShader *QSGTextureMaterial::createShader() const
 {
-    return new TextureMaterialWithOpacityShader;
+    return new QSGTextureMaterialShader;
 }
 
-void TextureMaterialWithOpacityShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
+void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
 {
     Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());
     if (state.isOpacityDirty())
         m_program.setUniformValue(m_opacity_id, state.opacity());
 
-    QSGTextureMaterialShader::updateState(state, newEffect, oldEffect);
+    QSGOpaqueTextureMaterialShader::updateState(state, newEffect, oldEffect);
 }
 
-void TextureMaterialWithOpacityShader::initialize()
+void QSGTextureMaterialShader::initialize()
 {
-    QSGTextureMaterialShader::initialize();
+    QSGOpaqueTextureMaterialShader::initialize();
     m_opacity_id = m_program.uniformLocation("opacity");
 }
 
index 8a7c1a9..375d484 100644 (file)
@@ -52,10 +52,10 @@ QT_BEGIN_NAMESPACE
 QT_MODULE(Declarative)
 
 
-class Q_DECLARATIVE_EXPORT QSGTextureMaterial : public QSGMaterial
+class Q_DECLARATIVE_EXPORT QSGOpaqueTextureMaterial : public QSGMaterial
 {
 public:
-    QSGTextureMaterial();
+    QSGOpaqueTextureMaterial();
 
     virtual QSGMaterialType *type() const;
     virtual QSGMaterialShader *createShader() const;
@@ -83,10 +83,12 @@ protected:
     uint m_mipmap_filtering: 2;
     uint m_horizontal_wrap : 1;
     uint m_vertical_wrap: 1;
+
+    uint m_reserved : 26;
 };
 
 
-class Q_DECLARATIVE_EXPORT QSGTextureMaterialWithOpacity : public QSGTextureMaterial
+class Q_DECLARATIVE_EXPORT QSGTextureMaterial : public QSGOpaqueTextureMaterial
 {
 public:
     virtual QSGMaterialType *type() const;
index 6b811c6..3e14da5 100644 (file)
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
 
 QT_MODULE(Declarative)
 
-class Q_DECLARATIVE_EXPORT QSGTextureMaterialShader : public QSGMaterialShader
+class Q_DECLARATIVE_EXPORT QSGOpaqueTextureMaterialShader : public QSGMaterialShader
 {
 public:
     virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);