| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 465 |
| 465 LayerImpl* layer_impl = | 466 LayerImpl* layer_impl = |
| 466 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( | 467 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 467 device_viewport_point, | 468 device_viewport_point, |
| 468 active_tree_->RenderSurfaceLayerList()); | 469 active_tree_->RenderSurfaceLayerList()); |
| 469 return layer_impl != NULL; | 470 return layer_impl != NULL; |
| 470 } | 471 } |
| 471 | 472 |
| 472 void LayerTreeHostImpl::SetLatencyInfoForInputEvent( | 473 void LayerTreeHostImpl::SetLatencyInfoForInputEvent( |
| 473 const ui::LatencyInfo& latency_info) { | 474 const ui::LatencyInfo& latency_info) { |
| 474 active_tree()->SetLatencyInfo(latency_info); | 475 scoped_ptr<SwapPromise> swap_promise( |
| 476 new LatencyInfoSwapPromise(latency_info)); |
| 477 active_tree()->QueueSwapPromise(swap_promise.Pass()); |
| 475 } | 478 } |
| 476 | 479 |
| 477 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 480 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
| 478 LayerImpl* root_draw_layer, | 481 LayerImpl* root_draw_layer, |
| 479 const LayerImplList& render_surface_layer_list) { | 482 const LayerImplList& render_surface_layer_list) { |
| 480 // 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 |
| 481 // 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 |
| 482 // 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 |
| 483 // surface. | 486 // surface. |
| 484 | 487 |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 } | 1262 } |
| 1260 | 1263 |
| 1261 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { | 1264 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { |
| 1262 CompositorFrameMetadata metadata; | 1265 CompositorFrameMetadata metadata; |
| 1263 metadata.device_scale_factor = device_scale_factor_; | 1266 metadata.device_scale_factor = device_scale_factor_; |
| 1264 metadata.page_scale_factor = active_tree_->total_page_scale_factor(); | 1267 metadata.page_scale_factor = active_tree_->total_page_scale_factor(); |
| 1265 metadata.viewport_size = active_tree_->ScrollableViewportSize(); | 1268 metadata.viewport_size = active_tree_->ScrollableViewportSize(); |
| 1266 metadata.root_layer_size = active_tree_->ScrollableSize(); | 1269 metadata.root_layer_size = active_tree_->ScrollableSize(); |
| 1267 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); | 1270 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); |
| 1268 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); | 1271 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); |
| 1269 metadata.latency_info = active_tree_->GetLatencyInfo(); | |
| 1270 if (top_controls_manager_) { | 1272 if (top_controls_manager_) { |
| 1271 metadata.location_bar_offset = | 1273 metadata.location_bar_offset = |
| 1272 gfx::Vector2dF(0.f, top_controls_manager_->controls_top_offset()); | 1274 gfx::Vector2dF(0.f, top_controls_manager_->controls_top_offset()); |
| 1273 metadata.location_bar_content_translation = | 1275 metadata.location_bar_content_translation = |
| 1274 gfx::Vector2dF(0.f, top_controls_manager_->content_top_offset()); | 1276 gfx::Vector2dF(0.f, top_controls_manager_->content_top_offset()); |
| 1275 metadata.overdraw_bottom_height = overdraw_bottom_height_; | 1277 metadata.overdraw_bottom_height = overdraw_bottom_height_; |
| 1276 } | 1278 } |
| 1277 | 1279 |
| 1278 if (!RootScrollLayer()) | 1280 if (!RootScrollLayer()) |
| 1279 return metadata; | 1281 return metadata; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { | 1420 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { |
| 1419 return renderer_->Capabilities(); | 1421 return renderer_->Capabilities(); |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1424 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
| 1423 if (frame.has_no_damage) { | 1425 if (frame.has_no_damage) { |
| 1424 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1426 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
| 1425 return false; | 1427 return false; |
| 1426 } | 1428 } |
| 1427 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1429 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
| 1430 active_tree()->FinishSwapPromises(&metadata); |
| 1428 renderer_->SwapBuffers(metadata); | 1431 renderer_->SwapBuffers(metadata); |
| 1429 active_tree_->ClearLatencyInfo(); | |
| 1430 active_tree()->FinishSwapPromises(); | |
| 1431 return true; | 1432 return true; |
| 1432 } | 1433 } |
| 1433 | 1434 |
| 1434 void LayerTreeHostImpl::SetNeedsBeginImplFrame(bool enable) { | 1435 void LayerTreeHostImpl::SetNeedsBeginImplFrame(bool enable) { |
| 1435 if (output_surface_) | 1436 if (output_surface_) |
| 1436 output_surface_->SetNeedsBeginImplFrame(enable); | 1437 output_surface_->SetNeedsBeginImplFrame(enable); |
| 1437 } | 1438 } |
| 1438 | 1439 |
| 1439 gfx::SizeF LayerTreeHostImpl::UnscaledScrollableViewportSize() const { | 1440 gfx::SizeF LayerTreeHostImpl::UnscaledScrollableViewportSize() const { |
| 1440 // Use the root container layer bounds if it clips to them, otherwise, the | 1441 // Use the root container layer bounds if it clips to them, otherwise, the |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 if (evicted_ui_resources_.empty()) | 2866 if (evicted_ui_resources_.empty()) |
| 2866 client_->OnCanDrawStateChanged(CanDraw()); | 2867 client_->OnCanDrawStateChanged(CanDraw()); |
| 2867 } | 2868 } |
| 2868 | 2869 |
| 2869 void LayerTreeHostImpl::ScheduleMicroBenchmark( | 2870 void LayerTreeHostImpl::ScheduleMicroBenchmark( |
| 2870 scoped_ptr<MicroBenchmarkImpl> benchmark) { | 2871 scoped_ptr<MicroBenchmarkImpl> benchmark) { |
| 2871 micro_benchmark_controller_.ScheduleRun(benchmark.Pass()); | 2872 micro_benchmark_controller_.ScheduleRun(benchmark.Pass()); |
| 2872 } | 2873 } |
| 2873 | 2874 |
| 2874 } // namespace cc | 2875 } // namespace cc |
| OLD | NEW |