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

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

Issue 2894093002: Don't access DisplayItemClient::VisualRect() for cached display items. (Closed)
Patch Set: Created 3 years, 7 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/graphics/GraphicsLayer.h" 7 #include "platform/graphics/GraphicsLayer.h"
8 #include "platform/graphics/paint/DrawingDisplayItem.h" 8 #include "platform/graphics/paint/DrawingDisplayItem.h"
9 #include "platform/instrumentation/tracing/TraceEvent.h" 9 #include "platform/instrumentation/tracing/TraceEvent.h"
10 #include "platform/wtf/AutoReset.h" 10 #include "platform/wtf/AutoReset.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // The status will end when the subsequence owner is invalidated or 239 // The status will end when the subsequence owner is invalidated or
240 // deleted. 240 // deleted.
241 client.BeginShouldKeepAlive(current_subsequence_clients_.back()); 241 client.BeginShouldKeepAlive(current_subsequence_clients_.back());
242 } 242 }
243 } 243 }
244 } 244 }
245 #endif 245 #endif
246 246
247 void PaintController::ProcessNewItem(DisplayItem& display_item) { 247 void PaintController::ProcessNewItem(DisplayItem& display_item) {
248 DCHECK(!construction_disabled_); 248 DCHECK(!construction_disabled_);
249 DCHECK(display_item.VisualRect() == display_item.Client().VisualRect());
249 250
250 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 251 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
251 if (display_item.IsCacheable()) { 252 if (display_item.IsCacheable()) {
252 BeginShouldKeepAlive(display_item.Client()); 253 BeginShouldKeepAlive(display_item.Client());
253 } 254 }
254 #endif 255 #endif
255 256
256 if (IsSkippingCache()) 257 if (IsSkippingCache())
257 display_item.SetSkippedCache(); 258 display_item.SetSkippedCache();
258 259
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 new_paint_chunks_.LastChunk().Matches(*cached_chunk)); 523 new_paint_chunks_.LastChunk().Matches(*cached_chunk));
523 } 524 }
524 } 525 }
525 526
526 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { 527 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
527 under_invalidation_checking_end_ = end_index + 1; 528 under_invalidation_checking_end_ = end_index + 1;
528 DCHECK(IsCheckingUnderInvalidation()); 529 DCHECK(IsCheckingUnderInvalidation());
529 } 530 }
530 } 531 }
531 532
532 DISABLE_CFI_PERF
533 static IntRect VisualRectForDisplayItem(
534 const DisplayItem& display_item,
535 const LayoutSize& offset_from_layout_object) {
536 LayoutRect visual_rect = display_item.Client().VisualRect();
537 visual_rect.Move(-offset_from_layout_object);
538 return EnclosingIntRect(visual_rect);
539 }
540
541 void PaintController::ResetCurrentListIndices() { 533 void PaintController::ResetCurrentListIndices() {
542 next_item_to_match_ = 0; 534 next_item_to_match_ = 0;
543 next_item_to_index_ = 0; 535 next_item_to_index_ = 0;
544 next_chunk_to_match_ = 0; 536 next_chunk_to_match_ = 0;
545 under_invalidation_checking_begin_ = 0; 537 under_invalidation_checking_begin_ = 0;
546 under_invalidation_checking_end_ = 0; 538 under_invalidation_checking_end_ = 0;
547 skipped_probable_under_invalidation_count_ = 0; 539 skipped_probable_under_invalidation_count_ = 0;
548 } 540 }
549 541
550 DISABLE_CFI_PERF 542 DISABLE_CFI_PERF
551 void PaintController::CommitNewDisplayItems( 543 void PaintController::CommitNewDisplayItems() {
552 const LayoutSize& offset_from_layout_object) {
553 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", 544 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems",
554 "current_display_list_size", 545 "current_display_list_size",
555 (int)current_paint_artifact_.GetDisplayItemList().size(), 546 (int)current_paint_artifact_.GetDisplayItemList().size(),
556 "num_non_cached_new_items", 547 "num_non_cached_new_items",
557 (int)new_display_item_list_.size() - num_cached_new_items_); 548 (int)new_display_item_list_.size() - num_cached_new_items_);
549
558 num_cached_new_items_ = 0; 550 num_cached_new_items_ = 0;
559 // These data structures are used during painting only. 551 // These data structures are used during painting only.
560 DCHECK(!IsSkippingCache()); 552 DCHECK(!IsSkippingCache());
561 #if DCHECK_IS_ON() 553 #if DCHECK_IS_ON()
562 new_display_item_indices_by_client_.clear(); 554 new_display_item_indices_by_client_.clear();
563 #endif 555 #endif
564 556
565 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 557 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
566 !new_display_item_list_.IsEmpty()) 558 !new_display_item_list_.IsEmpty())
567 GenerateRasterInvalidations(new_paint_chunks_.LastChunk()); 559 GenerateRasterInvalidations(new_paint_chunks_.LastChunk());
(...skipping 13 matching lines...) Expand all
581 DCHECK(current_subsequence_clients_.IsEmpty()); 573 DCHECK(current_subsequence_clients_.IsEmpty());
582 #endif 574 #endif
583 } 575 }
584 576
585 Vector<const DisplayItemClient*> skipped_cache_clients; 577 Vector<const DisplayItemClient*> skipped_cache_clients;
586 for (const auto& item : new_display_item_list_) { 578 for (const auto& item : new_display_item_list_) {
587 // No reason to continue the analysis once we have a veto. 579 // No reason to continue the analysis once we have a veto.
588 if (num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto) 580 if (num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto)
589 num_slow_paths += item.NumberOfSlowPaths(); 581 num_slow_paths += item.NumberOfSlowPaths();
590 582
591 // TODO(wkorman): Only compute and append visual rect for drawings.
592 new_display_item_list_.AppendVisualRect(
593 VisualRectForDisplayItem(item, offset_from_layout_object));
594
595 if (item.IsCacheable()) { 583 if (item.IsCacheable()) {
596 item.Client().SetDisplayItemsCached(current_cache_generation_); 584 item.Client().SetDisplayItemsCached(current_cache_generation_);
597 } else { 585 } else {
598 if (item.Client().IsJustCreated()) 586 if (item.Client().IsJustCreated())
599 item.Client().ClearIsJustCreated(); 587 item.Client().ClearIsJustCreated();
600 if (item.SkippedCache()) 588 if (item.SkippedCache())
601 skipped_cache_clients.push_back(&item.Client()); 589 skipped_cache_clients.push_back(&item.Client());
602 } 590 }
603 } 591 }
604 592
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // Memory outside this class due to m_newDisplayItemList. 657 // Memory outside this class due to m_newDisplayItemList.
670 DCHECK(new_display_item_list_.IsEmpty()); 658 DCHECK(new_display_item_list_.IsEmpty());
671 memory_usage += new_display_item_list_.MemoryUsageInBytes(); 659 memory_usage += new_display_item_list_.MemoryUsageInBytes();
672 660
673 return memory_usage; 661 return memory_usage;
674 } 662 }
675 663
676 void PaintController::AppendDebugDrawingAfterCommit( 664 void PaintController::AppendDebugDrawingAfterCommit(
677 const DisplayItemClient& display_item_client, 665 const DisplayItemClient& display_item_client,
678 sk_sp<PaintRecord> record, 666 sk_sp<PaintRecord> record,
679 const FloatRect& record_bounds, 667 const FloatRect& record_bounds) {
680 const LayoutSize& offset_from_layout_object) {
681 DCHECK(new_display_item_list_.IsEmpty()); 668 DCHECK(new_display_item_list_.IsEmpty());
682 DrawingDisplayItem& display_item = 669 DrawingDisplayItem& display_item =
683 current_paint_artifact_.GetDisplayItemList() 670 current_paint_artifact_.GetDisplayItemList()
684 .AllocateAndConstruct<DrawingDisplayItem>( 671 .AllocateAndConstruct<DrawingDisplayItem>(
685 display_item_client, DisplayItem::kDebugDrawing, 672 display_item_client, DisplayItem::kDebugDrawing,
686 std::move(record), record_bounds); 673 std::move(record), record_bounds);
687 display_item.SetSkippedCache(); 674 display_item.SetSkippedCache();
688 // TODO(wkorman): Only compute and append visual rect for drawings.
689 current_paint_artifact_.GetDisplayItemList().AppendVisualRect(
690 VisualRectForDisplayItem(display_item, offset_from_layout_object));
691 } 675 }
692 676
693 void PaintController::GenerateRasterInvalidations(PaintChunk& new_chunk) { 677 void PaintController::GenerateRasterInvalidations(PaintChunk& new_chunk) {
694 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 678 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
695 if (new_chunk.begin_index >= 679 if (new_chunk.begin_index >=
696 current_cached_subsequence_begin_index_in_new_list_) 680 current_cached_subsequence_begin_index_in_new_list_)
697 return; 681 return;
698 682
699 static FloatRect infinite_float_rect(LayoutRect::InfiniteIntRect()); 683 static FloatRect infinite_float_rect(LayoutRect::InfiniteIntRect());
700 if (!new_chunk.id) { 684 if (!new_chunk.id) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 current_paint_artifact_.GetDisplayItemList()[old_index]; 778 current_paint_artifact_.GetDisplayItemList()[old_index];
795 const DisplayItemClient* client_to_invalidate = nullptr; 779 const DisplayItemClient* client_to_invalidate = nullptr;
796 780
797 if (!old_item.HasValidClient()) { 781 if (!old_item.HasValidClient()) {
798 size_t moved_to_index = items_moved_into_new_list_[old_index]; 782 size_t moved_to_index = items_moved_into_new_list_[old_index];
799 if (new_display_item_list_[moved_to_index].DrawsContent()) { 783 if (new_display_item_list_[moved_to_index].DrawsContent()) {
800 if (moved_to_index < new_chunk.begin_index || 784 if (moved_to_index < new_chunk.begin_index ||
801 moved_to_index >= new_chunk.end_index) { 785 moved_to_index >= new_chunk.end_index) {
802 // The item has been moved into another chunk, so need to invalidate 786 // The item has been moved into another chunk, so need to invalidate
803 // it in the old chunk. 787 // it in the old chunk.
804 client_to_invalidate = 788 const auto& new_item = new_display_item_list_[moved_to_index];
805 &new_display_item_list_[moved_to_index].Client(); 789 client_to_invalidate = &new_item.Client();
806 // And invalidate in the new chunk into which the item was moved. 790 // And invalidate in the new chunk into which the item was moved.
807 PaintChunk& moved_to_chunk = 791 PaintChunk& moved_to_chunk =
808 new_paint_chunks_.FindChunkByDisplayItemIndex(moved_to_index); 792 new_paint_chunks_.FindChunkByDisplayItemIndex(moved_to_index);
809 AddRasterInvalidation(*client_to_invalidate, moved_to_chunk, 793 AddRasterInvalidation(*client_to_invalidate, moved_to_chunk,
810 FloatRect(client_to_invalidate->VisualRect())); 794 FloatRect(new_item.VisualRect()));
811 } else if (moved_to_index < highest_moved_to_index) { 795 } else if (moved_to_index < highest_moved_to_index) {
812 // The item has been moved behind other cached items, so need to 796 // The item has been moved behind other cached items, so need to
813 // invalidate the area that is probably exposed by the item moved 797 // invalidate the area that is probably exposed by the item moved
814 // earlier. 798 // earlier.
815 client_to_invalidate = 799 client_to_invalidate =
816 &new_display_item_list_[moved_to_index].Client(); 800 &new_display_item_list_[moved_to_index].Client();
817 } else { 801 } else {
818 highest_moved_to_index = moved_to_index; 802 highest_moved_to_index = moved_to_index;
819 } 803 }
820 } 804 }
821 } else if (old_item.DrawsContent()) { 805 } else if (old_item.DrawsContent()) {
822 client_to_invalidate = &old_item.Client(); 806 client_to_invalidate = &old_item.Client();
823 } 807 }
824 if (client_to_invalidate && 808 if (client_to_invalidate &&
825 invalidated_clients_in_old_chunk.insert(client_to_invalidate) 809 invalidated_clients_in_old_chunk.insert(client_to_invalidate)
826 .is_new_entry) { 810 .is_new_entry) {
827 AddRasterInvalidation( 811 AddRasterInvalidation(*client_to_invalidate, new_chunk,
828 *client_to_invalidate, new_chunk, 812 FloatRect(old_item.VisualRect()));
829 FloatRect(current_paint_artifact_.GetDisplayItemList().VisualRect(
830 old_index)));
831 } 813 }
832 } 814 }
833 815
834 HashSet<const DisplayItemClient*> invalidated_clients_in_new_chunk; 816 HashSet<const DisplayItemClient*> invalidated_clients_in_new_chunk;
835 for (size_t new_index = new_chunk.begin_index; 817 for (size_t new_index = new_chunk.begin_index;
836 new_index < new_chunk.end_index; ++new_index) { 818 new_index < new_chunk.end_index; ++new_index) {
837 const DisplayItem& new_item = new_display_item_list_[new_index]; 819 const DisplayItem& new_item = new_display_item_list_[new_index];
838 if (new_item.DrawsContent() && !ClientCacheIsValid(new_item.Client()) && 820 if (new_item.DrawsContent() && !ClientCacheIsValid(new_item.Client()) &&
839 invalidated_clients_in_new_chunk.insert(&new_item.Client()) 821 invalidated_clients_in_new_chunk.insert(&new_item.Client())
840 .is_new_entry) { 822 .is_new_entry) {
841 AddRasterInvalidation(new_item.Client(), new_chunk, 823 AddRasterInvalidation(new_item.Client(), new_chunk,
842 FloatRect(new_item.Client().VisualRect())); 824 FloatRect(new_item.VisualRect()));
843 } 825 }
844 } 826 }
845 } 827 }
846 828
847 void PaintController::ShowUnderInvalidationError( 829 void PaintController::ShowUnderInvalidationError(
848 const char* reason, 830 const char* reason,
849 const DisplayItem& new_item, 831 const DisplayItem& new_item,
850 const DisplayItem* old_item) const { 832 const DisplayItem* old_item) const {
851 LOG(ERROR) << under_invalidation_message_prefix_ << " " << reason; 833 LOG(ERROR) << under_invalidation_message_prefix_ << " " << reason;
852 #ifndef NDEBUG 834 #ifndef NDEBUG
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 } 987 }
1006 988
1007 FrameFirstPaint PaintController::EndFrame(const void* frame) { 989 FrameFirstPaint PaintController::EndFrame(const void* frame) {
1008 FrameFirstPaint result = frame_first_paints_.back(); 990 FrameFirstPaint result = frame_first_paints_.back();
1009 DCHECK(result.frame == frame); 991 DCHECK(result.frame == frame);
1010 frame_first_paints_.pop_back(); 992 frame_first_paints_.pop_back();
1011 return result; 993 return result;
1012 } 994 }
1013 995
1014 } // namespace blink 996 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698