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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
| 13 #include "cc/animation/animation_host.h" |
13 #include "cc/animation/keyframed_animation_curve.h" | 14 #include "cc/animation/keyframed_animation_curve.h" |
14 #include "cc/animation/scrollbar_animation_controller.h" | 15 #include "cc/animation/scrollbar_animation_controller.h" |
15 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 16 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
16 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 17 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
17 #include "cc/base/math_util.h" | 18 #include "cc/base/math_util.h" |
18 #include "cc/base/synced_property.h" | 19 #include "cc/base/synced_property.h" |
19 #include "cc/debug/devtools_instrumentation.h" | 20 #include "cc/debug/devtools_instrumentation.h" |
20 #include "cc/debug/traced_value.h" | 21 #include "cc/debug/traced_value.h" |
21 #include "cc/input/layer_scroll_offset_delegate.h" | 22 #include "cc/input/layer_scroll_offset_delegate.h" |
22 #include "cc/input/page_scale_animation.h" | 23 #include "cc/input/page_scale_animation.h" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 | 716 |
716 gfx::Size LayerTreeImpl::ScrollableSize() const { | 717 gfx::Size LayerTreeImpl::ScrollableSize() const { |
717 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 718 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
718 ? OuterViewportScrollLayer() | 719 ? OuterViewportScrollLayer() |
719 : InnerViewportScrollLayer(); | 720 : InnerViewportScrollLayer(); |
720 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 721 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
721 return gfx::Size(); | 722 return gfx::Size(); |
722 return root_scroll_layer->children()[0]->bounds(); | 723 return root_scroll_layer->children()[0]->bounds(); |
723 } | 724 } |
724 | 725 |
725 LayerImpl* LayerTreeImpl::LayerById(int id) { | 726 LayerImpl* LayerTreeImpl::LayerById(int id) const { |
726 LayerIdMap::iterator iter = layer_id_map_.find(id); | 727 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
727 return iter != layer_id_map_.end() ? iter->second : NULL; | 728 return iter != layer_id_map_.end() ? iter->second : NULL; |
728 } | 729 } |
729 | 730 |
730 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { | 731 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
731 DCHECK(!LayerById(layer->id())); | 732 DCHECK(!LayerById(layer->id())); |
732 layer_id_map_[layer->id()] = layer; | 733 layer_id_map_[layer->id()] = layer; |
| 734 if (layer_tree_host_impl_->animation_host()) |
| 735 layer_tree_host_impl_->animation_host()->RegisterLayer( |
| 736 layer->id(), |
| 737 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
733 } | 738 } |
734 | 739 |
735 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 740 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
736 DCHECK(LayerById(layer->id())); | 741 DCHECK(LayerById(layer->id())); |
| 742 if (layer_tree_host_impl_->animation_host()) |
| 743 layer_tree_host_impl_->animation_host()->UnregisterLayer( |
| 744 layer->id(), |
| 745 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
737 layer_id_map_.erase(layer->id()); | 746 layer_id_map_.erase(layer->id()); |
738 } | 747 } |
739 | 748 |
740 size_t LayerTreeImpl::NumLayers() { | 749 size_t LayerTreeImpl::NumLayers() { |
741 return layer_id_map_.size(); | 750 return layer_id_map_.size(); |
742 } | 751 } |
743 | 752 |
744 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { | 753 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { |
745 pending_tree->SetCurrentlyScrollingLayer( | 754 pending_tree->SetCurrentlyScrollingLayer( |
746 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), | 755 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1600 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
1592 pending_page_scale_animation_ = pending_animation.Pass(); | 1601 pending_page_scale_animation_ = pending_animation.Pass(); |
1593 } | 1602 } |
1594 | 1603 |
1595 scoped_ptr<PendingPageScaleAnimation> | 1604 scoped_ptr<PendingPageScaleAnimation> |
1596 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1605 LayerTreeImpl::TakePendingPageScaleAnimation() { |
1597 return pending_page_scale_animation_.Pass(); | 1606 return pending_page_scale_animation_.Pass(); |
1598 } | 1607 } |
1599 | 1608 |
1600 } // namespace cc | 1609 } // namespace cc |
OLD | NEW |