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 "platform/geometry/IntRect.h" | 8 #include "platform/geometry/IntRect.h" |
| 8 #include "platform/graphics/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
| 10 #include "platform/graphics/compositing/PaintChunksToCcLayer.h" | |
| 9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 11 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 12 #include "platform/graphics/paint/GeometryMapper.h" | |
| 10 #include "platform/instrumentation/tracing/TraceEvent.h" | 13 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 11 #include "public/platform/WebDisplayItemList.h" | 14 #include "public/platform/WebDisplayItemList.h" |
| 12 #include "third_party/skia/include/core/SkRegion.h" | 15 #include "third_party/skia/include/core/SkRegion.h" |
| 13 | 16 |
| 14 namespace blink { | 17 namespace blink { |
| 15 | 18 |
| 16 namespace { | 19 namespace { |
| 17 | 20 |
| 18 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, | 21 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, |
| 19 Vector<PaintChunk>& paintChunks) { | 22 Vector<PaintChunk>& paintChunks) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 void PaintArtifact::reset() { | 77 void PaintArtifact::reset() { |
| 75 m_displayItemList.clear(); | 78 m_displayItemList.clear(); |
| 76 m_paintChunks.clear(); | 79 m_paintChunks.clear(); |
| 77 } | 80 } |
| 78 | 81 |
| 79 size_t PaintArtifact::approximateUnsharedMemoryUsage() const { | 82 size_t PaintArtifact::approximateUnsharedMemoryUsage() const { |
| 80 return sizeof(*this) + m_displayItemList.memoryUsageInBytes() + | 83 return sizeof(*this) + m_displayItemList.memoryUsageInBytes() + |
| 81 m_paintChunks.capacity() * sizeof(m_paintChunks[0]); | 84 m_paintChunks.capacity() * sizeof(m_paintChunks[0]); |
| 82 } | 85 } |
| 83 | 86 |
| 84 void PaintArtifact::replay(GraphicsContext& graphicsContext) const { | 87 void PaintArtifact::replay(const FloatRect& bounds, |
| 88 GraphicsContext& graphicsContext, | |
| 89 const PropertyTreeState& propertyTreeState) const { | |
| 85 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); | 90 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); |
| 86 for (const DisplayItem& displayItem : m_displayItemList) | 91 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 87 displayItem.replay(graphicsContext); | 92 for (const DisplayItem& displayItem : m_displayItemList) |
| 93 displayItem.replay(graphicsContext); | |
| 94 } else { | |
| 95 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | |
| 96 Vector<const PaintChunk*> pointerPaintChunks; | |
|
pdr.
2017/03/28 21:01:30
To prevent growing and copying this vector, please
chrishtr
2017/03/28 21:43:23
Done.
| |
| 97 for (const auto& chunk : paintChunks()) | |
| 98 pointerPaintChunks.push_back(&chunk); | |
| 99 | |
| 100 scoped_refptr<cc::DisplayItemList> displayItemList = | |
| 101 PaintChunksToCcLayer::convert(pointerPaintChunks, propertyTreeState, | |
| 102 gfx::Vector2dF(), getDisplayItemList(), | |
| 103 *geometryMapper); | |
| 104 graphicsContext.canvas()->drawDisplayItemList(displayItemList); | |
| 105 } | |
| 88 } | 106 } |
| 89 | 107 |
| 90 DISABLE_CFI_PERF | 108 DISABLE_CFI_PERF |
| 91 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { | 109 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { |
| 92 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); | 110 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); |
| 93 size_t visualRectIndex = 0; | 111 size_t visualRectIndex = 0; |
| 94 for (const DisplayItem& displayItem : m_displayItemList) { | 112 for (const DisplayItem& displayItem : m_displayItemList) { |
| 95 displayItem.appendToWebDisplayItemList( | 113 displayItem.appendToWebDisplayItemList( |
| 96 m_displayItemList.visualRect(visualRectIndex), list); | 114 m_displayItemList.visualRect(visualRectIndex), list); |
| 97 visualRectIndex++; | 115 visualRectIndex++; |
| 98 } | 116 } |
| 99 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); | 117 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); |
| 100 } | 118 } |
| 101 | 119 |
| 102 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |