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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 max_background_texture_bytes = bytes; | 822 max_background_texture_bytes = bytes; |
823 if (!readback_bytes) { | 823 if (!readback_bytes) { |
824 readback_bytes = Resource::MemorySizeBytes(device_viewport_size_, | 824 readback_bytes = Resource::MemorySizeBytes(device_viewport_size_, |
825 GL_RGBA); | 825 GL_RGBA); |
826 } | 826 } |
827 } | 827 } |
828 return readback_bytes + max_background_texture_bytes + contents_texture_bytes; | 828 return readback_bytes + max_background_texture_bytes + contents_texture_bytes; |
829 } | 829 } |
830 | 830 |
831 bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, | 831 bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, |
832 ResourceUpdateQueue* queue, | 832 ResourceUpdateQueue* queue) { |
833 RenderingStats* stats) { | |
834 // Note: Masks and replicas only exist for layers that own render surfaces. If | 833 // Note: Masks and replicas only exist for layers that own render surfaces. If |
835 // we reach this point in code, we already know that at least something will | 834 // we reach this point in code, we already know that at least something will |
836 // be drawn into this render surface, so the mask and replica should be | 835 // be drawn into this render surface, so the mask and replica should be |
837 // painted. | 836 // painted. |
838 | 837 |
839 bool need_more_updates = false; | 838 bool need_more_updates = false; |
840 Layer* mask_layer = render_surface_layer->mask_layer(); | 839 Layer* mask_layer = render_surface_layer->mask_layer(); |
841 if (mask_layer) { | 840 if (mask_layer) { |
842 mask_layer->Update(queue, NULL, stats); | 841 mask_layer->Update(queue, NULL); |
843 need_more_updates |= mask_layer->NeedMoreUpdates(); | 842 need_more_updates |= mask_layer->NeedMoreUpdates(); |
844 } | 843 } |
845 | 844 |
846 Layer* replica_mask_layer = | 845 Layer* replica_mask_layer = |
847 render_surface_layer->replica_layer() ? | 846 render_surface_layer->replica_layer() ? |
848 render_surface_layer->replica_layer()->mask_layer() : NULL; | 847 render_surface_layer->replica_layer()->mask_layer() : NULL; |
849 if (replica_mask_layer) { | 848 if (replica_mask_layer) { |
850 replica_mask_layer->Update(queue, NULL, stats); | 849 replica_mask_layer->Update(queue, NULL); |
851 need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 850 need_more_updates |= replica_mask_layer->NeedMoreUpdates(); |
852 } | 851 } |
853 return need_more_updates; | 852 return need_more_updates; |
854 } | 853 } |
855 | 854 |
856 bool LayerTreeHost::PaintLayerContents( | 855 bool LayerTreeHost::PaintLayerContents( |
857 const LayerList& render_surface_layer_list, ResourceUpdateQueue* queue) { | 856 const LayerList& render_surface_layer_list, ResourceUpdateQueue* queue) { |
858 // Use FrontToBack to allow for testing occlusion and performing culling | 857 // Use FrontToBack to allow for testing occlusion and performing culling |
859 // during the tree walk. | 858 // during the tree walk. |
860 typedef LayerIterator<Layer, | 859 typedef LayerIterator<Layer, |
861 LayerList, | 860 LayerList, |
862 RenderSurface, | 861 RenderSurface, |
863 LayerIteratorActions::FrontToBack> LayerIteratorType; | 862 LayerIteratorActions::FrontToBack> LayerIteratorType; |
864 | 863 |
865 bool need_more_updates = false; | 864 bool need_more_updates = false; |
866 bool record_metrics_for_frame = | 865 bool record_metrics_for_frame = |
867 settings_.show_overdraw_in_tracing && | 866 settings_.show_overdraw_in_tracing && |
868 base::debug::TraceLog::GetInstance() && | 867 base::debug::TraceLog::GetInstance() && |
869 base::debug::TraceLog::GetInstance()->IsEnabled(); | 868 base::debug::TraceLog::GetInstance()->IsEnabled(); |
870 OcclusionTracker occlusion_tracker( | 869 OcclusionTracker occlusion_tracker( |
871 root_layer_->render_surface()->content_rect(), record_metrics_for_frame); | 870 root_layer_->render_surface()->content_rect(), record_metrics_for_frame); |
872 occlusion_tracker.set_minimum_tracking_size( | 871 occlusion_tracker.set_minimum_tracking_size( |
873 settings_.minimum_occlusion_tracking_size); | 872 settings_.minimum_occlusion_tracking_size); |
874 | 873 |
875 PrioritizeTextures(render_surface_layer_list, | 874 PrioritizeTextures(render_surface_layer_list, |
876 occlusion_tracker.overdraw_metrics()); | 875 occlusion_tracker.overdraw_metrics()); |
877 | 876 |
878 // TODO(egraether): Use RenderingStatsInstrumentation in Layer::update() | |
879 RenderingStats stats; | |
880 RenderingStats* stats_ptr = | |
881 debug_state_.RecordRenderingStats() ? &stats : NULL; | |
882 | |
883 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); | 877 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); |
884 for (LayerIteratorType it = | 878 for (LayerIteratorType it = |
885 LayerIteratorType::Begin(&render_surface_layer_list); | 879 LayerIteratorType::Begin(&render_surface_layer_list); |
886 it != end; | 880 it != end; |
887 ++it) { | 881 ++it) { |
888 occlusion_tracker.EnterLayer(it); | 882 occlusion_tracker.EnterLayer(it); |
889 | 883 |
890 if (it.represents_target_render_surface()) { | 884 if (it.represents_target_render_surface()) { |
891 DCHECK(it->render_surface()->draw_opacity() || | 885 DCHECK(it->render_surface()->draw_opacity() || |
892 it->render_surface()->draw_opacity_is_animating()); | 886 it->render_surface()->draw_opacity_is_animating()); |
893 need_more_updates |= PaintMasksForRenderSurface(*it, queue, stats_ptr); | 887 need_more_updates |= PaintMasksForRenderSurface(*it, queue); |
894 } else if (it.represents_itself()) { | 888 } else if (it.represents_itself()) { |
895 DCHECK(!it->bounds().IsEmpty()); | 889 DCHECK(!it->bounds().IsEmpty()); |
896 it->Update(queue, &occlusion_tracker, stats_ptr); | 890 it->Update(queue, &occlusion_tracker); |
897 need_more_updates |= it->NeedMoreUpdates(); | 891 need_more_updates |= it->NeedMoreUpdates(); |
898 } | 892 } |
899 | 893 |
900 occlusion_tracker.LeaveLayer(it); | 894 occlusion_tracker.LeaveLayer(it); |
901 } | 895 } |
902 | 896 |
903 rendering_stats_instrumentation_->AddStats(stats); | |
904 | |
905 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); | 897 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); |
906 | 898 |
907 return need_more_updates; | 899 return need_more_updates; |
908 } | 900 } |
909 | 901 |
910 void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) { | 902 void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) { |
911 if (!root_layer_) | 903 if (!root_layer_) |
912 return; | 904 return; |
913 | 905 |
914 Layer* root_scroll_layer = FindFirstScrollableLayer(root_layer_.get()); | 906 Layer* root_scroll_layer = FindFirstScrollableLayer(root_layer_.get()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 SetAnimationEventsRecursive(events, | 1048 SetAnimationEventsRecursive(events, |
1057 layer->children()[child_index].get(), | 1049 layer->children()[child_index].get(), |
1058 wall_clock_time); | 1050 wall_clock_time); |
1059 } | 1051 } |
1060 | 1052 |
1061 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1053 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
1062 return proxy_->CapturePicture(); | 1054 return proxy_->CapturePicture(); |
1063 } | 1055 } |
1064 | 1056 |
1065 } // namespace cc | 1057 } // namespace cc |
OLD | NEW |