Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1414)

Unified Diff: Source/platform/graphics/paint/DisplayItemList.cpp

Issue 1313223002: Simplify subtree (now subsequence) caching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/graphics/paint/DisplayItemList.cpp
diff --git a/Source/platform/graphics/paint/DisplayItemList.cpp b/Source/platform/graphics/paint/DisplayItemList.cpp
index 9c8fad763e60b0b3cbb4dbcea05602878a2bd54c..bf8d38c868b3007c82b95050953df488091c6f57 100644
--- a/Source/platform/graphics/paint/DisplayItemList.cpp
+++ b/Source/platform/graphics/paint/DisplayItemList.cpp
@@ -178,20 +178,20 @@ DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItem(DisplayItems::i
{
ASSERT(clientCacheIsValid(id.client));
- // Skip indexing of copied items.
- if (currentIt - context.nextItemToIndex > 0)
- context.nextItemToIndex = currentIt;
-
size_t foundIndex = findMatchingItemFromIndex(id, context.displayItemIndicesByClient, m_currentDisplayItems);
if (foundIndex != kNotFound)
return m_currentDisplayItems.begin() + foundIndex;
- return findOutOfOrderCachedItemForward(id, context);
+ return findOutOfOrderCachedItemForward(currentIt, id, context);
}
// Find forward for the item and index all skipped indexable items.
-DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(const DisplayItem::Id& id, OutOfOrderIndexContext& context)
+DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(DisplayItems::iterator currentIt, const DisplayItem::Id& id, OutOfOrderIndexContext& context)
{
+ // Items before currentIt should have been copied. Skip indexing of them.
+ if (currentIt - context.nextItemToIndex > 0)
+ context.nextItemToIndex = currentIt;
+
DisplayItems::iterator currentEnd = m_currentDisplayItems.end();
for (; context.nextItemToIndex != currentEnd; ++context.nextItemToIndex) {
const DisplayItem& item = *context.nextItemToIndex;
@@ -209,9 +209,9 @@ DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(const Di
void DisplayItemList::copyCachedSubtree(DisplayItems::iterator& currentIt, DisplayItems& updatedList)
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
- ASSERT(currentIt->isBeginSubtree());
+ ASSERT(currentIt->type() == DisplayItem::BeginSubtree);
ASSERT(!currentIt->scope());
- DisplayItem::Id endSubtreeId(currentIt->client(), DisplayItem::beginSubtreeTypeToEndSubtreeType(currentIt->type()), 0);
+ DisplayItem::Id endSubtreeId(currentIt->client(), DisplayItem::EndSubtree, 0);
do {
// We should always find the EndSubtree display item.
ASSERT(currentIt != m_currentDisplayItems.end());
@@ -295,32 +295,28 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
ASSERT(newDisplayItem.isCached());
ASSERT(clientCacheIsValid(newDisplayItem.client()));
if (!isSynchronized) {
- DisplayItems::iterator foundIt = findOutOfOrderCachedItem(currentIt, newDisplayItemId, outOfOrderIndexContext);
+ currentIt = findOutOfOrderCachedItem(currentIt, newDisplayItemId, outOfOrderIndexContext);
- if (foundIt == currentEnd) {
+ if (currentIt == currentEnd) {
#ifndef NDEBUG
showDebugData();
WTFLogAlways("%s not found in m_currentDisplayItems\n", newDisplayItem.asDebugString().utf8().data());
#endif
ASSERT_NOT_REACHED();
-
- // If foundIt == currentEnd, it means that we did not find the cached display item. This should be impossible, but may occur
- // if there is a bug in the system, such as under-invalidation, incorrect cache checking or duplicate display ids. In this case,
- // attempt to recover rather than crashing or bailing on display of the rest of the display list.
+ // We did not find the cached display item. This should be impossible, but may occur if there is a bug
+ // in the system, such as under-invalidation, incorrect cache checking or duplicate display ids.
+ // In this case, attempt to recover rather than crashing or bailing on display of the rest of the display list.
continue;
}
-
- ASSERT(foundIt != currentIt); // because we are in 'if (!isSynchronized)'
- currentIt = foundIt;
}
if (newDisplayItem.isCachedDrawing()) {
updatedList.appendByMoving(*currentIt, currentIt->derivedSize());
++currentIt;
} else {
- ASSERT(newDisplayItem.isCachedSubtree());
+ ASSERT(newDisplayItem.type() == DisplayItem::CachedSubtree);
copyCachedSubtree(currentIt, updatedList);
- ASSERT(updatedList.last().isEndSubtree());
+ ASSERT(updatedList.last().type() == DisplayItem::EndSubtree);
}
} else {
#if ENABLE(ASSERT)

Powered by Google App Engine
This is Rietveld 408576698