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