Add QSGFlatColorMaterial::compare for better sorting
authorGunnar Sletta <gunnar.sletta@nokia.com>
Thu, 1 Sep 2011 10:29:17 +0000 (12:29 +0200)
committerKim M. Kalland <kim.kalland@nokia.com>
Thu, 1 Sep 2011 13:25:18 +0000 (15:25 +0200)
Change-Id: Ic6229c777a30191ba131b3896984da4f3fecc9d5
Reviewed-on: http://codereview.qt.nokia.com/4066
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>

src/declarative/scenegraph/util/qsgflatcolormaterial.cpp
src/declarative/scenegraph/util/qsgflatcolormaterial.h

index 06ca28a..affdcad 100644 (file)
@@ -189,4 +189,12 @@ QSGMaterialShader *QSGFlatColorMaterial::createShader() const
     return new FlatColorMaterialShader;
 }
 
+
+int QSGFlatColorMaterial::compare(const QSGMaterial *other) const
+{
+    const QSGFlatColorMaterial *flat = static_cast<const QSGFlatColorMaterial *>(other);
+    return m_color.rgba() - flat->color().rgba();
+
+}
+
 QT_END_NAMESPACE
index fb04110..f6345b6 100644 (file)
@@ -61,6 +61,8 @@ public:
     void setColor(const QColor &color);
     const QColor &color() const { return m_color; }
 
+    int compare(const QSGMaterial *other) const;
+
 private:
     QColor m_color;
 };