Chromium Code Reviews| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) const { |
| 89 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); | 89 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); |
| 90 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 90 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 91 for (const DisplayItem& displayItem : m_displayItemList) | 91 for (const DisplayItem& displayItem : m_displayItemList) |
| 92 displayItem.replay(graphicsContext); | 92 displayItem.replay(graphicsContext); |
| 93 } else { | 93 } else { |
| 94 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | 94 replay(bounds, *graphicsContext.canvas()); |
| 95 Vector<const PaintChunk*> pointerPaintChunks; | 95 } |
| 96 pointerPaintChunks.reserveInitialCapacity(paintChunks().size()); | 96 } |
| 97 | 97 |
| 98 // TODO(chrishtr): it's sad to have to copy this vector just to turn | 98 void PaintArtifact::replay(const FloatRect& bounds, PaintCanvas& canvas) const { |
| 99 // references into pointers. | 99 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); |
| 100 for (const auto& chunk : paintChunks()) | 100 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 101 pointerPaintChunks.push_back(&chunk); | 101 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); |
|
wkorman
2017/04/01 00:32:40
Separate from this change but commenting while rea
chrishtr
2017/04/01 04:05:25
A good question. I don't think there is a good rea
| |
| 102 scoped_refptr<cc::DisplayItemList> displayItemList = | 102 Vector<const PaintChunk*> pointerPaintChunks; |
| 103 PaintChunksToCcLayer::convert( | 103 pointerPaintChunks.reserveInitialCapacity(paintChunks().size()); |
| 104 pointerPaintChunks, PropertyTreeState::root(), gfx::Vector2dF(), | 104 |
| 105 getDisplayItemList(), *geometryMapper); | 105 // TODO(chrishtr): it's sad to have to copy this vector just to turn |
| 106 graphicsContext.canvas()->drawDisplayItemList(displayItemList); | 106 // references into pointers. |
| 107 } | 107 for (const auto& chunk : paintChunks()) |
| 108 pointerPaintChunks.push_back(&chunk); | |
| 109 scoped_refptr<cc::DisplayItemList> displayItemList = | |
| 110 PaintChunksToCcLayer::convert(pointerPaintChunks, | |
| 111 PropertyTreeState::root(), gfx::Vector2dF(), | |
| 112 getDisplayItemList(), *geometryMapper); | |
| 113 canvas.drawDisplayItemList(displayItemList); | |
| 108 } | 114 } |
| 109 | 115 |
| 110 DISABLE_CFI_PERF | 116 DISABLE_CFI_PERF |
| 111 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { | 117 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { |
| 112 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); | 118 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); |
| 113 size_t visualRectIndex = 0; | 119 size_t visualRectIndex = 0; |
| 114 for (const DisplayItem& displayItem : m_displayItemList) { | 120 for (const DisplayItem& displayItem : m_displayItemList) { |
| 115 displayItem.appendToWebDisplayItemList( | 121 displayItem.appendToWebDisplayItemList( |
| 116 m_displayItemList.visualRect(visualRectIndex), list); | 122 m_displayItemList.visualRect(visualRectIndex), list); |
| 117 visualRectIndex++; | 123 visualRectIndex++; |
| 118 } | 124 } |
| 119 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); | 125 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); |
| 120 } | 126 } |
| 121 | 127 |
| 122 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |