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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <map> | 12 #include <map> |
13 #include <set> | 13 #include <set> |
14 #include <unordered_map> | 14 #include <unordered_map> |
15 #include <utility> | 15 #include <utility> |
16 | 16 |
17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 18 #include "base/bind.h" |
18 #include "base/containers/small_map.h" | 19 #include "base/containers/small_map.h" |
19 #include "base/json/json_writer.h" | 20 #include "base/json/json_writer.h" |
20 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
21 #include "base/numerics/safe_conversions.h" | 22 #include "base/numerics/safe_conversions.h" |
22 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
24 #include "base/trace_event/trace_event_argument.h" | 25 #include "base/trace_event/trace_event_argument.h" |
25 #include "cc/animation/animation_events.h" | 26 #include "cc/animation/animation_events.h" |
26 #include "cc/animation/animation_host.h" | 27 #include "cc/animation/animation_host.h" |
| 28 #include "cc/animation/animation_id_provider.h" |
| 29 #include "cc/animation/scroll_offset_animation_curve.h" |
27 #include "cc/animation/timing_function.h" | 30 #include "cc/animation/timing_function.h" |
28 #include "cc/base/histograms.h" | 31 #include "cc/base/histograms.h" |
29 #include "cc/base/math_util.h" | 32 #include "cc/base/math_util.h" |
30 #include "cc/debug/benchmark_instrumentation.h" | 33 #include "cc/debug/benchmark_instrumentation.h" |
31 #include "cc/debug/debug_rect_history.h" | 34 #include "cc/debug/debug_rect_history.h" |
32 #include "cc/debug/devtools_instrumentation.h" | 35 #include "cc/debug/devtools_instrumentation.h" |
33 #include "cc/debug/frame_rate_counter.h" | 36 #include "cc/debug/frame_rate_counter.h" |
34 #include "cc/debug/frame_viewer_instrumentation.h" | 37 #include "cc/debug/frame_viewer_instrumentation.h" |
35 #include "cc/debug/rendering_stats_instrumentation.h" | 38 #include "cc/debug/rendering_stats_instrumentation.h" |
36 #include "cc/debug/traced_value.h" | 39 #include "cc/debug/traced_value.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 output_is_secure_(false), | 232 output_is_secure_(false), |
230 animation_host_(), | 233 animation_host_(), |
231 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 234 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
232 micro_benchmark_controller_(this), | 235 micro_benchmark_controller_(this), |
233 shared_bitmap_manager_(shared_bitmap_manager), | 236 shared_bitmap_manager_(shared_bitmap_manager), |
234 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 237 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
235 task_graph_runner_(task_graph_runner), | 238 task_graph_runner_(task_graph_runner), |
236 id_(id), | 239 id_(id), |
237 requires_high_res_to_draw_(false), | 240 requires_high_res_to_draw_(false), |
238 is_likely_to_require_a_draw_(false), | 241 is_likely_to_require_a_draw_(false), |
239 frame_timing_tracker_(FrameTimingTracker::Create(this)) { | 242 frame_timing_tracker_(FrameTimingTracker::Create(this)), |
| 243 mutator_(nullptr) { |
240 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); | 244 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); |
241 animation_host_->SetMutatorHostClient(this); | 245 animation_host_->SetMutatorHostClient(this); |
242 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); | 246 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); |
243 | 247 |
244 DCHECK(task_runner_provider_->IsImplThread()); | 248 DCHECK(task_runner_provider_->IsImplThread()); |
245 DidVisibilityChange(this, visible_); | 249 DidVisibilityChange(this, visible_); |
246 | 250 |
247 SetDebugState(settings.initial_debug_state); | 251 SetDebugState(settings.initial_debug_state); |
248 | 252 |
249 // LTHI always has an active tree. | 253 // LTHI always has an active tree. |
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2244 request_ids, start_time, end_time, active_tree_->source_frame_number()); | 2248 request_ids, start_time, end_time, active_tree_->source_frame_number()); |
2245 } | 2249 } |
2246 | 2250 |
2247 void LayerTreeHostImpl::PostFrameTimingEvents( | 2251 void LayerTreeHostImpl::PostFrameTimingEvents( |
2248 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 2252 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
2249 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 2253 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
2250 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), | 2254 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), |
2251 std::move(main_frame_events)); | 2255 std::move(main_frame_events)); |
2252 } | 2256 } |
2253 | 2257 |
| 2258 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
| 2259 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 2260 "LayerTreeHostImpl::SetLayerTreeMutator"); |
| 2261 mutator_ = mutator; |
| 2262 } |
| 2263 |
2254 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2264 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2255 ClearUIResources(); | 2265 ClearUIResources(); |
2256 tile_manager_->FinishTasksAndCleanUp(); | 2266 tile_manager_->FinishTasksAndCleanUp(); |
2257 resource_pool_ = nullptr; | 2267 resource_pool_ = nullptr; |
2258 tile_task_worker_pool_ = nullptr; | 2268 tile_task_worker_pool_ = nullptr; |
2259 single_thread_synchronous_task_graph_runner_ = nullptr; | 2269 single_thread_synchronous_task_graph_runner_ = nullptr; |
2260 image_decode_controller_ = nullptr; | 2270 image_decode_controller_ = nullptr; |
2261 } | 2271 } |
2262 | 2272 |
2263 void LayerTreeHostImpl::ReleaseOutputSurface() { | 2273 void LayerTreeHostImpl::ReleaseOutputSurface() { |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 viewport()->PinchEnd(); | 3286 viewport()->PinchEnd(); |
3277 top_controls_manager_->PinchEnd(); | 3287 top_controls_manager_->PinchEnd(); |
3278 client_->SetNeedsCommitOnImplThread(); | 3288 client_->SetNeedsCommitOnImplThread(); |
3279 // When a pinch ends, we may be displaying content cached at incorrect scales, | 3289 // When a pinch ends, we may be displaying content cached at incorrect scales, |
3280 // so updating draw properties and drawing will ensure we are using the right | 3290 // so updating draw properties and drawing will ensure we are using the right |
3281 // scales that we want when we're not inside a pinch. | 3291 // scales that we want when we're not inside a pinch. |
3282 active_tree_->set_needs_update_draw_properties(); | 3292 active_tree_->set_needs_update_draw_properties(); |
3283 SetNeedsRedraw(); | 3293 SetNeedsRedraw(); |
3284 } | 3294 } |
3285 | 3295 |
| 3296 scoped_ptr<BeginFrameCallbackList> |
| 3297 LayerTreeHostImpl::ProcessLayerTreeMutations() { |
| 3298 auto callbacks = make_scoped_ptr(new BeginFrameCallbackList()); |
| 3299 if (mutator_) { |
| 3300 const base::Closure& callback = mutator_->TakeMutations(); |
| 3301 if (!callback.is_null()) |
| 3302 callbacks->push_back(callback); |
| 3303 } |
| 3304 return callbacks; |
| 3305 } |
| 3306 |
3286 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 3307 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
3287 LayerImpl* root_layer) { | 3308 LayerImpl* root_layer) { |
3288 if (!root_layer) | 3309 if (!root_layer) |
3289 return; | 3310 return; |
3290 | 3311 |
3291 return root_layer->layer_tree_impl() | 3312 return root_layer->layer_tree_impl() |
3292 ->property_trees() | 3313 ->property_trees() |
3293 ->scroll_tree.CollectScrollDeltas(scroll_info); | 3314 ->scroll_tree.CollectScrollDeltas(scroll_info); |
3294 } | 3315 } |
3295 | 3316 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3922 return task_runner_provider_->HasImplThread(); | 3943 return task_runner_provider_->HasImplThread(); |
3923 } | 3944 } |
3924 | 3945 |
3925 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3946 bool LayerTreeHostImpl::CommitToActiveTree() const { |
3926 // In single threaded mode we skip the pending tree and commit directly to the | 3947 // In single threaded mode we skip the pending tree and commit directly to the |
3927 // active tree. | 3948 // active tree. |
3928 return !task_runner_provider_->HasImplThread(); | 3949 return !task_runner_provider_->HasImplThread(); |
3929 } | 3950 } |
3930 | 3951 |
3931 } // namespace cc | 3952 } // namespace cc |
OLD | NEW |