From 884e0194eecb5d0c13218818972542f87ca46393 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Sun, 11 Sep 2011 09:26:05 +0200 Subject: [PATCH] Implement QSGVertexColorMaterial::compare and make the class public Since the opaque state is just as easily settable through the Blending flag, we ditch it Change-Id: I92598e3305bd056fdf0711f1fbd6c1be8bf88275 Reviewed-on: http://codereview.qt-project.org/4628 Reviewed-by: Qt Sanity Bot Reviewed-by: Kim M. Kalland --- .../scenegraph/qsgdefaultrectanglenode.cpp | 2 +- .../scenegraph/util/qsgvertexcolormaterial.cpp | 14 ++-- .../scenegraph/util/qsgvertexcolormaterial.h | 69 ++++++++++++++++++++ .../scenegraph/util/qsgvertexcolormaterial_p.h | 69 -------------------- 4 files changed, 77 insertions(+), 77 deletions(-) create mode 100644 src/declarative/scenegraph/util/qsgvertexcolormaterial.h delete mode 100644 src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h diff --git a/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp b/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp index b49966b..2905f06 100644 --- a/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp +++ b/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp @@ -174,7 +174,7 @@ void QSGDefaultRectangleNode::setGradientStops(const QGradientStops &stops) setGeometry(g); setFlag(OwnsGeometry); } - static_cast(material())->setColorsAreOpaque(m_gradient_is_opaque); + static_cast(material())->setFlag(QSGMaterial::Blending, !m_gradient_is_opaque); } m_dirty_geometry = true; diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp index c31e9dc..26edbc2 100644 --- a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp @@ -134,20 +134,20 @@ QSGVertexColorMaterial::QSGVertexColorMaterial() } - /*! - Sets if the renderer should treat colors as opaque. + int QSGVertexColorMaterial::compare() const + + As the vertex color material has all its state in the vertex attributes, + all materials will be equal. - Setting this flag can in some cases improve performance. + \internal */ -void QSGVertexColorMaterial::setColorsAreOpaque(bool opaqueHint) +int QSGVertexColorMaterial::compare(const QSGMaterial *other) const { - setFlag(Blending, !opaqueHint); + return 0; } - - /*! \internal */ diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial.h b/src/declarative/scenegraph/util/qsgvertexcolormaterial.h new file mode 100644 index 0000000..c244f63 --- /dev/null +++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VERTEXCOLORMATERIAL_H +#define VERTEXCOLORMATERIAL_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QSGVertexColorMaterial : public QSGMaterial +{ +public: + QSGVertexColorMaterial(); + + int compare(const QSGMaterial *other) const; + +protected: + virtual QSGMaterialType *type() const; + virtual QSGMaterialShader *createShader() const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // VERTEXCOLORMATERIAL_H diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h b/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h deleted file mode 100644 index 8392ef2..0000000 --- a/src/declarative/scenegraph/util/qsgvertexcolormaterial_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VERTEXCOLORMATERIAL_H -#define VERTEXCOLORMATERIAL_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QSGVertexColorMaterial : public QSGMaterial -{ -public: - QSGVertexColorMaterial(); - - void setColorsAreOpaque(bool opaqueHint); - -protected: - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // VERTEXCOLORMATERIAL_H -- 1.7.2.5