summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-11-24 17:22:40 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-11-24 20:21:14 +0000
commitd6d7e4a46ddd1ad14a3a4874b06f59d68e734b64 (patch)
treec7a84cf58d7254586215bd72b9fe2a0a4f035e8e /src
parentec365b503d1090f75fc3b53b92f682116ffc39b7 (diff)
QAbstractTexture: expose mipLevel
This is supposed to be exposed for Qt6 Change-Id: I3fefcd706ca16328946f33d665055dfe2a4c3563 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit 5457ad2a0a58157c2ba7aa77c73d4b22883e4d0b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/render/texture/qabstracttexture.cpp25
-rw-r--r--src/render/texture/qabstracttexture.h4
-rw-r--r--src/render/texture/texture.cpp2
3 files changed, 30 insertions, 1 deletions
diff --git a/src/render/texture/qabstracttexture.cpp b/src/render/texture/qabstracttexture.cpp
index 3cc7177f8..0e8abe090 100644
--- a/src/render/texture/qabstracttexture.cpp
+++ b/src/render/texture/qabstracttexture.cpp
@@ -588,6 +588,15 @@ void QAbstractTexture::setSamples(int samples)
}
}
+void QAbstractTexture::setMipLevels(int mipLevels)
+{
+ Q_D(QAbstractTexture);
+ if (d->m_mipmapLevels != mipLevels) {
+ d->m_mipmapLevels = mipLevels;
+ emit mipLevelsChanged(mipLevels);
+ }
+}
+
/*!
Returns the number of samples per texel for the texture provider.
@@ -601,6 +610,22 @@ int QAbstractTexture::samples() const
}
/*!
+ \property Qt3DRender::QAbstractTexture::mipLevels
+
+ Holds the mipmap levels of the texture provider.
+ */
+/*!
+ \qmlproperty int Qt3DRender::QAbstractTexture::format
+
+ Holds the mipmap levels of the texture provider.
+ */
+int QAbstractTexture::mipLevels() const
+{
+ Q_D(const QAbstractTexture);
+ return d->m_mipmapLevels;
+}
+
+/*!
\property Qt3DRender::QAbstractTexture::format
Holds the format of the texture provider.
diff --git a/src/render/texture/qabstracttexture.h b/src/render/texture/qabstracttexture.h
index 47fc2a81d..bd5b3fa25 100644
--- a/src/render/texture/qabstracttexture.h
+++ b/src/render/texture/qabstracttexture.h
@@ -65,6 +65,7 @@ class Q_3DRENDERSHARED_EXPORT QAbstractTexture : public Qt3DCore::QNode
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
Q_PROPERTY(int depth READ depth WRITE setDepth NOTIFY depthChanged)
+ Q_PROPERTY(int mipLevels READ mipLevels WRITE setMipLevels NOTIFY mipLevelsChanged)
Q_PROPERTY(Filter magnificationFilter READ magnificationFilter WRITE setMagnificationFilter NOTIFY magnificationFilterChanged)
Q_PROPERTY(Filter minificationFilter READ minificationFilter WRITE setMinificationFilter NOTIFY minificationFilterChanged)
Q_PROPERTY(float maximumAnisotropy READ maximumAnisotropy WRITE setMaximumAnisotropy NOTIFY maximumAnisotropyChanged)
@@ -305,6 +306,7 @@ public:
int depth() const;
int layers() const;
int samples() const;
+ int mipLevels() const;
HandleType handleType() const;
QVariant handle() const;
@@ -324,6 +326,7 @@ public Q_SLOTS:
void setComparisonMode(ComparisonMode mode);
void setLayers(int layers);
void setSamples(int samples);
+ void setMipLevels(int mipLevels);
Q_SIGNALS:
void formatChanged(TextureFormat format);
@@ -341,6 +344,7 @@ Q_SIGNALS:
void samplesChanged(int samples);
Q_REVISION(13) void handleTypeChanged(HandleType handleType);
Q_REVISION(13) void handleChanged(QVariant handle);
+ void mipLevelsChanged(int mipLevels);
protected:
explicit QAbstractTexture(Qt3DCore::QNode *parent = nullptr);
diff --git a/src/render/texture/texture.cpp b/src/render/texture/texture.cpp
index 956d44a9e..27f45c949 100644
--- a/src/render/texture/texture.cpp
+++ b/src/render/texture/texture.cpp
@@ -124,7 +124,7 @@ void Texture::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
p.generateMipMaps = node->generateMipMaps();
p.layers = node->layers();
p.samples = node->samples();
- p.mipLevels = static_cast<const QAbstractTexturePrivate*>(QAbstractTexturePrivate::get(node))->m_mipmapLevels;
+ p.mipLevels = node->mipLevels();
if (p != m_properties) {
m_properties = p;
addDirtyFlag(DirtyProperties);