Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp

Issue 2751433002: [SPv2] Flatten property trees in PaintRecordBuilder into a single display list. (Closed)
Patch Set: none Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) const {
85 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay"); 89 TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay");
86 for (const DisplayItem& displayItem : m_displayItemList) 90 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
87 displayItem.replay(graphicsContext); 91 for (const DisplayItem& displayItem : m_displayItemList)
92 displayItem.replay(graphicsContext);
93 } else {
94 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
95 Vector<const PaintChunk*> pointerPaintChunks;
96 pointerPaintChunks.reserveInitialCapacity(paintChunks().size());
97
98 // TODO(chrishtr): it's sad to have to copy this vector just to turn
99 // references into pointers.
100 for (const auto& chunk : paintChunks())
101 pointerPaintChunks.push_back(&chunk);
102 scoped_refptr<cc::DisplayItemList> displayItemList =
103 PaintChunksToCcLayer::convert(
104 pointerPaintChunks, PropertyTreeState::root(), gfx::Vector2dF(),
105 getDisplayItemList(), *geometryMapper);
106 graphicsContext.canvas()->drawDisplayItemList(displayItemList);
107 }
88 } 108 }
89 109
90 DISABLE_CFI_PERF 110 DISABLE_CFI_PERF
91 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { 111 void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const {
92 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); 112 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList");
93 size_t visualRectIndex = 0; 113 size_t visualRectIndex = 0;
94 for (const DisplayItem& displayItem : m_displayItemList) { 114 for (const DisplayItem& displayItem : m_displayItemList) {
95 displayItem.appendToWebDisplayItemList( 115 displayItem.appendToWebDisplayItemList(
96 m_displayItemList.visualRect(visualRectIndex), list); 116 m_displayItemList.visualRect(visualRectIndex), list);
97 visualRectIndex++; 117 visualRectIndex++;
98 } 118 }
99 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); 119 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization());
100 } 120 }
101 121
102 } // namespace blink 122 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698