| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Only need to index DrawingDisplayItems and FIXME: BeginSubtreeDisplayItem
s. | 149 // Only need to index DrawingDisplayItems and FIXME: BeginSubtreeDisplayItem
s. |
| 150 if (!DisplayItem::isDrawingType(type)) | 150 if (!DisplayItem::isDrawingType(type)) |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 DisplayItemIndicesByClientMap::iterator it = displayItemIndicesByClient.find
(client); | 153 DisplayItemIndicesByClientMap::iterator it = displayItemIndicesByClient.find
(client); |
| 154 Vector<size_t>& indices = it == displayItemIndicesByClient.end() ? | 154 Vector<size_t>& indices = it == displayItemIndicesByClient.end() ? |
| 155 displayItemIndicesByClient.add(client, Vector<size_t>()).storedValue->va
lue : it->value; | 155 displayItemIndicesByClient.add(client, Vector<size_t>()).storedValue->va
lue : it->value; |
| 156 indices.append(index); | 156 indices.append(index); |
| 157 } | 157 } |
| 158 | 158 |
| 159 DisplayItems::Iterator DisplayItemList::findOutOfOrderCachedItem(DisplayItems::I
terator& currentIt, const DisplayItem::Id& id, DisplayItem::Type matchingType, D
isplayItemIndicesByClientMap& displayItemIndicesByClient) | 159 DisplayItems::Iterator DisplayItemList::findOutOfOrderCachedItem(DisplayItems::I
terator currentIt, const DisplayItem::Id& id, DisplayItem::Type matchingType, Di
splayItemIndicesByClientMap& displayItemIndicesByClient) |
| 160 { | 160 { |
| 161 ASSERT(DisplayItem::isCachedType(id.type)); | 161 ASSERT(DisplayItem::isCachedType(id.type)); |
| 162 ASSERT(clientCacheIsValid(id.client)); | 162 ASSERT(clientCacheIsValid(id.client)); |
| 163 | 163 |
| 164 size_t foundIndex = findMatchingItemFromIndex(id, matchingType, displayItemI
ndicesByClient, m_currentDisplayItems); | 164 size_t foundIndex = findMatchingItemFromIndex(id, matchingType, displayItemI
ndicesByClient, m_currentDisplayItems); |
| 165 if (foundIndex != kNotFound) | 165 if (foundIndex != kNotFound) |
| 166 return m_currentDisplayItems.iteratorAt(foundIndex); | 166 return m_currentDisplayItems.iteratorAt(foundIndex); |
| 167 | 167 |
| 168 return findOutOfOrderCachedItemForward(currentIt, id, matchingType, displayI
temIndicesByClient); | 168 return findOutOfOrderCachedItemForward(currentIt, id, matchingType, displayI
temIndicesByClient); |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Find forward for the item and index all skipped indexable items. | 171 // Find forward for the item and index all skipped indexable items. |
| 172 DisplayItems::Iterator DisplayItemList::findOutOfOrderCachedItemForward(DisplayI
tems::Iterator& currentIt, const DisplayItem::Id& id, DisplayItem::Type matching
Type, DisplayItemIndicesByClientMap& displayItemIndicesByClient) | 172 DisplayItems::Iterator DisplayItemList::findOutOfOrderCachedItemForward(DisplayI
tems::Iterator currentIt, const DisplayItem::Id& id, DisplayItem::Type matchingT
ype, DisplayItemIndicesByClientMap& displayItemIndicesByClient) |
| 173 { | 173 { |
| 174 DisplayItems::Iterator currentEnd = m_currentDisplayItems.end(); | 174 DisplayItems::Iterator currentEnd = m_currentDisplayItems.end(); |
| 175 for (; currentIt != currentEnd; ++currentIt) { | 175 for (; currentIt != currentEnd; ++currentIt) { |
| 176 DisplayItems::ItemHandle item = *currentIt; | 176 DisplayItems::ItemHandle item = *currentIt; |
| 177 if (!item.isGone() | 177 if (!item.isGone() |
| 178 && DisplayItem::isDrawingType(item.type()) | 178 && DisplayItem::isDrawingType(item.type()) |
| 179 && m_validlyCachedClients.contains(item.client())) { | 179 && m_validlyCachedClients.contains(item.client())) { |
| 180 if (item.id().equalToExceptForType(id, matchingType)) | 180 if (item.id().equalToExceptForType(id, matchingType)) |
| 181 return currentIt; | 181 return currentIt; |
| 182 | 182 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 updatedList.appendByMoving(currentIt); | 262 updatedList.appendByMoving(currentIt); |
| 263 } else { | 263 } else { |
| 264 DisplayItems::Iterator foundIt = findOutOfOrderCachedItem(curren
tIt, newDisplayItem.id(), matchingType, displayItemIndicesByClient); | 264 DisplayItems::Iterator foundIt = findOutOfOrderCachedItem(curren
tIt, newDisplayItem.id(), matchingType, displayItemIndicesByClient); |
| 265 isSynchronized = (foundIt == currentIt); | 265 isSynchronized = (foundIt == currentIt); |
| 266 | 266 |
| 267 #ifndef NDEBUG | 267 #ifndef NDEBUG |
| 268 if (foundIt == currentEnd) { | 268 if (foundIt == currentEnd) { |
| 269 showDebugData(); | 269 showDebugData(); |
| 270 WTFLogAlways("CachedDisplayItem %s not found in m_currentDis
playItems\n", | 270 WTFLogAlways("CachedDisplayItem %s not found in m_currentDis
playItems\n", |
| 271 newDisplayItem.asDebugString().utf8().data()); | 271 newDisplayItem.asDebugString().utf8().data()); |
| 272 ASSERT_NOT_REACHED(); |
| 272 } | 273 } |
| 273 #endif | 274 #endif |
| 274 // TODO(chrishtr): downgrade to ASSERT as this goes to beta user
s, and replace with bailing out of the rest of the merge. | 275 // If foundIt == currentEnd, it means that we did not find the c
ached display item. This should be impossible, but may occur |
| 275 // This assert hits if we couldn't find the cached display item
in our cache, which should be impossible. | 276 // if there is a bug in the system, such as under-invalidation,
incorrect cache checking or duplicate display ids. In this case, |
| 276 RELEASE_ASSERT(foundIt != currentEnd); | 277 // attempt to recover rather than crashing or bailing on display
of the rest of the display list. |
| 278 if (foundIt == currentEnd) |
| 279 continue; |
| 280 |
| 281 currentIt = foundIt; |
| 277 | 282 |
| 278 updatedList.appendByMoving(foundIt); | 283 updatedList.appendByMoving(foundIt); |
| 279 } | 284 } |
| 280 } else { | 285 } else { |
| 281 #if ENABLE(ASSERT) | 286 #if ENABLE(ASSERT) |
| 282 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
abled()) | 287 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
abled()) |
| 283 checkCachedDisplayItemIsUnchanged(newDisplayItem, displayItemInd
icesByClient); | 288 checkCachedDisplayItemIsUnchanged(newDisplayItem, displayItemInd
icesByClient); |
| 284 else | 289 else |
| 285 ASSERT(!DisplayItem::isDrawingType(newDisplayItem.type()) || new
DisplayItem.skippedCache() || !clientCacheIsValid(newDisplayItem.client())); | 290 ASSERT(!DisplayItem::isDrawingType(newDisplayItem.type()) || new
DisplayItem.skippedCache() || !clientCacheIsValid(newDisplayItem.client())); |
| 286 #endif // ENABLE(ASSERT) | 291 #endif // ENABLE(ASSERT) |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 479 |
| 475 void DisplayItemList::replay(GraphicsContext& context) const | 480 void DisplayItemList::replay(GraphicsContext& context) const |
| 476 { | 481 { |
| 477 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 482 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 478 ASSERT(m_newDisplayItems.isEmpty()); | 483 ASSERT(m_newDisplayItems.isEmpty()); |
| 479 for (auto& displayItem : m_currentDisplayItems) | 484 for (auto& displayItem : m_currentDisplayItems) |
| 480 displayItem.replay(context); | 485 displayItem.replay(context); |
| 481 } | 486 } |
| 482 | 487 |
| 483 } // namespace blink | 488 } // namespace blink |
| OLD | NEW |