| 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/paint/display_item_list.h" | 10 #include "cc/paint/display_item_list.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 const PaintArtifact& paint_artifact, | 600 const PaintArtifact& paint_artifact, |
| 601 RasterInvalidationTrackingMap<const PaintChunk>* raster_chunk_invalidations, | 601 RasterInvalidationTrackingMap<const PaintChunk>* raster_chunk_invalidations, |
| 602 bool store_debug_info, | 602 bool store_debug_info, |
| 603 CompositorElementIdSet& composited_element_ids) { | 603 CompositorElementIdSet& composited_element_ids) { |
| 604 #ifndef NDEBUG | 604 #ifndef NDEBUG |
| 605 store_debug_info = true; | 605 store_debug_info = true; |
| 606 #endif | 606 #endif |
| 607 | 607 |
| 608 DCHECK(root_layer_); | 608 DCHECK(root_layer_); |
| 609 | 609 |
| 610 cc::LayerTreeHost* layer_tree_host = root_layer_->layer_tree_host(); | |
| 611 | |
| 612 // The tree will be null after detaching and this update can be ignored. | 610 // The tree will be null after detaching and this update can be ignored. |
| 613 // See: WebViewImpl::detachPaintArtifactCompositor(). | 611 // See: WebViewImpl::detachPaintArtifactCompositor(). |
| 614 if (!layer_tree_host) | 612 cc::LayerTreeHost* host = root_layer_->layer_tree_host(); |
| 613 if (!host) |
| 615 return; | 614 return; |
| 616 | 615 |
| 617 if (extra_data_for_testing_enabled_) | 616 if (extra_data_for_testing_enabled_) |
| 618 extra_data_for_testing_ = WTF::WrapUnique(new ExtraDataForTesting); | 617 extra_data_for_testing_ = WTF::WrapUnique(new ExtraDataForTesting); |
| 619 | 618 |
| 619 // Unregister element ids for all layers. For now we rely on the |
| 620 // element id being set on the layer, but we'll both be removing |
| 621 // that for SPv2 soon. We may also shift to having multiple element |
| 622 // ids per layer. When we do either of these, we'll need to keep |
| 623 // around the element ids for unregistering in some other manner. |
| 624 for (auto child : root_layer_->children()) { |
| 625 host->UnregisterElement(child->element_id(), cc::ElementListType::ACTIVE, |
| 626 child.get()); |
| 627 } |
| 620 root_layer_->RemoveAllChildren(); | 628 root_layer_->RemoveAllChildren(); |
| 621 | 629 |
| 622 root_layer_->set_property_tree_sequence_number( | 630 root_layer_->set_property_tree_sequence_number( |
| 623 g_s_property_tree_sequence_number); | 631 g_s_property_tree_sequence_number); |
| 624 | 632 |
| 625 PropertyTreeManager property_tree_manager(*layer_tree_host->property_trees(), | 633 PropertyTreeManager property_tree_manager(*host->property_trees(), |
| 626 root_layer_.get(), | 634 root_layer_.get(), |
| 627 g_s_property_tree_sequence_number); | 635 g_s_property_tree_sequence_number); |
| 628 | 636 |
| 629 Vector<PendingLayer, 0> pending_layers; | 637 Vector<PendingLayer, 0> pending_layers; |
| 630 CollectPendingLayers(paint_artifact, pending_layers); | 638 CollectPendingLayers(paint_artifact, pending_layers); |
| 631 | 639 |
| 632 Vector<std::unique_ptr<ContentLayerClientImpl>> new_content_layer_clients; | 640 Vector<std::unique_ptr<ContentLayerClientImpl>> new_content_layer_clients; |
| 633 new_content_layer_clients.ReserveCapacity( | 641 new_content_layer_clients.ReserveCapacity( |
| 634 paint_artifact.PaintChunks().size()); | 642 paint_artifact.PaintChunks().size()); |
| 635 for (const PendingLayer& pending_layer : pending_layers) { | 643 for (const PendingLayer& pending_layer : pending_layers) { |
| 636 gfx::Vector2dF layer_offset; | 644 gfx::Vector2dF layer_offset; |
| 637 scoped_refptr<cc::Layer> layer = CompositedLayerForPendingLayer( | 645 scoped_refptr<cc::Layer> layer = CompositedLayerForPendingLayer( |
| 638 paint_artifact, pending_layer, layer_offset, new_content_layer_clients, | 646 paint_artifact, pending_layer, layer_offset, new_content_layer_clients, |
| 639 raster_chunk_invalidations, store_debug_info); | 647 raster_chunk_invalidations, store_debug_info); |
| 640 | 648 |
| 641 const auto* transform = pending_layer.property_tree_state.Transform(); | 649 const auto* transform = pending_layer.property_tree_state.Transform(); |
| 642 int transform_id = | 650 int transform_id = |
| 643 property_tree_manager.EnsureCompositorTransformNode(transform); | 651 property_tree_manager.EnsureCompositorTransformNode(transform); |
| 644 int clip_id = property_tree_manager.EnsureCompositorClipNode( | 652 int clip_id = property_tree_manager.EnsureCompositorClipNode( |
| 645 pending_layer.property_tree_state.Clip()); | 653 pending_layer.property_tree_state.Clip()); |
| 646 int effect_id = property_tree_manager.SwitchToEffectNode( | 654 int effect_id = property_tree_manager.SwitchToEffectNode( |
| 647 *pending_layer.property_tree_state.Effect()); | 655 *pending_layer.property_tree_state.Effect()); |
| 648 | 656 |
| 649 layer->set_offset_to_transform_parent(layer_offset); | 657 layer->set_offset_to_transform_parent(layer_offset); |
| 650 CompositorElementId element_id = | 658 CompositorElementId element_id = |
| 651 pending_layer.property_tree_state.GetCompositorElementId( | 659 pending_layer.property_tree_state.GetCompositorElementId( |
| 652 composited_element_ids); | 660 composited_element_ids); |
| 653 if (element_id) { | 661 if (element_id) { |
| 662 // TODO(wkorman): Cease setting element id on layer once |
| 663 // animation subsystem no longer requires element id to layer |
| 664 // map. http://crbug.com/709137 |
| 654 layer->SetElementId(element_id); | 665 layer->SetElementId(element_id); |
| 655 composited_element_ids.insert(element_id); | 666 composited_element_ids.insert(element_id); |
| 656 } | 667 } |
| 657 | 668 |
| 658 root_layer_->AddChild(layer); | 669 root_layer_->AddChild(layer); |
| 670 // TODO(wkorman): Once we've removed all uses of |
| 671 // LayerTreeHost::{LayerByElementId,element_layers_map} we can |
| 672 // revise element register/unregister to cease passing layer and |
| 673 // only register/unregister element id with the mutator host. |
| 674 if (element_id) { |
| 675 host->RegisterElement(element_id, cc::ElementListType::ACTIVE, |
| 676 layer.get()); |
| 677 } |
| 678 |
| 659 layer->set_property_tree_sequence_number(g_s_property_tree_sequence_number); | 679 layer->set_property_tree_sequence_number(g_s_property_tree_sequence_number); |
| 660 layer->SetTransformTreeIndex(transform_id); | 680 layer->SetTransformTreeIndex(transform_id); |
| 661 layer->SetClipTreeIndex(clip_id); | 681 layer->SetClipTreeIndex(clip_id); |
| 662 layer->SetEffectTreeIndex(effect_id); | 682 layer->SetEffectTreeIndex(effect_id); |
| 663 property_tree_manager.UpdateLayerScrollMapping(layer.get(), transform); | 683 property_tree_manager.UpdateLayerScrollMapping(layer.get(), transform); |
| 664 | 684 |
| 665 layer->SetShouldCheckBackfaceVisibility(pending_layer.backface_hidden); | 685 layer->SetShouldCheckBackfaceVisibility(pending_layer.backface_hidden); |
| 666 | 686 |
| 667 if (extra_data_for_testing_enabled_) | 687 if (extra_data_for_testing_enabled_) |
| 668 extra_data_for_testing_->content_layers.push_back(layer); | 688 extra_data_for_testing_->content_layers.push_back(layer); |
| 669 } | 689 } |
| 670 content_layer_clients_.clear(); | 690 content_layer_clients_.clear(); |
| 671 content_layer_clients_.swap(new_content_layer_clients); | 691 content_layer_clients_.swap(new_content_layer_clients); |
| 672 | 692 |
| 673 // Mark the property trees as having been rebuilt. | 693 // Mark the property trees as having been rebuilt. |
| 674 layer_tree_host->property_trees()->sequence_number = | 694 host->property_trees()->sequence_number = g_s_property_tree_sequence_number; |
| 675 g_s_property_tree_sequence_number; | 695 host->property_trees()->needs_rebuild = false; |
| 676 layer_tree_host->property_trees()->needs_rebuild = false; | 696 host->property_trees()->ResetCachedData(); |
| 677 layer_tree_host->property_trees()->ResetCachedData(); | |
| 678 | 697 |
| 679 g_s_property_tree_sequence_number++; | 698 g_s_property_tree_sequence_number++; |
| 680 } | 699 } |
| 681 | 700 |
| 682 #ifndef NDEBUG | 701 #ifndef NDEBUG |
| 683 void PaintArtifactCompositor::ShowDebugData() { | 702 void PaintArtifactCompositor::ShowDebugData() { |
| 684 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo) | 703 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo) |
| 685 ->ToPrettyJSONString() | 704 ->ToPrettyJSONString() |
| 686 .Utf8() | 705 .Utf8() |
| 687 .data(); | 706 .data(); |
| 688 } | 707 } |
| 689 #endif | 708 #endif |
| 690 | 709 |
| 691 } // namespace blink | 710 } // namespace blink |
| OLD | NEW |