| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 const DisplayItems& DisplayItemList::displayItems() const | 28 const DisplayItems& DisplayItemList::displayItems() const |
| 29 { | 29 { |
| 30 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 30 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 31 ASSERT(m_newDisplayItems.empty()); | 31 ASSERT(m_newDisplayItems.empty()); |
| 32 return m_currentDisplayItems; | 32 return m_currentDisplayItems; |
| 33 } | 33 } |
| 34 | 34 |
| 35 const WebVector<WebDisplayItem>& DisplayItemList::webDisplayItems() const |
| 36 { |
| 37 return m_webDisplayItems; |
| 38 } |
| 39 |
| 40 const skia::DiscardablePixelRefList& DisplayItemList::pixelRefs() const |
| 41 { |
| 42 ASSERT(RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled())
; |
| 43 ASSERT(m_newPixelRefs.empty()); |
| 44 return m_currentPixelRefs; |
| 45 } |
| 46 |
| 47 |
| 35 bool DisplayItemList::lastDisplayItemIsNoopBegin() const | 48 bool DisplayItemList::lastDisplayItemIsNoopBegin() const |
| 36 { | 49 { |
| 37 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 50 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 38 if (m_newDisplayItems.empty()) | 51 if (m_newDisplayItems.empty()) |
| 39 return false; | 52 return false; |
| 40 | 53 |
| 41 const auto& lastDisplayItem = *m_newDisplayItems.back(); | 54 const auto& lastDisplayItem = *m_newDisplayItems.back(); |
| 42 return lastDisplayItem.isBegin() && !lastDisplayItem.drawsContent(); | 55 return lastDisplayItem.isBegin() && !lastDisplayItem.drawsContent(); |
| 43 } | 56 } |
| 44 | 57 |
| 45 void DisplayItemList::removeLastDisplayItem() | 58 void DisplayItemList::removeLastDisplayItem() |
| 46 { | 59 { |
| 47 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 60 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 48 if (m_newDisplayItems.empty()) | 61 if (m_newDisplayItems.empty()) |
| 49 return; | 62 return; |
| 50 | 63 |
| 51 #if ENABLE(ASSERT) | 64 #if ENABLE(ASSERT) |
| 52 // Also remove the index pointing to the removed display item. | 65 // Also remove the index pointing to the removed display item. |
| 53 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient
.find(m_newDisplayItems.back()->client()); | 66 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient
.find(m_newDisplayItems.back()->client()); |
| 54 if (it != m_newDisplayItemIndicesByClient.end()) { | 67 if (it != m_newDisplayItemIndicesByClient.end()) { |
| 55 Vector<size_t>& indices = it->value; | 68 Vector<size_t>& indices = it->value; |
| 56 if (!indices.isEmpty() && indices.last() == (m_newDisplayItems.size() -
1)) | 69 if (!indices.isEmpty() && indices.last() == (m_newDisplayItems.size() -
1)) |
| 57 indices.removeLast(); | 70 indices.removeLast(); |
| 58 } | 71 } |
| 59 #endif | 72 #endif |
| 60 m_newDisplayItems.removeLast(); | 73 m_newDisplayItems.removeLast(); |
| 61 } | 74 } |
| 62 | 75 |
| 76 void DisplayItemList::addPixelRef(const skia::PixelRefUtils::PositionPixelRef& p
ixelRef) |
| 77 { |
| 78 m_newPixelRefs.push_back(pixelRef); |
| 79 } |
| 80 |
| 63 void DisplayItemList::processNewItem(DisplayItem* displayItem) | 81 void DisplayItemList::processNewItem(DisplayItem* displayItem) |
| 64 { | 82 { |
| 65 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 83 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 66 ASSERT(!m_constructionDisabled); | 84 ASSERT(!m_constructionDisabled); |
| 67 ASSERT(!skippingCache() || !displayItem->isCached()); | 85 ASSERT(!skippingCache() || !displayItem->isCached()); |
| 68 | 86 |
| 69 if (DisplayItem::isCachedType(displayItem->type())) | 87 if (DisplayItem::isCachedType(displayItem->type())) |
| 70 ++m_numCachedItems; | 88 ++m_numCachedItems; |
| 71 | 89 |
| 72 #if ENABLE(ASSERT) | 90 #if ENABLE(ASSERT) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // repainted ones, and appending new items. | 227 // repainted ones, and appending new items. |
| 210 // - For CachedDisplayItem, copy the corresponding cached DrawingDisplayItem; | 228 // - For CachedDisplayItem, copy the corresponding cached DrawingDisplayItem; |
| 211 // - FIXME: Re-enable SubtreeCachedDisplayItem: | 229 // - FIXME: Re-enable SubtreeCachedDisplayItem: |
| 212 // For SubtreeCachedDisplayItem, copy the cached display items between the | 230 // For SubtreeCachedDisplayItem, copy the cached display items between the |
| 213 // corresponding BeginSubtreeDisplayItem and EndSubtreeDisplayItem (incl.); | 231 // corresponding BeginSubtreeDisplayItem and EndSubtreeDisplayItem (incl.); |
| 214 // - Otherwise, copy the new display item. | 232 // - Otherwise, copy the new display item. |
| 215 // | 233 // |
| 216 // The algorithm is O(|m_currentDisplayItems| + |m_newDisplayItems|). | 234 // The algorithm is O(|m_currentDisplayItems| + |m_newDisplayItems|). |
| 217 // Coefficients are related to the ratio of out-of-order [Subtree]CachedDisplayI
tems | 235 // Coefficients are related to the ratio of out-of-order [Subtree]CachedDisplayI
tems |
| 218 // and the average number of (Drawing|BeginSubtree)DisplayItems per client. | 236 // and the average number of (Drawing|BeginSubtree)DisplayItems per client. |
| 219 void DisplayItemList::commitNewDisplayItems() | 237 // TODO(chrishtr); implement filling of displayListDiff. |
| 238 void DisplayItemList::commitNewDisplayItems(WebDisplayListDiff* displayListDiff) |
| 220 { | 239 { |
| 221 TRACE_EVENT2("blink,benchmark", "DisplayItemList::commitNewDisplayItems", "c
urrent_display_list_size", (int)m_currentDisplayItems.size(), | 240 TRACE_EVENT2("blink,benchmark", "DisplayItemList::commitNewDisplayItems", "c
urrent_display_list_size", (int)m_currentDisplayItems.size(), |
| 222 "num_non_cached_new_items", (int)m_newDisplayItems.size() - m_numCachedI
tems); | 241 "num_non_cached_new_items", (int)m_newDisplayItems.size() - m_numCachedI
tems); |
| 223 | 242 |
| 224 // These data structures are used during painting only. | 243 // These data structures are used during painting only. |
| 225 m_clientScopeIdMap.clear(); | 244 m_clientScopeIdMap.clear(); |
| 226 ASSERT(m_scopeStack.isEmpty()); | 245 ASSERT(m_scopeStack.isEmpty()); |
| 227 m_scopeStack.clear(); | 246 m_scopeStack.clear(); |
| 228 ASSERT(!skippingCache()); | 247 ASSERT(!skippingCache()); |
| 229 #if ENABLE(ASSERT) | 248 #if ENABLE(ASSERT) |
| 230 m_newDisplayItemIndicesByClient.clear(); | 249 m_newDisplayItemIndicesByClient.clear(); |
| 231 #endif | 250 #endif |
| 232 | 251 |
| 233 if (m_currentDisplayItems.empty()) { | 252 if (m_currentDisplayItems.empty()) { |
| 234 #if ENABLE(ASSERT) | 253 #if ENABLE(ASSERT) |
| 235 for (const auto& item : m_newDisplayItems) { | 254 for (const auto& item : m_newDisplayItems) { |
| 236 ASSERT(!DisplayItem::isCachedType(item->type()) | 255 ASSERT(!DisplayItem::isCachedType(item->type()) |
| 237 && !DisplayItem::isSubtreeCachedType(item->type())); | 256 && !DisplayItem::isSubtreeCachedType(item->type())); |
| 238 } | 257 } |
| 239 #endif | 258 #endif |
| 240 m_currentDisplayItems.swap(m_newDisplayItems); | 259 m_currentDisplayItems.swap(m_newDisplayItems); |
| 241 m_validlyCachedClientsDirty = true; | 260 m_validlyCachedClientsDirty = true; |
| 242 m_numCachedItems = 0; | 261 m_numCachedItems = 0; |
| 262 m_currentPixelRefs.swap(m_newPixelRefs); |
| 243 return; | 263 return; |
| 244 } | 264 } |
| 245 | 265 |
| 246 updateValidlyCachedClientsIfNeeded(); | 266 updateValidlyCachedClientsIfNeeded(); |
| 247 | 267 |
| 248 // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that
have not been matched | 268 // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that
have not been matched |
| 249 // by CachedDisplayItems during synchronized matching. The indexed items wil
l be matched | 269 // by CachedDisplayItems during synchronized matching. The indexed items wil
l be matched |
| 250 // by later out-of-order CachedDisplayItems in m_newDisplayItems. This ensur
es that when | 270 // by later out-of-order CachedDisplayItems in m_newDisplayItems. This ensur
es that when |
| 251 // out-of-order CachedDisplayItems occur, we only traverse at most once over
m_currentDisplayItems | 271 // out-of-order CachedDisplayItems occur, we only traverse at most once over
m_currentDisplayItems |
| 252 // looking for potential matches. Thus we can ensure that the algorithm runs
in linear time. | 272 // looking for potential matches. Thus we can ensure that the algorithm runs
in linear time. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 338 } |
| 319 | 339 |
| 320 #if ENABLE(ASSERT) | 340 #if ENABLE(ASSERT) |
| 321 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) | 341 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) |
| 322 checkNoRemainingCachedDisplayItems(); | 342 checkNoRemainingCachedDisplayItems(); |
| 323 #endif // ENABLE(ASSERT) | 343 #endif // ENABLE(ASSERT) |
| 324 | 344 |
| 325 m_newDisplayItems.clear(); | 345 m_newDisplayItems.clear(); |
| 326 m_validlyCachedClientsDirty = true; | 346 m_validlyCachedClientsDirty = true; |
| 327 m_currentDisplayItems.swap(updatedList); | 347 m_currentDisplayItems.swap(updatedList); |
| 348 m_currentPixelRefs.swap(m_newPixelRefs); |
| 328 m_numCachedItems = 0; | 349 m_numCachedItems = 0; |
| 329 } | 350 } |
| 330 | 351 |
| 331 size_t DisplayItemList::approximateUnsharedMemoryUsage() const | 352 size_t DisplayItemList::approximateUnsharedMemoryUsage() const |
| 332 { | 353 { |
| 333 size_t memoryUsage = sizeof(*this); | 354 size_t memoryUsage = sizeof(*this); |
| 334 | 355 |
| 335 // Memory outside this class due to m_currentDisplayItems. | 356 // Memory outside this class due to m_currentDisplayItems. |
| 336 memoryUsage += m_currentDisplayItems.getCapacityInBytes(); | 357 memoryUsage += m_currentDisplayItems.getCapacityInBytes(); |
| 337 | 358 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 542 |
| 522 void DisplayItemList::replay(GraphicsContext& context) | 543 void DisplayItemList::replay(GraphicsContext& context) |
| 523 { | 544 { |
| 524 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 545 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 525 ASSERT(m_newDisplayItems.empty()); | 546 ASSERT(m_newDisplayItems.empty()); |
| 526 for (auto displayItem : m_currentDisplayItems) | 547 for (auto displayItem : m_currentDisplayItems) |
| 527 displayItem->replay(context); | 548 displayItem->replay(context); |
| 528 } | 549 } |
| 529 | 550 |
| 530 } // namespace blink | 551 } // namespace blink |
| OLD | NEW |