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/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
6 | 6 |
7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/picture_layer.h" | 9 #include "cc/layers/picture_layer.h" |
10 #include "cc/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
11 #include "cc/playback/display_item_list_settings.h" | 11 #include "cc/playback/display_item_list_settings.h" |
12 #include "cc/playback/drawing_display_item.h" | 12 #include "cc/playback/drawing_display_item.h" |
13 #include "cc/playback/transform_display_item.h" | 13 #include "cc/playback/transform_display_item.h" |
14 #include "cc/trees/clip_node.h" | 14 #include "cc/trees/clip_node.h" |
15 #include "cc/trees/effect_node.h" | 15 #include "cc/trees/effect_node.h" |
16 #include "cc/trees/layer_tree_host.h" | 16 #include "cc/trees/layer_tree_host.h" |
17 #include "cc/trees/property_tree.h" | 17 #include "cc/trees/property_tree.h" |
18 #include "cc/trees/scroll_node.h" | 18 #include "cc/trees/scroll_node.h" |
19 #include "cc/trees/transform_node.h" | 19 #include "cc/trees/transform_node.h" |
20 #include "platform/RuntimeEnabledFeatures.h" | 20 #include "platform/RuntimeEnabledFeatures.h" |
21 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 21 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
22 #include "platform/graphics/paint/DisplayItem.h" | 22 #include "platform/graphics/paint/DisplayItem.h" |
23 #include "platform/graphics/paint/DrawingDisplayItem.h" | 23 #include "platform/graphics/paint/DrawingDisplayItem.h" |
24 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 24 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
25 #include "platform/graphics/paint/GeometryPropertyTreeState.h" | 25 #include "platform/graphics/paint/GeometryPropertyTreeState.h" |
26 #include "platform/graphics/paint/PaintArtifact.h" | 26 #include "platform/graphics/paint/PaintArtifact.h" |
| 27 #include "platform/graphics/paint/RasterInvalidationTracking.h" |
27 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 28 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
28 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 29 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
29 #include "public/platform/Platform.h" | 30 #include "public/platform/Platform.h" |
30 #include "public/platform/WebCompositorSupport.h" | 31 #include "public/platform/WebCompositorSupport.h" |
31 #include "public/platform/WebLayer.h" | 32 #include "public/platform/WebLayer.h" |
32 #include "ui/gfx/geometry/point.h" | 33 #include "ui/gfx/geometry/point.h" |
33 #include "ui/gfx/geometry/point_f.h" | 34 #include "ui/gfx/geometry/point_f.h" |
34 #include "ui/gfx/geometry/rect.h" | 35 #include "ui/gfx/geometry/rect.h" |
35 #include "ui/gfx/geometry/rect_f.h" | 36 #include "ui/gfx/geometry/rect_f.h" |
36 #include "ui/gfx/geometry/size.h" | 37 #include "ui/gfx/geometry/size.h" |
37 #include "ui/gfx/geometry/size_conversions.h" | 38 #include "ui/gfx/geometry/size_conversions.h" |
38 #include "ui/gfx/geometry/size_f.h" | 39 #include "ui/gfx/geometry/size_f.h" |
39 #include "ui/gfx/skia_util.h" | 40 #include "ui/gfx/skia_util.h" |
40 #include "wtf/Allocator.h" | 41 #include "wtf/Allocator.h" |
41 #include "wtf/Noncopyable.h" | 42 #include "wtf/Noncopyable.h" |
42 #include "wtf/PtrUtil.h" | 43 #include "wtf/PtrUtil.h" |
43 #include <algorithm> | 44 #include <algorithm> |
44 #include <memory> | 45 #include <memory> |
45 #include <utility> | 46 #include <utility> |
46 | 47 |
47 namespace blink { | 48 namespace blink { |
48 | 49 |
| 50 template class RasterInvalidationTrackingMap<const cc::Layer>; |
| 51 static RasterInvalidationTrackingMap<const cc::Layer>& |
| 52 ccLayersRasterInvalidationTrackingMap() { |
| 53 DEFINE_STATIC_LOCAL(RasterInvalidationTrackingMap<const cc::Layer>, map, ()); |
| 54 return map; |
| 55 } |
| 56 |
| 57 template <typename T> |
| 58 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) { |
| 59 std::unique_ptr<JSONArray> array = JSONArray::create(); |
| 60 array->pushDouble(size.width()); |
| 61 array->pushDouble(size.height()); |
| 62 return array; |
| 63 } |
| 64 |
49 class PaintArtifactCompositor::ContentLayerClientImpl | 65 class PaintArtifactCompositor::ContentLayerClientImpl |
50 : public cc::ContentLayerClient { | 66 : public cc::ContentLayerClient { |
51 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); | 67 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); |
52 USING_FAST_MALLOC(ContentLayerClientImpl); | 68 USING_FAST_MALLOC(ContentLayerClientImpl); |
53 | 69 |
54 public: | 70 public: |
55 ContentLayerClientImpl(Optional<DisplayItem::Id> paintChunkId) | 71 ContentLayerClientImpl(DisplayItem::Id paintChunkId) |
56 : m_id(paintChunkId), m_ccPictureLayer(cc::PictureLayer::Create(this)) {} | 72 : m_id(paintChunkId), |
| 73 m_debugName(paintChunkId.client.debugName()), |
| 74 m_ccPictureLayer(cc::PictureLayer::Create(this)) {} |
57 | 75 |
58 void SetDisplayList(scoped_refptr<cc::DisplayItemList> ccDisplayItemList) { | 76 void SetDisplayList(scoped_refptr<cc::DisplayItemList> ccDisplayItemList) { |
59 m_ccDisplayItemList = std::move(ccDisplayItemList); | 77 m_ccDisplayItemList = std::move(ccDisplayItemList); |
60 } | 78 } |
61 void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } | 79 void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } |
62 | 80 |
63 // cc::ContentLayerClient | 81 // cc::ContentLayerClient |
64 gfx::Rect PaintableRegion() override { return m_paintableRegion; } | 82 gfx::Rect PaintableRegion() override { return m_paintableRegion; } |
65 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( | 83 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( |
66 PaintingControlSetting) override { | 84 PaintingControlSetting) override { |
67 return m_ccDisplayItemList; | 85 return m_ccDisplayItemList; |
68 } | 86 } |
69 bool FillsBoundsCompletely() const override { return false; } | 87 bool FillsBoundsCompletely() const override { return false; } |
70 size_t GetApproximateUnsharedMemoryUsage() const override { | 88 size_t GetApproximateUnsharedMemoryUsage() const override { |
71 // TODO(jbroman): Actually calculate memory usage. | 89 // TODO(jbroman): Actually calculate memory usage. |
72 return 0; | 90 return 0; |
73 } | 91 } |
74 | 92 |
| 93 void resetTrackedRasterInvalidations() { |
| 94 RasterInvalidationTracking* tracking = |
| 95 ccLayersRasterInvalidationTrackingMap().find(m_ccPictureLayer.get()); |
| 96 if (!tracking) |
| 97 return; |
| 98 |
| 99 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
| 100 tracking->trackedRasterInvalidations.clear(); |
| 101 else |
| 102 ccLayersRasterInvalidationTrackingMap().remove(m_ccPictureLayer.get()); |
| 103 } |
| 104 |
| 105 bool hasTrackedRasterInvalidations() const { |
| 106 RasterInvalidationTracking* tracking = |
| 107 ccLayersRasterInvalidationTrackingMap().find(m_ccPictureLayer.get()); |
| 108 if (tracking) |
| 109 return !tracking->trackedRasterInvalidations.isEmpty(); |
| 110 return false; |
| 111 } |
| 112 |
| 113 void setNeedsDisplayRect(const gfx::Rect& rect, |
| 114 RasterInvalidationInfo* rasterInvalidationInfo) { |
| 115 m_ccPictureLayer->SetNeedsDisplayRect(rect); |
| 116 |
| 117 if (!rasterInvalidationInfo || rect.IsEmpty()) |
| 118 return; |
| 119 |
| 120 RasterInvalidationTracking& tracking = |
| 121 ccLayersRasterInvalidationTrackingMap().add(m_ccPictureLayer.get()); |
| 122 |
| 123 tracking.trackedRasterInvalidations.append(*rasterInvalidationInfo); |
| 124 |
| 125 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 126 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint i
nvalidation rect. |
| 127 IntRect r = rasterInvalidationInfo->rect; |
| 128 r.inflate(1); |
| 129 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); |
| 130 } |
| 131 } |
| 132 |
| 133 std::unique_ptr<JSONObject> layerAsJSON() { |
| 134 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 135 json->setString("name", m_debugName); |
| 136 IntSize bounds(m_ccPictureLayer->bounds().width(), |
| 137 m_ccPictureLayer->bounds().height()); |
| 138 if (!bounds.isEmpty()) |
| 139 json->setArray("bounds", sizeAsJSONArray(bounds)); |
| 140 json->setBoolean("contentsOpaque", m_ccPictureLayer->contents_opaque()); |
| 141 json->setBoolean("drawsContent", m_ccPictureLayer->DrawsContent()); |
| 142 |
| 143 ccLayersRasterInvalidationTrackingMap().asJSON(m_ccPictureLayer.get(), |
| 144 json.get()); |
| 145 return json; |
| 146 } |
| 147 |
75 scoped_refptr<cc::PictureLayer> ccPictureLayer() { return m_ccPictureLayer; } | 148 scoped_refptr<cc::PictureLayer> ccPictureLayer() { return m_ccPictureLayer; } |
76 | 149 |
77 bool matches(const PaintChunk& paintChunk) { | 150 bool matches(const PaintChunk& paintChunk) { |
78 return m_id && paintChunk.id && *m_id == *paintChunk.id; | 151 return paintChunk.id && m_id == *paintChunk.id; |
79 } | 152 } |
80 | 153 |
81 private: | 154 private: |
82 Optional<PaintChunk::Id> m_id; | 155 PaintChunk::Id m_id; |
| 156 String m_debugName; |
83 scoped_refptr<cc::PictureLayer> m_ccPictureLayer; | 157 scoped_refptr<cc::PictureLayer> m_ccPictureLayer; |
84 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; | 158 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; |
85 gfx::Rect m_paintableRegion; | 159 gfx::Rect m_paintableRegion; |
86 }; | 160 }; |
87 | 161 |
88 PaintArtifactCompositor::PaintArtifactCompositor() { | 162 PaintArtifactCompositor::PaintArtifactCompositor() { |
89 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 163 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
90 return; | 164 return; |
91 m_rootLayer = cc::Layer::Create(); | 165 m_rootLayer = cc::Layer::Create(); |
92 m_webLayer = wrapUnique( | 166 m_webLayer = wrapUnique( |
93 Platform::current()->compositorSupport()->createLayerFromCCLayer( | 167 Platform::current()->compositorSupport()->createLayerFromCCLayer( |
94 m_rootLayer.get())); | 168 m_rootLayer.get())); |
| 169 m_isTrackingRasterInvalidations = false; |
95 } | 170 } |
96 | 171 |
97 PaintArtifactCompositor::~PaintArtifactCompositor() {} | 172 PaintArtifactCompositor::~PaintArtifactCompositor() {} |
98 | 173 |
| 174 void PaintArtifactCompositor::setTracksRasterInvalidations( |
| 175 bool tracksPaintInvalidations) { |
| 176 resetTrackedRasterInvalidations(); |
| 177 m_isTrackingRasterInvalidations = tracksPaintInvalidations; |
| 178 } |
| 179 |
| 180 void PaintArtifactCompositor::resetTrackedRasterInvalidations() { |
| 181 for (auto& client : m_contentLayerClients) |
| 182 client->resetTrackedRasterInvalidations(); |
| 183 } |
| 184 |
| 185 bool PaintArtifactCompositor::hasTrackedRasterInvalidations() const { |
| 186 for (auto& client : m_contentLayerClients) { |
| 187 if (client->hasTrackedRasterInvalidations()) |
| 188 return true; |
| 189 } |
| 190 return false; |
| 191 } |
| 192 |
| 193 std::unique_ptr<JSONObject> PaintArtifactCompositor::layersAsJSON( |
| 194 LayerTreeFlags flags) const { |
| 195 std::unique_ptr<JSONArray> layersJSON = JSONArray::create(); |
| 196 for (const auto& client : m_contentLayerClients) { |
| 197 layersJSON->pushObject(client->layerAsJSON()); |
| 198 } |
| 199 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 200 json->setArray("layers", std::move(layersJSON)); |
| 201 return json; |
| 202 } |
| 203 |
99 namespace { | 204 namespace { |
100 | 205 |
101 static gfx::Rect largeRect(-200000, -200000, 400000, 400000); | 206 static gfx::Rect largeRect(-200000, -200000, 400000, 400000); |
102 | 207 |
103 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem, | 208 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem, |
104 cc::DisplayItemList* list) { | 209 cc::DisplayItemList* list) { |
105 if (DisplayItem::isDrawingType(displayItem.getType())) { | 210 if (DisplayItem::isDrawingType(displayItem.getType())) { |
106 const SkPicture* picture = | 211 const SkPicture* picture = |
107 static_cast<const DrawingDisplayItem&>(displayItem).picture(); | 212 static_cast<const DrawingDisplayItem&>(displayItem).picture(); |
108 if (!picture) | 213 if (!picture) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 cc::ScrollNode& scrollNode = | 311 cc::ScrollNode& scrollNode = |
207 *scrollTree.Node(scrollTree.Insert(cc::ScrollNode(), kRealRootNodeId)); | 312 *scrollTree.Node(scrollTree.Insert(cc::ScrollNode(), kRealRootNodeId)); |
208 DCHECK_EQ(scrollNode.id, kSecondaryRootNodeId); | 313 DCHECK_EQ(scrollNode.id, kSecondaryRootNodeId); |
209 scrollNode.owner_id = ownerId; | 314 scrollNode.owner_id = ownerId; |
210 scrollNode.transform_id = kRealRootNodeId; | 315 scrollNode.transform_id = kRealRootNodeId; |
211 } | 316 } |
212 | 317 |
213 } // namespace | 318 } // namespace |
214 | 319 |
215 std::unique_ptr<PaintArtifactCompositor::ContentLayerClientImpl> | 320 std::unique_ptr<PaintArtifactCompositor::ContentLayerClientImpl> |
216 PaintArtifactCompositor::clientForPaintChunk(const PaintChunk& paintChunk) { | 321 PaintArtifactCompositor::clientForPaintChunk( |
| 322 const PaintChunk& paintChunk, |
| 323 const PaintArtifact& paintArtifact) { |
217 // TODO(chrishtr): for now, just using a linear walk. In the future we can opt
imize this by using the same techniques used in | 324 // TODO(chrishtr): for now, just using a linear walk. In the future we can opt
imize this by using the same techniques used in |
218 // PaintController for display lists. | 325 // PaintController for display lists. |
219 for (auto& client : m_contentLayerClients) { | 326 for (auto& client : m_contentLayerClients) { |
220 if (client && client->matches(paintChunk)) | 327 if (client && client->matches(paintChunk)) |
221 return std::move(client); | 328 return std::move(client); |
222 } | 329 } |
223 return wrapUnique(new ContentLayerClientImpl(paintChunk.id)); | 330 |
| 331 return wrapUnique(new ContentLayerClientImpl( |
| 332 paintChunk.id |
| 333 ? *paintChunk.id |
| 334 : paintArtifact.getDisplayItemList()[paintChunk.beginIndex].getId())); |
224 } | 335 } |
225 | 336 |
226 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk( | 337 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk( |
227 const PaintArtifact& paintArtifact, | 338 const PaintArtifact& paintArtifact, |
228 const PaintChunk& paintChunk, | 339 const PaintChunk& paintChunk, |
229 gfx::Vector2dF& layerOffset, | 340 gfx::Vector2dF& layerOffset, |
230 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients) { | 341 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, |
| 342 RasterInvalidationTracking* tracking) { |
231 DCHECK(paintChunk.size()); | 343 DCHECK(paintChunk.size()); |
232 | 344 |
233 // If the paint chunk is a foreign layer, just return that layer. | 345 // If the paint chunk is a foreign layer, just return that layer. |
234 if (scoped_refptr<cc::Layer> foreignLayer = | 346 if (scoped_refptr<cc::Layer> foreignLayer = |
235 foreignLayerForPaintChunk(paintArtifact, paintChunk, layerOffset)) | 347 foreignLayerForPaintChunk(paintArtifact, paintChunk, layerOffset)) |
236 return foreignLayer; | 348 return foreignLayer; |
237 | 349 |
238 // The common case: create or reuse a PictureLayer for painted content. | 350 // The common case: create or reuse a PictureLayer for painted content. |
239 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = | 351 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = |
240 clientForPaintChunk(paintChunk); | 352 clientForPaintChunk(paintChunk, paintArtifact); |
241 | 353 |
242 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); | 354 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); |
243 scoped_refptr<cc::DisplayItemList> displayList = | 355 scoped_refptr<cc::DisplayItemList> displayList = |
244 recordPaintChunk(paintArtifact, paintChunk, combinedBounds); | 356 recordPaintChunk(paintArtifact, paintChunk, combinedBounds); |
245 contentLayerClient->SetDisplayList(std::move(displayList)); | 357 contentLayerClient->SetDisplayList(std::move(displayList)); |
246 contentLayerClient->SetPaintableRegion(gfx::Rect(combinedBounds.size())); | 358 contentLayerClient->SetPaintableRegion(gfx::Rect(combinedBounds.size())); |
247 | 359 |
248 layerOffset = combinedBounds.OffsetFromOrigin(); | 360 layerOffset = combinedBounds.OffsetFromOrigin(); |
249 scoped_refptr<cc::PictureLayer> ccPictureLayer = | 361 scoped_refptr<cc::PictureLayer> ccPictureLayer = |
250 contentLayerClient->ccPictureLayer(); | 362 contentLayerClient->ccPictureLayer(); |
251 ccPictureLayer->SetBounds(combinedBounds.size()); | 363 ccPictureLayer->SetBounds(combinedBounds.size()); |
252 ccPictureLayer->SetIsDrawable(true); | 364 ccPictureLayer->SetIsDrawable(true); |
253 if (paintChunk.knownToBeOpaque) | 365 if (paintChunk.knownToBeOpaque) |
254 ccPictureLayer->SetContentsOpaque(true); | 366 ccPictureLayer->SetContentsOpaque(true); |
255 for (auto& invalidation : paintChunk.rasterInvalidationRects) { | 367 DCHECK(!tracking || |
256 IntRect rect(enclosingIntRect(invalidation)); | 368 tracking->trackedRasterInvalidations.size() == |
| 369 paintChunk.rasterInvalidationRects.size()); |
| 370 for (unsigned index = 0; index < paintChunk.rasterInvalidationRects.size(); |
| 371 ++index) { |
| 372 IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index])); |
257 gfx::Rect ccInvalidationRect(rect.x(), rect.y(), std::max(0, rect.width()), | 373 gfx::Rect ccInvalidationRect(rect.x(), rect.y(), std::max(0, rect.width()), |
258 std::max(0, rect.height())); | 374 std::max(0, rect.height())); |
| 375 ccInvalidationRect.Offset(-combinedBounds.OffsetFromOrigin()); |
259 // Raster paintChunk.rasterInvalidationRects is in the space of the containi
ng transform node, so need to subtract off the layer offset. | 376 // Raster paintChunk.rasterInvalidationRects is in the space of the containi
ng transform node, so need to subtract off the layer offset. |
260 ccInvalidationRect.Offset(-combinedBounds.OffsetFromOrigin()); | 377 contentLayerClient->setNeedsDisplayRect( |
261 ccPictureLayer->SetNeedsDisplayRect(ccInvalidationRect); | 378 ccInvalidationRect, |
| 379 tracking ? &tracking->trackedRasterInvalidations[index] : nullptr); |
262 } | 380 } |
263 | 381 |
264 newContentLayerClients.append(std::move(contentLayerClient)); | 382 newContentLayerClients.append(std::move(contentLayerClient)); |
265 return ccPictureLayer; | 383 return ccPictureLayer; |
266 } | 384 } |
267 | 385 |
268 namespace { | 386 namespace { |
269 | 387 |
270 class PropertyTreeManager { | 388 class PropertyTreeManager { |
271 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); | 389 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 679 |
562 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); | 680 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); |
563 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); | 681 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); |
564 dummyLayer->SetClipTreeIndex(dummyClip.id); | 682 dummyLayer->SetClipTreeIndex(dummyClip.id); |
565 dummyLayer->SetEffectTreeIndex(effectNode.id); | 683 dummyLayer->SetEffectTreeIndex(effectNode.id); |
566 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); | 684 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); |
567 } | 685 } |
568 | 686 |
569 } // namespace | 687 } // namespace |
570 | 688 |
571 void PaintArtifactCompositor::update(const PaintArtifact& paintArtifact) { | 689 void PaintArtifactCompositor::update( |
| 690 const PaintArtifact& paintArtifact, |
| 691 RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations) { |
572 DCHECK(m_rootLayer); | 692 DCHECK(m_rootLayer); |
573 | 693 |
574 cc::LayerTree* layerTree = m_rootLayer->GetLayerTree(); | 694 cc::LayerTree* layerTree = m_rootLayer->GetLayerTree(); |
575 | 695 |
576 // The tree will be null after detaching and this update can be ignored. | 696 // The tree will be null after detaching and this update can be ignored. |
577 // See: WebViewImpl::detachPaintArtifactCompositor(). | 697 // See: WebViewImpl::detachPaintArtifactCompositor(). |
578 if (!layerTree) | 698 if (!layerTree) |
579 return; | 699 return; |
580 | 700 |
581 if (m_extraDataForTestingEnabled) | 701 if (m_extraDataForTestingEnabled) |
(...skipping 10 matching lines...) Expand all Loading... |
592 | 712 |
593 PropertyTreeManager propertyTreeManager(*layerTree->property_trees(), | 713 PropertyTreeManager propertyTreeManager(*layerTree->property_trees(), |
594 m_rootLayer.get()); | 714 m_rootLayer.get()); |
595 propertyTreeManager.setDeviceScaleFactor(layerTree->device_scale_factor()); | 715 propertyTreeManager.setDeviceScaleFactor(layerTree->device_scale_factor()); |
596 | 716 |
597 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; | 717 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; |
598 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); | 718 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); |
599 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { | 719 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { |
600 gfx::Vector2dF layerOffset; | 720 gfx::Vector2dF layerOffset; |
601 scoped_refptr<cc::Layer> layer = layerForPaintChunk( | 721 scoped_refptr<cc::Layer> layer = layerForPaintChunk( |
602 paintArtifact, paintChunk, layerOffset, newContentLayerClients); | 722 paintArtifact, paintChunk, layerOffset, newContentLayerClients, |
| 723 rasterChunkInvalidations ? rasterChunkInvalidations->find(&paintChunk) |
| 724 : nullptr); |
603 | 725 |
604 int transformId = propertyTreeManager.compositorIdForTransformNode( | 726 int transformId = propertyTreeManager.compositorIdForTransformNode( |
605 paintChunk.properties.transform.get()); | 727 paintChunk.properties.transform.get()); |
606 int scrollId = propertyTreeManager.compositorIdForScrollNode( | 728 int scrollId = propertyTreeManager.compositorIdForScrollNode( |
607 paintChunk.properties.scroll.get()); | 729 paintChunk.properties.scroll.get()); |
608 int clipId = propertyTreeManager.compositorIdForClipNode( | 730 int clipId = propertyTreeManager.compositorIdForClipNode( |
609 paintChunk.properties.clip.get()); | 731 paintChunk.properties.clip.get()); |
610 int effectId = propertyTreeManager.switchToEffectNode( | 732 int effectId = propertyTreeManager.switchToEffectNode( |
611 *paintChunk.properties.effect.get()); | 733 *paintChunk.properties.effect.get()); |
612 | 734 |
(...skipping 22 matching lines...) Expand all Loading... |
635 } | 757 } |
636 m_contentLayerClients.clear(); | 758 m_contentLayerClients.clear(); |
637 m_contentLayerClients.swap(newContentLayerClients); | 759 m_contentLayerClients.swap(newContentLayerClients); |
638 | 760 |
639 // Mark the property trees as having been rebuilt. | 761 // Mark the property trees as having been rebuilt. |
640 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 762 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
641 layerTree->property_trees()->needs_rebuild = false; | 763 layerTree->property_trees()->needs_rebuild = false; |
642 } | 764 } |
643 | 765 |
644 } // namespace blink | 766 } // namespace blink |
OLD | NEW |