From c76f09b985dd7c4b4e4b5394c954ce5cd64f985a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 6 Dec 2013 14:59:06 +0100 Subject: [PATCH] Update cache size when pixmap size becomes known The QML engine can reserve space in the pixmap cache (a QHash of pointers) significantly before the pixmap is actually loaded. We can only be sure about the actual size of the loaded image after it has been loaded, though. This means we have to show pixmap cache updates in two stages. One for "space reserved" and for "pixmap actually cached" Change-Id: Ic7a7cd522e74d8b9b42dfbd6a9a0c4e9ffd6a401 Reviewed-by: Kai Koehne --- .../qmlprofilerextension/pixmapcachemodel.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index 04680543e7f..13b1dd03115 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -336,6 +336,7 @@ void PixmapCacheModel::loadData() int lastCacheSizeEvent = -1; int cumulatedCount = 0; QVector < int > pixmapStartPoints; + QVector < int > pixmapCachePoints; foreach (const QmlProfilerSimpleModel::QmlEventData &event, simpleModel->getEvents()) { if (!eventAccepted(event)) @@ -353,6 +354,7 @@ void PixmapCacheModel::loadData() d->pixmapUrls << event.location.filename; d->pixmapSizes << QPair(0,0); // default value pixmapStartPoints << -1; // dummy value to be filled by load event + pixmapCachePoints << -1; // dummy value to be filled by cache event } newEvent.eventId = newEvent.urlIndex + 1; @@ -361,7 +363,10 @@ void PixmapCacheModel::loadData() switch (newEvent.pixmapEventType) { case PixmapSizeKnown: // pixmap size d->pixmapSizes[newEvent.urlIndex] = QPair((int)event.numericData1, (int)event.numericData2); - break; + if (pixmapCachePoints[newEvent.urlIndex] == -1) + break; + // else fall through and update cache size + newEvent.pixmapEventType = PixmapCacheCountChanged; case PixmapCacheCountChanged: {// Cache Size Changed Event startTime = event.startTime + 1; // delay 1 ns for proper sorting newEvent.eventId = 0; @@ -372,13 +377,17 @@ void PixmapCacheModel::loadData() qint64 prevSize = 0; if (lastCacheSizeEvent != -1) { prevSize = d->range(lastCacheSizeEvent).cacheSize; - if (event.numericData3 < cumulatedCount) - pixSize = -pixSize; - cumulatedCount = event.numericData3; + if (pixmapCachePoints[newEvent.urlIndex] == -1) { + // else it's a synthesized update and doesn't have a valid cache count + if (event.numericData3 < cumulatedCount) + pixSize = -pixSize; + cumulatedCount = event.numericData3; + } d->insertEnd(lastCacheSizeEvent, startTime - d->range(lastCacheSizeEvent).start); } newEvent.cacheSize = prevSize + pixSize; lastCacheSizeEvent = d->insertStart(startTime, newEvent); + pixmapCachePoints[newEvent.urlIndex] = lastCacheSizeEvent; break; } case PixmapLoadingStarted: // Load