diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2013-12-06 14:59:06 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2013-12-12 11:41:40 +0200 |
commit | c76f09b985dd7c4b4e4b5394c954ce5cd64f985a (patch) | |
tree | fca759cf7d81df14bc209a381a83d24d50f96f9b | |
parent | 96e0cbacb2e93cccd6d6ed5937aa7ee4d8eaff86 (diff) |
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 <kai.koehne@digia.com>
-rw-r--r-- | plugins/qmlprofilerextension/pixmapcachemodel.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index 04680543e7..13b1dd0311 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<int, int>(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,int>((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 |