| 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) | 
|  | 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 872                                                ResourceUpdateQueue* queue, | 877                                                ResourceUpdateQueue* queue, | 
| 873                                                bool* did_paint_content, | 878                                                bool* did_paint_content, | 
| 874                                                bool* need_more_updates) { | 879                                                bool* need_more_updates) { | 
| 875   // Note: Masks and replicas only exist for layers that own render surfaces. If | 880   // Note: Masks and replicas only exist for layers that own render surfaces. If | 
| 876   // we reach this point in code, we already know that at least something will | 881   // we reach this point in code, we already know that at least something will | 
| 877   // be drawn into this render surface, so the mask and replica should be | 882   // be drawn into this render surface, so the mask and replica should be | 
| 878   // painted. | 883   // painted. | 
| 879 | 884 | 
| 880   Layer* mask_layer = render_surface_layer->mask_layer(); | 885   Layer* mask_layer = render_surface_layer->mask_layer(); | 
| 881   if (mask_layer) { | 886   if (mask_layer) { | 
|  | 887     devtools_instrumentation::ScopedLayerTreeTask | 
|  | 888         update_layer(devtools_instrumentation::kUpdateLayer, | 
|  | 889                      mask_layer->id(), | 
|  | 890                      id()); | 
| 882     *did_paint_content |= mask_layer->Update(queue, NULL); | 891     *did_paint_content |= mask_layer->Update(queue, NULL); | 
| 883     *need_more_updates |= mask_layer->NeedMoreUpdates(); | 892     *need_more_updates |= mask_layer->NeedMoreUpdates(); | 
| 884   } | 893   } | 
| 885 | 894 | 
| 886   Layer* replica_mask_layer = | 895   Layer* replica_mask_layer = | 
| 887       render_surface_layer->replica_layer() ? | 896       render_surface_layer->replica_layer() ? | 
| 888       render_surface_layer->replica_layer()->mask_layer() : NULL; | 897       render_surface_layer->replica_layer()->mask_layer() : NULL; | 
| 889   if (replica_mask_layer) { | 898   if (replica_mask_layer) { | 
|  | 899     devtools_instrumentation::ScopedLayerTreeTask | 
|  | 900         update_layer(devtools_instrumentation::kUpdateLayer, | 
|  | 901                      replica_mask_layer->id(), | 
|  | 902                      id()); | 
| 890     *did_paint_content |= replica_mask_layer->Update(queue, NULL); | 903     *did_paint_content |= replica_mask_layer->Update(queue, NULL); | 
| 891     *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 904     *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 
| 892   } | 905   } | 
| 893 } | 906 } | 
| 894 | 907 | 
| 895 void LayerTreeHost::PaintLayerContents( | 908 void LayerTreeHost::PaintLayerContents( | 
| 896     const LayerList& render_surface_layer_list, | 909     const LayerList& render_surface_layer_list, | 
| 897     ResourceUpdateQueue* queue, | 910     ResourceUpdateQueue* queue, | 
| 898     bool* did_paint_content, | 911     bool* did_paint_content, | 
| 899     bool* need_more_updates) { | 912     bool* need_more_updates) { | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 925        ++it) { | 938        ++it) { | 
| 926     bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); | 939     bool prevent_occlusion = it.target_render_surface_layer()->HasCopyRequest(); | 
| 927     occlusion_tracker.EnterLayer(it, prevent_occlusion); | 940     occlusion_tracker.EnterLayer(it, prevent_occlusion); | 
| 928 | 941 | 
| 929     if (it.represents_target_render_surface()) { | 942     if (it.represents_target_render_surface()) { | 
| 930       DCHECK(it->render_surface()->draw_opacity() || | 943       DCHECK(it->render_surface()->draw_opacity() || | 
| 931              it->render_surface()->draw_opacity_is_animating()); | 944              it->render_surface()->draw_opacity_is_animating()); | 
| 932       PaintMasksForRenderSurface( | 945       PaintMasksForRenderSurface( | 
| 933           *it, queue, did_paint_content, need_more_updates); | 946           *it, queue, did_paint_content, need_more_updates); | 
| 934     } else if (it.represents_itself()) { | 947     } else if (it.represents_itself()) { | 
|  | 948       devtools_instrumentation::ScopedLayerTreeTask | 
|  | 949           update_layer(devtools_instrumentation::kUpdateLayer, it->id(), id()); | 
| 935       DCHECK(!it->paint_properties().bounds.IsEmpty()); | 950       DCHECK(!it->paint_properties().bounds.IsEmpty()); | 
| 936       *did_paint_content |= it->Update(queue, &occlusion_tracker); | 951       *did_paint_content |= it->Update(queue, &occlusion_tracker); | 
| 937       *need_more_updates |= it->NeedMoreUpdates(); | 952       *need_more_updates |= it->NeedMoreUpdates(); | 
| 938     } | 953     } | 
| 939 | 954 | 
| 940     occlusion_tracker.LeaveLayer(it); | 955     occlusion_tracker.LeaveLayer(it); | 
| 941   } | 956   } | 
| 942 | 957 | 
| 943   in_paint_layer_contents_ = false; | 958   in_paint_layer_contents_ = false; | 
| 944 | 959 | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1059   for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 1074   for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); | 
| 1060        iter != copy.end(); | 1075        iter != copy.end(); | 
| 1061        ++iter) { | 1076        ++iter) { | 
| 1062     (*iter).second->Animate(monotonic_time); | 1077     (*iter).second->Animate(monotonic_time); | 
| 1063     bool start_ready_animations = true; | 1078     bool start_ready_animations = true; | 
| 1064     (*iter).second->UpdateState(start_ready_animations, NULL); | 1079     (*iter).second->UpdateState(start_ready_animations, NULL); | 
| 1065   } | 1080   } | 
| 1066 } | 1081 } | 
| 1067 | 1082 | 
| 1068 }  // namespace cc | 1083 }  // namespace cc | 
| OLD | NEW | 
|---|