| 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>& ccLayersRasterInvalidatio
nTrackingMap() |
| 52 { |
| 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 { |
| 60 std::unique_ptr<JSONArray> array = JSONArray::create(); |
| 61 array->pushDouble(size.width()); |
| 62 array->pushDouble(size.height()); |
| 63 return array; |
| 64 } |
| 65 |
| 49 class PaintArtifactCompositor::ContentLayerClientImpl : public cc::ContentLayerC
lient { | 66 class PaintArtifactCompositor::ContentLayerClientImpl : public cc::ContentLayerC
lient { |
| 50 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); | 67 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); |
| 51 USING_FAST_MALLOC(ContentLayerClientImpl); | 68 USING_FAST_MALLOC(ContentLayerClientImpl); |
| 52 public: | 69 public: |
| 53 ContentLayerClientImpl(Optional<DisplayItem::Id> paintChunkId) | 70 ContentLayerClientImpl(DisplayItem::Id paintChunkId) |
| 54 : m_id(paintChunkId), m_ccPictureLayer(cc::PictureLayer::Create(this)) | 71 : m_id(paintChunkId), m_ccPictureLayer(cc::PictureLayer::Create(this)) |
| 55 { | 72 { |
| 56 } | 73 } |
| 57 | 74 |
| 58 void SetDisplayList(scoped_refptr<cc::DisplayItemList> ccDisplayItemList) {
m_ccDisplayItemList = std::move(ccDisplayItemList); } | 75 void SetDisplayList(scoped_refptr<cc::DisplayItemList> ccDisplayItemList) {
m_ccDisplayItemList = std::move(ccDisplayItemList); } |
| 59 void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } | 76 void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } |
| 60 | 77 |
| 61 // cc::ContentLayerClient | 78 // cc::ContentLayerClient |
| 62 gfx::Rect PaintableRegion() override { return m_paintableRegion; } | 79 gfx::Rect PaintableRegion() override { return m_paintableRegion; } |
| 63 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList(PaintingContro
lSetting) override | 80 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList(PaintingContro
lSetting) override |
| 64 { | 81 { |
| 65 return m_ccDisplayItemList; | 82 return m_ccDisplayItemList; |
| 66 } | 83 } |
| 67 bool FillsBoundsCompletely() const override { return false; } | 84 bool FillsBoundsCompletely() const override { return false; } |
| 68 size_t GetApproximateUnsharedMemoryUsage() const override | 85 size_t GetApproximateUnsharedMemoryUsage() const override |
| 69 { | 86 { |
| 70 // TODO(jbroman): Actually calculate memory usage. | 87 // TODO(jbroman): Actually calculate memory usage. |
| 71 return 0; | 88 return 0; |
| 72 } | 89 } |
| 73 | 90 |
| 91 void resetTrackedRasterInvalidations() |
| 92 { |
| 93 RasterInvalidationTracking* tracking = ccLayersRasterInvalidationTrackin
gMap().find(m_ccPictureLayer.get()); |
| 94 if (!tracking) |
| 95 return; |
| 96 |
| 97 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
| 98 tracking->trackedRasterInvalidations.clear(); |
| 99 else |
| 100 ccLayersRasterInvalidationTrackingMap().remove(m_ccPictureLayer.get(
)); |
| 101 } |
| 102 |
| 103 bool hasTrackedRasterInvalidations() const |
| 104 { |
| 105 RasterInvalidationTracking* tracking = ccLayersRasterInvalidationTrackin
gMap().find(m_ccPictureLayer.get()); |
| 106 if (tracking) |
| 107 return !tracking->trackedRasterInvalidations.isEmpty(); |
| 108 return false; |
| 109 } |
| 110 |
| 111 void setNeedsDisplayRect(const gfx::Rect& rect, RasterInvalidationInfo* rast
erInvalidationInfo) |
| 112 { |
| 113 m_ccPictureLayer->SetNeedsDisplayRect(rect); |
| 114 |
| 115 if (!rasterInvalidationInfo || rect.IsEmpty()) |
| 116 return; |
| 117 |
| 118 RasterInvalidationTracking& tracking = ccLayersRasterInvalidationTrackin
gMap().add(m_ccPictureLayer.get()); |
| 119 |
| 120 tracking.trackedRasterInvalidations.append(*rasterInvalidationInfo); |
| 121 |
| 122 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 123 // TODO(crbug.com/496260): Some antialiasing effects overflows the p
aint invalidation rect. |
| 124 IntRect r = rasterInvalidationInfo->rect; |
| 125 r.inflate(1); |
| 126 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); |
| 127 } |
| 128 } |
| 129 |
| 130 std::unique_ptr<JSONObject> layerAsJSON() |
| 131 { |
| 132 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 133 json->setString("name", m_id.client.debugName()); |
| 134 IntSize bounds(m_ccPictureLayer->bounds().width(), m_ccPictureLayer->bou
nds().height()); |
| 135 if (!bounds.isEmpty()) |
| 136 json->setArray("bounds", sizeAsJSONArray(bounds)); |
| 137 json->setBoolean("contentsOpaque", m_ccPictureLayer->contents_opaque()); |
| 138 json->setBoolean("drawsContent", m_ccPictureLayer->DrawsContent()); |
| 139 |
| 140 ccLayersRasterInvalidationTrackingMap().asJSON(m_ccPictureLayer.get(), j
son.get()); |
| 141 return json; |
| 142 } |
| 143 |
| 74 scoped_refptr<cc::PictureLayer> ccPictureLayer() { return m_ccPictureLayer;
} | 144 scoped_refptr<cc::PictureLayer> ccPictureLayer() { return m_ccPictureLayer;
} |
| 75 | 145 |
| 76 bool matches(const PaintChunk& paintChunk) | 146 bool matches(const PaintChunk& paintChunk) |
| 77 { | 147 { |
| 78 return m_id && paintChunk.id && *m_id == *paintChunk.id; | 148 return paintChunk.id && m_id == *paintChunk.id; |
| 79 } | 149 } |
| 80 | 150 |
| 81 private: | 151 private: |
| 82 Optional<PaintChunk::Id> m_id; | 152 PaintChunk::Id m_id; |
| 83 scoped_refptr<cc::PictureLayer> m_ccPictureLayer; | 153 scoped_refptr<cc::PictureLayer> m_ccPictureLayer; |
| 84 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; | 154 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; |
| 85 gfx::Rect m_paintableRegion; | 155 gfx::Rect m_paintableRegion; |
| 86 }; | 156 }; |
| 87 | 157 |
| 88 PaintArtifactCompositor::PaintArtifactCompositor() | 158 PaintArtifactCompositor::PaintArtifactCompositor() |
| 89 { | 159 { |
| 90 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 160 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 91 return; | 161 return; |
| 92 m_rootLayer = cc::Layer::Create(); | 162 m_rootLayer = cc::Layer::Create(); |
| 93 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye
rFromCCLayer(m_rootLayer.get())); | 163 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye
rFromCCLayer(m_rootLayer.get())); |
| 164 m_isTrackingRasterInvalidations = false; |
| 94 } | 165 } |
| 95 | 166 |
| 96 PaintArtifactCompositor::~PaintArtifactCompositor() | 167 PaintArtifactCompositor::~PaintArtifactCompositor() |
| 97 { | 168 { |
| 98 } | 169 } |
| 99 | 170 |
| 171 void PaintArtifactCompositor::setTracksRasterInvalidations(bool tracksPaintInval
idations) |
| 172 { |
| 173 resetTrackedRasterInvalidations(); |
| 174 m_isTrackingRasterInvalidations = tracksPaintInvalidations; |
| 175 } |
| 176 |
| 177 void PaintArtifactCompositor::resetTrackedRasterInvalidations() |
| 178 { |
| 179 for (auto& client : m_contentLayerClients) |
| 180 client->resetTrackedRasterInvalidations(); |
| 181 } |
| 182 |
| 183 bool PaintArtifactCompositor::hasTrackedRasterInvalidations() const |
| 184 { |
| 185 for (auto& client : m_contentLayerClients) { |
| 186 if (client->hasTrackedRasterInvalidations()) |
| 187 return true; |
| 188 } |
| 189 return false; |
| 190 } |
| 191 |
| 192 std::unique_ptr<JSONObject> PaintArtifactCompositor::layersAsJSON(LayerTreeFlags
flags) const |
| 193 { |
| 194 std::unique_ptr<JSONArray> layersJSON = JSONArray::create(); |
| 195 for (const auto& client : m_contentLayerClients) { |
| 196 layersJSON->pushObject(client->layerAsJSON()); |
| 197 } |
| 198 |
| 199 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 200 json->setArray("layers", std::move(layersJSON)); |
| 201 return json; |
| 202 } |
| 203 |
| 100 namespace { | 204 namespace { |
| 101 | 205 |
| 102 static gfx::Rect largeRect(-200000, -200000, 400000, 400000); | 206 static gfx::Rect largeRect(-200000, -200000, 400000, 400000); |
| 103 | 207 |
| 104 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) | 208 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) |
| 105 { | 209 { |
| 106 if (DisplayItem::isDrawingType(displayItem.getType())) { | 210 if (DisplayItem::isDrawingType(displayItem.getType())) { |
| 107 const SkPicture* picture = static_cast<const DrawingDisplayItem&>(displa
yItem).picture(); | 211 const SkPicture* picture = static_cast<const DrawingDisplayItem&>(displa
yItem).picture(); |
| 108 if (!picture) | 212 if (!picture) |
| 109 return; | 213 return; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 cc::ScrollTree& scrollTree = propertyTrees->scroll_tree; | 297 cc::ScrollTree& scrollTree = propertyTrees->scroll_tree; |
| 194 scrollTree.clear(); | 298 scrollTree.clear(); |
| 195 cc::ScrollNode& scrollNode = *scrollTree.Node(scrollTree.Insert(cc::ScrollNo
de(), kRealRootNodeId)); | 299 cc::ScrollNode& scrollNode = *scrollTree.Node(scrollTree.Insert(cc::ScrollNo
de(), kRealRootNodeId)); |
| 196 DCHECK_EQ(scrollNode.id, kSecondaryRootNodeId); | 300 DCHECK_EQ(scrollNode.id, kSecondaryRootNodeId); |
| 197 scrollNode.owner_id = ownerId; | 301 scrollNode.owner_id = ownerId; |
| 198 scrollNode.transform_id = kRealRootNodeId; | 302 scrollNode.transform_id = kRealRootNodeId; |
| 199 } | 303 } |
| 200 | 304 |
| 201 } // namespace | 305 } // namespace |
| 202 | 306 |
| 203 std::unique_ptr<PaintArtifactCompositor::ContentLayerClientImpl> PaintArtifactCo
mpositor::clientForPaintChunk(const PaintChunk& paintChunk) | 307 std::unique_ptr<PaintArtifactCompositor::ContentLayerClientImpl> PaintArtifactCo
mpositor::clientForPaintChunk(const PaintChunk& paintChunk, const PaintArtifact&
paintArtifact) |
| 204 { | 308 { |
| 205 // TODO(chrishtr): for now, just using a linear walk. In the future we can o
ptimize this by using the same techniques used in | 309 // TODO(chrishtr): for now, just using a linear walk. In the future we can o
ptimize this by using the same techniques used in |
| 206 // PaintController for display lists. | 310 // PaintController for display lists. |
| 207 for (auto& client : m_contentLayerClients) { | 311 for (auto& client : m_contentLayerClients) { |
| 208 if (client && client->matches(paintChunk)) | 312 if (client && client->matches(paintChunk)) |
| 209 return std::move(client); | 313 return std::move(client); |
| 210 } | 314 } |
| 211 return wrapUnique(new ContentLayerClientImpl(paintChunk.id)); | 315 |
| 316 return wrapUnique(new ContentLayerClientImpl(paintChunk.id ? *paintChunk.id
: paintArtifact.getDisplayItemList()[paintChunk.beginIndex].getId())); |
| 212 } | 317 } |
| 213 | 318 |
| 214 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint
Artifact& paintArtifact, const PaintChunk& paintChunk, gfx::Vector2dF& layerOffs
et, | 319 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint
Artifact& paintArtifact, const PaintChunk& paintChunk, gfx::Vector2dF& layerOffs
et, |
| 215 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients) | 320 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, Ras
terInvalidationTracking* tracking) |
| 216 { | 321 { |
| 217 DCHECK(paintChunk.size()); | 322 DCHECK(paintChunk.size()); |
| 218 | 323 |
| 219 // If the paint chunk is a foreign layer, just return that layer. | 324 // If the paint chunk is a foreign layer, just return that layer. |
| 220 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk(paintA
rtifact, paintChunk, layerOffset)) | 325 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk(paintA
rtifact, paintChunk, layerOffset)) |
| 221 return foreignLayer; | 326 return foreignLayer; |
| 222 | 327 |
| 223 // The common case: create or reuse a PictureLayer for painted content. | 328 // The common case: create or reuse a PictureLayer for painted content. |
| 224 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = clientForPaintC
hunk(paintChunk); | 329 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = clientForPaintC
hunk(paintChunk, paintArtifact); |
| 225 | 330 |
| 226 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); | 331 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); |
| 227 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif
act, paintChunk, combinedBounds); | 332 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif
act, paintChunk, combinedBounds); |
| 228 contentLayerClient->SetDisplayList(std::move(displayList)); | 333 contentLayerClient->SetDisplayList(std::move(displayList)); |
| 229 contentLayerClient->SetPaintableRegion(gfx::Rect(combinedBounds.size())); | 334 contentLayerClient->SetPaintableRegion(gfx::Rect(combinedBounds.size())); |
| 230 | 335 |
| 231 layerOffset = combinedBounds.OffsetFromOrigin(); | 336 layerOffset = combinedBounds.OffsetFromOrigin(); |
| 232 scoped_refptr<cc::PictureLayer> ccPictureLayer = contentLayerClient->ccPictu
reLayer(); | 337 scoped_refptr<cc::PictureLayer> ccPictureLayer = contentLayerClient->ccPictu
reLayer(); |
| 233 ccPictureLayer->SetBounds(combinedBounds.size()); | 338 ccPictureLayer->SetBounds(combinedBounds.size()); |
| 234 ccPictureLayer->SetIsDrawable(true); | 339 ccPictureLayer->SetIsDrawable(true); |
| 235 if (paintChunk.knownToBeOpaque) | 340 if (paintChunk.knownToBeOpaque) |
| 236 ccPictureLayer->SetContentsOpaque(true); | 341 ccPictureLayer->SetContentsOpaque(true); |
| 237 for (auto& invalidation : paintChunk.rasterInvalidationRects) { | 342 DCHECK(!tracking || tracking->trackedRasterInvalidations.size() == paintChun
k.rasterInvalidationRects.size()); |
| 238 IntRect rect(enclosingIntRect(invalidation)); | 343 for (unsigned index = 0; index < paintChunk.rasterInvalidationRects.size();
++index) { |
| 344 IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index])
); |
| 239 gfx::Rect ccInvalidationRect(rect.x(), rect.y(), std::max(0, rect.width(
)), std::max(0, rect.height())); | 345 gfx::Rect ccInvalidationRect(rect.x(), rect.y(), std::max(0, rect.width(
)), std::max(0, rect.height())); |
| 346 ccInvalidationRect.Offset(-combinedBounds.OffsetFromOrigin()); |
| 240 // Raster paintChunk.rasterInvalidationRects is in the space of the cont
aining transform node, so need to subtract off the layer offset. | 347 // Raster paintChunk.rasterInvalidationRects is in the space of the cont
aining transform node, so need to subtract off the layer offset. |
| 241 ccInvalidationRect.Offset(-combinedBounds.OffsetFromOrigin()); | 348 contentLayerClient->setNeedsDisplayRect(ccInvalidationRect, tracking ? &
tracking->trackedRasterInvalidations[index] : nullptr); |
| 242 ccPictureLayer->SetNeedsDisplayRect(ccInvalidationRect); | |
| 243 } | 349 } |
| 244 | 350 |
| 245 newContentLayerClients.append(std::move(contentLayerClient)); | 351 newContentLayerClients.append(std::move(contentLayerClient)); |
| 246 return ccPictureLayer; | 352 return ccPictureLayer; |
| 247 } | 353 } |
| 248 | 354 |
| 249 namespace { | 355 namespace { |
| 250 | 356 |
| 251 class PropertyTreeManager { | 357 class PropertyTreeManager { |
| 252 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); | 358 WTF_MAKE_NONCOPYABLE(PropertyTreeManager); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 625 |
| 520 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); | 626 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); |
| 521 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); | 627 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); |
| 522 dummyLayer->SetClipTreeIndex(dummyClip.id); | 628 dummyLayer->SetClipTreeIndex(dummyClip.id); |
| 523 dummyLayer->SetEffectTreeIndex(effectNode.id); | 629 dummyLayer->SetEffectTreeIndex(effectNode.id); |
| 524 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); | 630 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); |
| 525 } | 631 } |
| 526 | 632 |
| 527 } // namespace | 633 } // namespace |
| 528 | 634 |
| 529 void PaintArtifactCompositor::update(const PaintArtifact& paintArtifact) | 635 void PaintArtifactCompositor::update(const PaintArtifact& paintArtifact, RasterI
nvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations) |
| 530 { | 636 { |
| 531 DCHECK(m_rootLayer); | 637 DCHECK(m_rootLayer); |
| 532 | 638 |
| 533 cc::LayerTree* layerTree = m_rootLayer->GetLayerTree(); | 639 cc::LayerTree* layerTree = m_rootLayer->GetLayerTree(); |
| 534 | 640 |
| 535 // The tree will be null after detaching and this update can be ignored. | 641 // The tree will be null after detaching and this update can be ignored. |
| 536 // See: WebViewImpl::detachPaintArtifactCompositor(). | 642 // See: WebViewImpl::detachPaintArtifactCompositor(). |
| 537 if (!layerTree) | 643 if (!layerTree) |
| 538 return; | 644 return; |
| 539 | 645 |
| 540 if (m_extraDataForTestingEnabled) | 646 if (m_extraDataForTestingEnabled) |
| 541 m_extraDataForTesting = wrapUnique(new ExtraDataForTesting); | 647 m_extraDataForTesting = wrapUnique(new ExtraDataForTesting); |
| 542 | 648 |
| 543 setMinimalPropertyTrees(layerTree->property_trees(), m_rootLayer->id()); | 649 setMinimalPropertyTrees(layerTree->property_trees(), m_rootLayer->id()); |
| 544 | 650 |
| 545 m_rootLayer->RemoveAllChildren(); | 651 m_rootLayer->RemoveAllChildren(); |
| 546 m_rootLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); | 652 m_rootLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); |
| 547 m_rootLayer->SetTransformTreeIndex(kSecondaryRootNodeId); | 653 m_rootLayer->SetTransformTreeIndex(kSecondaryRootNodeId); |
| 548 m_rootLayer->SetClipTreeIndex(kSecondaryRootNodeId); | 654 m_rootLayer->SetClipTreeIndex(kSecondaryRootNodeId); |
| 549 m_rootLayer->SetEffectTreeIndex(kSecondaryRootNodeId); | 655 m_rootLayer->SetEffectTreeIndex(kSecondaryRootNodeId); |
| 550 m_rootLayer->SetScrollTreeIndex(kRealRootNodeId); | 656 m_rootLayer->SetScrollTreeIndex(kRealRootNodeId); |
| 551 | 657 |
| 552 PropertyTreeManager propertyTreeManager(*layerTree->property_trees(), m_root
Layer.get()); | 658 PropertyTreeManager propertyTreeManager(*layerTree->property_trees(), m_root
Layer.get()); |
| 553 propertyTreeManager.setDeviceScaleFactor(layerTree->device_scale_factor()); | 659 propertyTreeManager.setDeviceScaleFactor(layerTree->device_scale_factor()); |
| 554 | 660 |
| 555 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; | 661 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; |
| 556 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); | 662 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); |
| 557 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { | 663 for (const PaintChunk& paintChunk : paintArtifact.paintChunks()) { |
| 558 gfx::Vector2dF layerOffset; | 664 gfx::Vector2dF layerOffset; |
| 559 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint
Chunk, layerOffset, newContentLayerClients); | 665 scoped_refptr<cc::Layer> layer = layerForPaintChunk(paintArtifact, paint
Chunk, layerOffset, newContentLayerClients, |
| 666 rasterChunkInvalidations ? rasterChunkInvalidations->find(&paintChun
k) : nullptr); |
| 560 | 667 |
| 561 int transformId = propertyTreeManager.compositorIdForTransformNode(paint
Chunk.properties.transform.get()); | 668 int transformId = propertyTreeManager.compositorIdForTransformNode(paint
Chunk.properties.transform.get()); |
| 562 int scrollId = propertyTreeManager.compositorIdForScrollNode(paintChunk.
properties.scroll.get()); | 669 int scrollId = propertyTreeManager.compositorIdForScrollNode(paintChunk.
properties.scroll.get()); |
| 563 int clipId = propertyTreeManager.compositorIdForClipNode(paintChunk.prop
erties.clip.get()); | 670 int clipId = propertyTreeManager.compositorIdForClipNode(paintChunk.prop
erties.clip.get()); |
| 564 int effectId = propertyTreeManager.switchToEffectNode(*paintChunk.proper
ties.effect.get()); | 671 int effectId = propertyTreeManager.switchToEffectNode(*paintChunk.proper
ties.effect.get()); |
| 565 | 672 |
| 566 propertyTreeManager.updateScrollOffset(layer->id(), scrollId); | 673 propertyTreeManager.updateScrollOffset(layer->id(), scrollId); |
| 567 | 674 |
| 568 layer->set_offset_to_transform_parent(layerOffset); | 675 layer->set_offset_to_transform_parent(layerOffset); |
| 569 | 676 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 585 } | 692 } |
| 586 m_contentLayerClients.clear(); | 693 m_contentLayerClients.clear(); |
| 587 m_contentLayerClients.swap(newContentLayerClients); | 694 m_contentLayerClients.swap(newContentLayerClients); |
| 588 | 695 |
| 589 // Mark the property trees as having been rebuilt. | 696 // Mark the property trees as having been rebuilt. |
| 590 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 697 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
| 591 layerTree->property_trees()->needs_rebuild = false; | 698 layerTree->property_trees()->needs_rebuild = false; |
| 592 } | 699 } |
| 593 | 700 |
| 594 } // namespace blink | 701 } // namespace blink |
| OLD | NEW |