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.h" | |
19 #include "cc/base/math_util.h" | 18 #include "cc/base/math_util.h" |
20 #include "cc/base/util.h" | 19 #include "cc/base/util.h" |
21 #include "cc/debug/benchmark_instrumentation.h" | 20 #include "cc/debug/benchmark_instrumentation.h" |
22 #include "cc/debug/debug_rect_history.h" | 21 #include "cc/debug/debug_rect_history.h" |
23 #include "cc/debug/frame_rate_counter.h" | 22 #include "cc/debug/frame_rate_counter.h" |
24 #include "cc/debug/overdraw_metrics.h" | 23 #include "cc/debug/overdraw_metrics.h" |
25 #include "cc/debug/paint_time_counter.h" | 24 #include "cc/debug/paint_time_counter.h" |
26 #include "cc/debug/rendering_stats_instrumentation.h" | 25 #include "cc/debug/rendering_stats_instrumentation.h" |
27 #include "cc/debug/traced_value.h" | 26 #include "cc/debug/traced_value.h" |
28 #include "cc/input/page_scale_animation.h" | 27 #include "cc/input/page_scale_animation.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 467 |
469 LayerImpl* layer_impl = | 468 LayerImpl* layer_impl = |
470 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 469 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
471 device_viewport_point, | 470 device_viewport_point, |
472 active_tree_->RenderSurfaceLayerList()); | 471 active_tree_->RenderSurfaceLayerList()); |
473 return layer_impl != NULL; | 472 return layer_impl != NULL; |
474 } | 473 } |
475 | 474 |
476 void LayerTreeHostImpl::SetLatencyInfoForInputEvent( | 475 void LayerTreeHostImpl::SetLatencyInfoForInputEvent( |
477 const ui::LatencyInfo& latency_info) { | 476 const ui::LatencyInfo& latency_info) { |
478 scoped_ptr<SwapPromise> swap_promise( | 477 active_tree()->SetLatencyInfo(latency_info); |
479 new LatencyInfoSwapPromise(latency_info)); | |
480 active_tree()->QueueSwapPromise(swap_promise.Pass()); | |
481 } | 478 } |
482 | 479 |
483 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 480 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
484 LayerImpl* root_draw_layer, | 481 LayerImpl* root_draw_layer, |
485 const LayerImplList& render_surface_layer_list) { | 482 const LayerImplList& render_surface_layer_list) { |
486 // For now, we use damage tracking to compute a global scissor. To do this, we | 483 // For now, we use damage tracking to compute a global scissor. To do this, we |
487 // must compute all damage tracking before drawing anything, so that we know | 484 // must compute all damage tracking before drawing anything, so that we know |
488 // the root damage rect. The root damage rect is then used to scissor each | 485 // the root damage rect. The root damage rect is then used to scissor each |
489 // surface. | 486 // surface. |
490 | 487 |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 } | 1262 } |
1266 | 1263 |
1267 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { | 1264 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { |
1268 CompositorFrameMetadata metadata; | 1265 CompositorFrameMetadata metadata; |
1269 metadata.device_scale_factor = device_scale_factor_; | 1266 metadata.device_scale_factor = device_scale_factor_; |
1270 metadata.page_scale_factor = active_tree_->total_page_scale_factor(); | 1267 metadata.page_scale_factor = active_tree_->total_page_scale_factor(); |
1271 metadata.viewport_size = active_tree_->ScrollableViewportSize(); | 1268 metadata.viewport_size = active_tree_->ScrollableViewportSize(); |
1272 metadata.root_layer_size = active_tree_->ScrollableSize(); | 1269 metadata.root_layer_size = active_tree_->ScrollableSize(); |
1273 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); | 1270 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); |
1274 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); | 1271 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); |
| 1272 metadata.latency_info = active_tree_->GetLatencyInfo(); |
1275 if (top_controls_manager_) { | 1273 if (top_controls_manager_) { |
1276 metadata.location_bar_offset = | 1274 metadata.location_bar_offset = |
1277 gfx::Vector2dF(0.f, top_controls_manager_->controls_top_offset()); | 1275 gfx::Vector2dF(0.f, top_controls_manager_->controls_top_offset()); |
1278 metadata.location_bar_content_translation = | 1276 metadata.location_bar_content_translation = |
1279 gfx::Vector2dF(0.f, top_controls_manager_->content_top_offset()); | 1277 gfx::Vector2dF(0.f, top_controls_manager_->content_top_offset()); |
1280 metadata.overdraw_bottom_height = overdraw_bottom_height_; | 1278 metadata.overdraw_bottom_height = overdraw_bottom_height_; |
1281 } | 1279 } |
1282 | 1280 |
1283 if (!RootScrollLayer()) | 1281 if (!RootScrollLayer()) |
1284 return metadata; | 1282 return metadata; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { | 1421 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { |
1424 return renderer_->Capabilities(); | 1422 return renderer_->Capabilities(); |
1425 } | 1423 } |
1426 | 1424 |
1427 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1425 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1428 if (frame.has_no_damage) { | 1426 if (frame.has_no_damage) { |
1429 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1427 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1430 return false; | 1428 return false; |
1431 } | 1429 } |
1432 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1430 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
1433 active_tree()->FinishSwapPromises(&metadata); | |
1434 renderer_->SwapBuffers(metadata); | 1431 renderer_->SwapBuffers(metadata); |
| 1432 active_tree_->ClearLatencyInfo(); |
| 1433 active_tree()->FinishSwapPromises(); |
1435 return true; | 1434 return true; |
1436 } | 1435 } |
1437 | 1436 |
1438 void LayerTreeHostImpl::SetNeedsBeginImplFrame(bool enable) { | 1437 void LayerTreeHostImpl::SetNeedsBeginImplFrame(bool enable) { |
1439 if (output_surface_) | 1438 if (output_surface_) |
1440 output_surface_->SetNeedsBeginImplFrame(enable); | 1439 output_surface_->SetNeedsBeginImplFrame(enable); |
1441 } | 1440 } |
1442 | 1441 |
1443 gfx::SizeF LayerTreeHostImpl::UnscaledScrollableViewportSize() const { | 1442 gfx::SizeF LayerTreeHostImpl::UnscaledScrollableViewportSize() const { |
1444 // Use the root container layer bounds if it clips to them, otherwise, the | 1443 // Use the root container layer bounds if it clips to them, otherwise, the |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 if (evicted_ui_resources_.empty()) | 2875 if (evicted_ui_resources_.empty()) |
2877 client_->OnCanDrawStateChanged(CanDraw()); | 2876 client_->OnCanDrawStateChanged(CanDraw()); |
2878 } | 2877 } |
2879 | 2878 |
2880 void LayerTreeHostImpl::ScheduleMicroBenchmark( | 2879 void LayerTreeHostImpl::ScheduleMicroBenchmark( |
2881 scoped_ptr<MicroBenchmarkImpl> benchmark) { | 2880 scoped_ptr<MicroBenchmarkImpl> benchmark) { |
2882 micro_benchmark_controller_.ScheduleRun(benchmark.Pass()); | 2881 micro_benchmark_controller_.ScheduleRun(benchmark.Pass()); |
2883 } | 2882 } |
2884 | 2883 |
2885 } // namespace cc | 2884 } // namespace cc |
OLD | NEW |