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

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

Issue 2820133005: Revert of Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: Created 3 years, 8 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 paint_chunks_raster_invalidation_tracking_map_ = 23 paint_chunks_raster_invalidation_tracking_map_ =
26 WTF::WrapUnique(new RasterInvalidationTrackingMap<const PaintChunk>); 24 WTF::WrapUnique(new RasterInvalidationTrackingMap<const PaintChunk>);
27 } else { 25 } else {
28 paint_chunks_raster_invalidation_tracking_map_ = nullptr; 26 paint_chunks_raster_invalidation_tracking_map_ = nullptr;
29 } 27 }
30 } 28 }
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // These data structures are used during painting only. 528 // These data structures are used during painting only.
531 DCHECK(!IsSkippingCache()); 529 DCHECK(!IsSkippingCache());
532 #if DCHECK_IS_ON() 530 #if DCHECK_IS_ON()
533 new_display_item_indices_by_client_.Clear(); 531 new_display_item_indices_by_client_.Clear();
534 #endif 532 #endif
535 533
536 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 534 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
537 !new_display_item_list_.IsEmpty()) 535 !new_display_item_list_.IsEmpty())
538 GenerateChunkRasterInvalidationRects(new_paint_chunks_.LastChunk()); 536 GenerateChunkRasterInvalidationRects(new_paint_chunks_.LastChunk());
539 537
540 int num_slow_paths = 0; 538 SkPictureGpuAnalyzer gpu_analyzer;
541 539
542 current_cache_generation_ = 540 current_cache_generation_ =
543 DisplayItemClient::CacheGenerationOrInvalidationReason::Next(); 541 DisplayItemClient::CacheGenerationOrInvalidationReason::Next();
544 542
545 new_cached_subsequences_.Swap(current_cached_subsequences_); 543 new_cached_subsequences_.Swap(current_cached_subsequences_);
546 new_cached_subsequences_.Clear(); 544 new_cached_subsequences_.Clear();
547 last_cached_subsequence_end_ = 0; 545 last_cached_subsequence_end_ = 0;
548 for (auto& item : current_cached_subsequences_) { 546 for (auto& item : current_cached_subsequences_) {
549 item.key->SetDisplayItemsCached(current_cache_generation_); 547 item.key->SetDisplayItemsCached(current_cache_generation_);
550 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 548 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
551 DisplayItemClient::EndShouldKeepAliveAllClients(item.key); 549 DisplayItemClient::EndShouldKeepAliveAllClients(item.key);
552 DCHECK(current_subsequence_clients_.IsEmpty()); 550 DCHECK(current_subsequence_clients_.IsEmpty());
553 #endif 551 #endif
554 } 552 }
555 553
556 Vector<const DisplayItemClient*> skipped_cache_clients; 554 Vector<const DisplayItemClient*> skipped_cache_clients;
557 for (const auto& item : new_display_item_list_) { 555 for (const auto& item : new_display_item_list_) {
558 // No reason to continue the analysis once we have a veto. 556 // No reason to continue the analysis once we have a veto.
559 if (num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto) 557 if (gpu_analyzer.suitableForGpuRasterization())
560 num_slow_paths += item.NumberOfSlowPaths(); 558 item.AnalyzeForGpuRasterization(gpu_analyzer);
561 559
562 // TODO(wkorman): Only compute and append visual rect for drawings. 560 // TODO(wkorman): Only compute and append visual rect for drawings.
563 new_display_item_list_.AppendVisualRect( 561 new_display_item_list_.AppendVisualRect(
564 VisualRectForDisplayItem(item, offset_from_layout_object)); 562 VisualRectForDisplayItem(item, offset_from_layout_object));
565 563
566 if (item.IsCacheable()) { 564 if (item.IsCacheable()) {
567 item.Client().SetDisplayItemsCached(current_cache_generation_); 565 item.Client().SetDisplayItemsCached(current_cache_generation_);
568 } else { 566 } else {
569 if (item.Client().IsJustCreated()) 567 if (item.Client().IsJustCreated())
570 item.Client().ClearIsJustCreated(); 568 item.Client().ClearIsJustCreated();
(...skipping 17 matching lines...) Expand all
588 } 586 }
589 } 587 }
590 588
591 for (auto* client : skipped_cache_clients) 589 for (auto* client : skipped_cache_clients)
592 client->SetDisplayItemsUncached(); 590 client->SetDisplayItemsUncached();
593 591
594 // The new list will not be appended to again so we can release unused memory. 592 // The new list will not be appended to again so we can release unused memory.
595 new_display_item_list_.ShrinkToFit(); 593 new_display_item_list_.ShrinkToFit();
596 current_paint_artifact_ = PaintArtifact( 594 current_paint_artifact_ = PaintArtifact(
597 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), 595 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(),
598 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); 596 gpu_analyzer.suitableForGpuRasterization());
599 ResetCurrentListIndices(); 597 ResetCurrentListIndices();
600 out_of_order_item_indices_.Clear(); 598 out_of_order_item_indices_.Clear();
601 out_of_order_chunk_indices_.Clear(); 599 out_of_order_chunk_indices_.Clear();
602 items_moved_into_new_list_.Clear(); 600 items_moved_into_new_list_.Clear();
603 601
604 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 602 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
605 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { 603 for (const auto& chunk : current_paint_artifact_.PaintChunks()) {
606 if (chunk.id && chunk.id->client.IsJustCreated()) 604 if (chunk.id && chunk.id->client.IsJustCreated())
607 chunk.id->client.ClearIsJustCreated(); 605 chunk.id->client.ClearIsJustCreated();
608 } 606 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 show_paint_records 932 show_paint_records
935 ? (DisplayItemList::JsonOptions::kShowPaintRecords | 933 ? (DisplayItemList::JsonOptions::kShowPaintRecords |
936 DisplayItemList::JsonOptions::kShowClientDebugName) 934 DisplayItemList::JsonOptions::kShowClientDebugName)
937 : DisplayItemList::JsonOptions::kShowClientDebugName) 935 : DisplayItemList::JsonOptions::kShowClientDebugName)
938 ->ToPrettyJSONString() 936 ->ToPrettyJSONString()
939 .Utf8() 937 .Utf8()
940 .Data()); 938 .Data());
941 } 939 }
942 940
943 } // namespace blink 941 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698