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 <iostream> |
8 #include <limits> | 9 #include <limits> |
9 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
12 #include "base/debug/trace_event_argument.h" | 13 #include "base/debug/trace_event_argument.h" |
13 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "cc/animation/animation_id_provider.h" | 18 #include "cc/animation/animation_id_provider.h" |
18 #include "cc/animation/scroll_offset_animation_curve.h" | 19 #include "cc/animation/scroll_offset_animation_curve.h" |
19 #include "cc/animation/scrollbar_animation_controller.h" | 20 #include "cc/animation/scrollbar_animation_controller.h" |
20 #include "cc/animation/timing_function.h" | 21 #include "cc/animation/timing_function.h" |
21 #include "cc/base/latency_info_swap_promise_monitor.h" | 22 #include "cc/base/latency_info_swap_promise_monitor.h" |
22 #include "cc/base/math_util.h" | 23 #include "cc/base/math_util.h" |
23 #include "cc/base/util.h" | 24 #include "cc/base/util.h" |
24 #include "cc/debug/benchmark_instrumentation.h" | 25 #include "cc/debug/benchmark_instrumentation.h" |
25 #include "cc/debug/debug_rect_history.h" | 26 #include "cc/debug/debug_rect_history.h" |
26 #include "cc/debug/devtools_instrumentation.h" | 27 #include "cc/debug/devtools_instrumentation.h" |
27 #include "cc/debug/frame_rate_counter.h" | 28 #include "cc/debug/frame_rate_counter.h" |
28 #include "cc/debug/paint_time_counter.h" | 29 #include "cc/debug/paint_time_counter.h" |
29 #include "cc/debug/rendering_stats_instrumentation.h" | 30 #include "cc/debug/rendering_stats_instrumentation.h" |
| 31 #include "cc/debug/smoothness_timing_tracker.h" |
30 #include "cc/debug/traced_value.h" | 32 #include "cc/debug/traced_value.h" |
31 #include "cc/input/page_scale_animation.h" | 33 #include "cc/input/page_scale_animation.h" |
32 #include "cc/input/top_controls_manager.h" | 34 #include "cc/input/top_controls_manager.h" |
33 #include "cc/layers/append_quads_data.h" | 35 #include "cc/layers/append_quads_data.h" |
34 #include "cc/layers/heads_up_display_layer_impl.h" | 36 #include "cc/layers/heads_up_display_layer_impl.h" |
35 #include "cc/layers/layer_impl.h" | 37 #include "cc/layers/layer_impl.h" |
36 #include "cc/layers/layer_iterator.h" | 38 #include "cc/layers/layer_iterator.h" |
37 #include "cc/layers/painted_scrollbar_layer_impl.h" | 39 #include "cc/layers/painted_scrollbar_layer_impl.h" |
38 #include "cc/layers/render_surface_impl.h" | 40 #include "cc/layers/render_surface_impl.h" |
39 #include "cc/layers/scrollbar_layer_impl_base.h" | 41 #include "cc/layers/scrollbar_layer_impl_base.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 root_layer_scroll_offset_delegate_(NULL), | 242 root_layer_scroll_offset_delegate_(NULL), |
241 settings_(settings), | 243 settings_(settings), |
242 visible_(true), | 244 visible_(true), |
243 cached_managed_memory_policy_( | 245 cached_managed_memory_policy_( |
244 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 246 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
245 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 247 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
246 ManagedMemoryPolicy::kDefaultNumResourcesLimit), | 248 ManagedMemoryPolicy::kDefaultNumResourcesLimit), |
247 pinch_gesture_active_(false), | 249 pinch_gesture_active_(false), |
248 pinch_gesture_end_should_clear_scrolling_layer_(false), | 250 pinch_gesture_end_should_clear_scrolling_layer_(false), |
249 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), | 251 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), |
| 252 smoothness_tracker_(SmoothnessTimingTracker::Create()), |
250 paint_time_counter_(PaintTimeCounter::Create()), | 253 paint_time_counter_(PaintTimeCounter::Create()), |
251 memory_history_(MemoryHistory::Create()), | 254 memory_history_(MemoryHistory::Create()), |
252 debug_rect_history_(DebugRectHistory::Create()), | 255 debug_rect_history_(DebugRectHistory::Create()), |
253 texture_mailbox_deleter_(new TextureMailboxDeleter( | 256 texture_mailbox_deleter_(new TextureMailboxDeleter( |
254 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 257 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
255 : proxy_->MainThreadTaskRunner())), | 258 : proxy_->MainThreadTaskRunner())), |
256 max_memory_needed_bytes_(0), | 259 max_memory_needed_bytes_(0), |
257 zero_budget_(false), | 260 zero_budget_(false), |
258 device_scale_factor_(1.f), | 261 device_scale_factor_(1.f), |
259 overhang_ui_resource_id_(0), | 262 overhang_ui_resource_id_(0), |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 860 |
858 contributing_render_pass_id = | 861 contributing_render_pass_id = |
859 it->NextContributingRenderPassId(contributing_render_pass_id); | 862 it->NextContributingRenderPassId(contributing_render_pass_id); |
860 } | 863 } |
861 } | 864 } |
862 | 865 |
863 AppendQuadsForLayer(target_render_pass, | 866 AppendQuadsForLayer(target_render_pass, |
864 *it, | 867 *it, |
865 occlusion_tracker, | 868 occlusion_tracker, |
866 &append_quads_data); | 869 &append_quads_data); |
| 870 |
| 871 const std::vector<std::pair<int64_t, gfx::Rect> >& vec = |
| 872 it->smoothness_timing_requests(); |
| 873 if (vec.size()) { |
| 874 gfx::Rect damage = |
| 875 root_surface->damage_tracker()->current_damage_rect(); |
| 876 |
| 877 gfx::Transform inverse_screen_space_transform( |
| 878 gfx::Transform::kSkipInitialization); |
| 879 if (it->screen_space_transform().GetInverse( |
| 880 &inverse_screen_space_transform)) |
| 881 damage = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 882 inverse_screen_space_transform, |
| 883 root_surface->damage_tracker()->current_damage_rect())); |
| 884 |
| 885 std::cout << "[LayerTreeHostImpl] it->id() " << it->id() |
| 886 << " it->damage = [" << damage.x() << ", " << damage.y() |
| 887 << ", " << damage.right() << ", " << damage.bottom() << "]" |
| 888 << std::endl; |
| 889 for (size_t i = 0; i < vec.size(); ++i) { |
| 890 int64_t rect_id = vec[i].first; |
| 891 gfx::Rect rect = gfx::ScaleToEnclosingRect( |
| 892 vec[i].second, it->contents_scale_x(), it->contents_scale_y()); |
| 893 bool intersects = damage.Intersects(rect); |
| 894 std::cout << "[LayerTreeHostImpl] Target " << rect_id |
| 895 << (intersects ? " Intersects " : " Misses ") << " - [" |
| 896 << rect.x() << ", " << rect.y() << ", " << rect.width() |
| 897 << ", " << rect.height() << "]" << std::endl; |
| 898 if (intersects) { |
| 899 uncommitted_composite_ids_.push_back( |
| 900 std::make_pair(active_tree_->source_frame_number(), rect_id)); |
| 901 } |
| 902 } |
| 903 } |
867 } | 904 } |
868 | |
869 ++layers_drawn; | 905 ++layers_drawn; |
870 } | 906 } |
871 | 907 |
872 rendering_stats_instrumentation_->AddVisibleContentArea( | 908 rendering_stats_instrumentation_->AddVisibleContentArea( |
873 append_quads_data.visible_content_area); | 909 append_quads_data.visible_content_area); |
874 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( | 910 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( |
875 append_quads_data.approximated_visible_content_area); | 911 append_quads_data.approximated_visible_content_area); |
876 | 912 |
877 num_missing_tiles += append_quads_data.num_missing_tiles; | 913 num_missing_tiles += append_quads_data.num_missing_tiles; |
878 num_incomplete_tiles += append_quads_data.num_incomplete_tiles; | 914 num_incomplete_tiles += append_quads_data.num_incomplete_tiles; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 | 1536 |
1501 void LayerTreeHostImpl::DrawLayers(FrameData* frame, | 1537 void LayerTreeHostImpl::DrawLayers(FrameData* frame, |
1502 base::TimeTicks frame_begin_time) { | 1538 base::TimeTicks frame_begin_time) { |
1503 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); | 1539 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); |
1504 DCHECK(CanDraw()); | 1540 DCHECK(CanDraw()); |
1505 | 1541 |
1506 if (frame->has_no_damage) { | 1542 if (frame->has_no_damage) { |
1507 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); | 1543 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); |
1508 DCHECK(!output_surface_->capabilities() | 1544 DCHECK(!output_surface_->capabilities() |
1509 .draw_and_swap_full_viewport_every_frame); | 1545 .draw_and_swap_full_viewport_every_frame); |
| 1546 uncommitted_composite_ids_.clear(); |
1510 return; | 1547 return; |
1511 } | 1548 } |
1512 | 1549 |
1513 DCHECK(!frame->render_passes.empty()); | 1550 DCHECK(!frame->render_passes.empty()); |
1514 | 1551 |
1515 fps_counter_->SaveTimeStamp(frame_begin_time, | 1552 fps_counter_->SaveTimeStamp(frame_begin_time, |
1516 !output_surface_->context_provider()); | 1553 !output_surface_->context_provider()); |
1517 bool on_main_thread = false; | 1554 bool on_main_thread = false; |
1518 rendering_stats_instrumentation_->IncrementFrameCount( | 1555 rendering_stats_instrumentation_->IncrementFrameCount( |
1519 1, on_main_thread); | 1556 1, on_main_thread); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 renderer_->DrawFrame(&frame->render_passes, | 1626 renderer_->DrawFrame(&frame->render_passes, |
1590 device_scale_factor_, | 1627 device_scale_factor_, |
1591 DeviceViewport(), | 1628 DeviceViewport(), |
1592 DeviceClip(), | 1629 DeviceClip(), |
1593 false); | 1630 false); |
1594 } | 1631 } |
1595 // The render passes should be consumed by the renderer. | 1632 // The render passes should be consumed by the renderer. |
1596 DCHECK(frame->render_passes.empty()); | 1633 DCHECK(frame->render_passes.empty()); |
1597 frame->render_passes_by_id.clear(); | 1634 frame->render_passes_by_id.clear(); |
1598 | 1635 |
| 1636 smoothness_tracker_->SaveTimeStamps(gfx::FrameTime::Now(), |
| 1637 uncommitted_composite_ids_); |
| 1638 uncommitted_composite_ids_.clear(); |
| 1639 |
1599 // The next frame should start by assuming nothing has changed, and changes | 1640 // The next frame should start by assuming nothing has changed, and changes |
1600 // are noted as they occur. | 1641 // are noted as they occur. |
1601 // TODO(boliu): If we did a temporary software renderer frame, propogate the | 1642 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
1602 // damage forward to the next frame. | 1643 // damage forward to the next frame. |
1603 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | 1644 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { |
1604 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> | 1645 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> |
1605 DidDrawDamagedArea(); | 1646 DidDrawDamagedArea(); |
1606 } | 1647 } |
1607 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); | 1648 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); |
1608 | 1649 |
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3378 } | 3419 } |
3379 | 3420 |
3380 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3421 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3381 std::vector<PictureLayerImpl*>::iterator it = | 3422 std::vector<PictureLayerImpl*>::iterator it = |
3382 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3423 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3383 DCHECK(it != picture_layers_.end()); | 3424 DCHECK(it != picture_layers_.end()); |
3384 picture_layers_.erase(it); | 3425 picture_layers_.erase(it); |
3385 } | 3426 } |
3386 | 3427 |
3387 } // namespace cc | 3428 } // namespace cc |
OLD | NEW |