From 6343aea363d2bd885f55339a9aa2f82fb8ec7bf2 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 1 Sep 2011 12:29:17 +0200 Subject: [PATCH] Add QSGFlatColorMaterial::compare for better sorting Change-Id: Ic6229c777a30191ba131b3896984da4f3fecc9d5 Reviewed-on: http://codereview.qt.nokia.com/4066 Reviewed-by: Qt Sanity Bot Reviewed-by: Kim M. Kalland --- .../scenegraph/util/qsgflatcolormaterial.cpp | 8 ++++++++ .../scenegraph/util/qsgflatcolormaterial.h | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp b/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp index 06ca28a..affdcad 100644 --- a/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp +++ b/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp @@ -189,4 +189,12 @@ QSGMaterialShader *QSGFlatColorMaterial::createShader() const return new FlatColorMaterialShader; } + +int QSGFlatColorMaterial::compare(const QSGMaterial *other) const +{ + const QSGFlatColorMaterial *flat = static_cast(other); + return m_color.rgba() - flat->color().rgba(); + +} + QT_END_NAMESPACE diff --git a/src/declarative/scenegraph/util/qsgflatcolormaterial.h b/src/declarative/scenegraph/util/qsgflatcolormaterial.h index fb04110..f6345b6 100644 --- a/src/declarative/scenegraph/util/qsgflatcolormaterial.h +++ b/src/declarative/scenegraph/util/qsgflatcolormaterial.h @@ -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; }; -- 1.7.2.5