| 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_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 "SwapBuffers"); | 1725 "SwapBuffers"); |
| 1726 // Only add the latency component once for renderer swap, not the browser | 1726 // Only add the latency component once for renderer swap, not the browser |
| 1727 // swap. | 1727 // swap. |
| 1728 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | 1728 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
| 1729 0, nullptr)) { | 1729 0, nullptr)) { |
| 1730 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | 1730 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
| 1731 0, 0); | 1731 0, 0); |
| 1732 } | 1732 } |
| 1733 } | 1733 } |
| 1734 renderer_->SwapBuffers(metadata); | 1734 renderer_->SwapBuffers(metadata); |
| 1735 if (animation_host_) |
| 1736 animation_host_->ReportAndClearStatsOnFrameEnd(); |
| 1735 return true; | 1737 return true; |
| 1736 } | 1738 } |
| 1737 | 1739 |
| 1738 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1740 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1739 current_begin_frame_tracker_.Start(args); | 1741 current_begin_frame_tracker_.Start(args); |
| 1740 | 1742 |
| 1741 if (is_likely_to_require_a_draw_) { | 1743 if (is_likely_to_require_a_draw_) { |
| 1742 // Optimistically schedule a draw. This will let us expect the tile manager | 1744 // Optimistically schedule a draw. This will let us expect the tile manager |
| 1743 // to complete its work so that we can draw new tiles within the impl frame | 1745 // to complete its work so that we can draw new tiles within the impl frame |
| 1744 // we are beginning now. | 1746 // we are beginning now. |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3116 SetNeedsAnimate(); | 3118 SetNeedsAnimate(); |
| 3117 } | 3119 } |
| 3118 | 3120 |
| 3119 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 3121 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
| 3120 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer()) | 3122 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer()) |
| 3121 return; | 3123 return; |
| 3122 | 3124 |
| 3123 if (animation_host_) { | 3125 if (animation_host_) { |
| 3124 if (animation_host_->AnimateLayers(monotonic_time)) | 3126 if (animation_host_->AnimateLayers(monotonic_time)) |
| 3125 SetNeedsAnimate(); | 3127 SetNeedsAnimate(); |
| 3128 ReportAndClearStatsAfterAnimateLayers(); |
| 3126 } else { | 3129 } else { |
| 3127 if (animation_registrar_->AnimateLayers(monotonic_time)) | 3130 if (animation_registrar_->AnimateLayers(monotonic_time)) |
| 3128 SetNeedsAnimate(); | 3131 SetNeedsAnimate(); |
| 3129 } | 3132 } |
| 3130 } | 3133 } |
| 3131 | 3134 |
| 3132 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 3135 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
| 3133 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer()) | 3136 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer()) |
| 3134 return; | 3137 return; |
| 3135 | 3138 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3610 int layer_id) const { | 3613 int layer_id) const { |
| 3611 if (active_tree()) { | 3614 if (active_tree()) { |
| 3612 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); | 3615 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); |
| 3613 if (layer) | 3616 if (layer) |
| 3614 return layer->ScrollOffsetForAnimation(); | 3617 return layer->ScrollOffsetForAnimation(); |
| 3615 } | 3618 } |
| 3616 | 3619 |
| 3617 return gfx::ScrollOffset(); | 3620 return gfx::ScrollOffset(); |
| 3618 } | 3621 } |
| 3619 | 3622 |
| 3623 void LayerTreeHostImpl::ReportAndClearStatsAfterAnimateLayers() { |
| 3624 base::TimeDelta find_layer_by_id_stats = |
| 3625 active_tree_->find_layer_by_id_stats(); |
| 3626 active_tree_->ClearStatsOnFrameEnd(); |
| 3627 |
| 3628 if (pending_tree_) { |
| 3629 find_layer_by_id_stats += pending_tree_->find_layer_by_id_stats(); |
| 3630 pending_tree_->ClearStatsOnFrameEnd(); |
| 3631 } |
| 3632 if (recycle_tree_) { |
| 3633 find_layer_by_id_stats += recycle_tree_->find_layer_by_id_stats(); |
| 3634 recycle_tree_->ClearStatsOnFrameEnd(); |
| 3635 } |
| 3636 |
| 3637 LOCAL_HISTOGRAM_CUSTOM_COUNTS("Mutators.FindLayerImplById", |
| 3638 find_layer_by_id_stats.InMicroseconds(), 1, |
| 3639 1000, 10); |
| 3640 } |
| 3641 |
| 3620 } // namespace cc | 3642 } // namespace cc |
| OLD | NEW |