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.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_client.h" | 33 #include "cc/resources/ui_resource_client.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; |
|
dshwang
2013/11/07 10:28:51
oh, great! thx.
| |
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 visible_(true), | 138 visible_(true), |
| 147 page_scale_factor_(1.f), | 139 page_scale_factor_(1.f), |
| 148 min_page_scale_factor_(1.f), | 140 min_page_scale_factor_(1.f), |
| 149 max_page_scale_factor_(1.f), | 141 max_page_scale_factor_(1.f), |
| 150 trigger_idle_updates_(true), | 142 trigger_idle_updates_(true), |
| 151 background_color_(SK_ColorWHITE), | 143 background_color_(SK_ColorWHITE), |
| 152 has_transparent_background_(false), | 144 has_transparent_background_(false), |
| 153 partial_texture_update_requests_(0), | 145 partial_texture_update_requests_(0), |
| 154 in_paint_layer_contents_(false), | 146 in_paint_layer_contents_(false), |
| 155 total_frames_used_for_lcd_text_metrics_(0), | 147 total_frames_used_for_lcd_text_metrics_(0), |
| 156 tree_id_(GetNextTreeId()), | 148 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
| 157 next_commit_forces_redraw_(false), | 149 next_commit_forces_redraw_(false), |
| 158 shared_bitmap_manager_(manager) { | 150 shared_bitmap_manager_(manager) { |
| 159 if (settings_.accelerated_animation_enabled) | 151 if (settings_.accelerated_animation_enabled) |
| 160 animation_registrar_ = AnimationRegistrar::Create(); | 152 animation_registrar_ = AnimationRegistrar::Create(); |
| 161 rendering_stats_instrumentation_->set_record_rendering_stats( | 153 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 162 debug_state_.RecordRenderingStats()); | 154 debug_state_.RecordRenderingStats()); |
| 163 } | 155 } |
| 164 | 156 |
| 165 bool LayerTreeHost::InitializeThreaded( | 157 bool LayerTreeHost::InitializeThreaded( |
| 166 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 158 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 if (new_impl_tree_has_no_evicted_resources) { | 437 if (new_impl_tree_has_no_evicted_resources) { |
| 446 if (sync_tree->ContentsTexturesPurged()) | 438 if (sync_tree->ContentsTexturesPurged()) |
| 447 sync_tree->ResetContentsTexturesPurged(); | 439 sync_tree->ResetContentsTexturesPurged(); |
| 448 } | 440 } |
| 449 | 441 |
| 450 if (!settings_.impl_side_painting) { | 442 if (!settings_.impl_side_painting) { |
| 451 // If we're not in impl-side painting, the tree is immediately | 443 // If we're not in impl-side painting, the tree is immediately |
| 452 // considered active. | 444 // considered active. |
| 453 sync_tree->DidBecomeActive(); | 445 sync_tree->DidBecomeActive(); |
| 454 } | 446 } |
| 447 devtools_instrumentation::didCommitMainThreadFrame(id_, source_frame_number_); | |
| 455 | 448 |
| 456 source_frame_number_++; | 449 source_frame_number_++; |
| 457 } | 450 } |
| 458 | 451 |
| 459 void LayerTreeHost::WillCommit() { | 452 void LayerTreeHost::WillCommit() { |
| 460 client_->WillCommit(); | 453 client_->WillCommit(); |
| 461 } | 454 } |
| 462 | 455 |
| 463 void LayerTreeHost::UpdateHudLayer() { | 456 void LayerTreeHost::UpdateHudLayer() { |
| 464 if (debug_state_.ShowHudInfo()) { | 457 if (debug_state_.ShowHudInfo()) { |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 | 1279 |
| 1287 bool LayerTreeHost::ScheduleMicroBenchmark( | 1280 bool LayerTreeHost::ScheduleMicroBenchmark( |
| 1288 const std::string& benchmark_name, | 1281 const std::string& benchmark_name, |
| 1289 scoped_ptr<base::Value> value, | 1282 scoped_ptr<base::Value> value, |
| 1290 const MicroBenchmark::DoneCallback& callback) { | 1283 const MicroBenchmark::DoneCallback& callback) { |
| 1291 return micro_benchmark_controller_.ScheduleRun( | 1284 return micro_benchmark_controller_.ScheduleRun( |
| 1292 benchmark_name, value.Pass(), callback); | 1285 benchmark_name, value.Pass(), callback); |
| 1293 } | 1286 } |
| 1294 | 1287 |
| 1295 } // namespace cc | 1288 } // namespace cc |
| OLD | NEW |