| 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 "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/TraceEvent.h" | 7 #include "platform/TraceEvent.h" |
| 8 #include "platform/graphics/GraphicsLayer.h" | 8 #include "platform/graphics/GraphicsLayer.h" |
| 9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 9 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" | 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 #if DCHECK_IS_ON() | 134 #if DCHECK_IS_ON() |
| 135 // Also remove the index pointing to the removed display item. | 135 // Also remove the index pointing to the removed display item. |
| 136 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient
.find(&m_newDisplayItemList.last().client()); | 136 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient
.find(&m_newDisplayItemList.last().client()); |
| 137 if (it != m_newDisplayItemIndicesByClient.end()) { | 137 if (it != m_newDisplayItemIndicesByClient.end()) { |
| 138 Vector<size_t>& indices = it->value; | 138 Vector<size_t>& indices = it->value; |
| 139 if (!indices.isEmpty() && indices.last() == (m_newDisplayItemList.size()
- 1)) | 139 if (!indices.isEmpty() && indices.last() == (m_newDisplayItemList.size()
- 1)) |
| 140 indices.removeLast(); | 140 indices.removeLast(); |
| 141 } | 141 } |
| 142 |
| 143 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()
&& isCheckingUnderInvalidation()) { |
| 144 if (m_skippedProbableUnderInvalidationCount) { |
| 145 --m_skippedProbableUnderInvalidationCount; |
| 146 } else { |
| 147 DCHECK(m_underInvalidationCheckingBegin); |
| 148 --m_underInvalidationCheckingBegin; |
| 149 } |
| 150 } |
| 142 #endif | 151 #endif |
| 143 m_newDisplayItemList.removeLast(); | 152 m_newDisplayItemList.removeLast(); |
| 144 | 153 |
| 145 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 154 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 146 m_newPaintChunks.decrementDisplayItemIndex(); | 155 m_newPaintChunks.decrementDisplayItemIndex(); |
| 147 } | 156 } |
| 148 | 157 |
| 149 void PaintController::processNewItem(DisplayItem& displayItem) | 158 void PaintController::processNewItem(DisplayItem& displayItem) |
| 150 { | 159 { |
| 151 DCHECK(!m_constructionDisabled); | 160 DCHECK(!m_constructionDisabled); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 return enclosingIntRect(visualRect); | 403 return enclosingIntRect(visualRect); |
| 395 } | 404 } |
| 396 | 405 |
| 397 void PaintController::resetCurrentListIndices() | 406 void PaintController::resetCurrentListIndices() |
| 398 { | 407 { |
| 399 m_nextItemToMatch = 0; | 408 m_nextItemToMatch = 0; |
| 400 m_nextItemToIndex = 0; | 409 m_nextItemToIndex = 0; |
| 401 #if DCHECK_IS_ON() | 410 #if DCHECK_IS_ON() |
| 402 m_underInvalidationCheckingBegin = 0; | 411 m_underInvalidationCheckingBegin = 0; |
| 403 m_underInvalidationCheckingEnd = 0; | 412 m_underInvalidationCheckingEnd = 0; |
| 413 m_skippedProbableUnderInvalidationCount = 0; |
| 404 #endif | 414 #endif |
| 405 } | 415 } |
| 406 | 416 |
| 407 void PaintController::commitNewDisplayItems(const LayoutSize& offsetFromLayoutOb
ject) | 417 void PaintController::commitNewDisplayItems(const LayoutSize& offsetFromLayoutOb
ject) |
| 408 { | 418 { |
| 409 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", | 419 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", |
| 410 "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemL
ist().size(), | 420 "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemL
ist().size(), |
| 411 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach
edNewItems); | 421 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach
edNewItems); |
| 412 m_numCachedNewItems = 0; | 422 m_numCachedNewItems = 0; |
| 413 | 423 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 void PaintController::appendDebugDrawingAfterCommit(const DisplayItemClient& dis
playItemClient, PassRefPtr<SkPicture> picture, const LayoutSize& offsetFromLayou
tObject) | 507 void PaintController::appendDebugDrawingAfterCommit(const DisplayItemClient& dis
playItemClient, PassRefPtr<SkPicture> picture, const LayoutSize& offsetFromLayou
tObject) |
| 498 { | 508 { |
| 499 DCHECK(m_newDisplayItemList.isEmpty()); | 509 DCHECK(m_newDisplayItemList.isEmpty()); |
| 500 DrawingDisplayItem& displayItem = m_currentPaintArtifact.getDisplayItemList(
).allocateAndConstruct<DrawingDisplayItem>(displayItemClient, DisplayItem::Debug
Drawing, picture); | 510 DrawingDisplayItem& displayItem = m_currentPaintArtifact.getDisplayItemList(
).allocateAndConstruct<DrawingDisplayItem>(displayItemClient, DisplayItem::Debug
Drawing, picture); |
| 501 displayItem.setSkippedCache(); | 511 displayItem.setSkippedCache(); |
| 502 m_currentPaintArtifact.getDisplayItemList().appendVisualRect(visualRectForDi
splayItem(displayItem, offsetFromLayoutObject)); | 512 m_currentPaintArtifact.getDisplayItemList().appendVisualRect(visualRectForDi
splayItem(displayItem, offsetFromLayoutObject)); |
| 503 } | 513 } |
| 504 | 514 |
| 505 #if DCHECK_IS_ON() | 515 #if DCHECK_IS_ON() |
| 506 | 516 |
| 507 void PaintController::showUnderInvalidationError(const char* reason, const Displ
ayItem& newItem, const DisplayItem& oldItem) const | 517 void PaintController::showUnderInvalidationError(const char* reason, const Displ
ayItem& newItem, const DisplayItem* oldItem) const |
| 508 { | 518 { |
| 509 LOG(ERROR) << m_underInvalidationMessagePrefix << " " << reason; | 519 LOG(ERROR) << m_underInvalidationMessagePrefix << " " << reason; |
| 510 #ifndef NDEBUG | 520 #ifndef NDEBUG |
| 511 LOG(ERROR) << "New display item: " << newItem.asDebugString(); | 521 LOG(ERROR) << "New display item: " << newItem.asDebugString(); |
| 512 LOG(ERROR) << "Old display item: " << oldItem.asDebugString(); | 522 LOG(ERROR) << "Old display item: " << (oldItem ? oldItem->asDebugString() :
"None"); |
| 513 #else | 523 #else |
| 514 LOG(ERROR) << "Run debug build to get more details."; | 524 LOG(ERROR) << "Run debug build to get more details."; |
| 515 #endif | 525 #endif |
| 516 LOG(ERROR) << "See http://crbug.com/619103."; | 526 LOG(ERROR) << "See http://crbug.com/619103."; |
| 517 | 527 |
| 518 #ifndef NDEBUG | 528 #ifndef NDEBUG |
| 519 if (newItem.isDrawing()) { | 529 const SkPicture* newPicture = newItem.isDrawing() ? static_cast<const Drawin
gDisplayItem&>(newItem).picture() : nullptr; |
| 520 RefPtr<const SkPicture> newPicture = static_cast<const DrawingDisplayIte
m&>(newItem).picture(); | 530 const SkPicture* oldPicture = oldItem && oldItem->isDrawing() ? static_cast<
const DrawingDisplayItem*>(oldItem)->picture() : nullptr; |
| 521 RefPtr<const SkPicture> oldPicture = static_cast<const DrawingDisplayIte
m&>(oldItem).picture(); | 531 LOG(INFO) << "new picture:\n" << (newPicture ? pictureAsDebugString(newPictu
re) : "None"); |
| 522 LOG(INFO) << "new picture:\n" << (newPicture ? pictureAsDebugString(newP
icture.get()) : "None"); | 532 LOG(INFO) << "old picture:\n" << (oldPicture ? pictureAsDebugString(oldPictu
re) : "None"); |
| 523 LOG(INFO) << "old picture:\n" << (oldPicture ? pictureAsDebugString(oldP
icture.get()) : "None"); | 533 |
| 524 } | 534 showDebugData(); |
| 525 #endif // NDEBUG | 535 #endif // NDEBUG |
| 526 } | 536 } |
| 527 | 537 |
| 528 void PaintController::checkUnderInvalidation() | 538 void PaintController::checkUnderInvalidation() |
| 529 { | 539 { |
| 530 DCHECK(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled
()); | 540 DCHECK(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled
()); |
| 531 | 541 |
| 532 if (!isCheckingUnderInvalidation()) | 542 if (!isCheckingUnderInvalidation()) |
| 533 return; | 543 return; |
| 534 | 544 |
| 535 const DisplayItem& newItem = m_newDisplayItemList.last(); | 545 const DisplayItem& newItem = m_newDisplayItemList.last(); |
| 536 const DisplayItem& oldItem = m_currentPaintArtifact.getDisplayItemList()[m_u
nderInvalidationCheckingBegin++]; | 546 size_t oldItemIndex = m_underInvalidationCheckingBegin + m_skippedProbableUn
derInvalidationCount; |
| 547 const DisplayItem* oldItem = oldItemIndex < m_currentPaintArtifact.getDispla
yItemList().size() ? &m_currentPaintArtifact.getDisplayItemList()[oldItemIndex]
: nullptr; |
| 537 | 548 |
| 538 if (newItem.isCacheable() && !clientCacheIsValid(newItem.client())) { | 549 if (newItem.isCacheable() && !clientCacheIsValid(newItem.client())) { |
| 539 showUnderInvalidationError("under-invalidation of PaintLayer: invalidate
d in cached subsequence", newItem, oldItem); | 550 showUnderInvalidationError("under-invalidation of PaintLayer: invalidate
d in cached subsequence", newItem, oldItem); |
| 540 NOTREACHED(); | 551 NOTREACHED(); |
| 541 } | 552 } |
| 542 if (!newItem.equals(oldItem)) { | 553 |
| 543 showUnderInvalidationError("under-invalidation: display item changed", n
ewItem, oldItem); | 554 bool oldAndNewEqual = oldItem && newItem.equals(*oldItem); |
| 555 if (!oldAndNewEqual) { |
| 556 if (newItem.isBegin()) { |
| 557 // Temporarily skip mismatching begin display item which may be remo
ved when we remove a no-op pair. |
| 558 ++m_skippedProbableUnderInvalidationCount; |
| 559 return; |
| 560 } |
| 561 if (newItem.isDrawing() && m_skippedProbableUnderInvalidationCount == 1)
{ |
| 562 DCHECK_GE(m_newDisplayItemList.size(), 2); |
| 563 if (m_newDisplayItemList[m_newDisplayItemList.size() - 2].getType()
== DisplayItem::BeginCompositing) { |
| 564 // This might be a drawing item between a pair of begin/end comp
ositing display items that will be folded |
| 565 // into a single drawing display item. |
| 566 ++m_skippedProbableUnderInvalidationCount; |
| 567 return; |
| 568 } |
| 569 } |
| 570 } |
| 571 |
| 572 if (m_skippedProbableUnderInvalidationCount || !oldAndNewEqual) { |
| 573 // If we ever skipped reporting any under-invalidations, report the earl
iest one. |
| 574 showUnderInvalidationError("under-invalidation: display item changed", |
| 575 m_newDisplayItemList[m_newDisplayItemList.size() - m_skippedProbable
UnderInvalidationCount - 1], |
| 576 &m_currentPaintArtifact.getDisplayItemList()[m_underInvalidationChec
kingBegin]); |
| 544 NOTREACHED(); | 577 NOTREACHED(); |
| 545 } | 578 } |
| 579 |
| 580 ++m_underInvalidationCheckingBegin; |
| 546 } | 581 } |
| 547 | 582 |
| 548 #endif // DCHECK_IS_ON() | 583 #endif // DCHECK_IS_ON() |
| 549 | 584 |
| 550 #ifndef NDEBUG | 585 #ifndef NDEBUG |
| 551 | 586 |
| 552 String PaintController::displayItemListAsDebugString(const DisplayItemList& list
) const | 587 String PaintController::displayItemListAsDebugString(const DisplayItemList& list
) const |
| 553 { | 588 { |
| 554 StringBuilder stringBuilder; | 589 StringBuilder stringBuilder; |
| 555 size_t i = 0; | 590 size_t i = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 576 | 611 |
| 577 void PaintController::showDebugData() const | 612 void PaintController::showDebugData() const |
| 578 { | 613 { |
| 579 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri
ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); | 614 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri
ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); |
| 580 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m
_newDisplayItemList).utf8().data()); | 615 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m
_newDisplayItemList).utf8().data()); |
| 581 } | 616 } |
| 582 | 617 |
| 583 #endif // ifndef NDEBUG | 618 #endif // ifndef NDEBUG |
| 584 | 619 |
| 585 } // namespace blink | 620 } // namespace blink |
| OLD | NEW |