| 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/PropertyTreeManager.h" | 5 #include "platform/graphics/compositing/PropertyTreeManager.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/trees/clip_node.h" | 8 #include "cc/trees/clip_node.h" |
| 9 #include "cc/trees/effect_node.h" | 9 #include "cc/trees/effect_node.h" |
| 10 #include "cc/trees/layer_tree_host.h" | 10 #include "cc/trees/layer_tree_host.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 void PropertyTreeManager::SetupRootEffectNode() { | 122 void PropertyTreeManager::SetupRootEffectNode() { |
| 123 // cc is hardcoded to use effect node index 1 for root render surface. | 123 // cc is hardcoded to use effect node index 1 for root render surface. |
| 124 cc::EffectTree& effect_tree = property_trees_.effect_tree; | 124 cc::EffectTree& effect_tree = property_trees_.effect_tree; |
| 125 effect_tree.clear(); | 125 effect_tree.clear(); |
| 126 property_trees_.element_id_to_effect_node_index.clear(); | 126 property_trees_.element_id_to_effect_node_index.clear(); |
| 127 cc::EffectNode& effect_node = | 127 cc::EffectNode& effect_node = |
| 128 *effect_tree.Node(effect_tree.Insert(cc::EffectNode(), kInvalidNodeId)); | 128 *effect_tree.Node(effect_tree.Insert(cc::EffectNode(), kInvalidNodeId)); |
| 129 DCHECK_EQ(effect_node.id, kSecondaryRootNodeId); | 129 DCHECK_EQ(effect_node.id, kSecondaryRootNodeId); |
| 130 effect_node.owning_layer_id = root_layer_->id(); | 130 effect_node.stable_id = root_layer_->id(); |
| 131 effect_node.transform_id = kRealRootNodeId; | 131 effect_node.transform_id = kRealRootNodeId; |
| 132 effect_node.clip_id = kSecondaryRootNodeId; | 132 effect_node.clip_id = kSecondaryRootNodeId; |
| 133 effect_node.has_render_surface = true; | 133 effect_node.has_render_surface = true; |
| 134 effect_tree.SetOwningLayerIdForNode(&effect_node, | |
| 135 effect_node.owning_layer_id); | |
| 136 | 134 |
| 137 effect_stack_.push_back( | 135 effect_stack_.push_back( |
| 138 BlinkEffectAndCcIdPair{EffectPaintPropertyNode::Root(), effect_node.id}); | 136 BlinkEffectAndCcIdPair{EffectPaintPropertyNode::Root(), effect_node.id}); |
| 139 root_layer_->SetEffectTreeIndex(effect_node.id); | 137 root_layer_->SetEffectTreeIndex(effect_node.id); |
| 140 } | 138 } |
| 141 | 139 |
| 142 void PropertyTreeManager::SetupRootScrollNode() { | 140 void PropertyTreeManager::SetupRootScrollNode() { |
| 143 cc::ScrollTree& scroll_tree = property_trees_.scroll_tree; | 141 cc::ScrollTree& scroll_tree = property_trees_.scroll_tree; |
| 144 scroll_tree.clear(); | 142 scroll_tree.clear(); |
| 145 property_trees_.element_id_to_scroll_node_index.clear(); | 143 property_trees_.element_id_to_scroll_node_index.clear(); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // We currently create dummy layers to host effect nodes and corresponding | 409 // We currently create dummy layers to host effect nodes and corresponding |
| 412 // render surfaces. This should be removed once cc implements better support | 410 // render surfaces. This should be removed once cc implements better support |
| 413 // for freestanding property trees. | 411 // for freestanding property trees. |
| 414 scoped_refptr<cc::Layer> dummy_layer = next_effect->EnsureDummyLayer(); | 412 scoped_refptr<cc::Layer> dummy_layer = next_effect->EnsureDummyLayer(); |
| 415 root_layer_->AddChild(dummy_layer); | 413 root_layer_->AddChild(dummy_layer); |
| 416 | 414 |
| 417 int output_clip_id = EnsureCompositorClipNode(next_effect->OutputClip()); | 415 int output_clip_id = EnsureCompositorClipNode(next_effect->OutputClip()); |
| 418 | 416 |
| 419 cc::EffectNode& effect_node = *GetEffectTree().Node(GetEffectTree().Insert( | 417 cc::EffectNode& effect_node = *GetEffectTree().Node(GetEffectTree().Insert( |
| 420 cc::EffectNode(), GetCurrentCompositorEffectNodeIndex())); | 418 cc::EffectNode(), GetCurrentCompositorEffectNodeIndex())); |
| 421 effect_node.owning_layer_id = dummy_layer->id(); | 419 effect_node.stable_id = dummy_layer->id(); |
| 422 effect_node.clip_id = output_clip_id; | 420 effect_node.clip_id = output_clip_id; |
| 423 // Every effect is supposed to have render surface enabled for grouping, | 421 // Every effect is supposed to have render surface enabled for grouping, |
| 424 // but we can get away without one if the effect is opacity-only and has only | 422 // but we can get away without one if the effect is opacity-only and has only |
| 425 // one compositing child with kSrcOver blend mode. This is both for | 423 // one compositing child with kSrcOver blend mode. This is both for |
| 426 // optimization and not introducing sub-pixel differences in layout tests. | 424 // optimization and not introducing sub-pixel differences in layout tests. |
| 427 // See PropertyTreeManager::switchToEffectNode() and above where we | 425 // See PropertyTreeManager::switchToEffectNode() and above where we |
| 428 // retrospectively enable render surface when more than one compositing child | 426 // retrospectively enable render surface when more than one compositing child |
| 429 // or a child with exotic blend mode is detected. | 427 // or a child with exotic blend mode is detected. |
| 430 // TODO(crbug.com/504464): There is ongoing work in cc to delay render surface | 428 // TODO(crbug.com/504464): There is ongoing work in cc to delay render surface |
| 431 // decision until later phase of the pipeline. Remove premature optimization | 429 // decision until later phase of the pipeline. Remove premature optimization |
| 432 // here once the work is ready. | 430 // here once the work is ready. |
| 433 if (!next_effect->Filter().IsEmpty() || | 431 if (!next_effect->Filter().IsEmpty() || |
| 434 next_effect->BlendMode() != SkBlendMode::kSrcOver) | 432 next_effect->BlendMode() != SkBlendMode::kSrcOver) |
| 435 effect_node.has_render_surface = true; | 433 effect_node.has_render_surface = true; |
| 436 effect_node.opacity = next_effect->Opacity(); | 434 effect_node.opacity = next_effect->Opacity(); |
| 437 if (next_effect->GetColorFilter() != kColorFilterNone) { | 435 if (next_effect->GetColorFilter() != kColorFilterNone) { |
| 438 // Currently color filter is only used by SVG masks. | 436 // Currently color filter is only used by SVG masks. |
| 439 // We are cutting corner here by support only specific configuration. | 437 // We are cutting corner here by support only specific configuration. |
| 440 DCHECK(next_effect->GetColorFilter() == kColorFilterLuminanceToAlpha); | 438 DCHECK(next_effect->GetColorFilter() == kColorFilterLuminanceToAlpha); |
| 441 DCHECK(next_effect->BlendMode() == SkBlendMode::kDstIn); | 439 DCHECK(next_effect->BlendMode() == SkBlendMode::kDstIn); |
| 442 DCHECK(next_effect->Filter().IsEmpty()); | 440 DCHECK(next_effect->Filter().IsEmpty()); |
| 443 effect_node.filters.Append(cc::FilterOperation::CreateReferenceFilter( | 441 effect_node.filters.Append(cc::FilterOperation::CreateReferenceFilter( |
| 444 SkColorFilterImageFilter::Make(SkLumaColorFilter::Make(), nullptr))); | 442 SkColorFilterImageFilter::Make(SkLumaColorFilter::Make(), nullptr))); |
| 445 } else { | 443 } else { |
| 446 effect_node.filters = next_effect->Filter().AsCcFilterOperations(); | 444 effect_node.filters = next_effect->Filter().AsCcFilterOperations(); |
| 447 } | 445 } |
| 448 effect_node.blend_mode = next_effect->BlendMode(); | 446 effect_node.blend_mode = next_effect->BlendMode(); |
| 449 GetEffectTree().SetOwningLayerIdForNode(&effect_node, | |
| 450 effect_node.owning_layer_id); | |
| 451 CompositorElementId compositor_element_id = | 447 CompositorElementId compositor_element_id = |
| 452 next_effect->GetCompositorElementId(); | 448 next_effect->GetCompositorElementId(); |
| 453 if (compositor_element_id) { | 449 if (compositor_element_id) { |
| 454 property_trees_.element_id_to_effect_node_index[compositor_element_id] = | 450 property_trees_.element_id_to_effect_node_index[compositor_element_id] = |
| 455 effect_node.id; | 451 effect_node.id; |
| 456 } | 452 } |
| 457 effect_stack_.push_back(BlinkEffectAndCcIdPair{next_effect, effect_node.id}); | 453 effect_stack_.push_back(BlinkEffectAndCcIdPair{next_effect, effect_node.id}); |
| 458 | 454 |
| 459 dummy_layer->set_property_tree_sequence_number(sequence_number_); | 455 dummy_layer->set_property_tree_sequence_number(sequence_number_); |
| 460 dummy_layer->SetTransformTreeIndex(kSecondaryRootNodeId); | 456 dummy_layer->SetTransformTreeIndex(kSecondaryRootNodeId); |
| 461 dummy_layer->SetClipTreeIndex(output_clip_id); | 457 dummy_layer->SetClipTreeIndex(output_clip_id); |
| 462 dummy_layer->SetEffectTreeIndex(effect_node.id); | 458 dummy_layer->SetEffectTreeIndex(effect_node.id); |
| 463 dummy_layer->SetScrollTreeIndex(kRealRootNodeId); | 459 dummy_layer->SetScrollTreeIndex(kRealRootNodeId); |
| 464 } | 460 } |
| 465 | 461 |
| 466 } // namespace blink | 462 } // namespace blink |
| OLD | NEW |