aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2012-03-01 11:24:57 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-01 12:22:00 +0100
commitc0da7869001a52668f4ffaa851e05dd0ca6e6d67 (patch)
tree457cc07456f8022496bc7e3ffe0a87a53f2fa39a /src
parent5422a86b39490c30ca86a272a111c3d7da15fb3f (diff)
Avoid unnecessary updates when using in-process cache
Whenever an in-process cache is updated, it will emit itemsAvailable() signals to all listening glyph caches. This will in turn cause each of the glyph caches to update and each of the glyph nodes to be preprocessed (the entire scene graph will be updated.) This happens even if the changes to the in-process cache are requested by an external client, due to a cross-process cache sharing mechanism. However, itemsAvailable() signals are only interesting if the items were requested by the in-process cache. We therefore add a mechanism now to check if the glyphs were actually requested by the cache before updating anything. Change-Id: I529f94b3928c2a5e06fec354014fa11d21671057 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp39
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h2
2 files changed, 36 insertions, 5 deletions
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
index e762898602..951ee210c5 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
@@ -90,7 +90,7 @@ QSGSharedDistanceFieldGlyphCache::QSGSharedDistanceFieldGlyphCache(const QByteAr
this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
Qt::DirectConnection);
connect(sharedGraphicsCache, SIGNAL(itemsUpdated(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
- this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
+ this, SLOT(reportItemsUpdated(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
Qt::DirectConnection);
connect(sharedGraphicsCache, SIGNAL(itemsInvalidated(QByteArray,QVector<quint32>)),
this, SLOT(reportItemsInvalidated(QByteArray,QVector<quint32>)),
@@ -542,9 +542,38 @@ void QSGSharedDistanceFieldGlyphCache::processPendingGlyphs()
}
void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &cacheId,
- void *bufferId, const QSize &bufferSize,
- const QVector<quint32> &itemIds,
- const QVector<QPoint> &positions)
+ void *bufferId,
+ const QSize &bufferSize,
+ const QVector<quint32> &itemIds,
+ const QVector<QPoint> &positions)
+{
+ bool requestedItemsInList = false;
+ {
+ QMutexLocker locker(&m_pendingGlyphsMutex);
+ if (m_cacheId != cacheId)
+ return;
+
+#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG)
+ qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsAvailable() called for %s (%d glyphs, bufferSize: %dx%d)",
+ cacheId.constData(), itemIds.size(), bufferSize.width(), bufferSize.height());
+#endif
+
+ for (int i=0; i<itemIds.size(); ++i) {
+ if (m_requestedGlyphsThatHaveNotBeenReturned.contains(itemIds.at(i))) {
+ requestedItemsInList = true;
+ break;
+ }
+ }
+ }
+
+ if (requestedItemsInList)
+ reportItemsUpdated(cacheId, bufferId, bufferSize, itemIds, positions);
+}
+
+void QSGSharedDistanceFieldGlyphCache::reportItemsUpdated(const QByteArray &cacheId,
+ void *bufferId, const QSize &bufferSize,
+ const QVector<quint32> &itemIds,
+ const QVector<QPoint> &positions)
{
{
QMutexLocker locker(&m_pendingGlyphsMutex);
@@ -554,7 +583,7 @@ void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &ca
Q_ASSERT(itemIds.size() == positions.size());
#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG)
- qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsAvailable() called for %s (%d glyphs, bufferSize: %dx%d)",
+ qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsUpdated() called for %s (%d glyphs, bufferSize: %dx%d)",
cacheId.constData(), itemIds.size(), bufferSize.width(), bufferSize.height());
#endif
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
index cadf4bc55b..8250b9706e 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
@@ -78,6 +78,8 @@ private Q_SLOTS:
void reportItemsAvailable(const QByteArray &cacheId,
void *bufferId, const QSize &bufferSize,
const QVector<quint32> &itemIds, const QVector<QPoint> &positions);
+ void reportItemsUpdated(const QByteArray &cacheId, void *bufferId, const QSize &bufferSize,
+ const QVector<quint32> &itemIds, const QVector<QPoint> &positions);
void reportItemsInvalidated(const QByteArray &cacheId, const QVector<quint32> &itemIds);
private: