| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 ElementLayers& layers = element_layers_map_[layer->element_id()]; | 477 ElementLayers& layers = element_layers_map_[layer->element_id()]; |
| 478 if (!layer->scrollable()) | 478 if (!layer->scrollable()) |
| 479 layers.main = nullptr; | 479 layers.main = nullptr; |
| 480 if (layer->scrollable()) | 480 if (layer->scrollable()) |
| 481 layers.scroll = nullptr; | 481 layers.scroll = nullptr; |
| 482 | 482 |
| 483 if (!layers.main && !layers.scroll) | 483 if (!layers.main && !layers.scroll) |
| 484 element_layers_map_.erase(layer->element_id()); | 484 element_layers_map_.erase(layer->element_id()); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void LayerTreeImpl::AddToOpacityAnimationsMap(int id, float opacity) { |
| 488 opacity_animations_map_[id] = opacity; |
| 489 } |
| 490 |
| 487 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( | 491 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( |
| 488 uint64_t element_id) { | 492 uint64_t element_id) { |
| 489 auto iter = element_layers_map_.find(element_id); | 493 auto iter = element_layers_map_.find(element_id); |
| 490 if (iter == element_layers_map_.end()) | 494 if (iter == element_layers_map_.end()) |
| 491 return ElementLayers(); | 495 return ElementLayers(); |
| 492 | 496 |
| 493 return iter->second; | 497 return iter->second; |
| 494 } | 498 } |
| 495 | 499 |
| 496 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { | 500 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 559 |
| 556 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { | 560 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { |
| 557 // TODO(enne): This should get replaced by pulling out scrolling and | 561 // TODO(enne): This should get replaced by pulling out scrolling and |
| 558 // animations into their own trees. Then scrolls and animations would have | 562 // animations into their own trees. Then scrolls and animations would have |
| 559 // their own ways of synchronizing across commits. This occurs to push | 563 // their own ways of synchronizing across commits. This occurs to push |
| 560 // updates from scrolling deltas on the compositor thread that have occurred | 564 // updates from scrolling deltas on the compositor thread that have occurred |
| 561 // after begin frame and updates from animations that have ticked since begin | 565 // after begin frame and updates from animations that have ticked since begin |
| 562 // frame to a newly-committed property tree. | 566 // frame to a newly-committed property tree. |
| 563 if (!root_layer()) | 567 if (!root_layer()) |
| 564 return; | 568 return; |
| 569 for (auto& layer_id_to_opacity : opacity_animations_map_) { |
| 570 if (LayerImpl* layer = LayerById(layer_id_to_opacity.first)) { |
| 571 EffectNode* node = |
| 572 property_trees_.effect_tree.Node(layer->effect_tree_index()); |
| 573 if (node->owner_id != layer->id() || |
| 574 !node->data.is_currently_animating_opacity) |
| 575 continue; |
| 576 node->data.opacity = layer_id_to_opacity.second; |
| 577 property_trees_.effect_tree.set_needs_update(true); |
| 578 } |
| 579 } |
| 580 opacity_animations_map_.clear(); |
| 565 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { | 581 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { |
| 566 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); | 582 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); |
| 567 }); | 583 }); |
| 568 } | 584 } |
| 569 | 585 |
| 570 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { | 586 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
| 571 DCHECK(IsActiveTree()); | 587 DCHECK(IsActiveTree()); |
| 572 if (page_scale_factor()->SetCurrent( | 588 if (page_scale_factor()->SetCurrent( |
| 573 ClampPageScaleFactorToLimits(active_page_scale))) { | 589 ClampPageScaleFactorToLimits(active_page_scale))) { |
| 574 DidUpdatePageScale(); | 590 DidUpdatePageScale(); |
| (...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 } | 2105 } |
| 2090 | 2106 |
| 2091 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { | 2107 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { |
| 2092 layers_that_should_push_properties_.clear(); | 2108 layers_that_should_push_properties_.clear(); |
| 2093 for (auto* layer : *this) | 2109 for (auto* layer : *this) |
| 2094 layer->ResetChangeTracking(); | 2110 layer->ResetChangeTracking(); |
| 2095 property_trees_.ResetAllChangeTracking(flag); | 2111 property_trees_.ResetAllChangeTracking(flag); |
| 2096 } | 2112 } |
| 2097 | 2113 |
| 2098 } // namespace cc | 2114 } // namespace cc |
| OLD | NEW |