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

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

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

Powered by Google App Engine
This is Rietveld 408576698