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/TraceEvent.h" | 9 #include "platform/TraceEvent.h" |
10 #include "platform/graphics/paint/DrawingDisplayItem.h" | 10 #include "platform/graphics/paint/DrawingDisplayItem.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 indices.append(index); | 237 indices.append(index); |
238 } | 238 } |
239 | 239 |
240 struct DisplayItemList::OutOfOrderIndexContext { | 240 struct DisplayItemList::OutOfOrderIndexContext { |
241 OutOfOrderIndexContext(DisplayItems::iterator begin) : nextItemToIndex(begin
) { } | 241 OutOfOrderIndexContext(DisplayItems::iterator begin) : nextItemToIndex(begin
) { } |
242 | 242 |
243 DisplayItems::iterator nextItemToIndex; | 243 DisplayItems::iterator nextItemToIndex; |
244 DisplayItemIndicesByClientMap displayItemIndicesByClient; | 244 DisplayItemIndicesByClientMap displayItemIndicesByClient; |
245 }; | 245 }; |
246 | 246 |
247 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItem(DisplayItems::i
terator currentIt, const DisplayItem::Id& id, OutOfOrderIndexContext& context) | 247 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItem(const DisplayIt
em::Id& id, OutOfOrderIndexContext& context) |
248 { | 248 { |
249 ASSERT(clientCacheIsValid(id.client)); | 249 ASSERT(clientCacheIsValid(id.client)); |
250 | 250 |
251 size_t foundIndex = findMatchingItemFromIndex(id, context.displayItemIndices
ByClient, m_currentDisplayItems); | 251 size_t foundIndex = findMatchingItemFromIndex(id, context.displayItemIndices
ByClient, m_currentDisplayItems); |
252 if (foundIndex != kNotFound) | 252 if (foundIndex != kNotFound) |
253 return m_currentDisplayItems.begin() + foundIndex; | 253 return m_currentDisplayItems.begin() + foundIndex; |
254 | 254 |
255 return findOutOfOrderCachedItemForward(currentIt, id, context); | 255 return findOutOfOrderCachedItemForward(id, context); |
256 } | 256 } |
257 | 257 |
258 // Find forward for the item and index all skipped indexable items. | 258 // Find forward for the item and index all skipped indexable items. |
259 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(DisplayI
tems::iterator currentIt, const DisplayItem::Id& id, OutOfOrderIndexContext& con
text) | 259 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(const Di
splayItem::Id& id, OutOfOrderIndexContext& context) |
260 { | 260 { |
261 // Items before currentIt should have been copied. Skip indexing of them. | |
262 if (currentIt - context.nextItemToIndex > 0) | |
263 context.nextItemToIndex = currentIt; | |
264 | |
265 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); | 261 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); |
266 for (; context.nextItemToIndex != currentEnd; ++context.nextItemToIndex) { | 262 for (; context.nextItemToIndex != currentEnd; ++context.nextItemToIndex) { |
267 const DisplayItem& item = *context.nextItemToIndex; | 263 const DisplayItem& item = *context.nextItemToIndex; |
268 ASSERT(item.isValid()); | 264 ASSERT(item.isValid()); |
269 if (item.isCacheable() && clientCacheIsValid(item.client())) { | 265 if (item.isCacheable() && clientCacheIsValid(item.client())) { |
270 if (id.matches(item)) | 266 if (id.matches(item)) |
271 return context.nextItemToIndex++; | 267 return context.nextItemToIndex++; |
272 | 268 |
273 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentDisp
layItems.begin(), context.displayItemIndicesByClient); | 269 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentDisp
layItems.begin(), context.displayItemIndicesByClient); |
274 } | 270 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); | 356 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); |
361 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt
emId.type; | 357 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt
emId.type; |
362 | 358 |
363 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche
s(*currentIt); | 359 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche
s(*currentIt); |
364 | 360 |
365 if (newDisplayItemHasCachedType) { | 361 if (newDisplayItemHasCachedType) { |
366 ASSERT(!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationChecki
ngEnabled()); | 362 ASSERT(!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationChecki
ngEnabled()); |
367 ASSERT(newDisplayItem.isCached()); | 363 ASSERT(newDisplayItem.isCached()); |
368 ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnable
dFeatures::slimmingPaintV2Enabled() && !paintOffsetWasInvalidated(newDisplayItem
.client()))); | 364 ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnable
dFeatures::slimmingPaintV2Enabled() && !paintOffsetWasInvalidated(newDisplayItem
.client()))); |
369 if (!isSynchronized) { | 365 if (!isSynchronized) { |
370 currentIt = findOutOfOrderCachedItem(currentIt, newDisplayItemId
, outOfOrderIndexContext); | 366 currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrde
rIndexContext); |
371 | 367 |
372 if (currentIt == currentEnd) { | 368 if (currentIt == currentEnd) { |
373 #ifndef NDEBUG | 369 #ifndef NDEBUG |
374 showDebugData(); | 370 showDebugData(); |
375 WTFLogAlways("%s not found in m_currentDisplayItems\n", newD
isplayItem.asDebugString().utf8().data()); | 371 WTFLogAlways("%s not found in m_currentDisplayItems\n", newD
isplayItem.asDebugString().utf8().data()); |
376 #endif | 372 #endif |
377 ASSERT_NOT_REACHED(); | 373 ASSERT_NOT_REACHED(); |
378 // We did not find the cached display item. This should be i
mpossible, but may occur if there is a bug | 374 // We did not find the cached display item. This should be i
mpossible, but may occur if there is a bug |
379 // in the system, such as under-invalidation, incorrect cach
e checking or duplicate display ids. | 375 // in the system, such as under-invalidation, incorrect cach
e checking or duplicate display ids. |
380 // In this case, attempt to recover rather than crashing or
bailing on display of the rest of the display list. | 376 // In this case, attempt to recover rather than crashing or
bailing on display of the rest of the display list. |
(...skipping 18 matching lines...) Expand all Loading... |
399 || newDisplayItem.skippedCache() | 395 || newDisplayItem.skippedCache() |
400 || !clientCacheIsValid(newDisplayItem.client()) | 396 || !clientCacheIsValid(newDisplayItem.client()) |
401 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && pain
tOffsetWasInvalidated(newDisplayItem.client()))); | 397 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && pain
tOffsetWasInvalidated(newDisplayItem.client()))); |
402 } | 398 } |
403 #endif | 399 #endif |
404 updatedList.appendByMoving(*newIt, newIt->derivedSize()); | 400 updatedList.appendByMoving(*newIt, newIt->derivedSize()); |
405 | 401 |
406 if (isSynchronized) | 402 if (isSynchronized) |
407 ++currentIt; | 403 ++currentIt; |
408 } | 404 } |
| 405 // Items before currentIt should have been copied so we don't need to in
dex them. |
| 406 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) |
| 407 outOfOrderIndexContext.nextItemToIndex = currentIt; |
409 } | 408 } |
410 | 409 |
411 #if ENABLE(ASSERT) | 410 #if ENABLE(ASSERT) |
412 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) | 411 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) |
413 checkNoRemainingCachedDisplayItems(); | 412 checkNoRemainingCachedDisplayItems(); |
414 #endif // ENABLE(ASSERT) | 413 #endif // ENABLE(ASSERT) |
415 | 414 |
416 m_newDisplayItems.clear(); | 415 m_newDisplayItems.clear(); |
417 m_validlyCachedClientsDirty = true; | 416 m_validlyCachedClientsDirty = true; |
418 m_currentDisplayItems.swap(updatedList); | 417 m_currentDisplayItems.swap(updatedList); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 623 |
625 void DisplayItemList::replay(GraphicsContext& context) | 624 void DisplayItemList::replay(GraphicsContext& context) |
626 { | 625 { |
627 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 626 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
628 ASSERT(m_newDisplayItems.isEmpty()); | 627 ASSERT(m_newDisplayItems.isEmpty()); |
629 for (DisplayItem& displayItem : m_currentDisplayItems) | 628 for (DisplayItem& displayItem : m_currentDisplayItems) |
630 displayItem.replay(context); | 629 displayItem.replay(context); |
631 } | 630 } |
632 | 631 |
633 } // namespace blink | 632 } // namespace blink |
OLD | NEW |