Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 #include "cc/scheduler/delay_based_time_source.h" | 69 #include "cc/scheduler/delay_based_time_source.h" |
| 70 #include "cc/trees/damage_tracker.h" | 70 #include "cc/trees/damage_tracker.h" |
| 71 #include "cc/trees/latency_info_swap_promise_monitor.h" | 71 #include "cc/trees/latency_info_swap_promise_monitor.h" |
| 72 #include "cc/trees/layer_tree_host.h" | 72 #include "cc/trees/layer_tree_host.h" |
| 73 #include "cc/trees/layer_tree_host_common.h" | 73 #include "cc/trees/layer_tree_host_common.h" |
| 74 #include "cc/trees/layer_tree_impl.h" | 74 #include "cc/trees/layer_tree_impl.h" |
| 75 #include "cc/trees/single_thread_proxy.h" | 75 #include "cc/trees/single_thread_proxy.h" |
| 76 #include "cc/trees/tree_synchronizer.h" | 76 #include "cc/trees/tree_synchronizer.h" |
| 77 #include "gpu/GLES2/gl2extchromium.h" | 77 #include "gpu/GLES2/gl2extchromium.h" |
| 78 #include "gpu/command_buffer/client/gles2_interface.h" | 78 #include "gpu/command_buffer/client/gles2_interface.h" |
| 79 #include "ui/gfx/frame_time.h" | |
| 80 #include "ui/gfx/geometry/rect_conversions.h" | 79 #include "ui/gfx/geometry/rect_conversions.h" |
| 81 #include "ui/gfx/geometry/scroll_offset.h" | 80 #include "ui/gfx/geometry/scroll_offset.h" |
| 82 #include "ui/gfx/geometry/size_conversions.h" | 81 #include "ui/gfx/geometry/size_conversions.h" |
| 83 #include "ui/gfx/geometry/vector2d_conversions.h" | 82 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 84 | 83 |
| 85 namespace cc { | 84 namespace cc { |
| 86 namespace { | 85 namespace { |
| 87 | 86 |
| 88 // Small helper class that saves the current viewport location as the user sees | 87 // Small helper class that saves the current viewport location as the user sees |
| 89 // it and resets to the same location. | 88 // it and resets to the same location. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 const LayerTreeSettings& settings, | 182 const LayerTreeSettings& settings, |
| 184 LayerTreeHostImplClient* client, | 183 LayerTreeHostImplClient* client, |
| 185 Proxy* proxy, | 184 Proxy* proxy, |
| 186 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 185 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 187 SharedBitmapManager* shared_bitmap_manager, | 186 SharedBitmapManager* shared_bitmap_manager, |
| 188 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 187 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 189 TaskGraphRunner* task_graph_runner, | 188 TaskGraphRunner* task_graph_runner, |
| 190 int id) | 189 int id) |
| 191 : client_(client), | 190 : client_(client), |
| 192 proxy_(proxy), | 191 proxy_(proxy), |
| 192 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | |
| 193 use_gpu_rasterization_(false), | 193 use_gpu_rasterization_(false), |
| 194 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), | 194 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), |
| 195 input_handler_client_(NULL), | 195 input_handler_client_(NULL), |
| 196 did_lock_scrolling_layer_(false), | 196 did_lock_scrolling_layer_(false), |
| 197 should_bubble_scrolls_(false), | 197 should_bubble_scrolls_(false), |
| 198 wheel_scrolling_(false), | 198 wheel_scrolling_(false), |
| 199 scroll_affects_scroll_handler_(false), | 199 scroll_affects_scroll_handler_(false), |
| 200 scroll_layer_id_when_mouse_over_scrollbar_(0), | 200 scroll_layer_id_when_mouse_over_scrollbar_(0), |
| 201 tile_priorities_dirty_(false), | 201 tile_priorities_dirty_(false), |
| 202 root_layer_scroll_offset_delegate_(NULL), | 202 root_layer_scroll_offset_delegate_(NULL), |
| 203 settings_(settings), | 203 settings_(settings), |
| 204 visible_(true), | 204 visible_(true), |
| 205 cached_managed_memory_policy_( | 205 cached_managed_memory_policy_( |
| 206 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 206 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
| 207 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 207 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 208 ManagedMemoryPolicy::kDefaultNumResourcesLimit), | 208 ManagedMemoryPolicy::kDefaultNumResourcesLimit), |
| 209 pinch_gesture_active_(false), | 209 pinch_gesture_active_(false), |
| 210 pinch_gesture_end_should_clear_scrolling_layer_(false), | 210 pinch_gesture_end_should_clear_scrolling_layer_(false), |
| 211 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), | 211 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), |
| 212 paint_time_counter_(PaintTimeCounter::Create()), | 212 paint_time_counter_(PaintTimeCounter::Create()), |
| 213 memory_history_(MemoryHistory::Create()), | 213 memory_history_(MemoryHistory::Create()), |
| 214 debug_rect_history_(DebugRectHistory::Create()), | 214 debug_rect_history_(DebugRectHistory::Create()), |
| 215 texture_mailbox_deleter_(new TextureMailboxDeleter( | 215 texture_mailbox_deleter_(new TextureMailboxDeleter( |
| 216 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 216 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 217 : proxy_->MainThreadTaskRunner())), | 217 : proxy_->MainThreadTaskRunner())), |
| 218 max_memory_needed_bytes_(0), | 218 max_memory_needed_bytes_(0), |
| 219 device_scale_factor_(1.f), | 219 device_scale_factor_(1.f), |
| 220 resourceless_software_draw_(false), | 220 resourceless_software_draw_(false), |
| 221 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | |
| 222 animation_registrar_(AnimationRegistrar::Create()), | 221 animation_registrar_(AnimationRegistrar::Create()), |
| 223 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 222 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 224 micro_benchmark_controller_(this), | 223 micro_benchmark_controller_(this), |
| 225 shared_bitmap_manager_(shared_bitmap_manager), | 224 shared_bitmap_manager_(shared_bitmap_manager), |
| 226 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 225 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 227 task_graph_runner_(task_graph_runner), | 226 task_graph_runner_(task_graph_runner), |
| 228 id_(id), | 227 id_(id), |
| 229 requires_high_res_to_draw_(false), | 228 requires_high_res_to_draw_(false), |
| 230 is_likely_to_require_a_draw_(false), | 229 is_likely_to_require_a_draw_(false), |
| 231 frame_timing_tracker_(FrameTimingTracker::Create()) { | 230 frame_timing_tracker_(FrameTimingTracker::Create()) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 if (EvictedUIResourcesExist()) { | 382 if (EvictedUIResourcesExist()) { |
| 384 TRACE_EVENT_INSTANT0( | 383 TRACE_EVENT_INSTANT0( |
| 385 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", | 384 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", |
| 386 TRACE_EVENT_SCOPE_THREAD); | 385 TRACE_EVENT_SCOPE_THREAD); |
| 387 return false; | 386 return false; |
| 388 } | 387 } |
| 389 return true; | 388 return true; |
| 390 } | 389 } |
| 391 | 390 |
| 392 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { | 391 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { |
| 392 // DCHECK(!current_begin_frame_tracker_.HasFinished()); | |
| 393 // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time) | |
| 394 // << "Called animate with unknown frame time!?"; | |
|
brianderson
2015/05/01 02:05:21
Delete?
mithro-old
2015/05/01 03:27:56
Added a TODO to enable these checks when I track d
| |
| 393 if (input_handler_client_) | 395 if (input_handler_client_) |
| 394 input_handler_client_->Animate(monotonic_time); | 396 input_handler_client_->Animate(monotonic_time); |
| 395 AnimatePageScale(monotonic_time); | 397 AnimatePageScale(monotonic_time); |
| 396 AnimateLayers(monotonic_time); | 398 AnimateLayers(monotonic_time); |
| 397 AnimateScrollbars(monotonic_time); | 399 AnimateScrollbars(monotonic_time); |
| 398 AnimateTopControls(monotonic_time); | 400 AnimateTopControls(monotonic_time); |
| 399 } | 401 } |
| 400 | 402 |
| 401 void LayerTreeHostImpl::PrepareTiles() { | 403 void LayerTreeHostImpl::PrepareTiles() { |
| 402 if (!tile_manager_) | 404 if (!tile_manager_) |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1636 0, 0); | 1638 0, 0); |
| 1637 } | 1639 } |
| 1638 } | 1640 } |
| 1639 renderer_->SwapBuffers(metadata); | 1641 renderer_->SwapBuffers(metadata); |
| 1640 return true; | 1642 return true; |
| 1641 } | 1643 } |
| 1642 | 1644 |
| 1643 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1645 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1644 // Sample the frame time now. This time will be used for updating animations | 1646 // Sample the frame time now. This time will be used for updating animations |
| 1645 // when we draw. | 1647 // when we draw. |
| 1646 DCHECK(!current_begin_frame_args_.IsValid()); | 1648 current_begin_frame_tracker_.Start(args); |
| 1647 current_begin_frame_args_ = args; | |
| 1648 // TODO(mithro): Stop overriding the frame time once the usage of frame | |
| 1649 // timing is unified. | |
| 1650 current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); | |
| 1651 | |
| 1652 // Cache the begin impl frame interval | |
| 1653 begin_impl_frame_interval_ = args.interval; | |
| 1654 | 1649 |
| 1655 if (is_likely_to_require_a_draw_) { | 1650 if (is_likely_to_require_a_draw_) { |
| 1656 // Optimistically schedule a draw. This will let us expect the tile manager | 1651 // Optimistically schedule a draw. This will let us expect the tile manager |
| 1657 // to complete its work so that we can draw new tiles within the impl frame | 1652 // to complete its work so that we can draw new tiles within the impl frame |
| 1658 // we are beginning now. | 1653 // we are beginning now. |
| 1659 SetNeedsRedraw(); | 1654 SetNeedsRedraw(); |
| 1660 } | 1655 } |
| 1661 | 1656 |
| 1662 for (auto& it : video_frame_controllers_) | 1657 for (auto& it : video_frame_controllers_) |
| 1663 it->OnBeginFrame(args); | 1658 it->OnBeginFrame(args); |
| 1664 } | 1659 } |
| 1665 | 1660 |
| 1666 void LayerTreeHostImpl::DidBeginImplFrameDeadline() { | 1661 void LayerTreeHostImpl::DidBeginImplFrameDeadline() { |
| 1667 DCHECK(current_begin_frame_args_.IsValid()); | 1662 current_begin_frame_tracker_.Finish(); |
| 1668 current_begin_frame_args_ = BeginFrameArgs(); | |
| 1669 } | 1663 } |
| 1670 | 1664 |
| 1671 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1665 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
| 1672 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1666 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
| 1673 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1667 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
| 1674 | 1668 |
| 1675 if (!inner_container) | 1669 if (!inner_container) |
| 1676 return; | 1670 return; |
| 1677 | 1671 |
| 1678 // TODO(bokan): This code is currently specific to top controls. It should be | 1672 // TODO(bokan): This code is currently specific to top controls. It should be |
| (...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3106 return; | 3100 return; |
| 3107 global_tile_state_.tree_priority = priority; | 3101 global_tile_state_.tree_priority = priority; |
| 3108 DidModifyTilePriorities(); | 3102 DidModifyTilePriorities(); |
| 3109 } | 3103 } |
| 3110 | 3104 |
| 3111 TreePriority LayerTreeHostImpl::GetTreePriority() const { | 3105 TreePriority LayerTreeHostImpl::GetTreePriority() const { |
| 3112 return global_tile_state_.tree_priority; | 3106 return global_tile_state_.tree_priority; |
| 3113 } | 3107 } |
| 3114 | 3108 |
| 3115 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { | 3109 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { |
| 3116 // Try to use the current frame time to keep animations non-jittery. But if | 3110 // TODO(mithro): Replace call with current_begin_frame_tracker_.Current() |
|
brianderson
2015/05/01 02:05:21
For my education, what are the places that call th
mithro-old
2015/05/01 03:27:56
There are a number of places mostly around cc/laye
| |
| 3117 // we're not in a frame (because this is during an input event or a delayed | 3111 // once all calls which happens outside impl frames are fixed. |
| 3118 // task), fall back to physical time. This should still be monotonic. | 3112 return current_begin_frame_tracker_.DangerousMethodCurrentOrLast(); |
| 3119 if (current_begin_frame_args_.IsValid()) | 3113 } |
| 3120 return current_begin_frame_args_; | 3114 |
| 3121 return BeginFrameArgs::Create( | 3115 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const { |
| 3122 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), | 3116 return current_begin_frame_tracker_.Interval(); |
| 3123 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); | |
| 3124 } | 3117 } |
| 3125 | 3118 |
| 3126 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 3119 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 3127 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3120 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
| 3128 scoped_refptr<base::trace_event::TracedValue> state = | 3121 scoped_refptr<base::trace_event::TracedValue> state = |
| 3129 new base::trace_event::TracedValue(); | 3122 new base::trace_event::TracedValue(); |
| 3130 AsValueWithFrameInto(frame, state.get()); | 3123 AsValueWithFrameInto(frame, state.get()); |
| 3131 return state; | 3124 return state; |
| 3132 } | 3125 } |
| 3133 | 3126 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3364 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3357 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
| 3365 | 3358 |
| 3366 curve->UpdateTarget( | 3359 curve->UpdateTarget( |
| 3367 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3360 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
| 3368 .InSecondsF(), | 3361 .InSecondsF(), |
| 3369 new_target); | 3362 new_target); |
| 3370 | 3363 |
| 3371 return true; | 3364 return true; |
| 3372 } | 3365 } |
| 3373 } // namespace cc | 3366 } // namespace cc |
| OLD | NEW |