| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { | 335 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { |
| 336 if (!EnsureRenderSurfaceLayerList()) | 336 if (!EnsureRenderSurfaceLayerList()) |
| 337 return false; | 337 return false; |
| 338 | 338 |
| 339 gfx::PointF device_viewport_point = | 339 gfx::PointF device_viewport_point = |
| 340 gfx::ScalePoint(viewport_point, device_scale_factor_); | 340 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 341 | 341 |
| 342 // First find out which layer was hit from the saved list of visible layers | 342 // First find out which layer was hit from the saved list of visible layers |
| 343 // in the most recent frame. | 343 // in the most recent frame. |
| 344 LayerImpl* layer_impl = LayerTreeHostCommon::findLayerThatIsHitByPoint( | 344 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 345 device_viewport_point, | 345 device_viewport_point, |
| 346 active_tree_->RenderSurfaceLayerList()); | 346 active_tree_->RenderSurfaceLayerList()); |
| 347 | 347 |
| 348 // Walk up the hierarchy and look for a layer with a touch event handler | 348 // Walk up the hierarchy and look for a layer with a touch event handler |
| 349 // region that the given point hits. | 349 // region that the given point hits. |
| 350 for (; layer_impl; layer_impl = layer_impl->parent()) { | 350 for (; layer_impl; layer_impl = layer_impl->parent()) { |
| 351 if (LayerTreeHostCommon::layerHasTouchEventHandlersAt(device_viewport_point, | 351 if (LayerTreeHostCommon::LayerHasTouchEventHandlersAt(device_viewport_point, |
| 352 layer_impl)) | 352 layer_impl)) |
| 353 return true; | 353 return true; |
| 354 } | 354 } |
| 355 | 355 |
| 356 return false; | 356 return false; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 359 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
| 360 LayerImpl* root_draw_layer, | 360 LayerImpl* root_draw_layer, |
| 361 const LayerList& render_surface_layer_list) { | 361 const LayerList& render_surface_layer_list) { |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 ClearCurrentlyScrollingLayer(); | 1358 ClearCurrentlyScrollingLayer(); |
| 1359 | 1359 |
| 1360 if (!EnsureRenderSurfaceLayerList()) | 1360 if (!EnsureRenderSurfaceLayerList()) |
| 1361 return ScrollIgnored; | 1361 return ScrollIgnored; |
| 1362 | 1362 |
| 1363 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 1363 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
| 1364 device_scale_factor_); | 1364 device_scale_factor_); |
| 1365 | 1365 |
| 1366 // First find out which layer was hit from the saved list of visible layers | 1366 // First find out which layer was hit from the saved list of visible layers |
| 1367 // in the most recent frame. | 1367 // in the most recent frame. |
| 1368 LayerImpl* layer_impl = LayerTreeHostCommon::findLayerThatIsHitByPoint( | 1368 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 1369 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | 1369 device_viewport_point, active_tree_->RenderSurfaceLayerList()); |
| 1370 | 1370 |
| 1371 // Walk up the hierarchy and look for a scrollable layer. | 1371 // Walk up the hierarchy and look for a scrollable layer. |
| 1372 LayerImpl* potentially_scrolling_layer_impl = 0; | 1372 LayerImpl* potentially_scrolling_layer_impl = 0; |
| 1373 for (; layer_impl; layer_impl = layer_impl->parent()) { | 1373 for (; layer_impl; layer_impl = layer_impl->parent()) { |
| 1374 // The content layer can also block attempts to scroll outside the main | 1374 // The content layer can also block attempts to scroll outside the main |
| 1375 // thread. | 1375 // thread. |
| 1376 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 1376 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
| 1377 if (status == ScrollOnMainThread) { | 1377 if (status == ScrollOnMainThread) { |
| 1378 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); | 1378 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 | 1638 |
| 1639 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 1639 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 1640 LayerImpl* layer_impl) { | 1640 LayerImpl* layer_impl) { |
| 1641 if (!layer_impl) | 1641 if (!layer_impl) |
| 1642 return; | 1642 return; |
| 1643 | 1643 |
| 1644 gfx::Vector2d scroll_delta = | 1644 gfx::Vector2d scroll_delta = |
| 1645 gfx::ToFlooredVector2d(layer_impl->scroll_delta()); | 1645 gfx::ToFlooredVector2d(layer_impl->scroll_delta()); |
| 1646 if (!scroll_delta.IsZero()) { | 1646 if (!scroll_delta.IsZero()) { |
| 1647 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 1647 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
| 1648 scroll.layerId = layer_impl->id(); | 1648 scroll.layer_id = layer_impl->id(); |
| 1649 scroll.scrollDelta = scroll_delta; | 1649 scroll.scroll_delta = scroll_delta; |
| 1650 scroll_info->scrolls.push_back(scroll); | 1650 scroll_info->scrolls.push_back(scroll); |
| 1651 layer_impl->SetSentScrollDelta(scroll_delta); | 1651 layer_impl->SetSentScrollDelta(scroll_delta); |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 1654 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
| 1655 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 1655 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
| 1656 } | 1656 } |
| 1657 | 1657 |
| 1658 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 1658 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 1659 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 1659 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 1660 | 1660 |
| 1661 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 1661 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
| 1662 scroll_info->pageScaleDelta = active_tree_->page_scale_delta(); | 1662 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
| 1663 active_tree_->set_sent_page_scale_delta(scroll_info->pageScaleDelta); | 1663 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
| 1664 | 1664 |
| 1665 return scroll_info.Pass(); | 1665 return scroll_info.Pass(); |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 1668 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
| 1669 if (active_tree_->root_layer()) { | 1669 if (active_tree_->root_layer()) { |
| 1670 RenderSurfaceImpl* render_surface = | 1670 RenderSurfaceImpl* render_surface = |
| 1671 active_tree_->root_layer()->render_surface(); | 1671 active_tree_->root_layer()->render_surface(); |
| 1672 if (render_surface) | 1672 if (render_surface) |
| 1673 render_surface->damage_tracker()->ForceFullDamageNextUpdate(); | 1673 render_surface->damage_tracker()->ForceFullDamageNextUpdate(); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 debug_state_ = debug_state; | 1965 debug_state_ = debug_state; |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, | 1968 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, |
| 1969 int commit_number) { | 1969 int commit_number) { |
| 1970 DCHECK(debug_state_.continuous_painting); | 1970 DCHECK(debug_state_.continuous_painting); |
| 1971 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); | 1971 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); |
| 1972 } | 1972 } |
| 1973 | 1973 |
| 1974 } // namespace cc | 1974 } // namespace cc |
| OLD | NEW |