From c0da7869001a52668f4ffaa851e05dd0ca6e6d67 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 1 Mar 2012 11:24:57 +0100 Subject: [PATCH] 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 --- .../qsgshareddistancefieldglyphcache.cpp | 39 +++++++++++++++++++--- .../qsgshareddistancefieldglyphcache_p.h | 2 ++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp index e762898..951ee21 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,QVector)), Qt::DirectConnection); connect(sharedGraphicsCache, SIGNAL(itemsUpdated(QByteArray,void*,QSize,QVector,QVector)), - this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector,QVector)), + this, SLOT(reportItemsUpdated(QByteArray,void*,QSize,QVector,QVector)), Qt::DirectConnection); connect(sharedGraphicsCache, SIGNAL(itemsInvalidated(QByteArray,QVector)), this, SLOT(reportItemsInvalidated(QByteArray,QVector)), @@ -542,9 +542,38 @@ void QSGSharedDistanceFieldGlyphCache::processPendingGlyphs() } void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &cacheId, - void *bufferId, const QSize &bufferSize, - const QVector &itemIds, - const QVector &positions) + void *bufferId, + const QSize &bufferSize, + const QVector &itemIds, + const QVector &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, + const QVector &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 cadf4bc..8250b97 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 &itemIds, const QVector &positions); + void reportItemsUpdated(const QByteArray &cacheId, void *bufferId, const QSize &bufferSize, + const QVector &itemIds, const QVector &positions); void reportItemsInvalidated(const QByteArray &cacheId, const QVector &itemIds); private: -- 2.7.4