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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 772 |
772 gfx::Size LayerTreeImpl::ScrollableSize() const { | 773 gfx::Size LayerTreeImpl::ScrollableSize() const { |
773 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 774 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
774 ? OuterViewportScrollLayer() | 775 ? OuterViewportScrollLayer() |
775 : InnerViewportScrollLayer(); | 776 : InnerViewportScrollLayer(); |
776 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 777 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
777 return gfx::Size(); | 778 return gfx::Size(); |
778 return root_scroll_layer->children()[0]->bounds(); | 779 return root_scroll_layer->children()[0]->bounds(); |
779 } | 780 } |
780 | 781 |
781 LayerImpl* LayerTreeImpl::LayerById(int id) { | 782 LayerImpl* LayerTreeImpl::LayerById(int id) const { |
782 LayerIdMap::iterator iter = layer_id_map_.find(id); | 783 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
783 return iter != layer_id_map_.end() ? iter->second : NULL; | 784 return iter != layer_id_map_.end() ? iter->second : NULL; |
784 } | 785 } |
785 | 786 |
786 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { | 787 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
787 DCHECK(!LayerById(layer->id())); | 788 DCHECK(!LayerById(layer->id())); |
788 layer_id_map_[layer->id()] = layer; | 789 layer_id_map_[layer->id()] = layer; |
| 790 if (layer_tree_host_impl_->animation_host()) |
| 791 layer_tree_host_impl_->animation_host()->RegisterLayer( |
| 792 layer->id(), |
| 793 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
789 } | 794 } |
790 | 795 |
791 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 796 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
792 DCHECK(LayerById(layer->id())); | 797 DCHECK(LayerById(layer->id())); |
| 798 if (layer_tree_host_impl_->animation_host()) |
| 799 layer_tree_host_impl_->animation_host()->UnregisterLayer( |
| 800 layer->id(), |
| 801 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
793 layer_id_map_.erase(layer->id()); | 802 layer_id_map_.erase(layer->id()); |
794 } | 803 } |
795 | 804 |
796 size_t LayerTreeImpl::NumLayers() { | 805 size_t LayerTreeImpl::NumLayers() { |
797 return layer_id_map_.size(); | 806 return layer_id_map_.size(); |
798 } | 807 } |
799 | 808 |
800 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { | 809 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { |
801 pending_tree->SetCurrentlyScrollingLayer( | 810 pending_tree->SetCurrentlyScrollingLayer( |
802 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), | 811 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1619 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
1611 pending_page_scale_animation_ = pending_animation.Pass(); | 1620 pending_page_scale_animation_ = pending_animation.Pass(); |
1612 } | 1621 } |
1613 | 1622 |
1614 scoped_ptr<PendingPageScaleAnimation> | 1623 scoped_ptr<PendingPageScaleAnimation> |
1615 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1624 LayerTreeImpl::TakePendingPageScaleAnimation() { |
1616 return pending_page_scale_animation_.Pass(); | 1625 return pending_page_scale_animation_.Pass(); |
1617 } | 1626 } |
1618 | 1627 |
1619 } // namespace cc | 1628 } // namespace cc |
OLD | NEW |