| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const | 134 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const |
| 135 { | 135 { |
| 136 if (skippingCache()) | 136 if (skippingCache()) |
| 137 return false; | 137 return false; |
| 138 updateValidlyCachedClientsIfNeeded(); | 138 updateValidlyCachedClientsIfNeeded(); |
| 139 return m_validlyCachedClients.contains(client); | 139 return m_validlyCachedClients.contains(client); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void DisplayItemList::invalidatePaintOffset(DisplayItemClient client) |
| 143 { |
| 144 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 145 |
| 146 m_validlyCachedClients.remove(client); |
| 147 |
| 148 #if ENABLE(ASSERT) |
| 149 m_clientsWithPaintOffsetInvalidations.add(client); |
| 150 |
| 151 // Ensure no phases slipped in using the old paint offset which would indica
te |
| 152 // different phases used different paint offsets, which should not happen. |
| 153 for (const auto& item : m_newDisplayItems) |
| 154 ASSERT(!item.isCached() || item.client() != client); |
| 155 #endif |
| 156 } |
| 157 |
| 158 #if ENABLE(ASSERT) |
| 159 bool DisplayItemList::paintOffsetWasInvalidated(DisplayItemClient client) const |
| 160 { |
| 161 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 162 return m_clientsWithPaintOffsetInvalidations.contains(client); |
| 163 } |
| 164 #endif |
| 165 |
| 142 size_t DisplayItemList::findMatchingItemFromIndex(const DisplayItem::Id& id, con
st DisplayItemIndicesByClientMap& displayItemIndicesByClient, const DisplayItems
& list) | 166 size_t DisplayItemList::findMatchingItemFromIndex(const DisplayItem::Id& id, con
st DisplayItemIndicesByClientMap& displayItemIndicesByClient, const DisplayItems
& list) |
| 143 { | 167 { |
| 144 DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien
t.find(id.client); | 168 DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien
t.find(id.client); |
| 145 if (it == displayItemIndicesByClient.end()) | 169 if (it == displayItemIndicesByClient.end()) |
| 146 return kNotFound; | 170 return kNotFound; |
| 147 | 171 |
| 148 const Vector<size_t>& indices = it->value; | 172 const Vector<size_t>& indices = it->value; |
| 149 for (size_t index : indices) { | 173 for (size_t index : indices) { |
| 150 const DisplayItem& existingItem = list[index]; | 174 const DisplayItem& existingItem = list[index]; |
| 151 ASSERT(!existingItem.isValid() || existingItem.client() == id.client); | 175 ASSERT(!existingItem.isValid() || existingItem.client() == id.client); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 const DisplayItem& newDisplayItem = *newIt; | 311 const DisplayItem& newDisplayItem = *newIt; |
| 288 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); | 312 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); |
| 289 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt
emId.type; | 313 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt
emId.type; |
| 290 | 314 |
| 291 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche
s(*currentIt); | 315 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche
s(*currentIt); |
| 292 | 316 |
| 293 if (newDisplayItemHasCachedType) { | 317 if (newDisplayItemHasCachedType) { |
| 294 ASSERT(!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationChecki
ngEnabled()); | 318 ASSERT(!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationChecki
ngEnabled()); |
| 295 ASSERT(newDisplayItem.isCached()); | 319 ASSERT(newDisplayItem.isCached()); |
| 296 ASSERT(clientCacheIsValid(newDisplayItem.client())); | 320 ASSERT(clientCacheIsValid(newDisplayItem.client())); |
| 321 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled() || !paintOf
fsetWasInvalidated(newDisplayItem.client())); |
| 297 if (!isSynchronized) { | 322 if (!isSynchronized) { |
| 298 DisplayItems::iterator foundIt = findOutOfOrderCachedItem(curren
tIt, newDisplayItemId, outOfOrderIndexContext); | 323 DisplayItems::iterator foundIt = findOutOfOrderCachedItem(curren
tIt, newDisplayItemId, outOfOrderIndexContext); |
| 299 | 324 |
| 300 if (foundIt == currentEnd) { | 325 if (foundIt == currentEnd) { |
| 301 #ifndef NDEBUG | 326 #ifndef NDEBUG |
| 302 showDebugData(); | 327 showDebugData(); |
| 303 WTFLogAlways("%s not found in m_currentDisplayItems\n", newD
isplayItem.asDebugString().utf8().data()); | 328 WTFLogAlways("%s not found in m_currentDisplayItems\n", newD
isplayItem.asDebugString().utf8().data()); |
| 304 #endif | 329 #endif |
| 305 ASSERT_NOT_REACHED(); | 330 ASSERT_NOT_REACHED(); |
| 306 | 331 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 317 if (newDisplayItem.isCachedDrawing()) { | 342 if (newDisplayItem.isCachedDrawing()) { |
| 318 updatedList.appendByMoving(*currentIt, currentIt->derivedSize())
; | 343 updatedList.appendByMoving(*currentIt, currentIt->derivedSize())
; |
| 319 ++currentIt; | 344 ++currentIt; |
| 320 } else { | 345 } else { |
| 321 ASSERT(newDisplayItem.isCachedSubtree()); | 346 ASSERT(newDisplayItem.isCachedSubtree()); |
| 322 copyCachedSubtree(currentIt, updatedList); | 347 copyCachedSubtree(currentIt, updatedList); |
| 323 ASSERT(updatedList.last().isEndSubtree()); | 348 ASSERT(updatedList.last().isEndSubtree()); |
| 324 } | 349 } |
| 325 } else { | 350 } else { |
| 326 #if ENABLE(ASSERT) | 351 #if ENABLE(ASSERT) |
| 327 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
abled()) | 352 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
abled()) { |
| 328 checkCachedDisplayItemIsUnchanged(newDisplayItem, outOfOrderInde
xContext.displayItemIndicesByClient); | 353 checkCachedDisplayItemIsUnchanged(newDisplayItem, outOfOrderInde
xContext.displayItemIndicesByClient); |
| 329 else | 354 } else { |
| 330 ASSERT(!newDisplayItem.isDrawing() || newDisplayItem.skippedCach
e() || !clientCacheIsValid(newDisplayItem.client())); | 355 ASSERT(!newDisplayItem.isDrawing() |
| 331 #endif // ENABLE(ASSERT) | 356 || newDisplayItem.skippedCache() |
| 357 || !clientCacheIsValid(newDisplayItem.client()) |
| 358 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && pain
tOffsetWasInvalidated(newDisplayItem.client()))); |
| 359 } |
| 360 #endif |
| 332 updatedList.appendByMoving(*newIt, newIt->derivedSize()); | 361 updatedList.appendByMoving(*newIt, newIt->derivedSize()); |
| 333 | 362 |
| 334 if (isSynchronized) | 363 if (isSynchronized) |
| 335 ++currentIt; | 364 ++currentIt; |
| 336 } | 365 } |
| 337 } | 366 } |
| 338 | 367 |
| 339 #if ENABLE(ASSERT) | 368 #if ENABLE(ASSERT) |
| 340 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) | 369 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) |
| 341 checkNoRemainingCachedDisplayItems(); | 370 checkNoRemainingCachedDisplayItems(); |
| 342 #endif // ENABLE(ASSERT) | 371 #endif // ENABLE(ASSERT) |
| 343 | 372 |
| 344 m_newDisplayItems.clear(); | 373 m_newDisplayItems.clear(); |
| 345 m_validlyCachedClientsDirty = true; | 374 m_validlyCachedClientsDirty = true; |
| 346 m_currentDisplayItems.swap(updatedList); | 375 m_currentDisplayItems.swap(updatedList); |
| 347 m_numCachedItems = 0; | 376 m_numCachedItems = 0; |
| 377 |
| 378 #if ENABLE(ASSERT) |
| 379 m_clientsWithPaintOffsetInvalidations.clear(); |
| 380 #endif |
| 348 } | 381 } |
| 349 | 382 |
| 350 size_t DisplayItemList::approximateUnsharedMemoryUsage() const | 383 size_t DisplayItemList::approximateUnsharedMemoryUsage() const |
| 351 { | 384 { |
| 352 size_t memoryUsage = sizeof(*this); | 385 size_t memoryUsage = sizeof(*this); |
| 353 | 386 |
| 354 // Memory outside this class due to m_currentDisplayItems. | 387 // Memory outside this class due to m_currentDisplayItems. |
| 355 memoryUsage += m_currentDisplayItems.memoryUsageInBytes(); | 388 memoryUsage += m_currentDisplayItems.memoryUsageInBytes(); |
| 356 | 389 |
| 357 // TODO(jbroman): If display items begin to have significant external memory | 390 // TODO(jbroman): If display items begin to have significant external memory |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 578 |
| 546 void DisplayItemList::replay(GraphicsContext& context) | 579 void DisplayItemList::replay(GraphicsContext& context) |
| 547 { | 580 { |
| 548 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 581 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 549 ASSERT(m_newDisplayItems.isEmpty()); | 582 ASSERT(m_newDisplayItems.isEmpty()); |
| 550 for (DisplayItem& displayItem : m_currentDisplayItems) | 583 for (DisplayItem& displayItem : m_currentDisplayItems) |
| 551 displayItem.replay(context); | 584 displayItem.replay(context); |
| 552 } | 585 } |
| 553 | 586 |
| 554 } // namespace blink | 587 } // namespace blink |
| OLD | NEW |