| 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 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 for (auto& item : current_cached_subsequences_) { | 582 for (auto& item : current_cached_subsequences_) { |
| 585 item.key->SetDisplayItemsCached(current_cache_generation_); | 583 item.key->SetDisplayItemsCached(current_cache_generation_); |
| 586 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 584 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 587 DisplayItemClient::EndShouldKeepAliveAllClients(item.key); | 585 DisplayItemClient::EndShouldKeepAliveAllClients(item.key); |
| 588 DCHECK(current_subsequence_clients_.IsEmpty()); | 586 DCHECK(current_subsequence_clients_.IsEmpty()); |
| 589 #endif | 587 #endif |
| 590 } | 588 } |
| 591 | 589 |
| 592 Vector<const DisplayItemClient*> skipped_cache_clients; | 590 Vector<const DisplayItemClient*> skipped_cache_clients; |
| 593 for (const auto& item : new_display_item_list_) { | 591 for (const auto& item : new_display_item_list_) { |
| 594 // No reason to continue the analysis once we have a veto. | 592 num_slow_paths += item.NumberOfSlowPaths(); |
| 595 if (num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto) | |
| 596 num_slow_paths += item.NumberOfSlowPaths(); | |
| 597 | 593 |
| 598 if (item.IsCacheable()) { | 594 if (item.IsCacheable()) { |
| 599 item.Client().SetDisplayItemsCached(current_cache_generation_); | 595 item.Client().SetDisplayItemsCached(current_cache_generation_); |
| 600 } else { | 596 } else { |
| 601 if (item.Client().IsJustCreated()) | 597 if (item.Client().IsJustCreated()) |
| 602 item.Client().ClearIsJustCreated(); | 598 item.Client().ClearIsJustCreated(); |
| 603 if (item.SkippedCache()) | 599 if (item.SkippedCache()) |
| 604 skipped_cache_clients.push_back(&item.Client()); | 600 skipped_cache_clients.push_back(&item.Client()); |
| 605 } | 601 } |
| 606 } | 602 } |
| 607 | 603 |
| 608 for (auto* client : skipped_cache_clients) | 604 for (auto* client : skipped_cache_clients) |
| 609 client->SetDisplayItemsUncached(); | 605 client->SetDisplayItemsUncached(); |
| 610 | 606 |
| 611 // The new list will not be appended to again so we can release unused memory. | 607 // The new list will not be appended to again so we can release unused memory. |
| 612 new_display_item_list_.ShrinkToFit(); | 608 new_display_item_list_.ShrinkToFit(); |
| 613 | 609 |
| 614 if (raster_invalidation_tracking_info_) { | 610 if (raster_invalidation_tracking_info_) { |
| 615 for (const auto& chunk : current_paint_artifact_.PaintChunks()) | 611 for (const auto& chunk : current_paint_artifact_.PaintChunks()) |
| 616 raster_invalidation_tracking_info_->map.Remove(&chunk); | 612 raster_invalidation_tracking_info_->map.Remove(&chunk); |
| 617 } | 613 } |
| 618 current_paint_artifact_ = PaintArtifact( | 614 current_paint_artifact_ = |
| 619 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), | 615 PaintArtifact(std::move(new_display_item_list_), |
| 620 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); | 616 new_paint_chunks_.ReleasePaintChunks(), num_slow_paths); |
| 621 | 617 |
| 622 ResetCurrentListIndices(); | 618 ResetCurrentListIndices(); |
| 623 out_of_order_item_indices_.clear(); | 619 out_of_order_item_indices_.clear(); |
| 624 out_of_order_chunk_indices_.clear(); | 620 out_of_order_chunk_indices_.clear(); |
| 625 items_moved_into_new_list_.clear(); | 621 items_moved_into_new_list_.clear(); |
| 626 | 622 |
| 627 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 623 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 628 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { | 624 for (const auto& chunk : current_paint_artifact_.PaintChunks()) { |
| 629 if (chunk.id && chunk.id->client.IsJustCreated()) | 625 if (chunk.id && chunk.id->client.IsJustCreated()) |
| 630 chunk.id->client.ClearIsJustCreated(); | 626 chunk.id->client.ClearIsJustCreated(); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 } | 998 } |
| 1003 | 999 |
| 1004 FrameFirstPaint PaintController::EndFrame(const void* frame) { | 1000 FrameFirstPaint PaintController::EndFrame(const void* frame) { |
| 1005 FrameFirstPaint result = frame_first_paints_.back(); | 1001 FrameFirstPaint result = frame_first_paints_.back(); |
| 1006 DCHECK(result.frame == frame); | 1002 DCHECK(result.frame == frame); |
| 1007 frame_first_paints_.pop_back(); | 1003 frame_first_paints_.pop_back(); |
| 1008 return result; | 1004 return result; |
| 1009 } | 1005 } |
| 1010 | 1006 |
| 1011 } // namespace blink | 1007 } // namespace blink |
| OLD | NEW |