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