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 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 0, 0); | 1664 0, 0); |
1665 } | 1665 } |
1666 } | 1666 } |
1667 renderer_->SwapBuffers(metadata); | 1667 renderer_->SwapBuffers(metadata); |
1668 return true; | 1668 return true; |
1669 } | 1669 } |
1670 | 1670 |
1671 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1671 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1672 // Sample the frame time now. This time will be used for updating animations | 1672 // Sample the frame time now. This time will be used for updating animations |
1673 // when we draw. | 1673 // when we draw. |
1674 UpdateCurrentBeginFrameArgs(args); | 1674 DCHECK(!current_begin_frame_args_.IsValid()); |
| 1675 current_begin_frame_args_ = args; |
| 1676 // TODO(mithro): Stop overriding the frame time once the usage of frame |
| 1677 // timing is unified. |
| 1678 current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); |
| 1679 |
1675 // Cache the begin impl frame interval | 1680 // Cache the begin impl frame interval |
1676 begin_impl_frame_interval_ = args.interval; | 1681 begin_impl_frame_interval_ = args.interval; |
1677 | 1682 |
1678 if (is_likely_to_require_a_draw_) { | 1683 if (is_likely_to_require_a_draw_) { |
1679 // Optimistically schedule a draw. This will let us expect the tile manager | 1684 // Optimistically schedule a draw. This will let us expect the tile manager |
1680 // to complete its work so that we can draw new tiles within the impl frame | 1685 // to complete its work so that we can draw new tiles within the impl frame |
1681 // we are beginning now. | 1686 // we are beginning now. |
1682 SetNeedsRedraw(); | 1687 SetNeedsRedraw(); |
1683 } | 1688 } |
1684 | 1689 |
1685 for (auto& it : video_frame_controllers_) | 1690 for (auto& it : video_frame_controllers_) |
1686 it->OnBeginFrame(args); | 1691 it->OnBeginFrame(args); |
1687 } | 1692 } |
1688 | 1693 |
| 1694 void LayerTreeHostImpl::DidFinishImplFrame() { |
| 1695 DCHECK(current_begin_frame_args_.IsValid()); |
| 1696 current_begin_frame_args_ = BeginFrameArgs(); |
| 1697 } |
| 1698 |
1689 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1699 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
1690 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1700 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
1691 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1701 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1692 | 1702 |
1693 if (!inner_container) | 1703 if (!inner_container) |
1694 return; | 1704 return; |
1695 | 1705 |
1696 // TODO(bokan): This code is currently specific to top controls. It should be | 1706 // TODO(bokan): This code is currently specific to top controls. It should be |
1697 // made general. crbug.com/464814. | 1707 // made general. crbug.com/464814. |
1698 if (!TopControlsHeight()) { | 1708 if (!TopControlsHeight()) { |
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 if (global_tile_state_.tree_priority == priority) | 3136 if (global_tile_state_.tree_priority == priority) |
3127 return; | 3137 return; |
3128 global_tile_state_.tree_priority = priority; | 3138 global_tile_state_.tree_priority = priority; |
3129 DidModifyTilePriorities(); | 3139 DidModifyTilePriorities(); |
3130 } | 3140 } |
3131 | 3141 |
3132 TreePriority LayerTreeHostImpl::GetTreePriority() const { | 3142 TreePriority LayerTreeHostImpl::GetTreePriority() const { |
3133 return global_tile_state_.tree_priority; | 3143 return global_tile_state_.tree_priority; |
3134 } | 3144 } |
3135 | 3145 |
3136 void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs( | |
3137 const BeginFrameArgs& args) { | |
3138 DCHECK(!current_begin_frame_args_.IsValid()); | |
3139 current_begin_frame_args_ = args; | |
3140 // TODO(skyostil): Stop overriding the frame time once the usage of frame | |
3141 // timing is unified. | |
3142 current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); | |
3143 } | |
3144 | |
3145 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() { | |
3146 current_begin_frame_args_ = BeginFrameArgs(); | |
3147 } | |
3148 | |
3149 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { | 3146 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { |
3150 // Try to use the current frame time to keep animations non-jittery. But if | 3147 // Try to use the current frame time to keep animations non-jittery. But if |
3151 // we're not in a frame (because this is during an input event or a delayed | 3148 // we're not in a frame (because this is during an input event or a delayed |
3152 // task), fall back to physical time. This should still be monotonic. | 3149 // task), fall back to physical time. This should still be monotonic. |
3153 if (current_begin_frame_args_.IsValid()) | 3150 if (current_begin_frame_args_.IsValid()) |
3154 return current_begin_frame_args_; | 3151 return current_begin_frame_args_; |
3155 return BeginFrameArgs::Create( | 3152 return BeginFrameArgs::Create( |
3156 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), | 3153 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), |
3157 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); | 3154 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); |
3158 } | 3155 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3395 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3399 | 3396 |
3400 curve->UpdateTarget( | 3397 curve->UpdateTarget( |
3401 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3398 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3402 .InSecondsF(), | 3399 .InSecondsF(), |
3403 new_target); | 3400 new_target); |
3404 | 3401 |
3405 return true; | 3402 return true; |
3406 } | 3403 } |
3407 } // namespace cc | 3404 } // namespace cc |
OLD | NEW |