aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-10-26 13:42:08 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-10-26 13:42:08 +0100
commit3832b1e05b80a0f509be17dd3619a2f8bb70074f (patch)
tree3763c243b13c8228b1508ce5902dc2f587cabfdd /src/quick
parentf9fae251ca07401ee1b0039edc6ea6b7a522b5a7 (diff)
parent5c53861cced2d40490e4c7bfc202aadc532df4c2 (diff)
Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts: tests/auto/qml/qml.pro tools/qmlprofiler/qmlprofilerclient.cpp Change-Id: Id47f15a5ab38f8ec79f0a26c92805acba62caac4
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp20
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h1
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickitem.cpp20
-rw-r--r--src/quick/items/qquickshadereffectnode.cpp50
-rw-r--r--src/quick/items/qquickshadereffectnode_p.h14
-rw-r--r--src/quick/items/qquicktext.cpp38
-rw-r--r--src/quick/items/qquicktext_p_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp4
9 files changed, 83 insertions, 68 deletions
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<QQuickSprite*>(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 fa022af4ee..87d489a60a 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -344,6 +344,7 @@ public Q_SLOTS:
if (m_curFrame != arg) {
m_curFrame = arg;
Q_EMIT currentFrameChanged(arg); //TODO-C Only emitted on manual advance!
+ update();
}
}
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.
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index fb4fc2df0d..b6f35ad638 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<QQuickItem *> 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<QQuickItem*>(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 {
@@ -5918,7 +5920,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
@@ -5930,7 +5932,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
{
@@ -5952,10 +5954,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
@@ -5964,14 +5966,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
{
diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp
index b84a4adaab..ed9e29d599 100644
--- a/src/quick/items/qquickshadereffectnode.cpp
+++ b/src/quick/items/qquickshadereffectnode.cpp
@@ -350,11 +350,22 @@ uint qHash(const QQuickShaderEffectMaterialKey &key)
return hash;
}
-
-typedef QHash<QQuickShaderEffectMaterialKey, QWeakPointer<QSGMaterialType> > 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<QQuickShaderEffectMaterialCache *>(QStringLiteral("__qt_ShaderEffectCache"), Qt::FindDirectChildrenOnly);
+ if (!me && create) {
+ me = new QQuickShaderEffectMaterialCache();
+ me->setObjectName(QStringLiteral("__qt_ShaderEffectCache"));
+ me->setParent(ctx);
+ }
+ return me;
+ }
+ QHash<QQuickShaderEffectMaterialKey, QSGMaterialType *> cache;
+};
QQuickShaderEffectMaterial::QQuickShaderEffectMaterial(QQuickShaderEffectNode *node)
: cullMode(NoCulling)
@@ -367,7 +378,7 @@ QQuickShaderEffectMaterial::QQuickShaderEffectMaterial(QQuickShaderEffectNode *n
QSGMaterialType *QQuickShaderEffectMaterial::type() const
{
- return m_type.data();
+ return m_type;
}
QSGMaterialShader *QQuickShaderEffectMaterial::createShader() const
@@ -425,30 +436,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<QSGMaterialType> weakPtr = materialHash->value(m_source);
- m_type = weakPtr.toStrongRef();
- if (m_type.isNull()) {
- m_type = QSharedPointer<QSGMaterialType>(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;
}
}
@@ -501,4 +505,6 @@ void QQuickShaderEffectNode::preprocess()
static_cast<QQuickShaderEffectMaterial *>(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 420ca1237b..76aecd1b04 100644
--- a/src/quick/items/qquickshadereffectnode_p.h
+++ b/src/quick/items/qquickshadereffectnode_p.h
@@ -73,7 +73,6 @@ struct QQuickShaderEffectMaterialKey {
uint qHash(const QQuickShaderEffectMaterialKey &key);
-
class QQuickCustomMaterialShader;
class QQuickShaderEffectNode;
class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectMaterial : public QSGMaterial
@@ -117,13 +116,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<QSGMaterialType> 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;
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 895a616cb7..3b5982c3d0 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -129,14 +129,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()
@@ -161,30 +162,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<QImage>();
+ 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;
@@ -199,11 +198,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<QImage>();
}
void QQuickTextDocumentWithImageResources::reset()
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index 21086f1c3f..acdf45dfad 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -197,7 +197,7 @@ public:
};
class QQuickPixmap;
-class QQuickTextDocumentWithImageResources : public QTextDocument, public QTextObjectInterface
+class Q_AUTOTEST_EXPORT QQuickTextDocumentWithImageResources : public QTextDocument, public QTextObjectInterface
{
Q_OBJECT
Q_INTERFACES(QTextObjectInterface)
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 66a8f6fbd3..b1792d27a7 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -890,11 +890,11 @@ void Renderer::map(Buffer *buffer, int byteSize, bool isIndexBuf)
if (byteSize > pool.size())
pool.resize(byteSize);
buffer->data = pool.data();
- } else {
+ } else if (buffer->size != byteSize) {
+ free(buffer->data);
buffer->data = (char *) malloc(byteSize);
}
buffer->size = byteSize;
-
}
void Renderer::unmap(Buffer *buffer, bool isIndexBuf)