From 6cb62485394e49791d2ea35dc3a59926df271f0d Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Thu, 14 May 2015 12:42:37 +0200 Subject: QAbstractTextureProvider add unique property Will allow to disable texture sharing in the backend when needed, defaults to false Change-Id: If3a75c7763db6eb479319d5c0b9356b164e0f163 Reviewed-by: Andy Nichols Reviewed-by: Sean Harmer --- src/core/nodes/qnodeid.h | 3 +- src/render/frontend/qabstracttextureprovider.cpp | 49 ++++++++++++++++++++++-- src/render/frontend/qabstracttextureprovider.h | 5 +++ src/render/frontend/qabstracttextureprovider_p.h | 1 + 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/core/nodes/qnodeid.h b/src/core/nodes/qnodeid.h index 77ea96ff3..ec1e6ce07 100644 --- a/src/core/nodes/qnodeid.h +++ b/src/core/nodes/qnodeid.h @@ -92,8 +92,9 @@ private: QT3DCORESHARED_EXPORT QDebug operator<<(QDebug d, const QNodeId &id); #endif -inline uint qHash(const QNodeId &id, uint) Q_DECL_NOTHROW +inline uint qHash(const QNodeId &id, uint seed = 0) Q_DECL_NOTHROW { + Q_UNUSED(seed); return id.id(); } diff --git a/src/render/frontend/qabstracttextureprovider.cpp b/src/render/frontend/qabstracttextureprovider.cpp index 549332c0c..cafe2861c 100644 --- a/src/render/frontend/qabstracttextureprovider.cpp +++ b/src/render/frontend/qabstracttextureprovider.cpp @@ -62,6 +62,7 @@ QAbstractTextureProviderPrivate::QAbstractTextureProviderPrivate(QAbstractTextur , m_comparisonFunction(QAbstractTextureProvider::CompareLessEqual) , m_comparisonMode(QAbstractTextureProvider::CompareNone) , m_maximumLayers(1) + , m_unique(false) { } @@ -126,9 +127,9 @@ QAbstractTextureProvider::~QAbstractTextureProvider() */ void QAbstractTextureProvider::setSize(int w, int h, int d) { - setWidth(w); - setHeight(h); - setDepth(d); + setWidth(w); + setHeight(h); + setDepth(d); } /*! @@ -209,12 +210,51 @@ void QAbstractTextureProvider::setMaximumLayers(int maximumLayers) } } +/*! + Returns the maximum number of layers for the texture provider. + + \note this has a meaning only for texture providers that have 3D or + array target formats. + */ int QAbstractTextureProvider::maximumLayers() const { Q_D(const QAbstractTextureProvider); return d->m_maximumLayers; } +/*! + \property Qt3D::QAbstractTextureProvider::unique + + Sets whether this texture provider should be unique by reading \a unique. + By default this is false. + + By default the renderer based on the attributes of texture providers is + able to compare them and detect duplicates (same size, format and image + sources) and smartly avoid unnecessary computations. In some cases however + (texture providers used as Qt3D::RenderTarget attachments) you don't want + the renderer to perform these comparison, in which case you can set is + unique to true. + */ +void QAbstractTextureProvider::setUnique(bool unique) +{ + Q_D(QAbstractTextureProvider); + if (d->m_unique != unique) { + d->m_unique = unique; + emit uniqueChanged(); + } +} + +/*! + Returns whether the texture should be shared with other textures in the + renderer or not. Defaults to false as this allow in most cases the renderer + to be faster. + */ +bool QAbstractTextureProvider::isUnique() const +{ + Q_D(const QAbstractTextureProvider); + return d->m_unique; +} + /*! \property Qt3D::QAbstractTextureProvider::format @@ -229,6 +269,9 @@ void QAbstractTextureProvider::setFormat(TextureFormat format) } } +/*! + Return the texture provider's format. + */ QAbstractTextureProvider::TextureFormat QAbstractTextureProvider::format() const { Q_D(const QAbstractTextureProvider); diff --git a/src/render/frontend/qabstracttextureprovider.h b/src/render/frontend/qabstracttextureprovider.h index b8cad3b6e..025270cd5 100644 --- a/src/render/frontend/qabstracttextureprovider.h +++ b/src/render/frontend/qabstracttextureprovider.h @@ -66,6 +66,7 @@ class QT3DRENDERERSHARED_EXPORT QAbstractTextureProvider : public QNode Q_PROPERTY(ComparisonFunction comparisonFunction READ comparisonFunction WRITE setComparisonFunction NOTIFY comparisonFunctionChanged) Q_PROPERTY(ComparisonMode comparisonMode READ comparisonMode WRITE setComparisonMode NOTIFY comparisonModeChanged) Q_PROPERTY(int maximumLayers READ maximumLayers WRITE setMaximumLayers NOTIFY maximumLayersChanged) + Q_PROPERTY(bool unique READ isUnique WRITE setUnique NOTIFY uniqueChanged) public: @@ -296,6 +297,9 @@ public: void setMaximumLayers(int maximumLayers); int maximumLayers() const; + void setUnique(bool unique); + bool isUnique() const; + Q_SIGNALS: void formatChanged(); void statusChanged(); @@ -309,6 +313,7 @@ Q_SIGNALS: void comparisonFunctionChanged(); void comparisonModeChanged(); void maximumLayersChanged(); + void uniqueChanged(); protected: explicit QAbstractTextureProvider(QNode *parent = 0); diff --git a/src/render/frontend/qabstracttextureprovider_p.h b/src/render/frontend/qabstracttextureprovider_p.h index d1d8eb982..c3fafb402 100644 --- a/src/render/frontend/qabstracttextureprovider_p.h +++ b/src/render/frontend/qabstracttextureprovider_p.h @@ -69,6 +69,7 @@ public : QAbstractTextureProvider::ComparisonMode m_comparisonMode; QList m_textureImages; int m_maximumLayers; + bool m_unique; }; } // QT3D -- cgit v1.2.3