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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/atomic_sequence_num.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
14 #include "base/lazy_instance.h" | |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/synchronization/lock.h" | |
20 #include "cc/animation/animation_registrar.h" | 19 #include "cc/animation/animation_registrar.h" |
21 #include "cc/animation/layer_animation_controller.h" | 20 #include "cc/animation/layer_animation_controller.h" |
22 #include "cc/base/math_util.h" | 21 #include "cc/base/math_util.h" |
23 #include "cc/debug/devtools_instrumentation.h" | 22 #include "cc/debug/devtools_instrumentation.h" |
24 #include "cc/debug/overdraw_metrics.h" | 23 #include "cc/debug/overdraw_metrics.h" |
25 #include "cc/debug/rendering_stats_instrumentation.h" | 24 #include "cc/debug/rendering_stats_instrumentation.h" |
26 #include "cc/input/top_controls_manager.h" | 25 #include "cc/input/top_controls_manager.h" |
27 #include "cc/layers/heads_up_display_layer.h" | 26 #include "cc/layers/heads_up_display_layer.h" |
28 #include "cc/layers/heads_up_display_layer_impl.h" | 27 #include "cc/layers/heads_up_display_layer_impl.h" |
29 #include "cc/layers/layer.h" | 28 #include "cc/layers/layer.h" |
30 #include "cc/layers/layer_iterator.h" | 29 #include "cc/layers/layer_iterator.h" |
31 #include "cc/layers/painted_scrollbar_layer.h" | 30 #include "cc/layers/painted_scrollbar_layer.h" |
32 #include "cc/layers/render_surface.h" | 31 #include "cc/layers/render_surface.h" |
33 #include "cc/resources/prioritized_resource_manager.h" | 32 #include "cc/resources/prioritized_resource_manager.h" |
34 #include "cc/resources/ui_resource_request.h" | 33 #include "cc/resources/ui_resource_request.h" |
35 #include "cc/trees/layer_tree_host_client.h" | 34 #include "cc/trees/layer_tree_host_client.h" |
36 #include "cc/trees/layer_tree_host_common.h" | 35 #include "cc/trees/layer_tree_host_common.h" |
37 #include "cc/trees/layer_tree_host_impl.h" | 36 #include "cc/trees/layer_tree_host_impl.h" |
38 #include "cc/trees/layer_tree_impl.h" | 37 #include "cc/trees/layer_tree_impl.h" |
39 #include "cc/trees/occlusion_tracker.h" | 38 #include "cc/trees/occlusion_tracker.h" |
40 #include "cc/trees/single_thread_proxy.h" | 39 #include "cc/trees/single_thread_proxy.h" |
41 #include "cc/trees/thread_proxy.h" | 40 #include "cc/trees/thread_proxy.h" |
42 #include "cc/trees/tree_synchronizer.h" | 41 #include "cc/trees/tree_synchronizer.h" |
43 #include "ui/gfx/size_conversions.h" | 42 #include "ui/gfx/size_conversions.h" |
44 | 43 |
45 namespace { | 44 namespace { |
46 static base::LazyInstance<base::Lock>::Leaky | 45 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; |
47 s_next_tree_id_lock = LAZY_INSTANCE_INITIALIZER; | |
48 | |
49 inline int GetNextTreeId() { | |
50 static int s_next_tree_id = 1; | |
51 base::AutoLock lock(s_next_tree_id_lock.Get()); | |
52 return s_next_tree_id++; | |
53 } | |
54 } | 46 } |
55 | 47 |
56 namespace cc { | 48 namespace cc { |
57 | 49 |
58 RendererCapabilities::RendererCapabilities() | 50 RendererCapabilities::RendererCapabilities() |
59 : best_texture_format(RGBA_8888), | 51 : best_texture_format(RGBA_8888), |
60 using_partial_swap(false), | 52 using_partial_swap(false), |
61 using_set_visibility(false), | 53 using_set_visibility(false), |
62 using_egl_image(false), | 54 using_egl_image(false), |
63 allow_partial_texture_updates(false), | 55 allow_partial_texture_updates(false), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 visible_(true), | 110 visible_(true), |
119 page_scale_factor_(1.f), | 111 page_scale_factor_(1.f), |
120 min_page_scale_factor_(1.f), | 112 min_page_scale_factor_(1.f), |
121 max_page_scale_factor_(1.f), | 113 max_page_scale_factor_(1.f), |
122 trigger_idle_updates_(true), | 114 trigger_idle_updates_(true), |
123 background_color_(SK_ColorWHITE), | 115 background_color_(SK_ColorWHITE), |
124 has_transparent_background_(false), | 116 has_transparent_background_(false), |
125 partial_texture_update_requests_(0), | 117 partial_texture_update_requests_(0), |
126 in_paint_layer_contents_(false), | 118 in_paint_layer_contents_(false), |
127 total_frames_used_for_lcd_text_metrics_(0), | 119 total_frames_used_for_lcd_text_metrics_(0), |
128 tree_id_(GetNextTreeId()), | 120 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
129 next_commit_forces_redraw_(false), | 121 next_commit_forces_redraw_(false), |
130 shared_bitmap_manager_(manager) { | 122 shared_bitmap_manager_(manager) { |
131 if (settings_.accelerated_animation_enabled) | 123 if (settings_.accelerated_animation_enabled) |
132 animation_registrar_ = AnimationRegistrar::Create(); | 124 animation_registrar_ = AnimationRegistrar::Create(); |
133 rendering_stats_instrumentation_->set_record_rendering_stats( | 125 rendering_stats_instrumentation_->set_record_rendering_stats( |
134 debug_state_.RecordRenderingStats()); | 126 debug_state_.RecordRenderingStats()); |
135 } | 127 } |
136 | 128 |
137 bool LayerTreeHost::InitializeThreaded( | 129 bool LayerTreeHost::InitializeThreaded( |
138 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 408 |
417 if (new_impl_tree_has_no_evicted_resources) { | 409 if (new_impl_tree_has_no_evicted_resources) { |
418 if (sync_tree->ContentsTexturesPurged()) | 410 if (sync_tree->ContentsTexturesPurged()) |
419 sync_tree->ResetContentsTexturesPurged(); | 411 sync_tree->ResetContentsTexturesPurged(); |
420 } | 412 } |
421 | 413 |
422 if (!settings_.impl_side_painting) { | 414 if (!settings_.impl_side_painting) { |
423 // If we're not in impl-side painting, the tree is immediately | 415 // If we're not in impl-side painting, the tree is immediately |
424 // considered active. | 416 // considered active. |
425 sync_tree->DidBecomeActive(); | 417 sync_tree->DidBecomeActive(); |
| 418 devtools_instrumentation::didActivateLayerTree(id_, source_frame_number_); |
426 } | 419 } |
427 | 420 |
428 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 421 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
429 | 422 |
430 source_frame_number_++; | 423 source_frame_number_++; |
431 } | 424 } |
432 | 425 |
433 void LayerTreeHost::WillCommit() { | 426 void LayerTreeHost::WillCommit() { |
434 client_->WillCommit(); | 427 client_->WillCommit(); |
435 } | 428 } |
(...skipping 20 matching lines...) Expand all Loading... |
456 } | 449 } |
457 | 450 |
458 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 451 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
459 LayerTreeHostImplClient* client) { | 452 LayerTreeHostImplClient* client) { |
460 DCHECK(proxy_->IsImplThread()); | 453 DCHECK(proxy_->IsImplThread()); |
461 scoped_ptr<LayerTreeHostImpl> host_impl = | 454 scoped_ptr<LayerTreeHostImpl> host_impl = |
462 LayerTreeHostImpl::Create(settings_, | 455 LayerTreeHostImpl::Create(settings_, |
463 client, | 456 client, |
464 proxy_.get(), | 457 proxy_.get(), |
465 rendering_stats_instrumentation_.get(), | 458 rendering_stats_instrumentation_.get(), |
466 shared_bitmap_manager_); | 459 shared_bitmap_manager_, |
| 460 id_); |
467 shared_bitmap_manager_ = NULL; | 461 shared_bitmap_manager_ = NULL; |
468 if (settings_.calculate_top_controls_position && | 462 if (settings_.calculate_top_controls_position && |
469 host_impl->top_controls_manager()) { | 463 host_impl->top_controls_manager()) { |
470 top_controls_manager_weak_ptr_ = | 464 top_controls_manager_weak_ptr_ = |
471 host_impl->top_controls_manager()->AsWeakPtr(); | 465 host_impl->top_controls_manager()->AsWeakPtr(); |
472 } | 466 } |
473 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); | 467 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); |
474 return host_impl.Pass(); | 468 return host_impl.Pass(); |
475 } | 469 } |
476 | 470 |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 swap_promise_list_.push_back(swap_promise.Pass()); | 1265 swap_promise_list_.push_back(swap_promise.Pass()); |
1272 } | 1266 } |
1273 | 1267 |
1274 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1268 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
1275 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1269 for (size_t i = 0; i < swap_promise_list_.size(); i++) |
1276 swap_promise_list_[i]->DidNotSwap(reason); | 1270 swap_promise_list_[i]->DidNotSwap(reason); |
1277 swap_promise_list_.clear(); | 1271 swap_promise_list_.clear(); |
1278 } | 1272 } |
1279 | 1273 |
1280 } // namespace cc | 1274 } // namespace cc |
OLD | NEW |