aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-01-27 10:08:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-12 09:24:40 +0100
commit15999f14f146b5c04fb40b31b69ceeeece273430 (patch)
treec4694e18da30dc10075ca10e254bca02c3061383 /src/quick/items
parent4cf4d18b98f5ceaafc3f595c5eadad9ceb337813 (diff)
Add Image::mipmap to support mipmapping of images.
[ChangeLog][QtQuick] New feature: Image.mipmap Task-number: QTBUG-19961 Change-Id: I13acb2408d5b126790adaf9d324ad4beda1e3646 Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp2
-rw-r--r--src/quick/items/qquickimage.cpp45
-rw-r--r--src/quick/items/qquickimage_p.h5
-rw-r--r--src/quick/items/qquickimage_p_p.h1
-rw-r--r--src/quick/items/qquickitemsmodule.cpp1
-rw-r--r--src/quick/items/qquickwindow.cpp1
6 files changed, 50 insertions, 5 deletions
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index 8dd48b4988..d3f2a956a3 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -427,7 +427,6 @@ QSGTexture *QQuickContext2DFBOTexture::textureForNextFrame(QSGTexture *lastTextu
if (m_fbo) {
if (!texture) {
texture = new QSGPlainTexture();
- texture->setHasMipmaps(false);
texture->setHasAlphaChannel(true);
texture->setOwnsTexture(false);
m_dirtyTexture = true;
@@ -655,7 +654,6 @@ QSGTexture *QQuickContext2DImageTexture::textureForNextFrame(QSGTexture *last)
if (!texture) {
texture = new QSGPlainTexture();
- texture->setHasMipmaps(false);
texture->setHasAlphaChannel(true);
m_dirtyTexture = true;
}
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index 62ac72d244..b6b8a2a39b 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -72,7 +72,7 @@ public:
QSGTexture *texture() const {
if (m_texture) {
m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
- m_texture->setMipmapFiltering(QSGTexture::Nearest);
+ m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge);
m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge);
}
@@ -83,6 +83,7 @@ public:
QSGTexture *m_texture;
bool m_smooth;
+ bool m_mipmap;
};
#include "qquickimage.moc"
@@ -92,6 +93,7 @@ QQuickImagePrivate::QQuickImagePrivate()
, paintedWidth(0)
, paintedHeight(0)
, pixmapChanged(false)
+ , mipmap(false)
, hAlign(QQuickImage::AlignHCenter)
, vAlign(QQuickImage::AlignVCenter)
, provider(0)
@@ -372,6 +374,8 @@ qreal QQuickImage::paintedHeight() const
no visual or performance effect.
By default, this property is set to true.
+
+ \sa mipmap
*/
/*!
@@ -549,6 +553,7 @@ QSGTextureProvider *QQuickImage::textureProvider() const
QQuickImagePrivate *dd = const_cast<QQuickImagePrivate *>(d);
dd->provider = new QQuickImageTextureProvider;
dd->provider->m_smooth = d->smooth;
+ dd->provider->m_mipmap = d->mipmap;
dd->provider->updateTexture(d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window()));
}
@@ -564,6 +569,7 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
// Copy over the current texture state into the texture provider...
if (d->provider) {
d->provider->m_smooth = d->smooth;
+ d->provider->m_mipmap = d->mipmap;
d->provider->updateTexture(texture);
}
@@ -673,13 +679,14 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
if (d->pixmapChanged) {
// force update the texture in the node to trigger reconstruction of
// geometry and the likes when a atlas segment has changed.
- if (texture->isAtlasTexture() && (hWrap == QSGTexture::Repeat || vWrap == QSGTexture::Repeat))
+ if (texture->isAtlasTexture() && (hWrap == QSGTexture::Repeat || vWrap == QSGTexture::Repeat || d->mipmap))
node->setTexture(texture->removedFromAtlas());
else
node->setTexture(texture);
d->pixmapChanged = false;
}
+ node->setMipmapFiltering(d->mipmap ? QSGTexture::Linear : QSGTexture::None);
node->setHorizontalWrapMode(hWrap);
node->setVerticalWrapMode(vWrap);
node->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest);
@@ -746,4 +753,38 @@ void QQuickImage::setHorizontalAlignment(HAlignment align)
emit horizontalAlignmentChanged(align);
}
+/*!
+ \qmlproperty bool QtQuick::Image::mipmap
+ \since 5.3
+
+ This property holds whether the image uses mipmap filtering when scaled or
+ transformed.
+
+ Mipmap filtering gives better visual quality when scaling down
+ compared to smooth, but it may come at a performance cost (both when
+ initializing the image and during rendering).
+
+ By default, this property is set to false.
+
+ \sa smooth
+ */
+
+bool QQuickImage::mipmap() const
+{
+ Q_D(const QQuickImage);
+ return d->mipmap;
+}
+
+void QQuickImage::setMipmap(bool use)
+{
+ Q_D(QQuickImage);
+ if (d->mipmap == use)
+ return;
+ d->mipmap = use;
+ emit mipmapChanged(d->mipmap);
+
+ d->pixmapChanged = true;
+ update();
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h
index e62c355dd4..902e613b04 100644
--- a/src/quick/items/qquickimage_p.h
+++ b/src/quick/items/qquickimage_p.h
@@ -60,6 +60,7 @@ class Q_AUTOTEST_EXPORT QQuickImage : public QQuickImageBase
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged)
Q_PROPERTY(HAlignment horizontalAlignment READ horizontalAlignment WRITE setHorizontalAlignment NOTIFY horizontalAlignmentChanged)
Q_PROPERTY(VAlignment verticalAlignment READ verticalAlignment WRITE setVerticalAlignment NOTIFY verticalAlignmentChanged)
+ Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged REVISION 1)
public:
QQuickImage(QQuickItem *parent=0);
@@ -91,11 +92,15 @@ public:
bool isTextureProvider() const { return true; }
QSGTextureProvider *textureProvider() const;
+ bool mipmap() const;
+ void setMipmap(bool use);
+
Q_SIGNALS:
void fillModeChanged();
void paintedGeometryChanged();
void horizontalAlignmentChanged(HAlignment alignment);
void verticalAlignmentChanged(VAlignment alignment);
+ void mipmapChanged(bool);
protected:
QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent);
diff --git a/src/quick/items/qquickimage_p_p.h b/src/quick/items/qquickimage_p_p.h
index 632f76c51f..de88662ab8 100644
--- a/src/quick/items/qquickimage_p_p.h
+++ b/src/quick/items/qquickimage_p_p.h
@@ -73,6 +73,7 @@ public:
void setImage(const QImage &img);
bool pixmapChanged : 1;
+ bool mipmap : 1;
QQuickImage::HAlignment hAlign;
QQuickImage::VAlignment vAlign;
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index a52ccf4832..c9c8eeace3 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -272,6 +272,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickText, 3>(uri, 2, 3, "Text");
qmlRegisterType<QQuickTextEdit, 3>(uri, 2, 3, "TextEdit");
+ qmlRegisterType<QQuickImage, 1>(uri, 2, 3,"Image");
}
static void initResources()
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 6778cf13e9..3828c89dbf 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -3094,7 +3094,6 @@ QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, Create
QSGPlainTexture *texture = new QSGPlainTexture();
texture->setTextureId(id);
texture->setHasAlphaChannel(options & TextureHasAlphaChannel);
- texture->setHasMipmaps(options & TextureHasMipmaps);
texture->setOwnsTexture(options & TextureOwnsGLTexture);
texture->setTextureSize(size);
return texture;