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) const { | 88 GraphicsContext& graphicsContext, |
| 89 const PropertyTreeState& replayState) const { |
89 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); | 90 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); |
90 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 91 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
91 for (const DisplayItem& displayItem : m_displayItemList) | 92 for (const DisplayItem& displayItem : m_displayItemList) |
92 displayItem.replay(graphicsContext); | 93 displayItem.replay(graphicsContext); |
93 } else { | 94 } else { |
94 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | 95 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); |
95 Vector<const PaintChunk*> pointerPaintChunks; | 96 Vector<const PaintChunk*> pointerPaintChunks; |
96 pointerPaintChunks.reserveInitialCapacity(paintChunks().size()); | 97 pointerPaintChunks.reserveInitialCapacity(paintChunks().size()); |
97 | 98 |
98 // TODO(chrishtr): it's sad to have to copy this vector just to turn | 99 // TODO(chrishtr): it's sad to have to copy this vector just to turn |
99 // references into pointers. | 100 // references into pointers. |
100 for (const auto& chunk : paintChunks()) | 101 for (const auto& chunk : paintChunks()) |
101 pointerPaintChunks.push_back(&chunk); | 102 pointerPaintChunks.push_back(&chunk); |
102 scoped_refptr<cc::DisplayItemList> displayItemList = | 103 scoped_refptr<cc::DisplayItemList> displayItemList = |
103 PaintChunksToCcLayer::convert( | 104 PaintChunksToCcLayer::convert(pointerPaintChunks, replayState, |
104 pointerPaintChunks, PropertyTreeState::root(), gfx::Vector2dF(), | 105 gfx::Vector2dF(), getDisplayItemList(), |
105 getDisplayItemList(), *geometryMapper); | 106 *geometryMapper); |
106 graphicsContext.canvas()->drawDisplayItemList(displayItemList); | 107 graphicsContext.canvas()->drawDisplayItemList(displayItemList); |
107 } | 108 } |
108 } | 109 } |
109 | 110 |
110 DISABLE_CFI_PERF | 111 DISABLE_CFI_PERF |
111 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { | 112 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { |
112 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); | 113 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); |
113 size_t visualRectIndex = 0; | 114 size_t visualRectIndex = 0; |
114 for (const DisplayItem& displayItem : m_displayItemList) { | 115 for (const DisplayItem& displayItem : m_displayItemList) { |
115 displayItem.appendToWebDisplayItemList( | 116 displayItem.appendToWebDisplayItemList( |
116 m_displayItemList.visualRect(visualRectIndex), list); | 117 m_displayItemList.visualRect(visualRectIndex), list); |
117 visualRectIndex++; | 118 visualRectIndex++; |
118 } | 119 } |
119 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); | 120 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); |
120 } | 121 } |
121 | 122 |
122 } // namespace blink | 123 } // namespace blink |
OLD | NEW |