| 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" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 if (!rasterInvalidationInfo || rect.IsEmpty()) | 116 if (!rasterInvalidationInfo || rect.IsEmpty()) |
| 117 return; | 117 return; |
| 118 | 118 |
| 119 RasterInvalidationTracking& tracking = | 119 RasterInvalidationTracking& tracking = |
| 120 ccLayersRasterInvalidationTrackingMap().add(m_ccPictureLayer.get()); | 120 ccLayersRasterInvalidationTrackingMap().add(m_ccPictureLayer.get()); |
| 121 | 121 |
| 122 tracking.trackedRasterInvalidations.append(*rasterInvalidationInfo); | 122 tracking.trackedRasterInvalidations.append(*rasterInvalidationInfo); |
| 123 | 123 |
| 124 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 124 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 125 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint i
nvalidation rect. | 125 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint |
| 126 // invalidation rect. |
| 126 IntRect r = rasterInvalidationInfo->rect; | 127 IntRect r = rasterInvalidationInfo->rect; |
| 127 r.inflate(1); | 128 r.inflate(1); |
| 128 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); | 129 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 std::unique_ptr<JSONObject> layerAsJSON() { | 133 std::unique_ptr<JSONObject> layerAsJSON() { |
| 133 std::unique_ptr<JSONObject> json = JSONObject::create(); | 134 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 134 json->setString("name", m_debugName); | 135 json->setString("name", m_debugName); |
| 135 IntSize bounds(m_ccPictureLayer->bounds().width(), | 136 IntSize bounds(m_ccPictureLayer->bounds().width(), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 271 } |
| 271 | 272 |
| 272 // cc's property trees use 0 for the root node (always non-null). | 273 // cc's property trees use 0 for the root node (always non-null). |
| 273 constexpr int kRealRootNodeId = 0; | 274 constexpr int kRealRootNodeId = 0; |
| 274 // cc allocates special nodes for root effects such as the device scale. | 275 // cc allocates special nodes for root effects such as the device scale. |
| 275 constexpr int kSecondaryRootNodeId = 1; | 276 constexpr int kSecondaryRootNodeId = 1; |
| 276 constexpr int kPropertyTreeSequenceNumber = 1; | 277 constexpr int kPropertyTreeSequenceNumber = 1; |
| 277 | 278 |
| 278 // Creates a minimal set of property trees for the compositor. | 279 // Creates a minimal set of property trees for the compositor. |
| 279 void setMinimalPropertyTrees(cc::PropertyTrees* propertyTrees, int ownerId) { | 280 void setMinimalPropertyTrees(cc::PropertyTrees* propertyTrees, int ownerId) { |
| 280 // cc is hardcoded to use transform node index 1 for device scale and transfor
m. | 281 // cc is hardcoded to use transform node index 1 for device scale and |
| 282 // transform. |
| 281 cc::TransformTree& transformTree = propertyTrees->transform_tree; | 283 cc::TransformTree& transformTree = propertyTrees->transform_tree; |
| 282 transformTree.clear(); | 284 transformTree.clear(); |
| 283 cc::TransformNode& transformNode = *transformTree.Node( | 285 cc::TransformNode& transformNode = *transformTree.Node( |
| 284 transformTree.Insert(cc::TransformNode(), kRealRootNodeId)); | 286 transformTree.Insert(cc::TransformNode(), kRealRootNodeId)); |
| 285 DCHECK_EQ(transformNode.id, kSecondaryRootNodeId); | 287 DCHECK_EQ(transformNode.id, kSecondaryRootNodeId); |
| 286 transformNode.source_node_id = transformNode.parent_id; | 288 transformNode.source_node_id = transformNode.parent_id; |
| 287 transformTree.SetTargetId(transformNode.id, kRealRootNodeId); | 289 transformTree.SetTargetId(transformNode.id, kRealRootNodeId); |
| 288 transformTree.SetContentTargetId(transformNode.id, kRealRootNodeId); | 290 transformTree.SetContentTargetId(transformNode.id, kRealRootNodeId); |
| 289 | 291 |
| 290 // cc is hardcoded to use clip node index 1 for viewport clip. | 292 // cc is hardcoded to use clip node index 1 for viewport clip. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 313 scrollNode.owner_id = ownerId; | 315 scrollNode.owner_id = ownerId; |
| 314 scrollNode.transform_id = kRealRootNodeId; | 316 scrollNode.transform_id = kRealRootNodeId; |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace | 319 } // namespace |
| 318 | 320 |
| 319 std::unique_ptr<PaintArtifactCompositor::ContentLayerClientImpl> | 321 std::unique_ptr<PaintArtifactCompositor::ContentLayerClientImpl> |
| 320 PaintArtifactCompositor::clientForPaintChunk( | 322 PaintArtifactCompositor::clientForPaintChunk( |
| 321 const PaintChunk& paintChunk, | 323 const PaintChunk& paintChunk, |
| 322 const PaintArtifact& paintArtifact) { | 324 const PaintArtifact& paintArtifact) { |
| 323 // TODO(chrishtr): for now, just using a linear walk. In the future we can opt
imize this by using the same techniques used in | 325 // TODO(chrishtr): for now, just using a linear walk. In the future we can |
| 324 // PaintController for display lists. | 326 // optimize this by using the same techniques used in PaintController for |
| 327 // display lists. |
| 325 for (auto& client : m_contentLayerClients) { | 328 for (auto& client : m_contentLayerClients) { |
| 326 if (client && client->matches(paintChunk)) | 329 if (client && client->matches(paintChunk)) |
| 327 return std::move(client); | 330 return std::move(client); |
| 328 } | 331 } |
| 329 | 332 |
| 330 return wrapUnique(new ContentLayerClientImpl( | 333 return wrapUnique(new ContentLayerClientImpl( |
| 331 paintChunk.id | 334 paintChunk.id |
| 332 ? *paintChunk.id | 335 ? *paintChunk.id |
| 333 : paintArtifact.getDisplayItemList()[paintChunk.beginIndex].getId())); | 336 : paintArtifact.getDisplayItemList()[paintChunk.beginIndex].getId())); |
| 334 } | 337 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 364 if (paintChunk.knownToBeOpaque) | 367 if (paintChunk.knownToBeOpaque) |
| 365 ccPictureLayer->SetContentsOpaque(true); | 368 ccPictureLayer->SetContentsOpaque(true); |
| 366 DCHECK(!tracking || | 369 DCHECK(!tracking || |
| 367 tracking->trackedRasterInvalidations.size() == | 370 tracking->trackedRasterInvalidations.size() == |
| 368 paintChunk.rasterInvalidationRects.size()); | 371 paintChunk.rasterInvalidationRects.size()); |
| 369 for (unsigned index = 0; index < paintChunk.rasterInvalidationRects.size(); | 372 for (unsigned index = 0; index < paintChunk.rasterInvalidationRects.size(); |
| 370 ++index) { | 373 ++index) { |
| 371 IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index])); | 374 IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index])); |
| 372 gfx::Rect ccInvalidationRect(rect.x(), rect.y(), std::max(0, rect.width()), | 375 gfx::Rect ccInvalidationRect(rect.x(), rect.y(), std::max(0, rect.width()), |
| 373 std::max(0, rect.height())); | 376 std::max(0, rect.height())); |
| 377 // Raster paintChunk.rasterInvalidationRects is in the space of the |
| 378 // containing transform node, so need to subtract off the layer offset. |
| 374 ccInvalidationRect.Offset(-combinedBounds.OffsetFromOrigin()); | 379 ccInvalidationRect.Offset(-combinedBounds.OffsetFromOrigin()); |
| 375 // Raster paintChunk.rasterInvalidationRects is in the space of the containi
ng transform node, so need to subtract off the layer offset. | |
| 376 contentLayerClient->setNeedsDisplayRect( | 380 contentLayerClient->setNeedsDisplayRect( |
| 377 ccInvalidationRect, | 381 ccInvalidationRect, |
| 378 tracking ? &tracking->trackedRasterInvalidations[index] : nullptr); | 382 tracking ? &tracking->trackedRasterInvalidations[index] : nullptr); |
| 379 } | 383 } |
| 380 | 384 |
| 381 newContentLayerClients.append(std::move(contentLayerClient)); | 385 newContentLayerClients.append(std::move(contentLayerClient)); |
| 382 return ccPictureLayer; | 386 return ccPictureLayer; |
| 383 } | 387 } |
| 384 | 388 |
| 385 namespace { | 389 namespace { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 buildEffectNodesRecursively(nextEffect->parent()); | 654 buildEffectNodesRecursively(nextEffect->parent()); |
| 651 DCHECK_EQ(nextEffect->parent(), currentEffectNode()); | 655 DCHECK_EQ(nextEffect->parent(), currentEffectNode()); |
| 652 | 656 |
| 653 #if DCHECK_IS_ON() | 657 #if DCHECK_IS_ON() |
| 654 DCHECK(!m_effectNodesConverted.contains(nextEffect)) | 658 DCHECK(!m_effectNodesConverted.contains(nextEffect)) |
| 655 << "Malformed paint artifact. Paint chunks under the same effect should " | 659 << "Malformed paint artifact. Paint chunks under the same effect should " |
| 656 "be contiguous."; | 660 "be contiguous."; |
| 657 m_effectNodesConverted.add(nextEffect); | 661 m_effectNodesConverted.add(nextEffect); |
| 658 #endif | 662 #endif |
| 659 | 663 |
| 660 // We currently create dummy layers to host effect nodes and corresponding ren
der surface. | 664 // We currently create dummy layers to host effect nodes and corresponding |
| 661 // This should be removed once cc implements better support for freestanding p
roperty trees. | 665 // render surfaces. This should be removed once cc implements better support |
| 666 // for freestanding property trees. |
| 662 scoped_refptr<cc::Layer> dummyLayer = cc::Layer::Create(); | 667 scoped_refptr<cc::Layer> dummyLayer = cc::Layer::Create(); |
| 663 m_rootLayer->AddChild(dummyLayer); | 668 m_rootLayer->AddChild(dummyLayer); |
| 664 | 669 |
| 665 // Also cc assumes a clip node is always created by a layer that creates rende
r surface. | 670 // Also cc assumes a clip node is always created by a layer that creates |
| 671 // render surface. |
| 666 cc::ClipNode& dummyClip = | 672 cc::ClipNode& dummyClip = |
| 667 *clipTree().Node(clipTree().Insert(cc::ClipNode(), kSecondaryRootNodeId)); | 673 *clipTree().Node(clipTree().Insert(cc::ClipNode(), kSecondaryRootNodeId)); |
| 668 dummyClip.owner_id = dummyLayer->id(); | 674 dummyClip.owner_id = dummyLayer->id(); |
| 669 dummyClip.transform_id = kRealRootNodeId; | 675 dummyClip.transform_id = kRealRootNodeId; |
| 670 dummyClip.target_transform_id = kRealRootNodeId; | 676 dummyClip.target_transform_id = kRealRootNodeId; |
| 671 | 677 |
| 672 cc::EffectNode& effectNode = *effectTree().Node(effectTree().Insert( | 678 cc::EffectNode& effectNode = *effectTree().Node(effectTree().Insert( |
| 673 cc::EffectNode(), compositorIdForCurrentEffectNode())); | 679 cc::EffectNode(), compositorIdForCurrentEffectNode())); |
| 674 effectNode.owner_id = dummyLayer->id(); | 680 effectNode.owner_id = dummyLayer->id(); |
| 675 effectNode.clip_id = dummyClip.id; | 681 effectNode.clip_id = dummyClip.id; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 762 } |
| 757 m_contentLayerClients.clear(); | 763 m_contentLayerClients.clear(); |
| 758 m_contentLayerClients.swap(newContentLayerClients); | 764 m_contentLayerClients.swap(newContentLayerClients); |
| 759 | 765 |
| 760 // Mark the property trees as having been rebuilt. | 766 // Mark the property trees as having been rebuilt. |
| 761 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 767 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
| 762 layerTree->property_trees()->needs_rebuild = false; | 768 layerTree->property_trees()->needs_rebuild = false; |
| 763 } | 769 } |
| 764 | 770 |
| 765 } // namespace blink | 771 } // namespace blink |
| OLD | NEW |