| 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_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 max_page_scale_factor_(0), | 78 max_page_scale_factor_(0), |
| 79 device_scale_factor_(1.f), | 79 device_scale_factor_(1.f), |
| 80 painted_device_scale_factor_(1.f), | 80 painted_device_scale_factor_(1.f), |
| 81 elastic_overscroll_(elastic_overscroll), | 81 elastic_overscroll_(elastic_overscroll), |
| 82 viewport_size_invalid_(false), | 82 viewport_size_invalid_(false), |
| 83 needs_update_draw_properties_(true), | 83 needs_update_draw_properties_(true), |
| 84 needs_full_tree_sync_(true), | 84 needs_full_tree_sync_(true), |
| 85 next_activation_forces_redraw_(false), | 85 next_activation_forces_redraw_(false), |
| 86 has_ever_been_drawn_(false), | 86 has_ever_been_drawn_(false), |
| 87 render_surface_layer_list_id_(0), | 87 render_surface_layer_list_id_(0), |
| 88 have_wheel_event_handlers_(false), |
| 88 top_controls_shrink_blink_size_(false), | 89 top_controls_shrink_blink_size_(false), |
| 89 top_controls_height_(0), | 90 top_controls_height_(0), |
| 90 top_controls_shown_ratio_(top_controls_shown_ratio) {} | 91 top_controls_shown_ratio_(top_controls_shown_ratio) {} |
| 91 | 92 |
| 92 LayerTreeImpl::~LayerTreeImpl() { | 93 LayerTreeImpl::~LayerTreeImpl() { |
| 93 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS | 94 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS |
| 94 : SwapPromise::ACTIVATION_FAILS); | 95 : SwapPromise::ACTIVATION_FAILS); |
| 95 | 96 |
| 96 // Need to explicitly clear the tree prior to destroying this so that | 97 // Need to explicitly clear the tree prior to destroying this so that |
| 97 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. | 98 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 overscroll_elasticity_layer_id_, page_scale_layer_id_, | 348 overscroll_elasticity_layer_id_, page_scale_layer_id_, |
| 348 inner_viewport_scroll_layer_id_, outer_viewport_scroll_layer_id_); | 349 inner_viewport_scroll_layer_id_, outer_viewport_scroll_layer_id_); |
| 349 | 350 |
| 350 target_tree->RegisterSelection(selection_); | 351 target_tree->RegisterSelection(selection_); |
| 351 | 352 |
| 352 // This should match the property synchronization in | 353 // This should match the property synchronization in |
| 353 // LayerTreeHost::finishCommitOnImplThread(). | 354 // LayerTreeHost::finishCommitOnImplThread(). |
| 354 target_tree->set_source_frame_number(source_frame_number()); | 355 target_tree->set_source_frame_number(source_frame_number()); |
| 355 target_tree->set_background_color(background_color()); | 356 target_tree->set_background_color(background_color()); |
| 356 target_tree->set_has_transparent_background(has_transparent_background()); | 357 target_tree->set_has_transparent_background(has_transparent_background()); |
| 358 target_tree->set_have_wheel_event_handlers(have_wheel_event_handlers()); |
| 357 | 359 |
| 358 if (ViewportSizeInvalid()) | 360 if (ViewportSizeInvalid()) |
| 359 target_tree->SetViewportSizeInvalid(); | 361 target_tree->SetViewportSizeInvalid(); |
| 360 else | 362 else |
| 361 target_tree->ResetViewportSizeInvalid(); | 363 target_tree->ResetViewportSizeInvalid(); |
| 362 | 364 |
| 363 if (hud_layer()) | 365 if (hud_layer()) |
| 364 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 366 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
| 365 LayerTreeHostCommon::FindLayerInSubtree( | 367 LayerTreeHostCommon::FindLayerInSubtree( |
| 366 target_tree->root_layer(), hud_layer()->id()))); | 368 target_tree->root_layer(), hud_layer()->id()))); |
| (...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 property_trees_.transform_tree, property_trees_.clip_tree, | 1694 property_trees_.transform_tree, property_trees_.clip_tree, |
| 1693 use_property_trees, &data_for_recursion); | 1695 use_property_trees, &data_for_recursion); |
| 1694 return data_for_recursion.closest_match; | 1696 return data_for_recursion.closest_match; |
| 1695 } | 1697 } |
| 1696 | 1698 |
| 1697 struct HitTestVisibleScrollableOrTouchableFunctor { | 1699 struct HitTestVisibleScrollableOrTouchableFunctor { |
| 1698 bool operator()(LayerImpl* layer) const { | 1700 bool operator()(LayerImpl* layer) const { |
| 1699 return layer->IsDrawnRenderSurfaceLayerListMember() || | 1701 return layer->IsDrawnRenderSurfaceLayerListMember() || |
| 1700 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || | 1702 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
| 1701 !layer->touch_event_handler_region().IsEmpty() || | 1703 !layer->touch_event_handler_region().IsEmpty() || |
| 1702 layer->have_wheel_event_handlers(); | 1704 layer->layer_tree_impl()->have_wheel_event_handlers(); |
| 1703 } | 1705 } |
| 1704 }; | 1706 }; |
| 1705 | 1707 |
| 1706 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( | 1708 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
| 1707 const gfx::PointF& screen_space_point) { | 1709 const gfx::PointF& screen_space_point) { |
| 1708 if (!root_layer()) | 1710 if (!root_layer()) |
| 1709 return NULL; | 1711 return NULL; |
| 1710 bool update_lcd_text = false; | 1712 bool update_lcd_text = false; |
| 1711 if (!UpdateDrawProperties(update_lcd_text)) | 1713 if (!UpdateDrawProperties(update_lcd_text)) |
| 1712 return NULL; | 1714 return NULL; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1738 // was not clipped in such a way that the hit point actually should not hit | 1740 // was not clipped in such a way that the hit point actually should not hit |
| 1739 // the layer. | 1741 // the layer. |
| 1740 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl, | 1742 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl, |
| 1741 transform_tree, clip_tree, | 1743 transform_tree, clip_tree, |
| 1742 use_property_trees)) | 1744 use_property_trees)) |
| 1743 return false; | 1745 return false; |
| 1744 | 1746 |
| 1745 return true; | 1747 return true; |
| 1746 } | 1748 } |
| 1747 | 1749 |
| 1748 struct FindWheelEventLayerFunctor { | |
| 1749 bool operator()(LayerImpl* layer) const { | |
| 1750 return layer->have_wheel_event_handlers(); | |
| 1751 } | |
| 1752 }; | |
| 1753 | |
| 1754 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( | |
| 1755 const gfx::PointF& screen_space_point) { | |
| 1756 if (!root_layer()) | |
| 1757 return NULL; | |
| 1758 bool update_lcd_text = false; | |
| 1759 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1760 return NULL; | |
| 1761 bool use_property_trees = | |
| 1762 settings().use_property_trees || settings().verify_property_trees; | |
| 1763 FindWheelEventLayerFunctor func; | |
| 1764 FindClosestMatchingLayerDataForRecursion data_for_recursion; | |
| 1765 FindClosestMatchingLayer( | |
| 1766 screen_space_point, root_layer(), func, property_trees_.transform_tree, | |
| 1767 property_trees_.clip_tree, use_property_trees, &data_for_recursion); | |
| 1768 return data_for_recursion.closest_match; | |
| 1769 } | |
| 1770 | |
| 1771 struct FindTouchEventLayerFunctor { | 1750 struct FindTouchEventLayerFunctor { |
| 1772 bool operator()(LayerImpl* layer) const { | 1751 bool operator()(LayerImpl* layer) const { |
| 1773 return LayerHasTouchEventHandlersAt(screen_space_point, layer, | 1752 return LayerHasTouchEventHandlersAt(screen_space_point, layer, |
| 1774 transform_tree, clip_tree, | 1753 transform_tree, clip_tree, |
| 1775 use_property_trees); | 1754 use_property_trees); |
| 1776 } | 1755 } |
| 1777 const gfx::PointF screen_space_point; | 1756 const gfx::PointF screen_space_point; |
| 1778 const TransformTree& transform_tree; | 1757 const TransformTree& transform_tree; |
| 1779 const ClipTree& clip_tree; | 1758 const ClipTree& clip_tree; |
| 1780 const bool use_property_trees; | 1759 const bool use_property_trees; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 const gfx::BoxF& box, | 2054 const gfx::BoxF& box, |
| 2076 gfx::BoxF* bounds) const { | 2055 gfx::BoxF* bounds) const { |
| 2077 *bounds = gfx::BoxF(); | 2056 *bounds = gfx::BoxF(); |
| 2078 return layer_tree_host_impl_->animation_host() | 2057 return layer_tree_host_impl_->animation_host() |
| 2079 ? layer_tree_host_impl_->animation_host() | 2058 ? layer_tree_host_impl_->animation_host() |
| 2080 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 2059 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
| 2081 : true; | 2060 : true; |
| 2082 } | 2061 } |
| 2083 | 2062 |
| 2084 } // namespace cc | 2063 } // namespace cc |
| OLD | NEW |