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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 layers.scroll = nullptr; | 493 layers.scroll = nullptr; |
494 | 494 |
495 if (!layers.main && !layers.scroll) | 495 if (!layers.main && !layers.scroll) |
496 element_layers_map_.erase(layer->element_id()); | 496 element_layers_map_.erase(layer->element_id()); |
497 } | 497 } |
498 | 498 |
499 void LayerTreeImpl::AddToOpacityAnimationsMap(int id, float opacity) { | 499 void LayerTreeImpl::AddToOpacityAnimationsMap(int id, float opacity) { |
500 opacity_animations_map_[id] = opacity; | 500 opacity_animations_map_[id] = opacity; |
501 } | 501 } |
502 | 502 |
| 503 void LayerTreeImpl::AddToTransformAnimationsMap(int id, |
| 504 gfx::Transform transform) { |
| 505 transform_animations_map_[id] = transform; |
| 506 } |
| 507 |
503 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( | 508 LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( |
504 uint64_t element_id) { | 509 uint64_t element_id) { |
505 auto iter = element_layers_map_.find(element_id); | 510 auto iter = element_layers_map_.find(element_id); |
506 if (iter == element_layers_map_.end()) | 511 if (iter == element_layers_map_.end()) |
507 return ElementLayers(); | 512 return ElementLayers(); |
508 | 513 |
509 return iter->second; | 514 return iter->second; |
510 } | 515 } |
511 | 516 |
512 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { | 517 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { | 577 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { |
573 // TODO(enne): This should get replaced by pulling out scrolling and | 578 // TODO(enne): This should get replaced by pulling out scrolling and |
574 // animations into their own trees. Then scrolls and animations would have | 579 // animations into their own trees. Then scrolls and animations would have |
575 // their own ways of synchronizing across commits. This occurs to push | 580 // their own ways of synchronizing across commits. This occurs to push |
576 // updates from scrolling deltas on the compositor thread that have occurred | 581 // updates from scrolling deltas on the compositor thread that have occurred |
577 // after begin frame and updates from animations that have ticked since begin | 582 // after begin frame and updates from animations that have ticked since begin |
578 // frame to a newly-committed property tree. | 583 // frame to a newly-committed property tree. |
579 if (!root_layer()) | 584 if (!root_layer()) |
580 return; | 585 return; |
581 for (auto& layer_id_to_opacity : opacity_animations_map_) { | 586 for (auto& layer_id_to_opacity : opacity_animations_map_) { |
582 if (LayerImpl* layer = LayerById(layer_id_to_opacity.first)) { | 587 const int id = layer_id_to_opacity.first; |
583 EffectNode* node = | 588 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) { |
584 property_trees_.effect_tree.Node(layer->effect_tree_index()); | 589 EffectNode* node = property_trees_.effect_tree.Node( |
585 if (node->owner_id != layer->id() || | 590 property_trees_.effect_id_to_index_map[id]); |
586 !node->data.is_currently_animating_opacity) | 591 if (!node->data.is_currently_animating_opacity || |
| 592 node->data.opacity == layer_id_to_opacity.second) |
587 continue; | 593 continue; |
588 node->data.opacity = layer_id_to_opacity.second; | 594 node->data.opacity = layer_id_to_opacity.second; |
589 property_trees_.effect_tree.set_needs_update(true); | 595 property_trees_.effect_tree.set_needs_update(true); |
590 } | 596 } |
591 } | 597 } |
592 opacity_animations_map_.clear(); | 598 opacity_animations_map_.clear(); |
| 599 |
| 600 for (auto& layer_id_to_transform : transform_animations_map_) { |
| 601 const int id = layer_id_to_transform.first; |
| 602 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 603 id)) { |
| 604 TransformNode* node = property_trees_.transform_tree.Node( |
| 605 property_trees_.transform_id_to_index_map[id]); |
| 606 if (!node->data.is_currently_animating || |
| 607 node->data.local == layer_id_to_transform.second) |
| 608 continue; |
| 609 node->data.local = layer_id_to_transform.second; |
| 610 node->data.needs_local_transform_update = true; |
| 611 property_trees_.transform_tree.set_needs_update(true); |
| 612 } |
| 613 } |
| 614 transform_animations_map_.clear(); |
| 615 |
593 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { | 616 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { |
594 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); | 617 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); |
595 }); | 618 }); |
596 } | 619 } |
597 | 620 |
598 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { | 621 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
599 DCHECK(IsActiveTree()); | 622 DCHECK(IsActiveTree()); |
600 if (page_scale_factor()->SetCurrent( | 623 if (page_scale_factor()->SetCurrent( |
601 ClampPageScaleFactorToLimits(active_page_scale))) { | 624 ClampPageScaleFactorToLimits(active_page_scale))) { |
602 DidUpdatePageScale(); | 625 DidUpdatePageScale(); |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 } | 2054 } |
2032 | 2055 |
2033 void LayerTreeImpl::ResetAllChangeTracking() { | 2056 void LayerTreeImpl::ResetAllChangeTracking() { |
2034 layers_that_should_push_properties_.clear(); | 2057 layers_that_should_push_properties_.clear(); |
2035 for (auto* layer : *this) | 2058 for (auto* layer : *this) |
2036 layer->ResetChangeTracking(); | 2059 layer->ResetChangeTracking(); |
2037 property_trees_.ResetAllChangeTracking(); | 2060 property_trees_.ResetAllChangeTracking(); |
2038 } | 2061 } |
2039 | 2062 |
2040 } // namespace cc | 2063 } // namespace cc |
OLD | NEW |