aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/items/qsgimage.cpp4
-rw-r--r--src/declarative/scenegraph/util/qsgtexture.cpp26
-rw-r--r--src/declarative/scenegraph/util/qsgtexture.h3
3 files changed, 30 insertions, 3 deletions
diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp
index 92b454b695..a23d9ede1b 100644
--- a/src/declarative/items/qsgimage.cpp
+++ b/src/declarative/items/qsgimage.cpp
@@ -63,6 +63,10 @@ public:
}
QSGTexture *texture() const {
+
+ if (m_texture->isAtlasTexture())
+ const_cast<QSGImageTextureProvider *>(this)->m_texture = m_texture->removedFromAtlas();
+
if (m_texture) {
m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
m_texture->setMipmapFiltering(QSGTexture::Nearest);
diff --git a/src/declarative/scenegraph/util/qsgtexture.cpp b/src/declarative/scenegraph/util/qsgtexture.cpp
index 4e208c02b7..7cd398d9e0 100644
--- a/src/declarative/scenegraph/util/qsgtexture.cpp
+++ b/src/declarative/scenegraph/util/qsgtexture.cpp
@@ -193,11 +193,33 @@ QSGTexture::~QSGTexture()
Binding a texture may also include uploading the texture data from
a previously set QImage.
+
+ \warning This function can only be called from the rendering thread.
+ */
+
+/*!
+ This function returns a copy of the current texture which is removed
+ from its atlas.
+
+ The current texture remains unchanged, so texture coordinates do not
+ need to be updated.
+
+ Removing a texture from an atlas is primarily useful when passing
+ it to a shader that operates on the texture coordinates 0-1 instead
+ of the texture subrect inside the atlas.
+
+ If the texture is not part of a texture atlas, this function returns 0.
+
+ Implementations of this function are recommended to return the same instance
+ for multiple calls to limit memory usage.
+
+ \warning This function can only be called from the rendering thread.
*/
-void QSGTexture::removeFromAtlas()
+QSGTexture *QSGTexture::removedFromAtlas() const
{
- // default textures are not in atlasses, so do nothing...
+ Q_ASSERT_X(!isAtlasTexture(), "QSGTexture::removedFromAtlas()", "Called on a non-atlas texture");
+ return 0;
}
/*!
diff --git a/src/declarative/scenegraph/util/qsgtexture.h b/src/declarative/scenegraph/util/qsgtexture.h
index 5506042c6a..135c5e403f 100644
--- a/src/declarative/scenegraph/util/qsgtexture.h
+++ b/src/declarative/scenegraph/util/qsgtexture.h
@@ -80,7 +80,8 @@ public:
virtual QRectF textureSubRect() const;
virtual bool isAtlasTexture() const;
- virtual void removeFromAtlas();
+
+ virtual QSGTexture *removedFromAtlas() const;
virtual void bind() = 0;
void updateBindOptions(bool force = false);