Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp

Issue 2184363002: Handle removed display items in under-invalidation checking in cached subsequences (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some small tweaks Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_skippedUnderInvalidationCount) {
145 --m_skippedUnderInvalidationCount;
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
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_skippedUnderInvalidationCount = 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
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_skippedUnderInval idationCount;
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) {
chrishtr 2016/07/28 16:55:36 Don't you need to reset m_skippedUnderInvalidation
Xianzhu 2016/07/28 17:20:48 No. If the pattern does not happen, non-zero m_ski
chrishtr 2016/07/28 17:29:21 Suppose the display list is this: BeginCompositin
Xianzhu 2016/07/28 17:38:40 It's not reset to 0. It is non-zero only if we hav
556 if (newItem.isBegin()) {
557 // Ignore mismatching begin display item which may be removed when w e remove a no-op pair.
558 ++m_skippedUnderInvalidationCount;
559 return;
560 }
561 if (newItem.isDrawing() && m_skippedUnderInvalidationCount == 1 && m_new DisplayItemList[m_newDisplayItemList.size() - 2].getType() == DisplayItem::Begin Compositing) {
chrishtr 2016/07/28 16:55:36 Check if the display list has length at least 2.
Xianzhu 2016/07/28 17:20:48 Added a DCHECK. The condition should be always tru
562 // This might be a drawing item between a pair of begin/end composit ing display items that will be folded into a single drawing display item.
563 ++m_skippedUnderInvalidationCount;
564 return;
565 }
566 }
567
568 if (m_skippedUnderInvalidationCount || !oldAndNewEqual) {
569 // If we ever skipped reporting any under-invalidations, report the earl iest one.
570 showUnderInvalidationError("under-invalidation: display item changed",
571 m_newDisplayItemList[m_newDisplayItemList.size() - m_skippedUnderInv alidationCount - 1],
572 &m_currentPaintArtifact.getDisplayItemList()[m_underInvalidationChec kingBegin]);
544 NOTREACHED(); 573 NOTREACHED();
545 } 574 }
575
576 ++m_underInvalidationCheckingBegin;
546 } 577 }
547 578
548 #endif // DCHECK_IS_ON() 579 #endif // DCHECK_IS_ON()
549 580
550 #ifndef NDEBUG 581 #ifndef NDEBUG
551 582
552 String PaintController::displayItemListAsDebugString(const DisplayItemList& list ) const 583 String PaintController::displayItemListAsDebugString(const DisplayItemList& list ) const
553 { 584 {
554 StringBuilder stringBuilder; 585 StringBuilder stringBuilder;
555 size_t i = 0; 586 size_t i = 0;
(...skipping 20 matching lines...) Expand all
576 607
577 void PaintController::showDebugData() const 608 void PaintController::showDebugData() const
578 { 609 {
579 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); 610 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()); 611 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data());
581 } 612 }
582 613
583 #endif // ifndef NDEBUG 614 #endif // ifndef NDEBUG
584 615
585 } // namespace blink 616 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698