Chromium Code Reviews| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 m_currentPaintArtifact.getDisplayItemList().appendVisualRect(visualRectForDi splayItem(displayItem, offsetFromLayoutObject)); | 532 m_currentPaintArtifact.getDisplayItemList().appendVisualRect(visualRectForDi splayItem(displayItem, offsetFromLayoutObject)); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void PaintController::generateChunkRasterInvalidationRects(PaintChunk& newChunk) | 535 void PaintController::generateChunkRasterInvalidationRects(PaintChunk& newChunk) |
| 536 { | 536 { |
| 537 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 537 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 538 if (newChunk.beginIndex >= m_currentCachedSubsequenceBeginIndexInNewList) | 538 if (newChunk.beginIndex >= m_currentCachedSubsequenceBeginIndexInNewList) |
| 539 return; | 539 return; |
| 540 | 540 |
| 541 if (!newChunk.id) { | 541 if (!newChunk.id) { |
| 542 newChunk.rasterInvalidationRects.append(FloatRect(LayoutRect::infiniteIn tRect())); | 542 PaintInvalidationInfo info; |
| 543 info.rect = LayoutRect::infiniteIntRect(); | |
| 544 newChunk.rasterInvalidationRects.append(info); | |
| 543 return; | 545 return; |
| 544 } | 546 } |
| 545 | 547 |
| 546 // Try to match old chunk sequentially first. | 548 // Try to match old chunk sequentially first. |
| 547 const auto& oldChunks = m_currentPaintArtifact.paintChunks(); | 549 const auto& oldChunks = m_currentPaintArtifact.paintChunks(); |
| 548 while (m_nextChunkToMatch < oldChunks.size()) { | 550 while (m_nextChunkToMatch < oldChunks.size()) { |
| 549 const PaintChunk& oldChunk = oldChunks[m_nextChunkToMatch]; | 551 const PaintChunk& oldChunk = oldChunks[m_nextChunkToMatch]; |
| 550 if (newChunk.matches(oldChunk)) { | 552 if (newChunk.matches(oldChunk)) { |
| 551 generateChunkRasterInvalidationRectsComparingOldChunk(newChunk, oldC hunk); | 553 generateChunkRasterInvalidationRectsComparingOldChunk(newChunk, oldC hunk); |
| 552 ++m_nextChunkToMatch; | 554 ++m_nextChunkToMatch; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 568 if (it != m_outOfOrderChunkIndices.end()) { | 570 if (it != m_outOfOrderChunkIndices.end()) { |
| 569 for (size_t i : it->value) { | 571 for (size_t i : it->value) { |
| 570 if (newChunk.matches(oldChunks[i])) { | 572 if (newChunk.matches(oldChunks[i])) { |
| 571 generateChunkRasterInvalidationRectsComparingOldChunk(newChunk, oldChunks[i]); | 573 generateChunkRasterInvalidationRectsComparingOldChunk(newChunk, oldChunks[i]); |
| 572 return; | 574 return; |
| 573 } | 575 } |
| 574 } | 576 } |
| 575 } | 577 } |
| 576 | 578 |
| 577 // We reach here because the chunk is new. | 579 // We reach here because the chunk is new. |
| 578 newChunk.rasterInvalidationRects.append(FloatRect(LayoutRect::infiniteIntRec t())); | 580 PaintInvalidationInfo info; |
| 581 info.rect = LayoutRect::infiniteIntRect(); | |
| 582 newChunk.rasterInvalidationRects.append(info); | |
| 579 } | 583 } |
| 580 | 584 |
| 581 void PaintController::generateChunkRasterInvalidationRectsComparingOldChunk(Pain tChunk& newChunk, const PaintChunk& oldChunk) | 585 void PaintController::generateChunkRasterInvalidationRectsComparingOldChunk(Pain tChunk& newChunk, const PaintChunk& oldChunk) |
| 582 { | 586 { |
| 583 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 587 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 584 | 588 |
| 585 // TODO(wangxianzhu): Handle PaintInvalidationIncremental. | 589 // TODO(wangxianzhu): Handle PaintInvalidationIncremental. |
| 586 // TODO(wangxianzhu): Optimize paint offset change. | 590 // TODO(wangxianzhu): Optimize paint offset change. |
| 587 | 591 |
| 588 HashSet<const DisplayItemClient*> invalidatedClientsInOldChunk; | 592 HashSet<const DisplayItemClient*> invalidatedClientsInOldChunk; |
| 589 size_t highestMovedToIndex = 0; | 593 size_t highestMovedToIndex = 0; |
| 590 for (size_t oldIndex = oldChunk.beginIndex; oldIndex < oldChunk.endIndex; ++ oldIndex) { | 594 for (size_t oldIndex = oldChunk.beginIndex; oldIndex < oldChunk.endIndex; ++ oldIndex) { |
| 591 const DisplayItem& oldItem = m_currentPaintArtifact.getDisplayItemList() [oldIndex]; | 595 const DisplayItem& oldItem = m_currentPaintArtifact.getDisplayItemList() [oldIndex]; |
| 592 const DisplayItemClient* clientToInvalidate = nullptr; | 596 const DisplayItemClient* clientToInvalidate = nullptr; |
| 593 if (!oldItem.hasValidClient()) { | 597 if (!oldItem.hasValidClient()) { |
| 594 size_t movedToIndex = m_itemsMovedIntoNewList[oldIndex]; | 598 size_t movedToIndex = m_itemsMovedIntoNewList[oldIndex]; |
| 595 if (m_newDisplayItemList[movedToIndex].drawsContent()) { | 599 if (m_newDisplayItemList[movedToIndex].drawsContent()) { |
| 596 if (movedToIndex < newChunk.beginIndex || movedToIndex >= newChu nk.endIndex) { | 600 if (movedToIndex < newChunk.beginIndex || movedToIndex >= newChu nk.endIndex) { |
| 597 // The item has been moved into another chunk, so need to in validate it in the old chunk. | 601 // The item has been moved into another chunk, so need to in validate it in the old chunk. |
| 598 clientToInvalidate = &m_newDisplayItemList[movedToIndex].cli ent(); | 602 clientToInvalidate = &m_newDisplayItemList[movedToIndex].cli ent(); |
| 599 // And invalidate in the new chunk into which the item was m oved. | 603 // And invalidate in the new chunk into which the item was m oved. |
| 600 PaintChunk& movedToChunk = m_newPaintChunks.findChunkByDispl ayItemIndex(movedToIndex); | 604 PaintChunk& movedToChunk = m_newPaintChunks.findChunkByDispl ayItemIndex(movedToIndex); |
| 601 movedToChunk.rasterInvalidationRects.append(clientToInvalida te->visualRect()); | 605 |
| 606 PaintInvalidationInfo info; | |
| 607 info.rect = enclosingIntRect(clientToInvalidate->visualRect( )); | |
| 608 if (m_isTrackingPaintInvalidations) { | |
| 609 info.client = clientToInvalidate; | |
| 610 info.clientDebugName = clientToInvalidate->debugName(); | |
| 611 info.reason = PaintInvalidationFull; | |
| 612 } | |
|
Xianzhu
2016/09/30 00:47:01
Can you extract this as a function?
We can get th
chrishtr
2016/09/30 18:19:10
Done.
| |
| 613 movedToChunk.rasterInvalidationRects.append(info); | |
| 602 } else if (movedToIndex < highestMovedToIndex) { | 614 } else if (movedToIndex < highestMovedToIndex) { |
| 603 // The item has been moved behind other cached items, so nee d to invalidate the area | 615 // The item has been moved behind other cached items, so nee d to invalidate the area |
| 604 // that is probably exposed by the item moved earlier. | 616 // that is probably exposed by the item moved earlier. |
| 605 clientToInvalidate = &m_newDisplayItemList[movedToIndex].cli ent(); | 617 clientToInvalidate = &m_newDisplayItemList[movedToIndex].cli ent(); |
| 606 } else { | 618 } else { |
| 607 highestMovedToIndex = movedToIndex; | 619 highestMovedToIndex = movedToIndex; |
| 608 } | 620 } |
| 609 } | 621 } |
| 610 } else if (oldItem.drawsContent()) { | 622 } else if (oldItem.drawsContent()) { |
| 611 clientToInvalidate = &oldItem.client(); | 623 clientToInvalidate = &oldItem.client(); |
| 612 } | 624 } |
| 613 if (clientToInvalidate && invalidatedClientsInOldChunk.add(clientToInval idate).isNewEntry) { | 625 if (clientToInvalidate && invalidatedClientsInOldChunk.add(clientToInval idate).isNewEntry) { |
| 614 newChunk.rasterInvalidationRects.append(m_currentPaintArtifact.getDi splayItemList().visualRect(oldIndex)); | 626 PaintInvalidationInfo info; |
| 627 info.rect = enclosingIntRect(m_currentPaintArtifact.getDisplayItemLi st().visualRect(oldIndex)); | |
| 628 if (m_isTrackingPaintInvalidations) { | |
| 629 info.client = clientToInvalidate; | |
| 630 info.clientDebugName = clientToInvalidate->debugName(); | |
| 631 info.reason = PaintInvalidationFull; | |
| 632 } | |
| 633 newChunk.rasterInvalidationRects.append(info); | |
| 615 } | 634 } |
| 616 } | 635 } |
| 617 | 636 |
| 618 HashSet<const DisplayItemClient*> invalidatedClientsInNewChunk; | 637 HashSet<const DisplayItemClient*> invalidatedClientsInNewChunk; |
| 619 for (size_t newIndex = newChunk.beginIndex; newIndex < newChunk.endIndex; ++ newIndex) { | 638 for (size_t newIndex = newChunk.beginIndex; newIndex < newChunk.endIndex; ++ newIndex) { |
| 620 const DisplayItem& newItem = m_newDisplayItemList[newIndex]; | 639 const DisplayItem& newItem = m_newDisplayItemList[newIndex]; |
| 621 if (newItem.drawsContent() && !clientCacheIsValid(newItem.client()) && i nvalidatedClientsInNewChunk.add(&newItem.client()).isNewEntry) | 640 if (newItem.drawsContent() && !clientCacheIsValid(newItem.client()) && i nvalidatedClientsInNewChunk.add(&newItem.client()).isNewEntry) { |
| 622 newChunk.rasterInvalidationRects.append(newItem.client().visualRect( )); | 641 PaintInvalidationInfo info; |
| 642 info.rect = enclosingIntRect(newItem.client().visualRect()); | |
| 643 if (m_isTrackingPaintInvalidations) { | |
| 644 info.client = &newItem.client(); | |
| 645 info.clientDebugName = newItem.client().debugName(); | |
| 646 info.reason = PaintInvalidationFull; | |
| 647 } | |
| 648 newChunk.rasterInvalidationRects.append(info); | |
| 649 } | |
| 623 } | 650 } |
| 624 } | 651 } |
| 625 | 652 |
| 626 void PaintController::showUnderInvalidationError(const char* reason, const Displ ayItem& newItem, const DisplayItem* oldItem) const | 653 void PaintController::showUnderInvalidationError(const char* reason, const Displ ayItem& newItem, const DisplayItem* oldItem) const |
| 627 { | 654 { |
| 628 LOG(ERROR) << m_underInvalidationMessagePrefix << " " << reason; | 655 LOG(ERROR) << m_underInvalidationMessagePrefix << " " << reason; |
| 629 #ifndef NDEBUG | 656 #ifndef NDEBUG |
| 630 LOG(ERROR) << "New display item: " << newItem.asDebugString(); | 657 LOG(ERROR) << "New display item: " << newItem.asDebugString(); |
| 631 LOG(ERROR) << "Old display item: " << (oldItem ? oldItem->asDebugString() : "None"); | 658 LOG(ERROR) << "Old display item: " << (oldItem ? oldItem->asDebugString() : "None"); |
| 632 #else | 659 #else |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 return stringBuilder.toString(); | 766 return stringBuilder.toString(); |
| 740 } | 767 } |
| 741 | 768 |
| 742 void PaintController::showDebugDataInternal(bool showPictures) const | 769 void PaintController::showDebugDataInternal(bool showPictures) const |
| 743 { | 770 { |
| 744 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList(), showPictures).utf8().data()); | 771 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList(), showPictures).utf8().data()); |
| 745 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList, showPictures).utf8().data()); | 772 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList, showPictures).utf8().data()); |
| 746 } | 773 } |
| 747 | 774 |
| 748 } // namespace blink | 775 } // namespace blink |
| OLD | NEW |