| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 bitmap.unlockPixels(); | 351 bitmap.unlockPixels(); |
| 352 return result; | 352 return result; |
| 353 } | 353 } |
| 354 | 354 |
| 355 void DisplayItemList::checkCachedDisplayItemIsUnchanged(const DisplayItems::Item
Handle& displayItem, DisplayItemIndicesByClientMap& displayItemIndicesByClient) | 355 void DisplayItemList::checkCachedDisplayItemIsUnchanged(const DisplayItems::Item
Handle& displayItem, DisplayItemIndicesByClientMap& displayItemIndicesByClient) |
| 356 { | 356 { |
| 357 ASSERT(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled
()); | 357 ASSERT(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled
()); |
| 358 | 358 |
| 359 if (!DisplayItem::isDrawingType(displayItem.type()) || !clientCacheIsValid(d
isplayItem.client())) | 359 if (!DisplayItem::isDrawingType(displayItem.type()) || displayItem.skippedCa
che() || !clientCacheIsValid(displayItem.client())) |
| 360 return; | |
| 361 | |
| 362 DrawingDisplayItem::UnderInvalidationCheckingMode mode = displayItem.underIn
validationCheckingMode(); | |
| 363 if (mode == DrawingDisplayItem::DontCheck) | |
| 364 return; | 360 return; |
| 365 | 361 |
| 366 // If checking under-invalidation, we always generate new display item even
if the client is not invalidated. | 362 // If checking under-invalidation, we always generate new display item even
if the client is not invalidated. |
| 367 // Checks if the new picture is the same as the cached old picture. If the n
ew picture is different but | 363 // Checks if the new picture is the same as the cached old picture. If the n
ew picture is different but |
| 368 // the client is not invalidated, issue error about under-invalidation. | 364 // the client is not invalidated, issue error about under-invalidation. |
| 369 size_t index = findMatchingItemFromIndex(displayItem.id(), displayItem.type(
), displayItemIndicesByClient, m_currentDisplayItems); | 365 size_t index = findMatchingItemFromIndex(displayItem.id(), displayItem.type(
), displayItemIndicesByClient, m_currentDisplayItems); |
| 370 if (index == kNotFound) { | 366 if (index == kNotFound) { |
| 371 showUnderInvalidationError("ERROR: under-invalidation: no cached display
item", displayItem); | 367 showUnderInvalidationError("ERROR: under-invalidation: no cached display
item", displayItem); |
| 372 ASSERT_NOT_REACHED(); | 368 ASSERT_NOT_REACHED(); |
| 373 return; | 369 return; |
| 374 } | 370 } |
| 375 | 371 |
| 376 DisplayItems::Iterator foundItem = m_currentDisplayItems.iteratorAt(index); | 372 DisplayItems::Iterator foundItem = m_currentDisplayItems.iteratorAt(index); |
| 377 RefPtr<const SkPicture> newPicture = displayItem.picture(); | 373 RefPtr<const SkPicture> newPicture = displayItem.picture(); |
| 378 RefPtr<const SkPicture> oldPicture = foundItem->picture(); | 374 RefPtr<const SkPicture> oldPicture = foundItem->picture(); |
| 379 // Remove the display item from cache so that we can check if there are any
remaining cached display items after merging. | 375 // Remove the display item from cache so that we can check if there are any
remaining cached display items after merging. |
| 380 m_currentDisplayItems.setGone(foundItem); | 376 m_currentDisplayItems.setGone(foundItem); |
| 381 | 377 |
| 382 if (!newPicture && !oldPicture) | 378 if (!newPicture && !oldPicture) |
| 383 return; | 379 return; |
| 384 if (newPicture && oldPicture) { | 380 if (newPicture && oldPicture) { |
| 385 switch (mode) { | 381 switch (displayItem.underInvalidationCheckingMode()) { |
| 386 case DrawingDisplayItem::CheckPicture: | 382 case DrawingDisplayItem::CheckPicture: |
| 387 if (newPicture->approximateOpCount() == oldPicture->approximateOpCou
nt()) { | 383 if (newPicture->approximateOpCount() == oldPicture->approximateOpCou
nt()) { |
| 388 SkDynamicMemoryWStream newPictureSerialized; | 384 SkDynamicMemoryWStream newPictureSerialized; |
| 389 newPicture->serialize(&newPictureSerialized); | 385 newPicture->serialize(&newPictureSerialized); |
| 390 SkDynamicMemoryWStream oldPictureSerialized; | 386 SkDynamicMemoryWStream oldPictureSerialized; |
| 391 oldPicture->serialize(&oldPictureSerialized); | 387 oldPicture->serialize(&oldPictureSerialized); |
| 392 | 388 |
| 393 if (newPictureSerialized.bytesWritten() == oldPictureSerialized.
bytesWritten()) { | 389 if (newPictureSerialized.bytesWritten() == oldPictureSerialized.
bytesWritten()) { |
| 394 RefPtr<SkData> oldData = adoptRef(oldPictureSerialized.copyT
oData()); | 390 RefPtr<SkData> oldData = adoptRef(oldPictureSerialized.copyT
oData()); |
| 395 RefPtr<SkData> newData = adoptRef(newPictureSerialized.copyT
oData()); | 391 RefPtr<SkData> newData = adoptRef(newPictureSerialized.copyT
oData()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 470 |
| 475 void DisplayItemList::replay(GraphicsContext& context) const | 471 void DisplayItemList::replay(GraphicsContext& context) const |
| 476 { | 472 { |
| 477 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 473 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 478 ASSERT(m_newDisplayItems.isEmpty()); | 474 ASSERT(m_newDisplayItems.isEmpty()); |
| 479 for (auto& displayItem : m_currentDisplayItems) | 475 for (auto& displayItem : m_currentDisplayItems) |
| 480 displayItem.replay(context); | 476 displayItem.replay(context); |
| 481 } | 477 } |
| 482 | 478 |
| 483 } // namespace blink | 479 } // namespace blink |
| OLD | NEW |