| 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 "third_party/skia/include/core/SkPictureAnalyzer.h" | 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
| 11 #include "wtf/AutoReset.h" | 11 #include "wtf/AutoReset.h" |
| 12 #include "wtf/text/StringBuilder.h" | 12 #include "wtf/text/StringBuilder.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 maxNumberOfSlowPathsBeforeVeto = 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 m_paintChunksRasterInvalidationTrackingMap = | 25 m_paintChunksRasterInvalidationTrackingMap = |
| 24 WTF::wrapUnique(new RasterInvalidationTrackingMap<const PaintChunk>); | 26 WTF::wrapUnique(new RasterInvalidationTrackingMap<const PaintChunk>); |
| 25 } else { | 27 } else { |
| 26 m_paintChunksRasterInvalidationTrackingMap = nullptr; | 28 m_paintChunksRasterInvalidationTrackingMap = nullptr; |
| 27 } | 29 } |
| 28 } | 30 } |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // These data structures are used during painting only. | 498 // These data structures are used during painting only. |
| 497 DCHECK(!isSkippingCache()); | 499 DCHECK(!isSkippingCache()); |
| 498 #if DCHECK_IS_ON() | 500 #if DCHECK_IS_ON() |
| 499 m_newDisplayItemIndicesByClient.clear(); | 501 m_newDisplayItemIndicesByClient.clear(); |
| 500 #endif | 502 #endif |
| 501 | 503 |
| 502 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 504 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 503 !m_newDisplayItemList.isEmpty()) | 505 !m_newDisplayItemList.isEmpty()) |
| 504 generateChunkRasterInvalidationRects(m_newPaintChunks.lastChunk()); | 506 generateChunkRasterInvalidationRects(m_newPaintChunks.lastChunk()); |
| 505 | 507 |
| 506 SkPictureGpuAnalyzer gpuAnalyzer; | 508 int numSlowPaths = 0; |
| 507 | 509 |
| 508 m_currentCacheGeneration = | 510 m_currentCacheGeneration = |
| 509 DisplayItemClient::CacheGenerationOrInvalidationReason::next(); | 511 DisplayItemClient::CacheGenerationOrInvalidationReason::next(); |
| 510 Vector<const DisplayItemClient*> skippedCacheClients; | 512 Vector<const DisplayItemClient*> skippedCacheClients; |
| 511 for (const auto& item : m_newDisplayItemList) { | 513 for (const auto& item : m_newDisplayItemList) { |
| 512 // No reason to continue the analysis once we have a veto. | 514 // No reason to continue the analysis once we have a veto. |
| 513 if (gpuAnalyzer.suitableForGpuRasterization()) | 515 if (numSlowPaths <= maxNumberOfSlowPathsBeforeVeto) |
| 514 item.analyzeForGpuRasterization(gpuAnalyzer); | 516 numSlowPaths += item.numberOfSlowPaths(); |
| 515 | 517 |
| 516 // TODO(wkorman): Only compute and append visual rect for drawings. | 518 // TODO(wkorman): Only compute and append visual rect for drawings. |
| 517 m_newDisplayItemList.appendVisualRect( | 519 m_newDisplayItemList.appendVisualRect( |
| 518 visualRectForDisplayItem(item, offsetFromLayoutObject)); | 520 visualRectForDisplayItem(item, offsetFromLayoutObject)); |
| 519 | 521 |
| 520 if (item.isCacheable()) { | 522 if (item.isCacheable()) { |
| 521 item.client().setDisplayItemsCached(m_currentCacheGeneration); | 523 item.client().setDisplayItemsCached(m_currentCacheGeneration); |
| 522 } else { | 524 } else { |
| 523 if (item.client().isJustCreated()) | 525 if (item.client().isJustCreated()) |
| 524 item.client().clearIsJustCreated(); | 526 item.client().clearIsJustCreated(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 542 } | 544 } |
| 543 } | 545 } |
| 544 | 546 |
| 545 for (auto* client : skippedCacheClients) | 547 for (auto* client : skippedCacheClients) |
| 546 client->setDisplayItemsUncached(); | 548 client->setDisplayItemsUncached(); |
| 547 | 549 |
| 548 // The new list will not be appended to again so we can release unused memory. | 550 // The new list will not be appended to again so we can release unused memory. |
| 549 m_newDisplayItemList.shrinkToFit(); | 551 m_newDisplayItemList.shrinkToFit(); |
| 550 m_currentPaintArtifact = PaintArtifact( | 552 m_currentPaintArtifact = PaintArtifact( |
| 551 std::move(m_newDisplayItemList), m_newPaintChunks.releasePaintChunks(), | 553 std::move(m_newDisplayItemList), m_newPaintChunks.releasePaintChunks(), |
| 552 gpuAnalyzer.suitableForGpuRasterization()); | 554 numSlowPaths <= maxNumberOfSlowPathsBeforeVeto); |
| 553 resetCurrentListIndices(); | 555 resetCurrentListIndices(); |
| 554 m_outOfOrderItemIndices.clear(); | 556 m_outOfOrderItemIndices.clear(); |
| 555 m_outOfOrderChunkIndices.clear(); | 557 m_outOfOrderChunkIndices.clear(); |
| 556 m_itemsMovedIntoNewList.clear(); | 558 m_itemsMovedIntoNewList.clear(); |
| 557 | 559 |
| 558 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 560 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 559 for (const auto& chunk : m_currentPaintArtifact.paintChunks()) { | 561 for (const auto& chunk : m_currentPaintArtifact.paintChunks()) { |
| 560 if (chunk.id && chunk.id->client.isJustCreated()) | 562 if (chunk.id && chunk.id->client.isJustCreated()) |
| 561 chunk.id->client.clearIsJustCreated(); | 563 chunk.id->client.clearIsJustCreated(); |
| 562 } | 564 } |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 showPaintRecords | 865 showPaintRecords |
| 864 ? (DisplayItemList::JsonOptions::ShowPaintRecords | | 866 ? (DisplayItemList::JsonOptions::ShowPaintRecords | |
| 865 DisplayItemList::JsonOptions::ShowClientDebugName) | 867 DisplayItemList::JsonOptions::ShowClientDebugName) |
| 866 : DisplayItemList::JsonOptions::ShowClientDebugName) | 868 : DisplayItemList::JsonOptions::ShowClientDebugName) |
| 867 ->toPrettyJSONString() | 869 ->toPrettyJSONString() |
| 868 .utf8() | 870 .utf8() |
| 869 .data()); | 871 .data()); |
| 870 } | 872 } |
| 871 | 873 |
| 872 } // namespace blink | 874 } // namespace blink |
| OLD | NEW |