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 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/containers/small_map.h" | 14 #include "base/containers/small_map.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/numerics/safe_conversions.h" |
17 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
19 #include "base/trace_event/trace_event_argument.h" | 20 #include "base/trace_event/trace_event_argument.h" |
20 #include "cc/animation/animation_id_provider.h" | 21 #include "cc/animation/animation_id_provider.h" |
21 #include "cc/animation/scroll_offset_animation_curve.h" | 22 #include "cc/animation/scroll_offset_animation_curve.h" |
22 #include "cc/animation/scrollbar_animation_controller.h" | 23 #include "cc/animation/scrollbar_animation_controller.h" |
23 #include "cc/animation/timing_function.h" | 24 #include "cc/animation/timing_function.h" |
24 #include "cc/base/math_util.h" | 25 #include "cc/base/math_util.h" |
25 #include "cc/debug/benchmark_instrumentation.h" | 26 #include "cc/debug/benchmark_instrumentation.h" |
26 #include "cc/debug/debug_rect_history.h" | 27 #include "cc/debug/debug_rect_history.h" |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 swap_promises_for_main_thread_scroll_update_.push_back(swap_promise.Pass()); | 565 swap_promises_for_main_thread_scroll_update_.push_back(swap_promise.Pass()); |
565 } | 566 } |
566 | 567 |
567 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 568 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
568 LayerImpl* root_draw_layer, | 569 LayerImpl* root_draw_layer, |
569 const LayerImplList& render_surface_layer_list) { | 570 const LayerImplList& render_surface_layer_list) { |
570 // For now, we use damage tracking to compute a global scissor. To do this, we | 571 // For now, we use damage tracking to compute a global scissor. To do this, we |
571 // must compute all damage tracking before drawing anything, so that we know | 572 // must compute all damage tracking before drawing anything, so that we know |
572 // the root damage rect. The root damage rect is then used to scissor each | 573 // the root damage rect. The root damage rect is then used to scissor each |
573 // surface. | 574 // surface. |
574 | 575 size_t render_surface_layer_list_size = render_surface_layer_list.size(); |
575 for (int surface_index = render_surface_layer_list.size() - 1; | 576 for (size_t i = 0; i < render_surface_layer_list_size; ++i) { |
576 surface_index >= 0; | 577 size_t surface_index = render_surface_layer_list_size - 1 - i; |
577 --surface_index) { | |
578 LayerImpl* render_surface_layer = render_surface_layer_list[surface_index]; | 578 LayerImpl* render_surface_layer = render_surface_layer_list[surface_index]; |
579 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); | 579 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); |
580 DCHECK(render_surface); | 580 DCHECK(render_surface); |
581 render_surface->damage_tracker()->UpdateDamageTrackingState( | 581 render_surface->damage_tracker()->UpdateDamageTrackingState( |
582 render_surface->layer_list(), | 582 render_surface->layer_list(), |
583 render_surface_layer->id(), | 583 render_surface_layer->id(), |
584 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 584 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
585 render_surface->content_rect(), | 585 render_surface->content_rect(), |
586 render_surface_layer->mask_layer(), | 586 render_surface_layer->mask_layer(), |
587 render_surface_layer->filters()); | 587 render_surface_layer->filters()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return DRAW_SUCCESS; | 743 return DRAW_SUCCESS; |
744 } | 744 } |
745 | 745 |
746 TRACE_EVENT_BEGIN2( | 746 TRACE_EVENT_BEGIN2( |
747 "cc", "LayerTreeHostImpl::CalculateRenderPasses", | 747 "cc", "LayerTreeHostImpl::CalculateRenderPasses", |
748 "render_surface_layer_list.size()", | 748 "render_surface_layer_list.size()", |
749 static_cast<uint64>(frame->render_surface_layer_list->size()), | 749 static_cast<uint64>(frame->render_surface_layer_list->size()), |
750 "RequiresHighResToDraw", RequiresHighResToDraw()); | 750 "RequiresHighResToDraw", RequiresHighResToDraw()); |
751 | 751 |
752 // Create the render passes in dependency order. | 752 // Create the render passes in dependency order. |
753 for (int surface_index = frame->render_surface_layer_list->size() - 1; | 753 size_t render_surface_layer_list_size = |
754 surface_index >= 0; | 754 frame->render_surface_layer_list->size(); |
755 --surface_index) { | 755 for (size_t i = 0; i < render_surface_layer_list_size; ++i) { |
| 756 size_t surface_index = render_surface_layer_list_size - 1 - i; |
756 LayerImpl* render_surface_layer = | 757 LayerImpl* render_surface_layer = |
757 (*frame->render_surface_layer_list)[surface_index]; | 758 (*frame->render_surface_layer_list)[surface_index]; |
758 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); | 759 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); |
759 | 760 |
760 bool should_draw_into_render_pass = | 761 bool should_draw_into_render_pass = |
761 render_surface_layer->parent() == NULL || | 762 render_surface_layer->parent() == NULL || |
762 render_surface->contributes_to_drawn_surface() || | 763 render_surface->contributes_to_drawn_surface() || |
763 render_surface_layer->HasCopyRequest(); | 764 render_surface_layer->HasCopyRequest(); |
764 if (should_draw_into_render_pass) | 765 if (should_draw_into_render_pass) |
765 render_surface->AppendRenderPasses(frame); | 766 render_surface->AppendRenderPasses(frame); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 | 990 |
990 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 991 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
991 TRACE_EVENT1("cc", | 992 TRACE_EVENT1("cc", |
992 "LayerTreeHostImpl::PrepareToDraw", | 993 "LayerTreeHostImpl::PrepareToDraw", |
993 "SourceFrameNumber", | 994 "SourceFrameNumber", |
994 active_tree_->source_frame_number()); | 995 active_tree_->source_frame_number()); |
995 if (input_handler_client_) | 996 if (input_handler_client_) |
996 input_handler_client_->ReconcileElasticOverscrollAndRootScroll(); | 997 input_handler_client_->ReconcileElasticOverscrollAndRootScroll(); |
997 | 998 |
998 UMA_HISTOGRAM_CUSTOM_COUNTS( | 999 UMA_HISTOGRAM_CUSTOM_COUNTS( |
999 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1000 "Compositing.NumActiveLayers", |
| 1001 base::saturated_cast<int>(active_tree_->NumLayers()), 1, 400, 20); |
1000 | 1002 |
1001 size_t total_picture_memory = 0; | 1003 size_t total_picture_memory = 0; |
1002 for (const PictureLayerImpl* layer : active_tree()->picture_layers()) | 1004 for (const PictureLayerImpl* layer : active_tree()->picture_layers()) |
1003 total_picture_memory += layer->GetRasterSource()->GetPictureMemoryUsage(); | 1005 total_picture_memory += layer->GetRasterSource()->GetPictureMemoryUsage(); |
1004 if (total_picture_memory != 0) { | 1006 if (total_picture_memory != 0) { |
1005 UMA_HISTOGRAM_COUNTS("Compositing.PictureMemoryUsageKb", | 1007 UMA_HISTOGRAM_COUNTS( |
1006 total_picture_memory / 1024); | 1008 "Compositing.PictureMemoryUsageKb", |
| 1009 base::saturated_cast<int>(total_picture_memory / 1024)); |
1007 } | 1010 } |
1008 | 1011 |
1009 bool update_lcd_text = false; | 1012 bool update_lcd_text = false; |
1010 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text); | 1013 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text); |
1011 DCHECK(ok) << "UpdateDrawProperties failed during draw"; | 1014 DCHECK(ok) << "UpdateDrawProperties failed during draw"; |
1012 | 1015 |
1013 // This will cause NotifyTileStateChanged() to be called for any visible tiles | 1016 // This will cause NotifyTileStateChanged() to be called for any visible tiles |
1014 // that completed, which will add damage to the frame for them so they appear | 1017 // that completed, which will add damage to the frame for them so they appear |
1015 // as part of the current frame being drawn. | 1018 // as part of the current frame being drawn. |
1016 if (tile_manager_) | 1019 if (tile_manager_) |
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3450 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3448 | 3451 |
3449 curve->UpdateTarget( | 3452 curve->UpdateTarget( |
3450 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3453 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3451 .InSecondsF(), | 3454 .InSecondsF(), |
3452 new_target); | 3455 new_target); |
3453 | 3456 |
3454 return true; | 3457 return true; |
3455 } | 3458 } |
3456 } // namespace cc | 3459 } // namespace cc |
OLD | NEW |