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; | 19 static constexpr int kMaxNumberOfSlowPathsBeforeVeto = 5; |
20 | 20 |
21 namespace blink { | 21 namespace blink { |
22 | 22 |
23 void PaintController::SetTracksRasterInvalidations(bool value) { | 23 void PaintController::SetTracksRasterInvalidations(bool value) { |
24 if (value) { | 24 if (value || |
| 25 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
25 paint_chunks_raster_invalidation_tracking_map_ = | 26 paint_chunks_raster_invalidation_tracking_map_ = |
26 WTF::WrapUnique(new RasterInvalidationTrackingMap<const PaintChunk>); | 27 WTF::WrapUnique(new RasterInvalidationTrackingMap<const PaintChunk>); |
27 } else { | 28 } else { |
28 paint_chunks_raster_invalidation_tracking_map_ = nullptr; | 29 paint_chunks_raster_invalidation_tracking_map_ = nullptr; |
29 } | 30 } |
30 } | 31 } |
31 | 32 |
32 const PaintArtifact& PaintController::GetPaintArtifact() const { | 33 const PaintArtifact& PaintController::GetPaintArtifact() const { |
33 DCHECK(new_display_item_list_.IsEmpty()); | 34 DCHECK(new_display_item_list_.IsEmpty()); |
34 DCHECK(new_paint_chunks_.IsInInitialState()); | 35 DCHECK(new_paint_chunks_.IsInInitialState()); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 break; | 591 break; |
591 } | 592 } |
592 } | 593 } |
593 } | 594 } |
594 | 595 |
595 for (auto* client : skipped_cache_clients) | 596 for (auto* client : skipped_cache_clients) |
596 client->SetDisplayItemsUncached(); | 597 client->SetDisplayItemsUncached(); |
597 | 598 |
598 // The new list will not be appended to again so we can release unused memory. | 599 // The new list will not be appended to again so we can release unused memory. |
599 new_display_item_list_.ShrinkToFit(); | 600 new_display_item_list_.ShrinkToFit(); |
| 601 |
| 602 if (paint_chunks_raster_invalidation_tracking_map_) { |
| 603 for (const auto& chunk : current_paint_artifact_.PaintChunks()) |
| 604 paint_chunks_raster_invalidation_tracking_map_->Remove(&chunk); |
| 605 } |
600 current_paint_artifact_ = PaintArtifact( | 606 current_paint_artifact_ = PaintArtifact( |
601 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), | 607 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), |
602 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); | 608 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); |
| 609 |
603 ResetCurrentListIndices(); | 610 ResetCurrentListIndices(); |
604 out_of_order_item_indices_.clear(); | 611 out_of_order_item_indices_.clear(); |
605 out_of_order_chunk_indices_.clear(); | 612 out_of_order_chunk_indices_.clear(); |
606 items_moved_into_new_list_.clear(); | 613 items_moved_into_new_list_.clear(); |
607 | 614 |
608 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 615 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
609 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { | 616 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { |
610 if (chunk.id && chunk.id->client.IsJustCreated()) | 617 if (chunk.id && chunk.id->client.IsJustCreated()) |
611 chunk.id->client.ClearIsJustCreated(); | 618 chunk.id->client.ClearIsJustCreated(); |
612 } | 619 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 show_paint_records | 945 show_paint_records |
939 ? (DisplayItemList::JsonOptions::kShowPaintRecords | | 946 ? (DisplayItemList::JsonOptions::kShowPaintRecords | |
940 DisplayItemList::JsonOptions::kShowClientDebugName) | 947 DisplayItemList::JsonOptions::kShowClientDebugName) |
941 : DisplayItemList::JsonOptions::kShowClientDebugName) | 948 : DisplayItemList::JsonOptions::kShowClientDebugName) |
942 ->ToPrettyJSONString() | 949 ->ToPrettyJSONString() |
943 .Utf8() | 950 .Utf8() |
944 .data()); | 951 .data()); |
945 } | 952 } |
946 | 953 |
947 } // namespace blink | 954 } // namespace blink |
OLD | NEW |