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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "cc/animation/animation_registrar.h" | 17 #include "cc/animation/animation_registrar.h" |
| 18 #include "cc/animation/layer_animation_controller.h" | 18 #include "cc/animation/layer_animation_controller.h" |
| 19 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
| 20 #include "cc/debug/devtools_instrumentation.h" | |
| 20 #include "cc/debug/overdraw_metrics.h" | 21 #include "cc/debug/overdraw_metrics.h" |
| 21 #include "cc/debug/rendering_stats_instrumentation.h" | 22 #include "cc/debug/rendering_stats_instrumentation.h" |
| 22 #include "cc/input/top_controls_manager.h" | 23 #include "cc/input/top_controls_manager.h" |
| 23 #include "cc/layers/heads_up_display_layer.h" | 24 #include "cc/layers/heads_up_display_layer.h" |
| 24 #include "cc/layers/heads_up_display_layer_impl.h" | 25 #include "cc/layers/heads_up_display_layer_impl.h" |
| 25 #include "cc/layers/layer.h" | 26 #include "cc/layers/layer.h" |
| 26 #include "cc/layers/layer_iterator.h" | 27 #include "cc/layers/layer_iterator.h" |
| 27 #include "cc/layers/render_surface.h" | 28 #include "cc/layers/render_surface.h" |
| 28 #include "cc/layers/scrollbar_layer.h" | 29 #include "cc/layers/scrollbar_layer.h" |
| 29 #include "cc/resources/prioritized_resource_manager.h" | 30 #include "cc/resources/prioritized_resource_manager.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 LayerTreeHostClient* client, | 66 LayerTreeHostClient* client, |
| 66 const LayerTreeSettings& settings, | 67 const LayerTreeSettings& settings, |
| 67 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 68 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 68 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, | 69 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, |
| 69 settings)); | 70 settings)); |
| 70 if (!layer_tree_host->Initialize(impl_task_runner)) | 71 if (!layer_tree_host->Initialize(impl_task_runner)) |
| 71 return scoped_ptr<LayerTreeHost>(); | 72 return scoped_ptr<LayerTreeHost>(); |
| 72 return layer_tree_host.Pass(); | 73 return layer_tree_host.Pass(); |
| 73 } | 74 } |
| 74 | 75 |
| 76 static int s_next_tree_id = 1; | |
| 77 | |
| 75 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, | 78 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
| 76 const LayerTreeSettings& settings) | 79 const LayerTreeSettings& settings) |
| 77 : animating_(false), | 80 : animating_(false), |
| 78 needs_full_tree_sync_(true), | 81 needs_full_tree_sync_(true), |
| 79 needs_filter_context_(false), | 82 needs_filter_context_(false), |
| 80 client_(client), | 83 client_(client), |
| 81 commit_number_(0), | 84 commit_number_(0), |
| 82 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 85 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
| 83 output_surface_can_be_initialized_(true), | 86 output_surface_can_be_initialized_(true), |
| 84 output_surface_lost_(true), | 87 output_surface_lost_(true), |
| 85 num_failed_recreate_attempts_(0), | 88 num_failed_recreate_attempts_(0), |
| 86 settings_(settings), | 89 settings_(settings), |
| 87 debug_state_(settings.initial_debug_state), | 90 debug_state_(settings.initial_debug_state), |
| 88 overdraw_bottom_height_(0.f), | 91 overdraw_bottom_height_(0.f), |
| 89 device_scale_factor_(1.f), | 92 device_scale_factor_(1.f), |
| 90 visible_(true), | 93 visible_(true), |
| 91 page_scale_factor_(1.f), | 94 page_scale_factor_(1.f), |
| 92 min_page_scale_factor_(1.f), | 95 min_page_scale_factor_(1.f), |
| 93 max_page_scale_factor_(1.f), | 96 max_page_scale_factor_(1.f), |
| 94 trigger_idle_updates_(true), | 97 trigger_idle_updates_(true), |
| 95 background_color_(SK_ColorWHITE), | 98 background_color_(SK_ColorWHITE), |
| 96 has_transparent_background_(false), | 99 has_transparent_background_(false), |
| 97 partial_texture_update_requests_(0), | 100 partial_texture_update_requests_(0), |
| 98 in_paint_layer_contents_(false), | 101 in_paint_layer_contents_(false), |
| 99 total_frames_used_for_lcd_text_metrics_(0) { | 102 total_frames_used_for_lcd_text_metrics_(0) { |
| 100 if (settings_.accelerated_animation_enabled) | 103 if (settings_.accelerated_animation_enabled) |
| 101 animation_registrar_ = AnimationRegistrar::Create(); | 104 animation_registrar_ = AnimationRegistrar::Create(); |
| 102 s_num_layer_tree_instances++; | 105 s_num_layer_tree_instances++; |
| 103 | 106 if (s_next_tree_id <= 0) |
| 107 s_next_tree_id = 1; | |
| 108 tree_id_ = s_next_tree_id++; | |
| 104 rendering_stats_instrumentation_->set_record_rendering_stats( | 109 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 105 debug_state_.RecordRenderingStats()); | 110 debug_state_.RecordRenderingStats()); |
| 106 } | 111 } |
| 107 | 112 |
| 108 bool LayerTreeHost::Initialize( | 113 bool LayerTreeHost::Initialize( |
| 109 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 114 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 110 if (impl_task_runner) | 115 if (impl_task_runner) |
| 111 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); | 116 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); |
| 112 else | 117 else |
| 113 return InitializeProxy(SingleThreadProxy::Create(this)); | 118 return InitializeProxy(SingleThreadProxy::Create(this)); |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 for (LayerIteratorType it = | 942 for (LayerIteratorType it = |
| 938 LayerIteratorType::Begin(&render_surface_layer_list); | 943 LayerIteratorType::Begin(&render_surface_layer_list); |
| 939 it != end; | 944 it != end; |
| 940 ++it) { | 945 ++it) { |
| 941 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); | 946 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); |
| 942 occlusion_tracker.EnterLayer(it, prevent_occlusion); | 947 occlusion_tracker.EnterLayer(it, prevent_occlusion); |
| 943 | 948 |
| 944 if (it.represents_target_render_surface()) { | 949 if (it.represents_target_render_surface()) { |
| 945 DCHECK(it->render_surface()->draw_opacity() || | 950 DCHECK(it->render_surface()->draw_opacity() || |
| 946 it->render_surface()->draw_opacity_is_animating()); | 951 it->render_surface()->draw_opacity_is_animating()); |
| 947 need_more_updates |= PaintMasksForRenderSurface(*it, queue, stats_ptr); | 952 need_more_updates |= PaintMasksForRenderSurface(*it, queue, stats_ptr); |
|
nduca
2013/06/26 15:08:01
hmm, should we do a followup bug for figuring out
| |
| 948 } else if (it.represents_itself()) { | 953 } else if (it.represents_itself()) { |
| 954 devtools_instrumentation::ScopedLayerTreeTask | |
| 955 update_layer(devtools_instrumentation::kUpdateLayer, it->id(), id()); | |
| 949 DCHECK(!it->paint_properties().bounds.IsEmpty()); | 956 DCHECK(!it->paint_properties().bounds.IsEmpty()); |
| 950 it->Update(queue, &occlusion_tracker, stats_ptr); | 957 it->Update(queue, &occlusion_tracker, stats_ptr); |
| 951 need_more_updates |= it->NeedMoreUpdates(); | 958 need_more_updates |= it->NeedMoreUpdates(); |
| 952 } | 959 } |
| 953 | 960 |
| 954 occlusion_tracker.LeaveLayer(it); | 961 occlusion_tracker.LeaveLayer(it); |
| 955 } | 962 } |
| 956 | 963 |
| 957 in_paint_layer_contents_ = false; | 964 in_paint_layer_contents_ = false; |
| 958 | 965 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 bool start_ready_animations = true; | 1088 bool start_ready_animations = true; |
| 1082 (*iter).second->UpdateState(start_ready_animations, NULL); | 1089 (*iter).second->UpdateState(start_ready_animations, NULL); |
| 1083 } | 1090 } |
| 1084 } | 1091 } |
| 1085 | 1092 |
| 1086 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1093 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
| 1087 return proxy_->CapturePicture(); | 1094 return proxy_->CapturePicture(); |
| 1088 } | 1095 } |
| 1089 | 1096 |
| 1090 } // namespace cc | 1097 } // namespace cc |
| OLD | NEW |