| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/PaintArtifact.h" | 5 #include "platform/graphics/paint/PaintArtifact.h" |
| 6 | 6 |
| 7 #include "cc/paint/display_item_list.h" | 7 #include "cc/paint/display_item_list.h" |
| 8 #include "platform/geometry/IntRect.h" | 8 #include "platform/geometry/IntRect.h" |
| 9 #include "platform/graphics/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
| 10 #include "platform/graphics/compositing/PaintChunksToCcLayer.h" | 10 #include "platform/graphics/compositing/PaintChunksToCcLayer.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 m_displayItemList.clear(); | 78 m_displayItemList.clear(); |
| 79 m_paintChunks.clear(); | 79 m_paintChunks.clear(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 size_t PaintArtifact::approximateUnsharedMemoryUsage() const { | 82 size_t PaintArtifact::approximateUnsharedMemoryUsage() const { |
| 83 return sizeof(*this) + m_displayItemList.memoryUsageInBytes() + | 83 return sizeof(*this) + m_displayItemList.memoryUsageInBytes() + |
| 84 m_paintChunks.capacity() * sizeof(m_paintChunks[0]); | 84 m_paintChunks.capacity() * sizeof(m_paintChunks[0]); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void PaintArtifact::replay(const FloatRect& bounds, | 87 void PaintArtifact::replay(const FloatRect& bounds, |
| 88 GraphicsContext& graphicsContext, | 88 GraphicsContext& graphicsContext) const { |
| 89 const PropertyTreeState& replayState) const { | |
| 90 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); | 89 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); |
| 91 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 90 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 92 for (const DisplayItem& displayItem : m_displayItemList) | 91 for (const DisplayItem& displayItem : m_displayItemList) |
| 93 displayItem.replay(graphicsContext); | 92 displayItem.replay(graphicsContext); |
| 94 } else { | 93 } else { |
| 95 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | 94 replay(bounds, *graphicsContext.canvas()); |
| 96 Vector<const PaintChunk*> pointerPaintChunks; | 95 } |
| 97 pointerPaintChunks.reserveInitialCapacity(paintChunks().size()); | 96 } |
| 98 | 97 |
| 99 // TODO(chrishtr): it's sad to have to copy this vector just to turn | 98 void PaintArtifact::replay(const FloatRect& bounds, |
| 100 // references into pointers. | 99 PaintCanvas& canvas, |
| 101 for (const auto& chunk : paintChunks()) | 100 const PropertyTreeState& replayState) const { |
| 102 pointerPaintChunks.push_back(&chunk); | 101 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); |
| 103 scoped_refptr<cc::DisplayItemList> displayItemList = | 102 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 104 PaintChunksToCcLayer::convert(pointerPaintChunks, replayState, | 103 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); |
| 105 gfx::Vector2dF(), getDisplayItemList(), | 104 Vector<const PaintChunk*> pointerPaintChunks; |
| 106 *geometryMapper); | 105 pointerPaintChunks.reserveInitialCapacity(paintChunks().size()); |
| 107 graphicsContext.canvas()->drawDisplayItemList(displayItemList); | 106 |
| 108 } | 107 // TODO(chrishtr): it's sad to have to copy this vector just to turn |
| 108 // references into pointers. |
| 109 for (const auto& chunk : paintChunks()) |
| 110 pointerPaintChunks.push_back(&chunk); |
| 111 scoped_refptr<cc::DisplayItemList> displayItemList = |
| 112 PaintChunksToCcLayer::convert(pointerPaintChunks, replayState, |
| 113 gfx::Vector2dF(), getDisplayItemList(), |
| 114 *geometryMapper); |
| 115 canvas.drawDisplayItemList(displayItemList); |
| 109 } | 116 } |
| 110 | 117 |
| 111 DISABLE_CFI_PERF | 118 DISABLE_CFI_PERF |
| 112 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { | 119 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { |
| 113 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); | 120 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); |
| 114 size_t visualRectIndex = 0; | 121 size_t visualRectIndex = 0; |
| 115 for (const DisplayItem& displayItem : m_displayItemList) { | 122 for (const DisplayItem& displayItem : m_displayItemList) { |
| 116 displayItem.appendToWebDisplayItemList( | 123 displayItem.appendToWebDisplayItemList( |
| 117 m_displayItemList.visualRect(visualRectIndex), list); | 124 m_displayItemList.visualRect(visualRectIndex), list); |
| 118 visualRectIndex++; | 125 visualRectIndex++; |
| 119 } | 126 } |
| 120 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); | 127 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); |
| 121 } | 128 } |
| 122 | 129 |
| 123 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |