QQuickWindow::setColor() will be used in a call to \c glClear(),
which is potentially faster.
+ \li Mipmapped Image items are not placed in global atlas and will
+ not be batched.
+
\endlist
If an application performs poorly, make sure that rendering is
if (m_fbo) {
if (!texture) {
texture = new QSGPlainTexture();
- texture->setHasMipmaps(false);
texture->setHasAlphaChannel(true);
texture->setOwnsTexture(false);
m_dirtyTexture = true;
if (!texture) {
texture = new QSGPlainTexture();
- texture->setHasMipmaps(false);
texture->setHasAlphaChannel(true);
m_dirtyTexture = true;
}
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);
}
QSGTexture *m_texture;
bool m_smooth;
+ bool m_mipmap;
};
#include "qquickimage.moc"
, paintedWidth(0)
, paintedHeight(0)
, pixmapChanged(false)
+ , mipmap(false)
, hAlign(QQuickImage::AlignHCenter)
, vAlign(QQuickImage::AlignVCenter)
, provider(0)
no visual or performance effect.
By default, this property is set to true.
+
+ \sa mipmap
*/
/*!
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()));
}
// 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);
}
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);
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
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);
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);
void setImage(const QImage &img);
bool pixmapChanged : 1;
+ bool mipmap : 1;
QQuickImage::HAlignment hAlign;
QQuickImage::VAlignment vAlign;
qmlRegisterType<QQuickText, 3>(uri, 2, 3, "Text");
qmlRegisterType<QQuickTextEdit, 3>(uri, 2, 3, "TextEdit");
+ qmlRegisterType<QQuickImage, 1>(uri, 2, 3,"Image");
}
static void initResources()
QSGPlainTexture *texture = new QSGPlainTexture();
texture->setTextureId(id);
texture->setHasAlphaChannel(options & TextureHasAlphaChannel);
- texture->setHasMipmaps(options & TextureHasMipmaps);
texture->setOwnsTexture(options & TextureOwnsGLTexture);
texture->setTextureSize(size);
return texture;
m_nonatlas_texture = new QSGPlainTexture();
m_nonatlas_texture->setImage(m_image);
m_nonatlas_texture->setFiltering(filtering());
+ m_nonatlas_texture->setMipmapFiltering(mipmapFiltering());
}
return m_nonatlas_texture;
}
void QSGPainterNode::updateTexture()
{
- m_texture->setHasMipmaps(m_mipmapping);
m_texture->setHasAlphaChannel(!m_opaquePainting);
m_material.setTexture(m_texture);
m_materialO.setTexture(m_texture);
: QSGTexture()
, m_texture_id(0)
, m_has_alpha(false)
- , m_has_mipmaps(false)
, m_dirty_texture(false)
, m_dirty_bind_options(false)
, m_owns_texture(true)
m_mipmaps_generated = false;
}
-void QSGPlainTexture::setHasMipmaps(bool mm)
-{
- m_has_mipmaps = mm;
- m_mipmaps_generated = false;
-}
-
-
void QSGPlainTexture::bind()
{
if (!m_dirty_texture) {
glBindTexture(GL_TEXTURE_2D, m_texture_id);
- if (m_has_mipmaps && !m_mipmaps_generated) {
+ if (mipmapFiltering() != QSGTexture::None && !m_mipmaps_generated) {
QOpenGLContext *ctx = QOpenGLContext::currentContext();
ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
m_texture_id = 0;
m_texture_size = QSize();
- m_has_mipmaps = false;
m_has_alpha = false;
-
-
return;
}
#endif
- if (m_has_mipmaps) {
+ if (mipmapFiltering() != QSGTexture::None) {
context->functions()->glGenerateMipmap(GL_TEXTURE_2D);
m_mipmaps_generated = true;
}
void setHasAlphaChannel(bool alpha) { m_has_alpha = alpha; }
bool hasAlphaChannel() const { return m_has_alpha; }
- void setHasMipmaps(bool mm);
- bool hasMipmaps() const { return m_has_mipmaps; }
+ bool hasMipmaps() const { return mipmapFiltering() != QSGTexture::None; }
void setImage(const QImage &image);
const QImage &image() { return m_image; }
QRectF m_texture_rect;
uint m_has_alpha : 1;
- uint m_has_mipmaps : 1;
uint m_dirty_texture : 1;
uint m_dirty_bind_options : 1;
uint m_owns_texture : 1;
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+
+/*
+ The test verifies that scaled down mipmapped images contains
+ colors from all pixels.
+
+ #samples: 2
+ PixelPos R G B Error-tolerance
+ #final: 0 0 0.33 0.33 0.33 0.1
+ #final: 1 0 0.33 0.33 0.33 0.1
+*/
+
+RenderTestBase
+{
+ Image {
+ x: 0
+ y: 0
+ transformOrigin: Item.TopLeft
+ source: "mipmap_small.png"
+ mipmap: true
+ smooth: false
+ scale: 1 / width;
+ }
+
+ Image {
+ x: 1
+ y: 0
+ transformOrigin: Item.TopLeft
+ source: "mipmap_large.png"
+ mipmap: true
+ smooth: false
+ scale: 1 / width;
+ }
+
+ onEnterFinalStage: finalStageComplete = true;
+}
<< "data/render_BreakOpacityBatch.qml"
<< "data/render_OutOfFloatRange.qml"
<< "data/render_StackingOrder.qml"
+ << "data/render_Mipmap.qml"
;
QRegExp sampleCount("#samples: *(\\d+)");