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

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

Issue 2876033005: Track slow paths in DisplayItemList (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"
11 #include "platform/wtf/text/StringBuilder.h" 11 #include "platform/wtf/text/StringBuilder.h"
12 #include "third_party/skia/include/core/SkPictureAnalyzer.h" 12 #include "third_party/skia/include/core/SkPictureAnalyzer.h"
13 13
14 #ifndef NDEBUG 14 #ifndef NDEBUG
15 #include "platform/graphics/LoggingCanvas.h" 15 #include "platform/graphics/LoggingCanvas.h"
16 #include <stdio.h> 16 #include <stdio.h>
17 #endif 17 #endif
18 18
19 static constexpr int kMaxNumberOfSlowPathsBeforeVeto = 5;
20
21 namespace blink { 19 namespace blink {
22 20
23 void PaintController::SetTracksRasterInvalidations(bool value) { 21 void PaintController::SetTracksRasterInvalidations(bool value) {
24 if (value || 22 if (value ||
25 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { 23 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
26 raster_invalidation_tracking_info_ = 24 raster_invalidation_tracking_info_ =
27 WTF::MakeUnique<RasterInvalidationTrackingInfo>(); 25 WTF::MakeUnique<RasterInvalidationTrackingInfo>();
28 26
29 // This is called just after a full document cycle update, so all clients in 27 // This is called just after a full document cycle update, so all clients in
30 // current_paint_artifact_ should be still alive. 28 // current_paint_artifact_ should be still alive.
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 for (auto& item : current_cached_subsequences_) { 565 for (auto& item : current_cached_subsequences_) {
568 item.key->SetDisplayItemsCached(current_cache_generation_); 566 item.key->SetDisplayItemsCached(current_cache_generation_);
569 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 567 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
570 DisplayItemClient::EndShouldKeepAliveAllClients(item.key); 568 DisplayItemClient::EndShouldKeepAliveAllClients(item.key);
571 DCHECK(current_subsequence_clients_.IsEmpty()); 569 DCHECK(current_subsequence_clients_.IsEmpty());
572 #endif 570 #endif
573 } 571 }
574 572
575 Vector<const DisplayItemClient*> skipped_cache_clients; 573 Vector<const DisplayItemClient*> skipped_cache_clients;
576 for (const auto& item : new_display_item_list_) { 574 for (const auto& item : new_display_item_list_) {
577 // No reason to continue the analysis once we have a veto. 575 num_slow_paths += item.NumberOfSlowPaths();
chrishtr 2017/05/13 01:12:04 Why remove the early-out?
enne (OOO) 2017/05/13 18:27:40 Because number of slow paths is a member accessor
578 if (num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto)
579 num_slow_paths += item.NumberOfSlowPaths();
580 576
581 // TODO(wkorman): Only compute and append visual rect for drawings. 577 // TODO(wkorman): Only compute and append visual rect for drawings.
582 new_display_item_list_.AppendVisualRect( 578 new_display_item_list_.AppendVisualRect(
583 VisualRectForDisplayItem(item, offset_from_layout_object)); 579 VisualRectForDisplayItem(item, offset_from_layout_object));
584 580
585 if (item.IsCacheable()) { 581 if (item.IsCacheable()) {
586 item.Client().SetDisplayItemsCached(current_cache_generation_); 582 item.Client().SetDisplayItemsCached(current_cache_generation_);
587 } else { 583 } else {
588 if (item.Client().IsJustCreated()) 584 if (item.Client().IsJustCreated())
589 item.Client().ClearIsJustCreated(); 585 item.Client().ClearIsJustCreated();
(...skipping 20 matching lines...) Expand all
610 for (auto* client : skipped_cache_clients) 606 for (auto* client : skipped_cache_clients)
611 client->SetDisplayItemsUncached(); 607 client->SetDisplayItemsUncached();
612 608
613 // The new list will not be appended to again so we can release unused memory. 609 // The new list will not be appended to again so we can release unused memory.
614 new_display_item_list_.ShrinkToFit(); 610 new_display_item_list_.ShrinkToFit();
615 611
616 if (raster_invalidation_tracking_info_) { 612 if (raster_invalidation_tracking_info_) {
617 for (const auto& chunk : current_paint_artifact_.PaintChunks()) 613 for (const auto& chunk : current_paint_artifact_.PaintChunks())
618 raster_invalidation_tracking_info_->map.Remove(&chunk); 614 raster_invalidation_tracking_info_->map.Remove(&chunk);
619 } 615 }
620 current_paint_artifact_ = PaintArtifact( 616 current_paint_artifact_ =
621 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), 617 PaintArtifact(std::move(new_display_item_list_),
622 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); 618 new_paint_chunks_.ReleasePaintChunks(), num_slow_paths);
623 619
624 ResetCurrentListIndices(); 620 ResetCurrentListIndices();
625 out_of_order_item_indices_.clear(); 621 out_of_order_item_indices_.clear();
626 out_of_order_chunk_indices_.clear(); 622 out_of_order_chunk_indices_.clear();
627 items_moved_into_new_list_.clear(); 623 items_moved_into_new_list_.clear();
628 624
629 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 625 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
630 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { 626 for (const auto& chunk : current_paint_artifact_.PaintChunks()) {
631 if (chunk.id && chunk.id->client.IsJustCreated()) 627 if (chunk.id && chunk.id->client.IsJustCreated())
632 chunk.id->client.ClearIsJustCreated(); 628 chunk.id->client.ClearIsJustCreated();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 show_paint_records 975 show_paint_records
980 ? (DisplayItemList::JsonOptions::kShowPaintRecords | 976 ? (DisplayItemList::JsonOptions::kShowPaintRecords |
981 DisplayItemList::JsonOptions::kShowClientDebugName) 977 DisplayItemList::JsonOptions::kShowClientDebugName)
982 : DisplayItemList::JsonOptions::kShowClientDebugName) 978 : DisplayItemList::JsonOptions::kShowClientDebugName)
983 ->ToPrettyJSONString() 979 ->ToPrettyJSONString()
984 .Utf8() 980 .Utf8()
985 .data()); 981 .data());
986 } 982 }
987 983
988 } // namespace blink 984 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698