| 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/compositing_display_item.h" | 10 #include "cc/playback/compositing_display_item.h" |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (currentState->hasDirectCompositingReasons()) | 590 if (currentState->hasDirectCompositingReasons()) |
| 591 return false; | 591 return false; |
| 592 } | 592 } |
| 593 return false; | 593 return false; |
| 594 } | 594 } |
| 595 | 595 |
| 596 bool PaintArtifactCompositor::mightOverlap( | 596 bool PaintArtifactCompositor::mightOverlap( |
| 597 const PaintChunk& paintChunk, | 597 const PaintChunk& paintChunk, |
| 598 const PendingLayer& candidatePendingLayer, | 598 const PendingLayer& candidatePendingLayer, |
| 599 GeometryMapper& geometryMapper) { | 599 GeometryMapper& geometryMapper) { |
| 600 PropertyTreeState rootPropertyTreeState( | 600 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(), |
| 601 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 601 ClipPaintPropertyNode::root(), |
| 602 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 602 EffectPaintPropertyNode::root()); |
| 603 | 603 |
| 604 FloatRect paintChunkScreenVisualRect = | 604 FloatRect paintChunkScreenVisualRect = |
| 605 geometryMapper.localToAncestorVisualRect( | 605 geometryMapper.localToAncestorVisualRect( |
| 606 paintChunk.bounds, paintChunk.properties.propertyTreeState, | 606 paintChunk.bounds, paintChunk.properties.propertyTreeState, |
| 607 rootPropertyTreeState); | 607 rootPropertyTreeState); |
| 608 | 608 |
| 609 FloatRect pendingLayerScreenVisualRect = | 609 FloatRect pendingLayerScreenVisualRect = |
| 610 geometryMapper.localToAncestorVisualRect( | 610 geometryMapper.localToAncestorVisualRect( |
| 611 candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState, | 611 candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState, |
| 612 rootPropertyTreeState); | 612 rootPropertyTreeState); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper); | 701 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper); |
| 702 | 702 |
| 703 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; | 703 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; |
| 704 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); | 704 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); |
| 705 for (const PendingLayer& pendingLayer : pendingLayers) { | 705 for (const PendingLayer& pendingLayer : pendingLayers) { |
| 706 gfx::Vector2dF layerOffset; | 706 gfx::Vector2dF layerOffset; |
| 707 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer( | 707 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer( |
| 708 paintArtifact, pendingLayer, layerOffset, newContentLayerClients, | 708 paintArtifact, pendingLayer, layerOffset, newContentLayerClients, |
| 709 rasterChunkInvalidations, storeDebugInfo, geometryMapper); | 709 rasterChunkInvalidations, storeDebugInfo, geometryMapper); |
| 710 | 710 |
| 711 int transformId = propertyTreeManager.ensureCompositorTransformNode( | 711 const auto* transform = pendingLayer.propertyTreeState.transform(); |
| 712 pendingLayer.propertyTreeState.transform()); | 712 int transformId = |
| 713 int scrollId = propertyTreeManager.ensureCompositorScrollNode( | 713 propertyTreeManager.ensureCompositorTransformNode(transform); |
| 714 pendingLayer.propertyTreeState.scroll()); | |
| 715 int clipId = propertyTreeManager.ensureCompositorClipNode( | 714 int clipId = propertyTreeManager.ensureCompositorClipNode( |
| 716 pendingLayer.propertyTreeState.clip()); | 715 pendingLayer.propertyTreeState.clip()); |
| 717 int effectId = propertyTreeManager.switchToEffectNode( | 716 int effectId = propertyTreeManager.switchToEffectNode( |
| 718 *pendingLayer.propertyTreeState.effect()); | 717 *pendingLayer.propertyTreeState.effect()); |
| 719 | 718 |
| 720 layer->set_offset_to_transform_parent(layerOffset); | 719 layer->set_offset_to_transform_parent(layerOffset); |
| 721 layer->SetElementId(pendingLayer.propertyTreeState.compositorElementId()); | 720 layer->SetElementId(pendingLayer.propertyTreeState.compositorElementId()); |
| 722 | 721 |
| 723 m_rootLayer->AddChild(layer); | 722 m_rootLayer->AddChild(layer); |
| 724 layer->set_property_tree_sequence_number( | 723 layer->set_property_tree_sequence_number( |
| 725 PropertyTreeManager::kPropertyTreeSequenceNumber); | 724 PropertyTreeManager::kPropertyTreeSequenceNumber); |
| 726 layer->SetTransformTreeIndex(transformId); | 725 layer->SetTransformTreeIndex(transformId); |
| 727 layer->SetClipTreeIndex(clipId); | 726 layer->SetClipTreeIndex(clipId); |
| 728 layer->SetEffectTreeIndex(effectId); | 727 layer->SetEffectTreeIndex(effectId); |
| 729 layer->SetScrollTreeIndex(scrollId); | 728 if (const auto* scrollNode = transform->scrollNode()) { |
| 729 layer->SetScrollTreeIndex( |
| 730 propertyTreeManager.ensureCompositorScrollNode(scrollNode)); |
| 731 } |
| 730 | 732 |
| 731 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden); | 733 layer->SetShouldCheckBackfaceVisibility(pendingLayer.backfaceHidden); |
| 732 | 734 |
| 733 if (m_extraDataForTestingEnabled) | 735 if (m_extraDataForTestingEnabled) |
| 734 m_extraDataForTesting->contentLayers.push_back(layer); | 736 m_extraDataForTesting->contentLayers.push_back(layer); |
| 735 } | 737 } |
| 736 m_contentLayerClients.clear(); | 738 m_contentLayerClients.clear(); |
| 737 m_contentLayerClients.swap(newContentLayerClients); | 739 m_contentLayerClients.swap(newContentLayerClients); |
| 738 | 740 |
| 739 // Mark the property trees as having been rebuilt. | 741 // Mark the property trees as having been rebuilt. |
| 740 layerTree->property_trees()->sequence_number = | 742 layerTree->property_trees()->sequence_number = |
| 741 PropertyTreeManager::kPropertyTreeSequenceNumber; | 743 PropertyTreeManager::kPropertyTreeSequenceNumber; |
| 742 layerTree->property_trees()->needs_rebuild = false; | 744 layerTree->property_trees()->needs_rebuild = false; |
| 743 layerTree->property_trees()->ResetCachedData(); | 745 layerTree->property_trees()->ResetCachedData(); |
| 744 } | 746 } |
| 745 | 747 |
| 746 #ifndef NDEBUG | 748 #ifndef NDEBUG |
| 747 void PaintArtifactCompositor::showDebugData() { | 749 void PaintArtifactCompositor::showDebugData() { |
| 748 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) | 750 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) |
| 749 ->toPrettyJSONString() | 751 ->toPrettyJSONString() |
| 750 .utf8() | 752 .utf8() |
| 751 .data(); | 753 .data(); |
| 752 } | 754 } |
| 753 #endif | 755 #endif |
| 754 | 756 |
| 755 } // namespace blink | 757 } // namespace blink |
| OLD | NEW |