From 90a67f40dc866889fc4b77184006036b290aaa26 Mon Sep 17 00:00:00 2001 From: Daniel Levin Date: Mon, 5 Oct 2015 17:42:32 -0400 Subject: Fixed 'plataforms' typo in WheelEvent documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I08907f6c0d435c2a056f759ba58f616a5b0368d2 Signed-off-by: Daniel Levin Reviewed-by: Tor Arne Vestbø --- src/quick/items/qquickevents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 1380452718..520b9d46bb 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -322,7 +322,7 @@ Item { /*! \qmlproperty point QtQuick::WheelEvent::pixelDelta - This property holds the delta in screen pixels and is available in plataforms that + This property holds the delta in screen pixels and is available in platforms that have high-resolution trackpads, such as OS X. The x and y cordinate of this property holds the delta in horizontal and vertical orientation. The value should be used directly to scroll content on screen. -- cgit v1.2.3 From 1551187f9c17bfa15686626d896ccbdd04d1f37a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 13 Oct 2015 09:58:33 +0200 Subject: Correct some areas of QQuickItem's documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2a2c684cd3f55a5a4311fd28b893e6a93c022ace Reviewed-by: Topi Reiniö --- src/quick/items/qquickitem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 1b728584b4..ab93974f60 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -5766,7 +5766,7 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt In Qt Quick 2.0, this property has minimal impact on performance. - By default is true. + By default, this property is set to \c true. */ /*! \property QQuickItem::smooth @@ -5778,7 +5778,7 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt In Qt Quick 2.0, this property has minimal impact on performance. - By default is true. + By default, this property is set to \c true. */ bool QQuickItem::smooth() const { @@ -5800,10 +5800,10 @@ void QQuickItem::setSmooth(bool smooth) /*! \qmlproperty bool QtQuick::Item::activeFocusOnTab - This property holds whether the item wants to be in tab focus - chain. By default this is set to false. + This property holds whether the item wants to be in the tab focus + chain. By default, this is set to \c false. - The tab focus chain traverses elements by visiting first the + The tab focus chain traverses elements by first visiting the parent, and then its children in the order they occur in the children property. Pressing the tab key on an item in the tab focus chain will move keyboard focus to the next item in the @@ -5812,14 +5812,14 @@ void QQuickItem::setSmooth(bool smooth) To set up a manual tab focus chain, see \l KeyNavigation. Tab key events used by Keys or KeyNavigation have precedence over - focus chain behavior, ignore the events in other key handlers + focus chain behavior; ignore the events in other key handlers to allow it to propagate. */ /*! \property QQuickItem::activeFocusOnTab - This property holds whether the item wants to be in tab focus - chain. By default this is set to false. + This property holds whether the item wants to be in the tab focus + chain. By default, this is set to \c false. */ bool QQuickItem::activeFocusOnTab() const { -- cgit v1.2.3 From 0789923f391f1e5bebe07b676a41c85a820b2533 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 12 Oct 2015 10:24:38 +0200 Subject: QQuickItem: detect loop in KeyNavigation chain Task-number: QTBUG-47229 Change-Id: I22dbe5ee1fff4e9a8de4fa69b43e4d9a87677192 Reviewed-by: J-P Nurmi --- src/quick/items/qquickitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index ab93974f60..fbea3a0ee1 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -724,6 +724,7 @@ void QQuickKeyNavigationAttached::setFocusNavigation(QQuickItem *currentItem, co { QQuickItem *initialItem = currentItem; bool isNextItem = false; + QVector visitedItems; do { isNextItem = false; if (currentItem->isVisible() && currentItem->isEnabled()) { @@ -734,13 +735,14 @@ void QQuickKeyNavigationAttached::setFocusNavigation(QQuickItem *currentItem, co if (attached) { QQuickItem *tempItem = qvariant_cast(attached->property(dir)); if (tempItem) { + visitedItems.append(currentItem); currentItem = tempItem; isNextItem = true; } } } } - while (currentItem != initialItem && isNextItem); + while (currentItem != initialItem && isNextItem && !visitedItems.contains(currentItem)); } struct SigMap { -- cgit v1.2.3 From 6aedee898e51804863f4e94f5bdcaece9398fe0a Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 31 Aug 2015 10:16:29 +0200 Subject: AnimatedSprite: avoid unnecessary redraws MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AnimatedSprite currently triggers a redraw for every update. however this should only be done, when the next frame will actually be different to the current one. Change-Id: I550bd32c02807e4c3f4847fb2608f5ad0cf0a59a Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickanimatedsprite.cpp | 20 ++++++++++++++++---- src/quick/items/qquickanimatedsprite_p.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index 5e653e426c..e37ed6c18c 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -374,6 +374,7 @@ void QQuickAnimatedSprite::stop() return; m_pauseOffset = 0; emit runningChanged(false); + update(); } /*! @@ -391,6 +392,7 @@ void QQuickAnimatedSprite::advance(int frames) m_curFrame += m_spriteEngine->maxFrames(); m_curFrame = m_curFrame % m_spriteEngine->maxFrames(); emit currentFrameChanged(m_curFrame); + update(); } /*! @@ -408,6 +410,7 @@ void QQuickAnimatedSprite::pause() m_pauseOffset = m_timestamp.elapsed(); m_paused = true; emit pausedChanged(true); + update(); } /*! @@ -425,6 +428,7 @@ void QQuickAnimatedSprite::resume() m_pauseOffset = m_pauseOffset - m_timestamp.elapsed(); m_paused = false; emit pausedChanged(false); + update(); } void QQuickAnimatedSprite::createEngine() @@ -436,6 +440,7 @@ void QQuickAnimatedSprite::createEngine() m_spriteEngine = new QQuickSpriteEngine(QList(spriteList), this); m_spriteEngine->startAssemblingImage(); reset(); + update(); } static QSGGeometry::Attribute AnimatedSprite_Attributes[] = { @@ -555,9 +560,12 @@ QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *, UpdatePaintNodeData *) prepareNextFrame(); if (m_running) { - update(); - if (m_node) + if (!m_paused) + update(); + + if (m_node) { m_node->markDirty(QSGNode::DirtyMaterial); + } } return m_node; @@ -614,12 +622,16 @@ void QQuickAnimatedSprite::prepareNextFrame() frameAt = 0; m_running = false; emit runningChanged(false); + update(); } } else { frameAt = m_curFrame; } - if (m_curFrame != lastFrame && isCurrentFrameChangedConnected()) - emit currentFrameChanged(m_curFrame); + if (m_curFrame != lastFrame) { + if (isCurrentFrameChangedConnected()) + emit currentFrameChanged(m_curFrame); + update(); + } qreal frameCount = m_spriteEngine->spriteFrames(); bool reverse = m_spriteEngine->sprite()->reverse(); diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index 4778afc88b..e535f1b077 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -333,6 +333,7 @@ public Q_SLOTS: if (m_curFrame != arg) { m_curFrame = arg; Q_EMIT currentFrameChanged(arg); //TODO-C Only emitted on manual advance! + update(); } } -- cgit v1.2.3 From b63185824ea213c2d19472fee302f007151dd5ca Mon Sep 17 00:00:00 2001 From: Roman Pasechnik Date: Sat, 11 Apr 2015 12:49:56 +0200 Subject: Fix QQuickTextDocumentWithImageResources image loading QQuickTextDocumentWithImageResources always tries to load images itself and not using QTextDocument internal resources. What it should do: 1) Check if QTextDocument already has image resource and use it. 2) If not, try to load resource manually. Change-Id: Ifc4d919fc4a08b4efae50e06a42f1af7cee67af3 Task-number: QTBUG-32525 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktext.cpp | 38 +++++++++++++++++--------------------- src/quick/items/qquicktext_p_p.h | 2 +- 2 files changed, 18 insertions(+), 22 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 205571f2e7..f848d0baee 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -120,14 +120,15 @@ QQuickTextDocumentWithImageResources::~QQuickTextDocumentWithImageResources() QVariant QQuickTextDocumentWithImageResources::loadResource(int type, const QUrl &name) { - QQmlContext *context = qmlContext(parent()); - - if (type == QTextDocument::ImageResource) { - QQuickPixmap *p = loadPixmap(context, name); - return p->image(); + QVariant resource = QTextDocument::loadResource(type, name); + if (resource.isNull() && type == QTextDocument::ImageResource) { + QQmlContext *context = qmlContext(parent()); + QUrl url = baseUrl().resolved(name); + QQuickPixmap *p = loadPixmap(context, url); + resource = p->image(); } - return QTextDocument::loadResource(type, name); + return resource; } void QQuickTextDocumentWithImageResources::requestFinished() @@ -152,30 +153,28 @@ QSizeF QQuickTextDocumentWithImageResources::intrinsicSize( QSizeF size(width, height); if (!hasWidth || !hasHeight) { - QQmlContext *context = qmlContext(parent()); - QUrl url = baseUrl().resolved(QUrl(imageFormat.name())); - - QQuickPixmap *p = loadPixmap(context, url); - if (!p->isReady()) { + QVariant res = resource(QTextDocument::ImageResource, QUrl(imageFormat.name())); + QImage image = res.value(); + if (image.isNull()) { if (!hasWidth) size.setWidth(16); if (!hasHeight) size.setHeight(16); return size; } - QSize implicitSize = p->implicitSize(); + QSize imgSize = image.size(); if (!hasWidth) { if (!hasHeight) - size.setWidth(implicitSize.width()); + size.setWidth(imgSize.width()); else - size.setWidth(qRound(height * (implicitSize.width() / (qreal) implicitSize.height()))); + size.setWidth(qRound(height * (imgSize.width() / (qreal) imgSize.height()))); } if (!hasHeight) { if (!hasWidth) - size.setHeight(implicitSize.height()); + size.setHeight(imgSize.height()); else - size.setHeight(qRound(width * (implicitSize.height() / (qreal) implicitSize.width()))); + size.setHeight(qRound(width * (imgSize.height() / (qreal) imgSize.width()))); } } return size; @@ -190,11 +189,8 @@ void QQuickTextDocumentWithImageResources::drawObject( QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format) { - QQmlContext *context = qmlContext(parent()); - QUrl url = baseUrl().resolved(QUrl(format.name())); - - QQuickPixmap *p = loadPixmap(context, url); - return p->image(); + QVariant res = resource(QTextDocument::ImageResource, QUrl(format.name())); + return res.value(); } void QQuickTextDocumentWithImageResources::reset() diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index cd14008728..28435bc8c5 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -179,7 +179,7 @@ public: }; class QQuickPixmap; -class QQuickTextDocumentWithImageResources : public QTextDocument, public QTextObjectInterface +class Q_AUTOTEST_EXPORT QQuickTextDocumentWithImageResources : public QTextDocument, public QTextObjectInterface { Q_OBJECT Q_INTERFACES(QTextObjectInterface) -- cgit v1.2.3 From d12391470f5a9b2f0ae22e11960177c5b7496a75 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 19 Oct 2015 14:50:06 +0200 Subject: Make it possible to change sources of ShaderEffect again. 92433623b31388e2e8c4d532033dad6189eaab24 introduced a bug where an unused material would clear its typeid pointer. This resulted in that a changed shadereffect would in all likelyhood get the same pointer for its changed shader which would result in using the same GL shader inside the renderer. This change rewrites the logic so that the cache is per render thread and the cache is cleaned up along with other GL/SG resources as part of scene graph invalidation. Task-number: QTBUG-48856 Change-Id: Id2feb14f584b5f5c176e8176cc9f1b54abd0d079 Reviewed-by: Michael Brasser Reviewed-by: Robert Griebl --- src/quick/items/qquickshadereffectnode.cpp | 50 +++++++++++++++++------------- src/quick/items/qquickshadereffectnode_p.h | 14 ++++----- 2 files changed, 34 insertions(+), 30 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp index de6cae0ea6..be6ecfae18 100644 --- a/src/quick/items/qquickshadereffectnode.cpp +++ b/src/quick/items/qquickshadereffectnode.cpp @@ -348,11 +348,22 @@ uint qHash(const QQuickShaderEffectMaterialKey &key) return hash; } - -typedef QHash > MaterialHash; - -Q_GLOBAL_STATIC(MaterialHash, materialHash) -Q_GLOBAL_STATIC(QMutex, materialHashMutex) +class QQuickShaderEffectMaterialCache : public QObject +{ + Q_OBJECT +public: + static QQuickShaderEffectMaterialCache *get(bool create = true) { + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QQuickShaderEffectMaterialCache *me = ctx->findChild(QStringLiteral("__qt_ShaderEffectCache"), Qt::FindDirectChildrenOnly); + if (!me && create) { + me = new QQuickShaderEffectMaterialCache(); + me->setObjectName(QStringLiteral("__qt_ShaderEffectCache")); + me->setParent(ctx); + } + return me; + } + QHash cache; +}; QQuickShaderEffectMaterial::QQuickShaderEffectMaterial(QQuickShaderEffectNode *node) : cullMode(NoCulling) @@ -365,7 +376,7 @@ QQuickShaderEffectMaterial::QQuickShaderEffectMaterial(QQuickShaderEffectNode *n QSGMaterialType *QQuickShaderEffectMaterial::type() const { - return m_type.data(); + return m_type; } QSGMaterialShader *QQuickShaderEffectMaterial::createShader() const @@ -423,30 +434,23 @@ int QQuickShaderEffectMaterial::compare(const QSGMaterial *o) const void QQuickShaderEffectMaterial::setProgramSource(const QQuickShaderEffectMaterialKey &source) { - QMutexLocker locker(materialHashMutex); - Q_UNUSED(locker); - m_source = source; m_emittedLogChanged = false; - QWeakPointer weakPtr = materialHash->value(m_source); - m_type = weakPtr.toStrongRef(); - if (m_type.isNull()) { - m_type = QSharedPointer(new QSGMaterialType); - materialHash->insert(m_source, m_type.toWeakRef()); + QQuickShaderEffectMaterialCache *cache = QQuickShaderEffectMaterialCache::get(); + m_type = cache->cache.value(m_source); + if (!m_type) { + m_type = new QSGMaterialType(); + cache->cache.insert(source, m_type); } } void QQuickShaderEffectMaterial::cleanupMaterialCache() { - QMutexLocker locker(materialHashMutex); - Q_UNUSED(locker); - - for (MaterialHash::iterator it = materialHash->begin(); it != materialHash->end(); ) { - if (!it.value().toStrongRef()) - it = materialHash->erase(it); - else - ++it; + QQuickShaderEffectMaterialCache *cache = QQuickShaderEffectMaterialCache::get(false); + if (cache) { + qDeleteAll(cache->cache.values()); + delete cache; } } @@ -499,4 +503,6 @@ void QQuickShaderEffectNode::preprocess() static_cast(material())->updateTextures(); } +#include "qquickshadereffectnode.moc" + QT_END_NAMESPACE diff --git a/src/quick/items/qquickshadereffectnode_p.h b/src/quick/items/qquickshadereffectnode_p.h index 28382c483c..a6a6d1b2fc 100644 --- a/src/quick/items/qquickshadereffectnode_p.h +++ b/src/quick/items/qquickshadereffectnode_p.h @@ -62,7 +62,6 @@ struct QQuickShaderEffectMaterialKey { uint qHash(const QQuickShaderEffectMaterialKey &key); - class QQuickCustomMaterialShader; class QQuickShaderEffectNode; class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectMaterial : public QSGMaterial @@ -106,13 +105,12 @@ public: protected: friend class QQuickCustomMaterialShader; - // The type pointer needs to be unique. It is not safe to let the type object be part of the - // QQuickShaderEffectMaterial, since it can be deleted and a new one constructed on top of the old - // one. The new QQuickShaderEffectMaterial would then get the same type pointer as the old one, and - // CustomMaterialShaders based on the old one would incorrectly be used together with the new - // one. To guarantee that the type pointer is unique, the type object must live as long as - // there are any CustomMaterialShaders of that type. - QSharedPointer m_type; + // Each material needs a unique type to ensure that the renderer has a one + // and exactly one GL program for every unique set of shader sources. + // setProgramSource() stores the sources in a cache along with the right + // type. The type is cleaned up in cleanupMaterialCache() which is called + // when the GL context is shut down. + QSGMaterialType *m_type; QQuickShaderEffectMaterialKey m_source; QQuickShaderEffectNode *m_node; -- cgit v1.2.3