| 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/metrics/histogram.h" |
| 11 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 12 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 13 #include "cc/animation/animation_host.h" | 14 #include "cc/animation/animation_host.h" |
| 14 #include "cc/animation/keyframed_animation_curve.h" | 15 #include "cc/animation/keyframed_animation_curve.h" |
| 15 #include "cc/animation/scrollbar_animation_controller.h" | 16 #include "cc/animation/scrollbar_animation_controller.h" |
| 16 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 17 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
| 17 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 18 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
| 18 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
| 19 #include "cc/base/synced_property.h" | 20 #include "cc/base/synced_property.h" |
| 20 #include "cc/debug/devtools_instrumentation.h" | 21 #include "cc/debug/devtools_instrumentation.h" |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 gfx::Size LayerTreeImpl::ScrollableSize() const { | 719 gfx::Size LayerTreeImpl::ScrollableSize() const { |
| 719 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 720 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 720 ? OuterViewportScrollLayer() | 721 ? OuterViewportScrollLayer() |
| 721 : InnerViewportScrollLayer(); | 722 : InnerViewportScrollLayer(); |
| 722 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 723 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
| 723 return gfx::Size(); | 724 return gfx::Size(); |
| 724 return root_scroll_layer->children()[0]->bounds(); | 725 return root_scroll_layer->children()[0]->bounds(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 LayerImpl* LayerTreeImpl::LayerById(int id) const { | 728 LayerImpl* LayerTreeImpl::LayerById(int id) const { |
| 729 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 728 LayerIdMap::const_iterator iter = layer_id_map_.find(id); | 730 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 731 find_layer_by_id_stats_ += base::TimeTicks::Now() - start_time; |
| 729 return iter != layer_id_map_.end() ? iter->second : NULL; | 732 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 730 } | 733 } |
| 731 | 734 |
| 732 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { | 735 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
| 733 DCHECK(!LayerById(layer->id())); | 736 DCHECK(!LayerById(layer->id())); |
| 734 layer_id_map_[layer->id()] = layer; | 737 layer_id_map_[layer->id()] = layer; |
| 735 if (layer_tree_host_impl_->animation_host()) | 738 if (layer_tree_host_impl_->animation_host()) |
| 736 layer_tree_host_impl_->animation_host()->RegisterLayer(layer->id(), | 739 layer_tree_host_impl_->animation_host()->RegisterLayer(layer->id(), |
| 737 IsActiveTree()); | 740 IsActiveTree()); |
| 738 } | 741 } |
| 739 | 742 |
| 740 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 743 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| 741 DCHECK(LayerById(layer->id())); | 744 DCHECK(LayerById(layer->id())); |
| 742 if (layer_tree_host_impl_->animation_host()) | 745 if (layer_tree_host_impl_->animation_host()) |
| 743 layer_tree_host_impl_->animation_host()->UnregisterLayer(layer->id(), | 746 layer_tree_host_impl_->animation_host()->UnregisterLayer(layer->id(), |
| 744 IsActiveTree()); | 747 IsActiveTree()); |
| 745 layer_id_map_.erase(layer->id()); | 748 layer_id_map_.erase(layer->id()); |
| 746 } | 749 } |
| 747 | 750 |
| 751 void LayerTreeImpl::ClearStatsOnFrameEnd() { |
| 752 find_layer_by_id_stats_ = base::TimeDelta(); |
| 753 } |
| 754 |
| 748 size_t LayerTreeImpl::NumLayers() { | 755 size_t LayerTreeImpl::NumLayers() { |
| 749 return layer_id_map_.size(); | 756 return layer_id_map_.size(); |
| 750 } | 757 } |
| 751 | 758 |
| 752 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { | 759 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { |
| 753 pending_tree->SetCurrentlyScrollingLayer( | 760 pending_tree->SetCurrentlyScrollingLayer( |
| 754 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), | 761 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), |
| 755 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0)); | 762 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0)); |
| 756 } | 763 } |
| 757 | 764 |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 const gfx::BoxF& box, | 1731 const gfx::BoxF& box, |
| 1725 gfx::BoxF* bounds) const { | 1732 gfx::BoxF* bounds) const { |
| 1726 *bounds = gfx::BoxF(); | 1733 *bounds = gfx::BoxF(); |
| 1727 return layer_tree_host_impl_->animation_host() | 1734 return layer_tree_host_impl_->animation_host() |
| 1728 ? layer_tree_host_impl_->animation_host() | 1735 ? layer_tree_host_impl_->animation_host() |
| 1729 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 1736 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
| 1730 : true; | 1737 : true; |
| 1731 } | 1738 } |
| 1732 | 1739 |
| 1733 } // namespace cc | 1740 } // namespace cc |
| OLD | NEW |