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