| 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), |
| 104 tree_id_(s_next_tree_id++) { |
| 101 if (settings_.accelerated_animation_enabled) | 105 if (settings_.accelerated_animation_enabled) |
| 102 animation_registrar_ = AnimationRegistrar::Create(); | 106 animation_registrar_ = AnimationRegistrar::Create(); |
| 103 s_num_layer_tree_instances++; | 107 s_num_layer_tree_instances++; |
| 104 | |
| 105 rendering_stats_instrumentation_->set_record_rendering_stats( | 108 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 106 debug_state_.RecordRenderingStats()); | 109 debug_state_.RecordRenderingStats()); |
| 107 } | 110 } |
| 108 | 111 |
| 109 bool LayerTreeHost::Initialize( | 112 bool LayerTreeHost::Initialize( |
| 110 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 113 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 111 if (impl_task_runner.get()) | 114 if (impl_task_runner.get()) |
| 112 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); | 115 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); |
| 113 else | 116 else |
| 114 return InitializeProxy(SingleThreadProxy::Create(this)); | 117 return InitializeProxy(SingleThreadProxy::Create(this)); |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 ResourceUpdateQueue* queue, | 879 ResourceUpdateQueue* queue, |
| 877 bool* did_paint_content, | 880 bool* did_paint_content, |
| 878 bool* need_more_updates) { | 881 bool* need_more_updates) { |
| 879 // Note: Masks and replicas only exist for layers that own render surfaces. If | 882 // 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 | 883 // 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 | 884 // be drawn into this render surface, so the mask and replica should be |
| 882 // painted. | 885 // painted. |
| 883 | 886 |
| 884 Layer* mask_layer = render_surface_layer->mask_layer(); | 887 Layer* mask_layer = render_surface_layer->mask_layer(); |
| 885 if (mask_layer) { | 888 if (mask_layer) { |
| 889 devtools_instrumentation::ScopedLayerTreeTask |
| 890 update_layer(devtools_instrumentation::kUpdateLayer, |
| 891 mask_layer->id(), |
| 892 id()); |
| 886 *did_paint_content |= mask_layer->Update(queue, NULL); | 893 *did_paint_content |= mask_layer->Update(queue, NULL); |
| 887 *need_more_updates |= mask_layer->NeedMoreUpdates(); | 894 *need_more_updates |= mask_layer->NeedMoreUpdates(); |
| 888 } | 895 } |
| 889 | 896 |
| 890 Layer* replica_mask_layer = | 897 Layer* replica_mask_layer = |
| 891 render_surface_layer->replica_layer() ? | 898 render_surface_layer->replica_layer() ? |
| 892 render_surface_layer->replica_layer()->mask_layer() : NULL; | 899 render_surface_layer->replica_layer()->mask_layer() : NULL; |
| 893 if (replica_mask_layer) { | 900 if (replica_mask_layer) { |
| 901 devtools_instrumentation::ScopedLayerTreeTask |
| 902 update_layer(devtools_instrumentation::kUpdateLayer, |
| 903 replica_mask_layer->id(), |
| 904 id()); |
| 894 *did_paint_content |= replica_mask_layer->Update(queue, NULL); | 905 *did_paint_content |= replica_mask_layer->Update(queue, NULL); |
| 895 *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 906 *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); |
| 896 } | 907 } |
| 897 } | 908 } |
| 898 | 909 |
| 899 void LayerTreeHost::PaintLayerContents( | 910 void LayerTreeHost::PaintLayerContents( |
| 900 const RenderSurfaceLayerList& render_surface_layer_list, | 911 const RenderSurfaceLayerList& render_surface_layer_list, |
| 901 ResourceUpdateQueue* queue, | 912 ResourceUpdateQueue* queue, |
| 902 bool* did_paint_content, | 913 bool* did_paint_content, |
| 903 bool* need_more_updates) { | 914 bool* need_more_updates) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 927 LayerIteratorType::Begin(&render_surface_layer_list); | 938 LayerIteratorType::Begin(&render_surface_layer_list); |
| 928 it != end; | 939 it != end; |
| 929 ++it) { | 940 ++it) { |
| 930 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); | 941 bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); |
| 931 occlusion_tracker.EnterLayer(it, prevent_occlusion); | 942 occlusion_tracker.EnterLayer(it, prevent_occlusion); |
| 932 | 943 |
| 933 if (it.represents_target_render_surface()) { | 944 if (it.represents_target_render_surface()) { |
| 934 PaintMasksForRenderSurface( | 945 PaintMasksForRenderSurface( |
| 935 *it, queue, did_paint_content, need_more_updates); | 946 *it, queue, did_paint_content, need_more_updates); |
| 936 } else if (it.represents_itself()) { | 947 } else if (it.represents_itself()) { |
| 948 devtools_instrumentation::ScopedLayerTreeTask |
| 949 update_layer(devtools_instrumentation::kUpdateLayer, it->id(), id()); |
| 937 DCHECK(!it->paint_properties().bounds.IsEmpty()); | 950 DCHECK(!it->paint_properties().bounds.IsEmpty()); |
| 938 *did_paint_content |= it->Update(queue, &occlusion_tracker); | 951 *did_paint_content |= it->Update(queue, &occlusion_tracker); |
| 939 *need_more_updates |= it->NeedMoreUpdates(); | 952 *need_more_updates |= it->NeedMoreUpdates(); |
| 940 } | 953 } |
| 941 | 954 |
| 942 occlusion_tracker.LeaveLayer(it); | 955 occlusion_tracker.LeaveLayer(it); |
| 943 } | 956 } |
| 944 | 957 |
| 945 in_paint_layer_contents_ = false; | 958 in_paint_layer_contents_ = false; |
| 946 | 959 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 1074 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); |
| 1062 iter != copy.end(); | 1075 iter != copy.end(); |
| 1063 ++iter) { | 1076 ++iter) { |
| 1064 (*iter).second->Animate(monotonic_time); | 1077 (*iter).second->Animate(monotonic_time); |
| 1065 bool start_ready_animations = true; | 1078 bool start_ready_animations = true; |
| 1066 (*iter).second->UpdateState(start_ready_animations, NULL); | 1079 (*iter).second->UpdateState(start_ready_animations, NULL); |
| 1067 } | 1080 } |
| 1068 } | 1081 } |
| 1069 | 1082 |
| 1070 } // namespace cc | 1083 } // namespace cc |
| OLD | NEW |