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 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 0, 0); | 1643 0, 0); |
1644 } | 1644 } |
1645 } | 1645 } |
1646 renderer_->SwapBuffers(metadata); | 1646 renderer_->SwapBuffers(metadata); |
1647 return true; | 1647 return true; |
1648 } | 1648 } |
1649 | 1649 |
1650 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1650 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1651 // Sample the frame time now. This time will be used for updating animations | 1651 // Sample the frame time now. This time will be used for updating animations |
1652 // when we draw. | 1652 // when we draw. |
1653 UpdateCurrentBeginFrameArgs(args); | 1653 DCHECK(!current_begin_frame_args_.IsValid()); |
| 1654 current_begin_frame_args_ = args; |
| 1655 // TODO(mithro): Stop overriding the frame time once the usage of frame |
| 1656 // timing is unified. |
| 1657 current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); |
| 1658 |
1654 // Cache the begin impl frame interval | 1659 // Cache the begin impl frame interval |
1655 begin_impl_frame_interval_ = args.interval; | 1660 begin_impl_frame_interval_ = args.interval; |
1656 | 1661 |
1657 if (is_likely_to_require_a_draw_) { | 1662 if (is_likely_to_require_a_draw_) { |
1658 // Optimistically schedule a draw. This will let us expect the tile manager | 1663 // Optimistically schedule a draw. This will let us expect the tile manager |
1659 // to complete its work so that we can draw new tiles within the impl frame | 1664 // to complete its work so that we can draw new tiles within the impl frame |
1660 // we are beginning now. | 1665 // we are beginning now. |
1661 SetNeedsRedraw(); | 1666 SetNeedsRedraw(); |
1662 } | 1667 } |
1663 | 1668 |
1664 for (auto& it : video_frame_controllers_) | 1669 for (auto& it : video_frame_controllers_) |
1665 it->OnBeginFrame(args); | 1670 it->OnBeginFrame(args); |
1666 } | 1671 } |
1667 | 1672 |
| 1673 void LayerTreeHostImpl::DidFinishImplFrame() { |
| 1674 DCHECK(current_begin_frame_args_.IsValid()); |
| 1675 current_begin_frame_args_ = BeginFrameArgs(); |
| 1676 } |
| 1677 |
1668 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1678 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
1669 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1679 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
1670 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1680 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1671 | 1681 |
1672 if (!inner_container) | 1682 if (!inner_container) |
1673 return; | 1683 return; |
1674 | 1684 |
1675 // TODO(bokan): This code is currently specific to top controls. It should be | 1685 // TODO(bokan): This code is currently specific to top controls. It should be |
1676 // made general. crbug.com/464814. | 1686 // made general. crbug.com/464814. |
1677 if (!TopControlsHeight()) { | 1687 if (!TopControlsHeight()) { |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3102 if (global_tile_state_.tree_priority == priority) | 3112 if (global_tile_state_.tree_priority == priority) |
3103 return; | 3113 return; |
3104 global_tile_state_.tree_priority = priority; | 3114 global_tile_state_.tree_priority = priority; |
3105 DidModifyTilePriorities(); | 3115 DidModifyTilePriorities(); |
3106 } | 3116 } |
3107 | 3117 |
3108 TreePriority LayerTreeHostImpl::GetTreePriority() const { | 3118 TreePriority LayerTreeHostImpl::GetTreePriority() const { |
3109 return global_tile_state_.tree_priority; | 3119 return global_tile_state_.tree_priority; |
3110 } | 3120 } |
3111 | 3121 |
3112 void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs( | |
3113 const BeginFrameArgs& args) { | |
3114 DCHECK(!current_begin_frame_args_.IsValid()); | |
3115 current_begin_frame_args_ = args; | |
3116 // TODO(skyostil): Stop overriding the frame time once the usage of frame | |
3117 // timing is unified. | |
3118 current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); | |
3119 } | |
3120 | |
3121 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() { | |
3122 current_begin_frame_args_ = BeginFrameArgs(); | |
3123 } | |
3124 | |
3125 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { | 3122 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { |
3126 // Try to use the current frame time to keep animations non-jittery. But if | 3123 // Try to use the current frame time to keep animations non-jittery. But if |
3127 // we're not in a frame (because this is during an input event or a delayed | 3124 // we're not in a frame (because this is during an input event or a delayed |
3128 // task), fall back to physical time. This should still be monotonic. | 3125 // task), fall back to physical time. This should still be monotonic. |
3129 if (current_begin_frame_args_.IsValid()) | 3126 if (current_begin_frame_args_.IsValid()) |
3130 return current_begin_frame_args_; | 3127 return current_begin_frame_args_; |
3131 return BeginFrameArgs::Create( | 3128 return BeginFrameArgs::Create( |
3132 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), | 3129 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), |
3133 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); | 3130 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); |
3134 } | 3131 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3371 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3375 | 3372 |
3376 curve->UpdateTarget( | 3373 curve->UpdateTarget( |
3377 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3374 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3378 .InSecondsF(), | 3375 .InSecondsF(), |
3379 new_target); | 3376 new_target); |
3380 | 3377 |
3381 return true; | 3378 return true; |
3382 } | 3379 } |
3383 } // namespace cc | 3380 } // namespace cc |
OLD | NEW |