| 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 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { | 332 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { |
| 333 if (!EnsureRenderSurfaceLayerList()) | 333 if (!EnsureRenderSurfaceLayerList()) |
| 334 return false; | 334 return false; |
| 335 | 335 |
| 336 gfx::PointF device_viewport_point = | 336 gfx::PointF device_viewport_point = |
| 337 gfx::ScalePoint(viewport_point, device_scale_factor_); | 337 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 338 | 338 |
| 339 // First find out which layer was hit from the saved list of visible layers | 339 // First find out which layer was hit from the saved list of visible layers |
| 340 // in the most recent frame. | 340 // in the most recent frame. |
| 341 LayerImpl* layer_impl = LayerTreeHostCommon::findLayerThatIsHitByPoint( | 341 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 342 device_viewport_point, | 342 device_viewport_point, |
| 343 active_tree_->RenderSurfaceLayerList()); | 343 active_tree_->RenderSurfaceLayerList()); |
| 344 | 344 |
| 345 // Walk up the hierarchy and look for a layer with a touch event handler | 345 // Walk up the hierarchy and look for a layer with a touch event handler |
| 346 // region that the given point hits. | 346 // region that the given point hits. |
| 347 for (; layer_impl; layer_impl = layer_impl->parent()) { | 347 for (; layer_impl; layer_impl = layer_impl->parent()) { |
| 348 if (LayerTreeHostCommon::layerHasTouchEventHandlersAt(device_viewport_point, | 348 if (LayerTreeHostCommon::LayerHasTouchEventHandlersAt(device_viewport_point, |
| 349 layer_impl)) | 349 layer_impl)) |
| 350 return true; | 350 return true; |
| 351 } | 351 } |
| 352 | 352 |
| 353 return false; | 353 return false; |
| 354 } | 354 } |
| 355 | 355 |
| 356 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 356 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
| 357 LayerImpl* root_draw_layer, | 357 LayerImpl* root_draw_layer, |
| 358 const LayerList& render_surface_layer_list) { | 358 const LayerList& render_surface_layer_list) { |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 ClearCurrentlyScrollingLayer(); | 1345 ClearCurrentlyScrollingLayer(); |
| 1346 | 1346 |
| 1347 if (!EnsureRenderSurfaceLayerList()) | 1347 if (!EnsureRenderSurfaceLayerList()) |
| 1348 return ScrollIgnored; | 1348 return ScrollIgnored; |
| 1349 | 1349 |
| 1350 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 1350 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
| 1351 device_scale_factor_); | 1351 device_scale_factor_); |
| 1352 | 1352 |
| 1353 // First find out which layer was hit from the saved list of visible layers | 1353 // First find out which layer was hit from the saved list of visible layers |
| 1354 // in the most recent frame. | 1354 // in the most recent frame. |
| 1355 LayerImpl* layer_impl = LayerTreeHostCommon::findLayerThatIsHitByPoint( | 1355 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 1356 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | 1356 device_viewport_point, active_tree_->RenderSurfaceLayerList()); |
| 1357 | 1357 |
| 1358 // Walk up the hierarchy and look for a scrollable layer. | 1358 // Walk up the hierarchy and look for a scrollable layer. |
| 1359 LayerImpl* potentially_scrolling_layer_impl = 0; | 1359 LayerImpl* potentially_scrolling_layer_impl = 0; |
| 1360 for (; layer_impl; layer_impl = layer_impl->parent()) { | 1360 for (; layer_impl; layer_impl = layer_impl->parent()) { |
| 1361 // The content layer can also block attempts to scroll outside the main | 1361 // The content layer can also block attempts to scroll outside the main |
| 1362 // thread. | 1362 // thread. |
| 1363 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 1363 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
| 1364 if (status == ScrollOnMainThread) { | 1364 if (status == ScrollOnMainThread) { |
| 1365 num_main_thread_scrolls_++; | 1365 num_main_thread_scrolls_++; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 | 1625 |
| 1626 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 1626 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 1627 LayerImpl* layer_impl) { | 1627 LayerImpl* layer_impl) { |
| 1628 if (!layer_impl) | 1628 if (!layer_impl) |
| 1629 return; | 1629 return; |
| 1630 | 1630 |
| 1631 gfx::Vector2d scroll_delta = | 1631 gfx::Vector2d scroll_delta = |
| 1632 gfx::ToFlooredVector2d(layer_impl->scroll_delta()); | 1632 gfx::ToFlooredVector2d(layer_impl->scroll_delta()); |
| 1633 if (!scroll_delta.IsZero()) { | 1633 if (!scroll_delta.IsZero()) { |
| 1634 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 1634 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
| 1635 scroll.layerId = layer_impl->id(); | 1635 scroll.layer_id = layer_impl->id(); |
| 1636 scroll.scrollDelta = scroll_delta; | 1636 scroll.scroll_delta = scroll_delta; |
| 1637 scroll_info->scrolls.push_back(scroll); | 1637 scroll_info->scrolls.push_back(scroll); |
| 1638 layer_impl->SetSentScrollDelta(scroll_delta); | 1638 layer_impl->SetSentScrollDelta(scroll_delta); |
| 1639 } | 1639 } |
| 1640 | 1640 |
| 1641 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 1641 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
| 1642 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 1642 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
| 1643 } | 1643 } |
| 1644 | 1644 |
| 1645 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 1645 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 1646 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 1646 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 1647 | 1647 |
| 1648 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 1648 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
| 1649 scroll_info->pageScaleDelta = active_tree_->page_scale_delta(); | 1649 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
| 1650 active_tree_->set_sent_page_scale_delta(scroll_info->pageScaleDelta); | 1650 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
| 1651 | 1651 |
| 1652 return scroll_info.Pass(); | 1652 return scroll_info.Pass(); |
| 1653 } | 1653 } |
| 1654 | 1654 |
| 1655 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 1655 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
| 1656 if (active_tree_->root_layer()) { | 1656 if (active_tree_->root_layer()) { |
| 1657 RenderSurfaceImpl* render_surface = | 1657 RenderSurfaceImpl* render_surface = |
| 1658 active_tree_->root_layer()->render_surface(); | 1658 active_tree_->root_layer()->render_surface(); |
| 1659 if (render_surface) | 1659 if (render_surface) |
| 1660 render_surface->damage_tracker()->ForceFullDamageNextUpdate(); | 1660 render_surface->damage_tracker()->ForceFullDamageNextUpdate(); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 tile_manager_->SetRecordRenderingStats(debug_state_.RecordRenderingStats()); | 1967 tile_manager_->SetRecordRenderingStats(debug_state_.RecordRenderingStats()); |
| 1968 } | 1968 } |
| 1969 | 1969 |
| 1970 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, | 1970 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, |
| 1971 int commit_number) { | 1971 int commit_number) { |
| 1972 DCHECK(debug_state_.continuous_painting); | 1972 DCHECK(debug_state_.continuous_painting); |
| 1973 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); | 1973 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); |
| 1974 } | 1974 } |
| 1975 | 1975 |
| 1976 } // namespace cc | 1976 } // namespace cc |
| OLD | NEW |