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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "cc/animation/scrollbar_animation_controller.h" | 16 #include "cc/animation/scrollbar_animation_controller.h" |
17 #include "cc/animation/timing_function.h" | 17 #include "cc/animation/timing_function.h" |
18 #include "cc/base/latency_info_swap_promise_monitor.h" | 18 #include "cc/base/latency_info_swap_promise_monitor.h" |
19 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
20 #include "cc/base/util.h" | 20 #include "cc/base/util.h" |
21 #include "cc/debug/benchmark_instrumentation.h" | 21 #include "cc/debug/benchmark_instrumentation.h" |
22 #include "cc/debug/debug_rect_history.h" | 22 #include "cc/debug/debug_rect_history.h" |
23 #include "cc/debug/devtools_instrumentation.h" | 23 #include "cc/debug/devtools_instrumentation.h" |
24 #include "cc/debug/frame_rate_counter.h" | 24 #include "cc/debug/frame_rate_counter.h" |
25 #include "cc/debug/overdraw_metrics.h" | |
26 #include "cc/debug/paint_time_counter.h" | 25 #include "cc/debug/paint_time_counter.h" |
27 #include "cc/debug/rendering_stats_instrumentation.h" | 26 #include "cc/debug/rendering_stats_instrumentation.h" |
28 #include "cc/debug/traced_value.h" | 27 #include "cc/debug/traced_value.h" |
29 #include "cc/input/page_scale_animation.h" | 28 #include "cc/input/page_scale_animation.h" |
30 #include "cc/input/top_controls_manager.h" | 29 #include "cc/input/top_controls_manager.h" |
31 #include "cc/layers/append_quads_data.h" | 30 #include "cc/layers/append_quads_data.h" |
32 #include "cc/layers/heads_up_display_layer_impl.h" | 31 #include "cc/layers/heads_up_display_layer_impl.h" |
33 #include "cc/layers/layer_impl.h" | 32 #include "cc/layers/layer_impl.h" |
34 #include "cc/layers/layer_iterator.h" | 33 #include "cc/layers/layer_iterator.h" |
35 #include "cc/layers/painted_scrollbar_layer_impl.h" | 34 #include "cc/layers/painted_scrollbar_layer_impl.h" |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // entire root surface. This will disable partial-swap/scissor optimizations | 752 // entire root surface. This will disable partial-swap/scissor optimizations |
754 // that would prevent the HUD from updating, since the HUD does not cause | 753 // that would prevent the HUD from updating, since the HUD does not cause |
755 // damage itself, to prevent it from messing with damage visualizations. Since | 754 // damage itself, to prevent it from messing with damage visualizations. Since |
756 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, | 755 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, |
757 // changing the RenderPass does not affect them. | 756 // changing the RenderPass does not affect them. |
758 if (active_tree_->hud_layer()) { | 757 if (active_tree_->hud_layer()) { |
759 RenderPass* root_pass = frame->render_passes.back(); | 758 RenderPass* root_pass = frame->render_passes.back(); |
760 root_pass->damage_rect = root_pass->output_rect; | 759 root_pass->damage_rect = root_pass->output_rect; |
761 } | 760 } |
762 | 761 |
763 bool record_metrics_for_frame = | |
764 settings_.show_overdraw_in_tracing && | |
765 base::debug::TraceLog::GetInstance() && | |
766 base::debug::TraceLog::GetInstance()->IsEnabled(); | |
767 OcclusionTracker<LayerImpl> occlusion_tracker( | 762 OcclusionTracker<LayerImpl> occlusion_tracker( |
768 active_tree_->root_layer()->render_surface()->content_rect(), | 763 active_tree_->root_layer()->render_surface()->content_rect()); |
769 record_metrics_for_frame); | |
770 occlusion_tracker.set_minimum_tracking_size( | 764 occlusion_tracker.set_minimum_tracking_size( |
771 settings_.minimum_occlusion_tracking_size); | 765 settings_.minimum_occlusion_tracking_size); |
772 | 766 |
773 if (debug_state_.show_occluding_rects) { | 767 if (debug_state_.show_occluding_rects) { |
774 occlusion_tracker.set_occluding_screen_space_rects_container( | 768 occlusion_tracker.set_occluding_screen_space_rects_container( |
775 &frame->occluding_screen_space_rects); | 769 &frame->occluding_screen_space_rects); |
776 } | 770 } |
777 if (debug_state_.show_non_occluding_rects) { | 771 if (debug_state_.show_non_occluding_rects) { |
778 occlusion_tracker.set_non_occluding_screen_space_rects_container( | 772 occlusion_tracker.set_non_occluding_screen_space_rects_container( |
779 &frame->non_occluding_screen_space_rects); | 773 &frame->non_occluding_screen_space_rects); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 AppendQuadsToFillScreen( | 900 AppendQuadsToFillScreen( |
907 ResourceIdForUIResource(overhang_ui_resource_id_), | 901 ResourceIdForUIResource(overhang_ui_resource_id_), |
908 gfx::ScaleSize(overhang_ui_resource_size_, device_scale_factor_), | 902 gfx::ScaleSize(overhang_ui_resource_size_, device_scale_factor_), |
909 active_tree_->RootScrollLayerDeviceViewportBounds(), | 903 active_tree_->RootScrollLayerDeviceViewportBounds(), |
910 frame->render_passes.back(), | 904 frame->render_passes.back(), |
911 active_tree_->root_layer(), | 905 active_tree_->root_layer(), |
912 active_tree_->background_color(), | 906 active_tree_->background_color(), |
913 occlusion_tracker); | 907 occlusion_tracker); |
914 } | 908 } |
915 | 909 |
916 if (draw_result == DrawSwapReadbackResult::DRAW_SUCCESS) | |
917 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); | |
918 else | |
919 DCHECK(!have_copy_request); | |
920 | |
921 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); | 910 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); |
922 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); | 911 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); |
923 | 912 |
924 // Any copy requests left in the tree are not going to get serviced, and | 913 // Any copy requests left in the tree are not going to get serviced, and |
925 // should be aborted. | 914 // should be aborted. |
926 ScopedPtrVector<CopyOutputRequest> requests_to_abort; | 915 ScopedPtrVector<CopyOutputRequest> requests_to_abort; |
927 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { | 916 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { |
928 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 917 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
929 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); | 918 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); |
930 } | 919 } |
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 swap_promise_monitor_.erase(monitor); | 3019 swap_promise_monitor_.erase(monitor); |
3031 } | 3020 } |
3032 | 3021 |
3033 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3022 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3034 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3023 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3035 for (; it != swap_promise_monitor_.end(); it++) | 3024 for (; it != swap_promise_monitor_.end(); it++) |
3036 (*it)->OnSetNeedsRedrawOnImpl(); | 3025 (*it)->OnSetNeedsRedrawOnImpl(); |
3037 } | 3026 } |
3038 | 3027 |
3039 } // namespace cc | 3028 } // namespace cc |
OLD | NEW |