| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
| 7 | 7 |
| 8 #include "platform/NotImplemented.h" | 8 #include "platform/NotImplemented.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/TraceEvent.h" | 10 #include "platform/TraceEvent.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient
.find(m_newDisplayItems.last().client()); | 53 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient
.find(m_newDisplayItems.last().client()); |
| 54 if (it != m_newDisplayItemIndicesByClient.end()) { | 54 if (it != m_newDisplayItemIndicesByClient.end()) { |
| 55 Vector<size_t>& indices = it->value; | 55 Vector<size_t>& indices = it->value; |
| 56 if (!indices.isEmpty() && indices.last() == (m_newDisplayItems.size() -
1)) | 56 if (!indices.isEmpty() && indices.last() == (m_newDisplayItems.size() -
1)) |
| 57 indices.removeLast(); | 57 indices.removeLast(); |
| 58 } | 58 } |
| 59 #endif | 59 #endif |
| 60 m_newDisplayItems.removeLast(); | 60 m_newDisplayItems.removeLast(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void DisplayItemList::add(WTF::PassOwnPtr<DisplayItem> displayItem) | 63 void DisplayItemList::processNewItem(DisplayItem* displayItem) |
| 64 { | 64 { |
| 65 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 65 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 66 ASSERT(!m_constructionDisabled); | 66 ASSERT(!m_constructionDisabled); |
| 67 ASSERT(!skippingCache() || !displayItem->isCached()); | 67 ASSERT(!skippingCache() || !displayItem->isCached()); |
| 68 | 68 |
| 69 if (DisplayItem::isCachedType(displayItem->type())) | 69 if (DisplayItem::isCachedType(displayItem->type())) |
| 70 ++m_numCachedItems; | 70 ++m_numCachedItems; |
| 71 | 71 |
| 72 #if ENABLE(ASSERT) | 72 #if ENABLE(ASSERT) |
| 73 // Verify noop begin/end pairs have been removed. | 73 // TODO(pdr): Reenable this assert. Note that the item has already been appended
. |
| 74 if (!m_newDisplayItems.isEmpty() && m_newDisplayItems.last().isBegin() && !m
_newDisplayItems.last().drawsContent()) | 74 // // Verify noop begin/end pairs have been removed. |
| 75 ASSERT(!displayItem->isEndAndPairedWith(m_newDisplayItems.last().type())
); | 75 // if (!m_newDisplayItems.isEmpty() && m_newDisplayItems.last().isBegin() &&
!m_newDisplayItems.last().drawsContent()) |
| 76 // ASSERT(!displayItem->isEndAndPairedWith(m_newDisplayItems.last().type(
))); |
| 76 #endif | 77 #endif |
| 77 | 78 |
| 78 if (!m_scopeStack.isEmpty()) | 79 if (!m_scopeStack.isEmpty()) |
| 79 displayItem->setScope(m_scopeStack.last().id, m_scopeStack.last().client
); | 80 displayItem->setScope(m_scopeStack.last().id, m_scopeStack.last().client
); |
| 80 | 81 |
| 81 #if ENABLE(ASSERT) | 82 #if ENABLE(ASSERT) |
| 82 size_t index = findMatchingItemFromIndex(displayItem->id(), displayItem->typ
e(), m_newDisplayItemIndicesByClient, m_newDisplayItems); | 83 size_t index = findMatchingItemFromIndex(displayItem->id(), displayItem->typ
e(), m_newDisplayItemIndicesByClient, m_newDisplayItems); |
| 83 if (index != kNotFound) { | 84 if (index != kNotFound) { |
| 84 #ifndef NDEBUG | 85 #ifndef NDEBUG |
| 85 showDebugData(); | 86 showDebugData(); |
| 86 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=%
d)\n", | 87 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=%
d)\n", |
| 87 displayItem->asDebugString().utf8().data(), m_newDisplayItems[index]
.asDebugString().utf8().data(), static_cast<int>(index)); | 88 displayItem->asDebugString().utf8().data(), m_newDisplayItems[index]
.asDebugString().utf8().data(), static_cast<int>(index)); |
| 88 #endif | 89 #endif |
| 89 ASSERT_NOT_REACHED(); | 90 ASSERT_NOT_REACHED(); |
| 90 } | 91 } |
| 91 addItemToIndex(displayItem->client(), displayItem->type(), m_newDisplayItems
.size(), m_newDisplayItemIndicesByClient); | 92 addItemToIndex(displayItem->client(), displayItem->type(), m_newDisplayItems
.size() - 1, m_newDisplayItemIndicesByClient); |
| 92 #endif // ENABLE(ASSERT) | 93 #endif // ENABLE(ASSERT) |
| 93 | 94 |
| 94 ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the fl
ag. | 95 ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the fl
ag. |
| 95 if (skippingCache()) | 96 if (skippingCache()) |
| 96 displayItem->setSkippedCache(); | 97 displayItem->setSkippedCache(); |
| 97 | |
| 98 m_newDisplayItems.append(displayItem); | |
| 99 } | 98 } |
| 100 | 99 |
| 101 void DisplayItemList::beginScope(DisplayItemClient client) | 100 void DisplayItemList::beginScope(DisplayItemClient client) |
| 102 { | 101 { |
| 103 ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); | 102 ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); |
| 104 int scopeId; | 103 int scopeId; |
| 105 if (it == m_clientScopeIdMap.end()) { | 104 if (it == m_clientScopeIdMap.end()) { |
| 106 m_clientScopeIdMap.add(client, 0); | 105 m_clientScopeIdMap.add(client, 0); |
| 107 scopeId = 0; | 106 scopeId = 0; |
| 108 } else { | 107 } else { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
{ | 255 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
{ |
| 257 // Under-invalidation checking requires a full index of m_currentDisplay
Items. | 256 // Under-invalidation checking requires a full index of m_currentDisplay
Items. |
| 258 size_t i = 0; | 257 size_t i = 0; |
| 259 for (const auto& item : m_currentDisplayItems) { | 258 for (const auto& item : m_currentDisplayItems) { |
| 260 addItemToIndex(item.client(), item.type(), i, displayItemIndicesByCl
ient); | 259 addItemToIndex(item.client(), item.type(), i, displayItemIndicesByCl
ient); |
| 261 ++i; | 260 ++i; |
| 262 } | 261 } |
| 263 } | 262 } |
| 264 #endif // ENABLE(ASSERT) | 263 #endif // ENABLE(ASSERT) |
| 265 | 264 |
| 266 DisplayItems updatedList; | 265 // TODO(pdr): Use some smarts to set this initial capacity. |
| 266 DisplayItems updatedList(kInitialDisplayItemsCapacity); |
| 267 DisplayItems::Iterator currentIt = m_currentDisplayItems.begin(); | 267 DisplayItems::Iterator currentIt = m_currentDisplayItems.begin(); |
| 268 DisplayItems::Iterator currentEnd = m_currentDisplayItems.end(); | 268 DisplayItems::Iterator currentEnd = m_currentDisplayItems.end(); |
| 269 for (DisplayItems::Iterator newIt = m_newDisplayItems.begin(); newIt != m_ne
wDisplayItems.end(); ++newIt) { | 269 for (DisplayItems::Iterator newIt = m_newDisplayItems.begin(); newIt != m_ne
wDisplayItems.end(); ++newIt) { |
| 270 DisplayItems::ItemHandle newDisplayItem = *newIt; | 270 DisplayItems::ItemHandle newDisplayItem = *newIt; |
| 271 DisplayItem::Type matchingType = newDisplayItem.type(); | 271 DisplayItem::Type matchingType = newDisplayItem.type(); |
| 272 if (DisplayItem::isCachedType(newDisplayItem.type())) | 272 if (DisplayItem::isCachedType(newDisplayItem.type())) |
| 273 matchingType = DisplayItem::cachedTypeToDrawingType(matchingType); | 273 matchingType = DisplayItem::cachedTypeToDrawingType(matchingType); |
| 274 bool isSynchronized = currentIt != currentEnd | 274 bool isSynchronized = currentIt != currentEnd |
| 275 && !currentIt->isGone() | 275 && !currentIt->isGone() |
| 276 && currentIt->id().equalToExceptForType(newDisplayItem.id(), matchin
gType); | 276 && currentIt->id().equalToExceptForType(newDisplayItem.id(), matchin
gType); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 496 |
| 497 void DisplayItemList::replay(GraphicsContext& context) const | 497 void DisplayItemList::replay(GraphicsContext& context) const |
| 498 { | 498 { |
| 499 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 499 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 500 ASSERT(m_newDisplayItems.isEmpty()); | 500 ASSERT(m_newDisplayItems.isEmpty()); |
| 501 for (auto& displayItem : m_currentDisplayItems) | 501 for (auto& displayItem : m_currentDisplayItems) |
| 502 displayItem.replay(context); | 502 displayItem.replay(context); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace blink | 505 } // namespace blink |
| OLD | NEW |