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/message_loop.h" | 13 #include "base/message_loop/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/benchmark_instrumentation.h" | 20 #include "cc/debug/benchmark_instrumentation.h" |
| 21 #include "cc/debug/devtools_instrumentation.h" | |
| 21 #include "cc/debug/overdraw_metrics.h" | 22 #include "cc/debug/overdraw_metrics.h" |
| 22 #include "cc/debug/rendering_stats_instrumentation.h" | 23 #include "cc/debug/rendering_stats_instrumentation.h" |
| 23 #include "cc/input/top_controls_manager.h" | 24 #include "cc/input/top_controls_manager.h" |
| 24 #include "cc/layers/heads_up_display_layer.h" | 25 #include "cc/layers/heads_up_display_layer.h" |
| 25 #include "cc/layers/heads_up_display_layer_impl.h" | 26 #include "cc/layers/heads_up_display_layer_impl.h" |
| 26 #include "cc/layers/layer.h" | 27 #include "cc/layers/layer.h" |
| 27 #include "cc/layers/layer_iterator.h" | 28 #include "cc/layers/layer_iterator.h" |
| 28 #include "cc/layers/render_surface.h" | 29 #include "cc/layers/render_surface.h" |
| 29 #include "cc/layers/scrollbar_layer.h" | 30 #include "cc/layers/scrollbar_layer.h" |
| 30 #include "cc/resources/prioritized_resource_manager.h" | 31 #include "cc/resources/prioritized_resource_manager.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 LayerTreeHostClient* client, | 67 LayerTreeHostClient* client, |
| 67 const LayerTreeSettings& settings, | 68 const LayerTreeSettings& settings, |
| 68 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 69 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 69 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, | 70 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, |
| 70 settings)); | 71 settings)); |
| 71 if (!layer_tree_host->Initialize(impl_task_runner)) | 72 if (!layer_tree_host->Initialize(impl_task_runner)) |
| 72 return scoped_ptr<LayerTreeHost>(); | 73 return scoped_ptr<LayerTreeHost>(); |
| 73 return layer_tree_host.Pass(); | 74 return layer_tree_host.Pass(); |
| 74 } | 75 } |
| 75 | 76 |
| 77 static int s_next_tree_id = 1; | |
| 78 | |
| 76 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, | 79 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
| 77 const LayerTreeSettings& settings) | 80 const LayerTreeSettings& settings) |
| 78 : animating_(false), | 81 : animating_(false), |
| 79 needs_full_tree_sync_(true), | 82 needs_full_tree_sync_(true), |
| 80 needs_filter_context_(false), | 83 needs_filter_context_(false), |
| 81 client_(client), | 84 client_(client), |
| 82 commit_number_(0), | 85 commit_number_(0), |
| 83 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 86 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
| 84 output_surface_can_be_initialized_(true), | 87 output_surface_can_be_initialized_(true), |
| 85 output_surface_lost_(true), | 88 output_surface_lost_(true), |
| 86 num_failed_recreate_attempts_(0), | 89 num_failed_recreate_attempts_(0), |
| 87 settings_(settings), | 90 settings_(settings), |
| 88 debug_state_(settings.initial_debug_state), | 91 debug_state_(settings.initial_debug_state), |
| 89 overdraw_bottom_height_(0.f), | 92 overdraw_bottom_height_(0.f), |
| 90 device_scale_factor_(1.f), | 93 device_scale_factor_(1.f), |
| 91 visible_(true), | 94 visible_(true), |
| 92 page_scale_factor_(1.f), | 95 page_scale_factor_(1.f), |
| 93 min_page_scale_factor_(1.f), | 96 min_page_scale_factor_(1.f), |
| 94 max_page_scale_factor_(1.f), | 97 max_page_scale_factor_(1.f), |
| 95 trigger_idle_updates_(true), | 98 trigger_idle_updates_(true), |
| 96 background_color_(SK_ColorWHITE), | 99 background_color_(SK_ColorWHITE), |
| 97 has_transparent_background_(false), | 100 has_transparent_background_(false), |
| 98 partial_texture_update_requests_(0), | 101 partial_texture_update_requests_(0), |
| 99 in_paint_layer_contents_(false), | 102 in_paint_layer_contents_(false), |
| 100 total_frames_used_for_lcd_text_metrics_(0) { | 103 total_frames_used_for_lcd_text_metrics_(0) { |
| 101 if (settings_.accelerated_animation_enabled) | 104 if (settings_.accelerated_animation_enabled) |
| 102 animation_registrar_ = AnimationRegistrar::Create(); | 105 animation_registrar_ = AnimationRegistrar::Create(); |
| 103 s_num_layer_tree_instances++; | 106 s_num_layer_tree_instances++; |
| 104 | 107 if (s_next_tree_id <= 0) |
|
jamesr
2013/07/22 18:01:02
what is this for? are you expecting to allocate mo
caseq
2013/07/22 18:56:47
This was mindlessly copied from layer.cc per Nat's
| |
| 108 s_next_tree_id = 1; | |
| 109 tree_id_ = s_next_tree_id++; | |
| 105 rendering_stats_instrumentation_->set_record_rendering_stats( | 110 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 106 debug_state_.RecordRenderingStats()); | 111 debug_state_.RecordRenderingStats()); |
| 107 } | 112 } |
| 108 | 113 |
| 109 bool LayerTreeHost::Initialize( | 114 bool LayerTreeHost::Initialize( |
| 110 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 115 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 111 if (impl_task_runner.get()) | 116 if (impl_task_runner.get()) |
| 112 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); | 117 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); |
| 113 else | 118 else |
| 114 return InitializeProxy(SingleThreadProxy::Create(this)); | 119 return InitializeProxy(SingleThreadProxy::Create(this)); |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 ResourceUpdateQueue* queue, | 881 ResourceUpdateQueue* queue, |
| 877 bool* did_paint_content, | 882 bool* did_paint_content, |
| 878 bool* need_more_updates) { | 883 bool* need_more_updates) { |
| 879 // Note: Masks and replicas only exist for layers that own render surfaces. If | 884 // Note: Masks and replicas only exist for layers that own render surfaces. If |
| 880 // we reach this point in code, we already know that at least something will | 885 // we reach this point in code, we already know that at least something will |
| 881 // be drawn into this render surface, so the mask and replica should be | 886 // be drawn into this render surface, so the mask and replica should be |
| 882 // painted. | 887 // painted. |
| 883 | 888 |
| 884 Layer* mask_layer = render_surface_layer->mask_layer(); | 889 Layer* mask_layer = render_surface_layer->mask_layer(); |
| 885 if (mask_layer) { | 890 if (mask_layer) { |
| 891 devtools_instrumentation::ScopedLayerTreeTask | |
|
danakj
2013/07/22 15:06:51
Just wondering: Does devtools have the ability to
caseq
2013/07/22 15:44:49
Yes.
| |
| 892 update_layer(devtools_instrumentation::kUpdateLayer, | |
| 893 mask_layer->id(), | |
| 894 id()); | |
| 886 *did_paint_content |= mask_layer->Update(queue, NULL); | 895 *did_paint_content |= mask_layer->Update(queue, NULL); |
| 887 *need_more_updates |= mask_layer->NeedMoreUpdates(); | 896 *need_more_updates |= mask_layer->NeedMoreUpdates(); |
| 888 } | 897 } |
| 889 | 898 |
| 890 Layer* replica_mask_layer = | 899 Layer* replica_mask_layer = |
| 891 render_surface_layer->replica_layer() ? | 900 render_surface_layer->replica_layer() ? |
| 892 render_surface_layer->replica_layer()->mask_layer() : NULL; | 901 render_surface_layer->replica_layer()->mask_layer() : NULL; |
| 893 if (replica_mask_layer) { | 902 if (replica_mask_layer) { |
| 903 devtools_instrumentation::ScopedLayerTreeTask | |
| 904 update_layer(devtools_instrumentation::kUpdateLayer, | |
| 905 replica_mask_layer->id(), | |
| 906 id()); | |
| 894 *did_paint_content |= replica_mask_layer->Update(queue, NULL); | 907 *did_paint_content |= replica_mask_layer->Update(queue, NULL); |
| 895 *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 908 *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); |
| 896 } | 909 } |
| 897 } | 910 } |
| 898 | 911 |
| 899 void LayerTreeHost::PaintLayerContents( | 912 void LayerTreeHost::PaintLayerContents( |
| 900 const RenderSurfaceLayerList& render_surface_layer_list, | 913 const RenderSurfaceLayerList& render_surface_layer_list, |
| 901 ResourceUpdateQueue* queue, | 914 ResourceUpdateQueue* queue, |
| 902 bool* did_paint_content, | 915 bool* did_paint_content, |
| 903 bool* need_more_updates) { | 916 bool* need_more_updates) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 927 LayerIteratorType::Begin(&render_surface_layer_list); | 940 LayerIteratorType::Begin(&render_surface_layer_list); |
| 928 it != end; | 941 it != end; |
| 929 ++it) { | 942 ++it) { |
| 930 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); | 943 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); |
| 931 occlusion_tracker.EnterLayer(it, prevent_occlusion); | 944 occlusion_tracker.EnterLayer(it, prevent_occlusion); |
| 932 | 945 |
| 933 if (it.represents_target_render_surface()) { | 946 if (it.represents_target_render_surface()) { |
| 934 PaintMasksForRenderSurface( | 947 PaintMasksForRenderSurface( |
| 935 *it, queue, did_paint_content, need_more_updates); | 948 *it, queue, did_paint_content, need_more_updates); |
| 936 } else if (it.represents_itself()) { | 949 } else if (it.represents_itself()) { |
| 950 devtools_instrumentation::ScopedLayerTreeTask | |
| 951 update_layer(devtools_instrumentation::kUpdateLayer, it->id(), id()); | |
| 937 DCHECK(!it->paint_properties().bounds.IsEmpty()); | 952 DCHECK(!it->paint_properties().bounds.IsEmpty()); |
| 938 *did_paint_content |= it->Update(queue, &occlusion_tracker); | 953 *did_paint_content |= it->Update(queue, &occlusion_tracker); |
| 939 *need_more_updates |= it->NeedMoreUpdates(); | 954 *need_more_updates |= it->NeedMoreUpdates(); |
| 940 } | 955 } |
| 941 | 956 |
| 942 occlusion_tracker.LeaveLayer(it); | 957 occlusion_tracker.LeaveLayer(it); |
| 943 } | 958 } |
| 944 | 959 |
| 945 in_paint_layer_contents_ = false; | 960 in_paint_layer_contents_ = false; |
| 946 | 961 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 1076 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
| 1062 iter != copy.end(); | 1077 iter != copy.end(); |
| 1063 ++iter) { | 1078 ++iter) { |
| 1064 (*iter).second->Animate(monotonic_time); | 1079 (*iter).second->Animate(monotonic_time); |
| 1065 bool start_ready_animations = true; | 1080 bool start_ready_animations = true; |
| 1066 (*iter).second->UpdateState(start_ready_animations, NULL); | 1081 (*iter).second->UpdateState(start_ready_animations, NULL); |
| 1067 } | 1082 } |
| 1068 } | 1083 } |
| 1069 | 1084 |
| 1070 } // namespace cc | 1085 } // namespace cc |
| OLD | NEW |