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