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/TraceEvent.h" | 7 #include "platform/TraceEvent.h" |
8 #include "platform/graphics/GraphicsLayer.h" | 8 #include "platform/graphics/GraphicsLayer.h" |
9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 9 #include "platform/graphics/paint/DrawingDisplayItem.h" |
10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" | 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 if (!indices.isEmpty() && indices.last() == (m_newDisplayItemList.size() - 1)) | 146 if (!indices.isEmpty() && indices.last() == (m_newDisplayItemList.size() - 1)) |
147 indices.removeLast(); | 147 indices.removeLast(); |
148 } | 148 } |
149 #endif | 149 #endif |
150 m_newDisplayItemList.removeLast(); | 150 m_newDisplayItemList.removeLast(); |
151 | 151 |
152 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 152 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
153 m_newPaintChunks.decrementDisplayItemIndex(); | 153 m_newPaintChunks.decrementDisplayItemIndex(); |
154 } | 154 } |
155 | 155 |
156 const DisplayItem* PaintController::lastDisplayItem(unsigned offset) | |
157 { | |
158 if (offset < m_newDisplayItemList.size()) | |
159 return &m_newDisplayItemList[m_newDisplayItemList.size() - offset - 1]; | |
160 return nullptr; | |
161 } | |
162 | |
156 void PaintController::processNewItem(DisplayItem& displayItem) | 163 void PaintController::processNewItem(DisplayItem& displayItem) |
157 { | 164 { |
158 DCHECK(!m_constructionDisabled); | 165 DCHECK(!m_constructionDisabled); |
159 | 166 |
160 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 167 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
161 if (!isSkippingCache()) { | 168 if (!isSkippingCache()) { |
162 if (displayItem.isCacheable()) { | 169 if (displayItem.isCacheable()) { |
163 // Mark the client shouldKeepAlive under this PaintController. | 170 // Mark the client shouldKeepAlive under this PaintController. |
164 // The status will end after the new display items are committed. | 171 // The status will end after the new display items are committed. |
165 displayItem.client().beginShouldKeepAlive(this); | 172 displayItem.client().beginShouldKeepAlive(this); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 m_currentCacheGeneration = DisplayItemClient::CacheGenerationOrInvalidationR eason::next(); | 422 m_currentCacheGeneration = DisplayItemClient::CacheGenerationOrInvalidationR eason::next(); |
416 for (const auto& item : m_newDisplayItemList) { | 423 for (const auto& item : m_newDisplayItemList) { |
417 // No reason to continue the analysis once we have a veto. | 424 // No reason to continue the analysis once we have a veto. |
418 if (gpuAnalyzer.suitableForGpuRasterization()) | 425 if (gpuAnalyzer.suitableForGpuRasterization()) |
419 item.analyzeForGpuRasterization(gpuAnalyzer); | 426 item.analyzeForGpuRasterization(gpuAnalyzer); |
420 | 427 |
421 m_newDisplayItemList.appendVisualRect(visualRectForDisplayItem(item, off setFromLayoutObject)); | 428 m_newDisplayItemList.appendVisualRect(visualRectForDisplayItem(item, off setFromLayoutObject)); |
422 | 429 |
423 if (item.isCacheable()) | 430 if (item.isCacheable()) |
424 item.client().setDisplayItemsCached(m_currentCacheGeneration); | 431 item.client().setDisplayItemsCached(m_currentCacheGeneration); |
432 else | |
433 item.client().setDisplayItemsUncached(); | |
chrishtr
2016/07/27 17:47:48
@xianzhu: added this. WDYT?
Xianzhu
2016/07/27 18:00:19
This has a problem that if any cacheable display i
| |
425 } | 434 } |
426 | 435 |
427 // The new list will not be appended to again so we can release unused memor y. | 436 // The new list will not be appended to again so we can release unused memor y. |
428 m_newDisplayItemList.shrinkToFit(); | 437 m_newDisplayItemList.shrinkToFit(); |
429 m_currentPaintArtifact = PaintArtifact(std::move(m_newDisplayItemList), m_ne wPaintChunks.releasePaintChunks(), gpuAnalyzer.suitableForGpuRasterization()); | 438 m_currentPaintArtifact = PaintArtifact(std::move(m_newDisplayItemList), m_ne wPaintChunks.releasePaintChunks(), gpuAnalyzer.suitableForGpuRasterization()); |
430 resetCurrentListIndices(); | 439 resetCurrentListIndices(); |
431 m_outOfOrderItemIndices.clear(); | 440 m_outOfOrderItemIndices.clear(); |
432 | 441 |
433 // We'll allocate the initial buffer when we start the next paint. | 442 // We'll allocate the initial buffer when we start the next paint. |
434 m_newDisplayItemList = DisplayItemList(0); | 443 m_newDisplayItemList = DisplayItemList(0); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 | 561 |
553 void PaintController::showDebugData() const | 562 void PaintController::showDebugData() const |
554 { | 563 { |
555 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); | 564 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); |
556 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); | 565 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); |
557 } | 566 } |
558 | 567 |
559 #endif // ifndef NDEBUG | 568 #endif // ifndef NDEBUG |
560 | 569 |
561 } // namespace blink | 570 } // namespace blink |
OLD | NEW |