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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 max_background_texture_bytes = bytes; | 803 max_background_texture_bytes = bytes; |
804 if (!readback_bytes) { | 804 if (!readback_bytes) { |
805 readback_bytes = Resource::MemorySizeBytes(device_viewport_size_, | 805 readback_bytes = Resource::MemorySizeBytes(device_viewport_size_, |
806 GL_RGBA); | 806 GL_RGBA); |
807 } | 807 } |
808 } | 808 } |
809 return readback_bytes + max_background_texture_bytes + contents_texture_bytes; | 809 return readback_bytes + max_background_texture_bytes + contents_texture_bytes; |
810 } | 810 } |
811 | 811 |
812 bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, | 812 bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, |
813 ResourceUpdateQueue* queue, | 813 ResourceUpdateQueue* queue) { |
814 RenderingStats* stats) { | |
815 // Note: Masks and replicas only exist for layers that own render surfaces. If | 814 // Note: Masks and replicas only exist for layers that own render surfaces. If |
816 // we reach this point in code, we already know that at least something will | 815 // we reach this point in code, we already know that at least something will |
817 // be drawn into this render surface, so the mask and replica should be | 816 // be drawn into this render surface, so the mask and replica should be |
818 // painted. | 817 // painted. |
819 | 818 |
820 bool need_more_updates = false; | 819 bool need_more_updates = false; |
821 Layer* mask_layer = render_surface_layer->mask_layer(); | 820 Layer* mask_layer = render_surface_layer->mask_layer(); |
822 if (mask_layer) { | 821 if (mask_layer) { |
823 mask_layer->Update(queue, NULL, stats); | 822 mask_layer->Update(queue, NULL); |
824 need_more_updates |= mask_layer->NeedMoreUpdates(); | 823 need_more_updates |= mask_layer->NeedMoreUpdates(); |
825 } | 824 } |
826 | 825 |
827 Layer* replica_mask_layer = | 826 Layer* replica_mask_layer = |
828 render_surface_layer->replica_layer() ? | 827 render_surface_layer->replica_layer() ? |
829 render_surface_layer->replica_layer()->mask_layer() : NULL; | 828 render_surface_layer->replica_layer()->mask_layer() : NULL; |
830 if (replica_mask_layer) { | 829 if (replica_mask_layer) { |
831 replica_mask_layer->Update(queue, NULL, stats); | 830 replica_mask_layer->Update(queue, NULL); |
832 need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 831 need_more_updates |= replica_mask_layer->NeedMoreUpdates(); |
833 } | 832 } |
834 return need_more_updates; | 833 return need_more_updates; |
835 } | 834 } |
836 | 835 |
837 bool LayerTreeHost::PaintLayerContents( | 836 bool LayerTreeHost::PaintLayerContents( |
838 const LayerList& render_surface_layer_list, ResourceUpdateQueue* queue) { | 837 const LayerList& render_surface_layer_list, ResourceUpdateQueue* queue) { |
839 // Use FrontToBack to allow for testing occlusion and performing culling | 838 // Use FrontToBack to allow for testing occlusion and performing culling |
840 // during the tree walk. | 839 // during the tree walk. |
841 typedef LayerIterator<Layer, | 840 typedef LayerIterator<Layer, |
842 LayerList, | 841 LayerList, |
843 RenderSurface, | 842 RenderSurface, |
844 LayerIteratorActions::FrontToBack> LayerIteratorType; | 843 LayerIteratorActions::FrontToBack> LayerIteratorType; |
845 | 844 |
846 bool need_more_updates = false; | 845 bool need_more_updates = false; |
847 bool record_metrics_for_frame = | 846 bool record_metrics_for_frame = |
848 settings_.show_overdraw_in_tracing && | 847 settings_.show_overdraw_in_tracing && |
849 base::debug::TraceLog::GetInstance() && | 848 base::debug::TraceLog::GetInstance() && |
850 base::debug::TraceLog::GetInstance()->IsEnabled(); | 849 base::debug::TraceLog::GetInstance()->IsEnabled(); |
851 OcclusionTracker occlusion_tracker( | 850 OcclusionTracker occlusion_tracker( |
852 root_layer_->render_surface()->content_rect(), record_metrics_for_frame); | 851 root_layer_->render_surface()->content_rect(), record_metrics_for_frame); |
853 occlusion_tracker.set_minimum_tracking_size( | 852 occlusion_tracker.set_minimum_tracking_size( |
854 settings_.minimum_occlusion_tracking_size); | 853 settings_.minimum_occlusion_tracking_size); |
855 | 854 |
856 PrioritizeTextures(render_surface_layer_list, | 855 PrioritizeTextures(render_surface_layer_list, |
857 occlusion_tracker.overdraw_metrics()); | 856 occlusion_tracker.overdraw_metrics()); |
858 | 857 |
859 // TODO(egraether): Use RenderingStatsInstrumentation in Layer::update() | |
860 RenderingStats stats; | |
861 RenderingStats* stats_ptr = | |
862 debug_state_.RecordRenderingStats() ? &stats : NULL; | |
863 | |
864 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); | 858 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); |
865 for (LayerIteratorType it = | 859 for (LayerIteratorType it = |
866 LayerIteratorType::Begin(&render_surface_layer_list); | 860 LayerIteratorType::Begin(&render_surface_layer_list); |
867 it != end; | 861 it != end; |
868 ++it) { | 862 ++it) { |
869 occlusion_tracker.EnterLayer(it); | 863 occlusion_tracker.EnterLayer(it); |
870 | 864 |
871 if (it.represents_target_render_surface()) { | 865 if (it.represents_target_render_surface()) { |
872 DCHECK(it->render_surface()->draw_opacity() || | 866 DCHECK(it->render_surface()->draw_opacity() || |
873 it->render_surface()->draw_opacity_is_animating()); | 867 it->render_surface()->draw_opacity_is_animating()); |
874 need_more_updates |= PaintMasksForRenderSurface(*it, queue, stats_ptr); | 868 need_more_updates |= PaintMasksForRenderSurface(*it, queue); |
875 } else if (it.represents_itself()) { | 869 } else if (it.represents_itself()) { |
876 DCHECK(!it->bounds().IsEmpty()); | 870 DCHECK(!it->bounds().IsEmpty()); |
877 it->Update(queue, &occlusion_tracker, stats_ptr); | 871 it->Update(queue, &occlusion_tracker); |
878 need_more_updates |= it->NeedMoreUpdates(); | 872 need_more_updates |= it->NeedMoreUpdates(); |
879 } | 873 } |
880 | 874 |
881 occlusion_tracker.LeaveLayer(it); | 875 occlusion_tracker.LeaveLayer(it); |
882 } | 876 } |
883 | 877 |
884 rendering_stats_instrumentation_->AddStats(stats); | |
885 | |
886 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); | 878 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); |
887 | 879 |
888 return need_more_updates; | 880 return need_more_updates; |
889 } | 881 } |
890 | 882 |
891 void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) { | 883 void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) { |
892 if (!root_layer_) | 884 if (!root_layer_) |
893 return; | 885 return; |
894 | 886 |
895 Layer* root_scroll_layer = FindFirstScrollableLayer(root_layer_.get()); | 887 Layer* root_scroll_layer = FindFirstScrollableLayer(root_layer_.get()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 SetAnimationEventsRecursive(events, | 1029 SetAnimationEventsRecursive(events, |
1038 layer->children()[child_index].get(), | 1030 layer->children()[child_index].get(), |
1039 wall_clock_time); | 1031 wall_clock_time); |
1040 } | 1032 } |
1041 | 1033 |
1042 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1034 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
1043 return proxy_->CapturePicture(); | 1035 return proxy_->CapturePicture(); |
1044 } | 1036 } |
1045 | 1037 |
1046 } // namespace cc | 1038 } // namespace cc |
OLD | NEW |