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 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "cc/animation/scrollbar_animation_controller.h" | 14 #include "cc/animation/scrollbar_animation_controller.h" |
15 #include "cc/animation/timing_function.h" | 15 #include "cc/animation/timing_function.h" |
16 #include "cc/base/math_util.h" | 16 #include "cc/base/math_util.h" |
17 #include "cc/base/thread.h" | |
18 #include "cc/base/util.h" | 17 #include "cc/base/util.h" |
19 #include "cc/debug/debug_rect_history.h" | 18 #include "cc/debug/debug_rect_history.h" |
20 #include "cc/debug/frame_rate_counter.h" | 19 #include "cc/debug/frame_rate_counter.h" |
21 #include "cc/debug/overdraw_metrics.h" | 20 #include "cc/debug/overdraw_metrics.h" |
22 #include "cc/debug/paint_time_counter.h" | 21 #include "cc/debug/paint_time_counter.h" |
23 #include "cc/debug/rendering_stats_instrumentation.h" | 22 #include "cc/debug/rendering_stats_instrumentation.h" |
24 #include "cc/debug/traced_value.h" | 23 #include "cc/debug/traced_value.h" |
25 #include "cc/input/page_scale_animation.h" | 24 #include "cc/input/page_scale_animation.h" |
26 #include "cc/input/top_controls_manager.h" | 25 #include "cc/input/top_controls_manager.h" |
27 #include "cc/layers/append_quads_data.h" | 26 #include "cc/layers/append_quads_data.h" |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 return draw_frame; | 759 return draw_frame; |
761 } | 760 } |
762 | 761 |
763 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 762 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
764 if (input_handler_client_) | 763 if (input_handler_client_) |
765 input_handler_client_->MainThreadHasStoppedFlinging(); | 764 input_handler_client_->MainThreadHasStoppedFlinging(); |
766 } | 765 } |
767 | 766 |
768 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( | 767 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( |
769 bool should_background_tick) { | 768 bool should_background_tick) { |
| 769 DCHECK(proxy_->IsImplThread()); |
| 770 |
770 bool enabled = should_background_tick && | 771 bool enabled = should_background_tick && |
771 !animation_registrar_->active_animation_controllers().empty(); | 772 !animation_registrar_->active_animation_controllers().empty(); |
772 | 773 |
773 // Lazily create the time_source adapter so that we can vary the interval for | 774 // Lazily create the time_source adapter so that we can vary the interval for |
774 // testing. | 775 // testing. |
775 if (!time_source_client_adapter_) { | 776 if (!time_source_client_adapter_) { |
776 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( | 777 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( |
777 this, | 778 this, |
778 DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(), | 779 DelayBasedTimeSource::Create( |
779 proxy_->CurrentThread()->TaskRunner())); | 780 LowFrequencyAnimationInterval(), |
| 781 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 782 : proxy_->MainThreadTaskRunner())); |
780 } | 783 } |
781 | 784 |
782 time_source_client_adapter_->SetActive(enabled); | 785 time_source_client_adapter_->SetActive(enabled); |
783 } | 786 } |
784 | 787 |
785 void LayerTreeHostImpl::SetViewportDamage(gfx::Rect damage_rect) { | 788 void LayerTreeHostImpl::SetViewportDamage(gfx::Rect damage_rect) { |
786 viewport_damage_rect_.Union(damage_rect); | 789 viewport_damage_rect_.Union(damage_rect); |
787 } | 790 } |
788 | 791 |
789 static inline RenderPass* FindRenderPassById( | 792 static inline RenderPass* FindRenderPassById( |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 } | 1514 } |
1512 | 1515 |
1513 // Setup BeginFrameEmulation if it's not supported natively | 1516 // Setup BeginFrameEmulation if it's not supported natively |
1514 if (!settings_.begin_frame_scheduling_enabled) { | 1517 if (!settings_.begin_frame_scheduling_enabled) { |
1515 const base::TimeDelta display_refresh_interval = | 1518 const base::TimeDelta display_refresh_interval = |
1516 base::TimeDelta::FromMicroseconds( | 1519 base::TimeDelta::FromMicroseconds( |
1517 base::Time::kMicrosecondsPerSecond / | 1520 base::Time::kMicrosecondsPerSecond / |
1518 settings_.refresh_rate); | 1521 settings_.refresh_rate); |
1519 | 1522 |
1520 output_surface->InitializeBeginFrameEmulation( | 1523 output_surface->InitializeBeginFrameEmulation( |
1521 proxy_->ImplThread() ? proxy_->ImplThread()->TaskRunner() : NULL, | 1524 proxy_->ImplThreadTaskRunner(), |
1522 settings_.throttle_frame_production, | 1525 settings_.throttle_frame_production, |
1523 display_refresh_interval); | 1526 display_refresh_interval); |
1524 } | 1527 } |
1525 | 1528 |
1526 int max_frames_pending = | 1529 int max_frames_pending = |
1527 output_surface->capabilities().max_frames_pending; | 1530 output_surface->capabilities().max_frames_pending; |
1528 if (max_frames_pending <= 0) | 1531 if (max_frames_pending <= 0) |
1529 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; | 1532 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; |
1530 output_surface->SetMaxFramesPending(max_frames_pending); | 1533 output_surface->SetMaxFramesPending(max_frames_pending); |
1531 | 1534 |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 } | 2340 } |
2338 | 2341 |
2339 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2342 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2340 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2343 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2341 paint_time_counter_->ClearHistory(); | 2344 paint_time_counter_->ClearHistory(); |
2342 | 2345 |
2343 debug_state_ = debug_state; | 2346 debug_state_ = debug_state; |
2344 } | 2347 } |
2345 | 2348 |
2346 } // namespace cc | 2349 } // namespace cc |
OLD | NEW |