| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ASSERT(!m_constructionDisabled); | 54 ASSERT(!m_constructionDisabled); |
| 55 ASSERT(!skippingCache() || !displayItem.isCached()); | 55 ASSERT(!skippingCache() || !displayItem.isCached()); |
| 56 | 56 |
| 57 if (displayItem.isCached()) | 57 if (displayItem.isCached()) |
| 58 ++m_numCachedItems; | 58 ++m_numCachedItems; |
| 59 | 59 |
| 60 #if ENABLE(ASSERT) | 60 #if ENABLE(ASSERT) |
| 61 // Verify noop begin/end pairs have been removed. | 61 // Verify noop begin/end pairs have been removed. |
| 62 if (m_newDisplayItems.size() >= 2 && displayItem.isEnd()) { | 62 if (m_newDisplayItems.size() >= 2 && displayItem.isEnd()) { |
| 63 const auto& beginDisplayItem = m_newDisplayItems[m_newDisplayItems.size(
) - 2]; | 63 const auto& beginDisplayItem = m_newDisplayItems[m_newDisplayItems.size(
) - 2]; |
| 64 if (beginDisplayItem.isBegin() && beginDisplayItem.type() != DisplayItem
::BeginSubsequence && !beginDisplayItem.drawsContent()) | 64 if (beginDisplayItem.isBegin() && !beginDisplayItem.isSubsequence() && !
beginDisplayItem.drawsContent()) |
| 65 ASSERT(!displayItem.isEndAndPairedWith(beginDisplayItem.type())); | 65 ASSERT(!displayItem.isEndAndPairedWith(beginDisplayItem.type())); |
| 66 } | 66 } |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 if (!m_scopeStack.isEmpty()) | 69 if (!m_scopeStack.isEmpty()) |
| 70 displayItem.setScope(m_scopeStack.last()); | 70 displayItem.setScope(m_scopeStack.last()); |
| 71 | 71 |
| 72 #if ENABLE(ASSERT) | 72 #if ENABLE(ASSERT) |
| 73 size_t index = findMatchingItemFromIndex(displayItem.nonCachedId(), m_newDis
playItemIndicesByClient, m_newDisplayItems); | 73 size_t index = findMatchingItemFromIndex(displayItem.nonCachedId(), m_newDis
playItemIndicesByClient, m_newDisplayItems); |
| 74 if (index != kNotFound) { | 74 if (index != kNotFound) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return context.nextItemToIndex++; | 221 return context.nextItemToIndex++; |
| 222 | 222 |
| 223 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentDisp
layItems.begin(), context.displayItemIndicesByClient); | 223 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentDisp
layItems.begin(), context.displayItemIndicesByClient); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 return currentEnd; | 226 return currentEnd; |
| 227 } | 227 } |
| 228 | 228 |
| 229 void DisplayItemList::copyCachedSubsequence(DisplayItems::iterator& currentIt, D
isplayItems& updatedList) | 229 void DisplayItemList::copyCachedSubsequence(DisplayItems::iterator& currentIt, D
isplayItems& updatedList) |
| 230 { | 230 { |
| 231 ASSERT(currentIt->type() == DisplayItem::BeginSubsequence); | 231 ASSERT(currentIt->isSubsequence()); |
| 232 ASSERT(!currentIt->scope()); | 232 ASSERT(!currentIt->scope()); |
| 233 DisplayItem::Id endSubsequenceId(currentIt->client(), DisplayItem::EndSubseq
uence, 0); | 233 DisplayItem::Id endSubsequenceId(currentIt->client(), DisplayItem::subsequen
ceTypeToEndSubsequenceType(currentIt->type()), 0); |
| 234 do { | 234 do { |
| 235 // We should always find the EndSubsequence display item. | 235 // We should always find the EndSubsequence display item. |
| 236 ASSERT(currentIt != m_currentDisplayItems.end()); | 236 ASSERT(currentIt != m_currentDisplayItems.end()); |
| 237 ASSERT(currentIt->isValid()); | 237 ASSERT(currentIt->isValid()); |
| 238 updatedList.appendByMoving(*currentIt); | 238 updatedList.appendByMoving(*currentIt); |
| 239 ++currentIt; | 239 ++currentIt; |
| 240 } while (!endSubsequenceId.matches(updatedList.last())); | 240 } while (!endSubsequenceId.matches(updatedList.last())); |
| 241 } | 241 } |
| 242 | 242 |
| 243 // Update the existing display items by removing invalidated entries, updating | 243 // Update the existing display items by removing invalidated entries, updating |
| 244 // repainted ones, and appending new items. | 244 // repainted ones, and appending new items. |
| 245 // - For CachedDisplayItem, copy the corresponding cached DrawingDisplayItem; | 245 // - For cached drawing display item, copy the corresponding cached DrawingDispl
ayItem; |
| 246 // - For SubsequenceCachedDisplayItem, copy the cached display items between the | 246 // - For cached subsequence display item, copy the cached display items between
the |
| 247 // corresponding BeginSubsequenceDisplayItem and EndSubsequenceDisplayItem (in
cl.); | 247 // corresponding SubsequenceDisplayItem and EndSubsequenceDisplayItem (incl.); |
| 248 // - Otherwise, copy the new display item. | 248 // - Otherwise, copy the new display item. |
| 249 // | 249 // |
| 250 // The algorithm is O(|m_currentDisplayItems| + |m_newDisplayItems|). | 250 // The algorithm is O(|m_currentDisplayItems| + |m_newDisplayItems|). |
| 251 // Coefficients are related to the ratio of out-of-order [Subsequence]CachedDisp
layItems | 251 // Coefficients are related to the ratio of out-of-order CachedDisplayItems |
| 252 // and the average number of (Drawing|BeginSubsequence)DisplayItems per client. | 252 // and the average number of (Drawing|Subsequence)DisplayItems per client. |
| 253 // | 253 // |
| 254 // TODO(pdr): Implement the DisplayListDiff algorithm for SlimmingPaintV2. | 254 // TODO(pdr): Implement the DisplayListDiff algorithm for SlimmingPaintV2. |
| 255 void DisplayItemList::commitNewDisplayItems(DisplayListDiff*) | 255 void DisplayItemList::commitNewDisplayItems(DisplayListDiff*) |
| 256 { | 256 { |
| 257 TRACE_EVENT2("blink,benchmark", "DisplayItemList::commitNewDisplayItems", "c
urrent_display_list_size", (int)m_currentDisplayItems.size(), | 257 TRACE_EVENT2("blink,benchmark", "DisplayItemList::commitNewDisplayItems", "c
urrent_display_list_size", (int)m_currentDisplayItems.size(), |
| 258 "num_non_cached_new_items", (int)m_newDisplayItems.size() - m_numCachedI
tems); | 258 "num_non_cached_new_items", (int)m_newDisplayItems.size() - m_numCachedI
tems); |
| 259 | 259 |
| 260 // These data structures are used during painting only. | 260 // These data structures are used during painting only. |
| 261 ASSERT(m_scopeStack.isEmpty()); | 261 ASSERT(m_scopeStack.isEmpty()); |
| 262 m_scopeStack.clear(); | 262 m_scopeStack.clear(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 #if ENABLE(ASSERT) | 318 #if ENABLE(ASSERT) |
| 319 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
abled()) { | 319 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
abled()) { |
| 320 DisplayItems::iterator temp = currentIt; | 320 DisplayItems::iterator temp = currentIt; |
| 321 checkUnderInvalidation(newIt, temp); | 321 checkUnderInvalidation(newIt, temp); |
| 322 } | 322 } |
| 323 #endif | 323 #endif |
| 324 if (newDisplayItem.isCachedDrawing()) { | 324 if (newDisplayItem.isCachedDrawing()) { |
| 325 updatedList.appendByMoving(*currentIt); | 325 updatedList.appendByMoving(*currentIt); |
| 326 ++currentIt; | 326 ++currentIt; |
| 327 } else { | 327 } else { |
| 328 ASSERT(newDisplayItem.type() == DisplayItem::CachedSubsequence); | 328 ASSERT(newDisplayItem.isCachedSubsequence()); |
| 329 copyCachedSubsequence(currentIt, updatedList); | 329 copyCachedSubsequence(currentIt, updatedList); |
| 330 ASSERT(updatedList.last().type() == DisplayItem::EndSubsequence)
; | 330 ASSERT(updatedList.last().isEndSubsequence()); |
| 331 } | 331 } |
| 332 } else { | 332 } else { |
| 333 ASSERT(!newDisplayItem.isDrawing() | 333 ASSERT(!newDisplayItem.isDrawing() |
| 334 || newDisplayItem.skippedCache() | 334 || newDisplayItem.skippedCache() |
| 335 || !clientCacheIsValid(newDisplayItem.client()) | 335 || !clientCacheIsValid(newDisplayItem.client()) |
| 336 || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()
&& paintOffsetWasInvalidated(newDisplayItem.client()))); | 336 || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()
&& paintOffsetWasInvalidated(newDisplayItem.client()))); |
| 337 | 337 |
| 338 updatedList.appendByMoving(*newIt); | 338 updatedList.appendByMoving(*newIt); |
| 339 | 339 |
| 340 if (isSynchronized) | 340 if (isSynchronized) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // When under-invalidation-checking is enabled, the forced painting is follo
wing the cached display item. | 426 // When under-invalidation-checking is enabled, the forced painting is follo
wing the cached display item. |
| 427 DisplayItem::Type nextItemType = DisplayItem::nonCachedType(newIt->type()); | 427 DisplayItem::Type nextItemType = DisplayItem::nonCachedType(newIt->type()); |
| 428 ++newIt; | 428 ++newIt; |
| 429 ASSERT(newIt->type() == nextItemType); | 429 ASSERT(newIt->type() == nextItemType); |
| 430 | 430 |
| 431 if (newIt->isDrawing()) { | 431 if (newIt->isDrawing()) { |
| 432 checkCachedDisplayItemIsUnchanged("", *newIt, *currentIt); | 432 checkCachedDisplayItemIsUnchanged("", *newIt, *currentIt); |
| 433 return; | 433 return; |
| 434 } | 434 } |
| 435 | 435 |
| 436 ASSERT(newIt->type() == DisplayItem::BeginSubsequence); | 436 ASSERT(newIt->isSubsequence()); |
| 437 | 437 |
| 438 #ifndef NDEBUG | 438 #ifndef NDEBUG |
| 439 CString messagePrefix = String::format("(In CachedSubsequence of %s)", newIt
->clientDebugString().utf8().data()).utf8(); | 439 CString messagePrefix = String::format("(In CachedSubsequence of %s)", newIt
->clientDebugString().utf8().data()).utf8(); |
| 440 #else | 440 #else |
| 441 CString messagePrefix = "(In CachedSubsequence)"; | 441 CString messagePrefix = "(In CachedSubsequence)"; |
| 442 #endif | 442 #endif |
| 443 | 443 |
| 444 DisplayItem::Id endSubsequenceId(newIt->client(), DisplayItem::EndSubsequenc
e, 0); | 444 DisplayItem::Id endSubsequenceId(newIt->client(), DisplayItem::subsequenceTy
peToEndSubsequenceType(newIt->type()), 0); |
| 445 while (true) { | 445 while (true) { |
| 446 ASSERT(newIt != m_newDisplayItems.end()); | 446 ASSERT(newIt != m_newDisplayItems.end()); |
| 447 if (newIt->isCached()) | 447 if (newIt->isCached()) |
| 448 checkUnderInvalidation(newIt, currentIt); | 448 checkUnderInvalidation(newIt, currentIt); |
| 449 else | 449 else |
| 450 checkCachedDisplayItemIsUnchanged(messagePrefix.data(), *newIt, *cur
rentIt); | 450 checkCachedDisplayItemIsUnchanged(messagePrefix.data(), *newIt, *cur
rentIt); |
| 451 | 451 |
| 452 if (endSubsequenceId.matches(*newIt)) | 452 if (endSubsequenceId.matches(*newIt)) |
| 453 break; | 453 break; |
| 454 | 454 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 547 |
| 548 void DisplayItemList::replay(GraphicsContext& context) | 548 void DisplayItemList::replay(GraphicsContext& context) |
| 549 { | 549 { |
| 550 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 550 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 551 ASSERT(m_newDisplayItems.isEmpty()); | 551 ASSERT(m_newDisplayItems.isEmpty()); |
| 552 for (DisplayItem& displayItem : m_currentDisplayItems) | 552 for (DisplayItem& displayItem : m_currentDisplayItems) |
| 553 displayItem.replay(context); | 553 displayItem.replay(context); |
| 554 } | 554 } |
| 555 | 555 |
| 556 } // namespace blink | 556 } // namespace blink |
| OLD | NEW |