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

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

Issue 2876033005: Track slow paths in DisplayItemList (Closed)
Patch Set: Rebase Created 3 years, 6 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 for (auto& item : current_cached_subsequences_) { 575 for (auto& item : current_cached_subsequences_) {
578 item.key->SetDisplayItemsCached(current_cache_generation_); 576 item.key->SetDisplayItemsCached(current_cache_generation_);
579 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 577 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
580 DisplayItemClient::EndShouldKeepAliveAllClients(item.key); 578 DisplayItemClient::EndShouldKeepAliveAllClients(item.key);
581 DCHECK(current_subsequence_clients_.IsEmpty()); 579 DCHECK(current_subsequence_clients_.IsEmpty());
582 #endif 580 #endif
583 } 581 }
584 582
585 Vector<const DisplayItemClient*> skipped_cache_clients; 583 Vector<const DisplayItemClient*> skipped_cache_clients;
586 for (const auto& item : new_display_item_list_) { 584 for (const auto& item : new_display_item_list_) {
587 // No reason to continue the analysis once we have a veto. 585 num_slow_paths += item.NumberOfSlowPaths();
588 if (num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto)
589 num_slow_paths += item.NumberOfSlowPaths();
590 586
591 // TODO(wkorman): Only compute and append visual rect for drawings. 587 // TODO(wkorman): Only compute and append visual rect for drawings.
592 new_display_item_list_.AppendVisualRect( 588 new_display_item_list_.AppendVisualRect(
593 VisualRectForDisplayItem(item, offset_from_layout_object)); 589 VisualRectForDisplayItem(item, offset_from_layout_object));
594 590
595 if (item.IsCacheable()) { 591 if (item.IsCacheable()) {
596 item.Client().SetDisplayItemsCached(current_cache_generation_); 592 item.Client().SetDisplayItemsCached(current_cache_generation_);
597 } else { 593 } else {
598 if (item.Client().IsJustCreated()) 594 if (item.Client().IsJustCreated())
599 item.Client().ClearIsJustCreated(); 595 item.Client().ClearIsJustCreated();
600 if (item.SkippedCache()) 596 if (item.SkippedCache())
601 skipped_cache_clients.push_back(&item.Client()); 597 skipped_cache_clients.push_back(&item.Client());
602 } 598 }
603 } 599 }
604 600
605 for (auto* client : skipped_cache_clients) 601 for (auto* client : skipped_cache_clients)
606 client->SetDisplayItemsUncached(); 602 client->SetDisplayItemsUncached();
607 603
608 // The new list will not be appended to again so we can release unused memory. 604 // The new list will not be appended to again so we can release unused memory.
609 new_display_item_list_.ShrinkToFit(); 605 new_display_item_list_.ShrinkToFit();
610 606
611 if (raster_invalidation_tracking_info_) { 607 if (raster_invalidation_tracking_info_) {
612 for (const auto& chunk : current_paint_artifact_.PaintChunks()) 608 for (const auto& chunk : current_paint_artifact_.PaintChunks())
613 raster_invalidation_tracking_info_->map.Remove(&chunk); 609 raster_invalidation_tracking_info_->map.Remove(&chunk);
614 } 610 }
615 current_paint_artifact_ = PaintArtifact( 611 current_paint_artifact_ =
616 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), 612 PaintArtifact(std::move(new_display_item_list_),
617 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); 613 new_paint_chunks_.ReleasePaintChunks(), num_slow_paths);
618 614
619 ResetCurrentListIndices(); 615 ResetCurrentListIndices();
620 out_of_order_item_indices_.clear(); 616 out_of_order_item_indices_.clear();
621 out_of_order_chunk_indices_.clear(); 617 out_of_order_chunk_indices_.clear();
622 items_moved_into_new_list_.clear(); 618 items_moved_into_new_list_.clear();
623 619
624 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 620 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
625 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { 621 for (const auto& chunk : current_paint_artifact_.PaintChunks()) {
626 if (chunk.id && chunk.id->client.IsJustCreated()) 622 if (chunk.id && chunk.id->client.IsJustCreated())
627 chunk.id->client.ClearIsJustCreated(); 623 chunk.id->client.ClearIsJustCreated();
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 } 1001 }
1006 1002
1007 FrameFirstPaint PaintController::EndFrame(const void* frame) { 1003 FrameFirstPaint PaintController::EndFrame(const void* frame) {
1008 FrameFirstPaint result = frame_first_paints_.back(); 1004 FrameFirstPaint result = frame_first_paints_.back();
1009 DCHECK(result.frame == frame); 1005 DCHECK(result.frame == frame);
1010 frame_first_paints_.pop_back(); 1006 frame_first_paints_.pop_back();
1011 return result; 1007 return result;
1012 } 1008 }
1013 1009
1014 } // namespace blink 1010 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698