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 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 | 1790 |
1791 // If ProjectPoint could not project to a valid value, then we assume that | 1791 // If ProjectPoint could not project to a valid value, then we assume that |
1792 // this point doesn't hit this region. | 1792 // this point doesn't hit this region. |
1793 if (clipped) | 1793 if (clipped) |
1794 return false; | 1794 return false; |
1795 | 1795 |
1796 return layer_space_region.Contains( | 1796 return layer_space_region.Contains( |
1797 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); | 1797 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); |
1798 } | 1798 } |
1799 | 1799 |
1800 static const gfx::Transform SurfaceScreenSpaceTransform( | |
1801 const LayerImpl* layer) { | |
1802 const PropertyTrees* property_trees = | |
1803 layer->layer_tree_impl()->property_trees(); | |
1804 RenderSurfaceImpl* render_surface = layer->GetRenderSurface(); | |
1805 DCHECK(render_surface); | |
1806 return layer->contributes_to_drawn_render_surface() | |
1807 ? render_surface->screen_space_transform() | |
1808 : property_trees | |
1809 ->ToScreenSpaceTransformWithoutSurfaceContentsScale( | |
1810 render_surface->TransformTreeIndex(), | |
1811 render_surface->EffectTreeIndex()); | |
1812 } | |
1813 | |
1814 static bool PointIsClippedByAncestorClipNode( | 1800 static bool PointIsClippedByAncestorClipNode( |
1815 const gfx::PointF& screen_space_point, | 1801 const gfx::PointF& screen_space_point, |
1816 const LayerImpl* layer) { | 1802 const LayerImpl* layer) { |
1817 // We need to visit all ancestor clip nodes to check this. Checking with just | 1803 // We need to visit all ancestor clip nodes to check this. Checking with just |
1818 // the combined clip stored at a clip node is not enough because parent | 1804 // the combined clip stored at a clip node is not enough because parent |
1819 // combined clip can sometimes be smaller than current combined clip. This can | 1805 // combined clip can sometimes be smaller than current combined clip. This can |
1820 // happen when we have transforms like rotation that inflate the combined | 1806 // happen when we have transforms like rotation that inflate the combined |
1821 // clip's bounds. Also, the point can be clipped by the content rect of an | 1807 // clip's bounds. Also, the point can be clipped by the content rect of an |
1822 // ancestor render surface. | 1808 // ancestor render surface. |
1823 | 1809 |
(...skipping 13 matching lines...) Expand all Loading... |
1837 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) { | 1823 if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) { |
1838 gfx::Rect clip = gfx::ToEnclosingRect(clip_node->clip); | 1824 gfx::Rect clip = gfx::ToEnclosingRect(clip_node->clip); |
1839 | 1825 |
1840 gfx::Transform screen_space_transform = | 1826 gfx::Transform screen_space_transform = |
1841 transform_tree.ToScreen(clip_node->transform_id); | 1827 transform_tree.ToScreen(clip_node->transform_id); |
1842 if (!PointHitsRect(screen_space_point, screen_space_transform, clip, | 1828 if (!PointHitsRect(screen_space_point, screen_space_transform, clip, |
1843 NULL)) { | 1829 NULL)) { |
1844 return true; | 1830 return true; |
1845 } | 1831 } |
1846 } | 1832 } |
1847 const LayerImpl* clip_node_owner = | |
1848 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id); | |
1849 RenderSurfaceImpl* render_surface = clip_node_owner->GetRenderSurface(); | |
1850 if (render_surface && | |
1851 !PointHitsRect(screen_space_point, | |
1852 SurfaceScreenSpaceTransform(clip_node_owner), | |
1853 render_surface->content_rect(), NULL)) { | |
1854 return true; | |
1855 } | |
1856 } | 1833 } |
1857 return false; | 1834 return false; |
1858 } | 1835 } |
1859 | 1836 |
1860 static bool PointIsClippedBySurfaceOrClipRect( | 1837 static bool PointIsClippedBySurfaceOrClipRect( |
1861 const gfx::PointF& screen_space_point, | 1838 const gfx::PointF& screen_space_point, |
1862 const LayerImpl* layer) { | 1839 const LayerImpl* layer) { |
1863 // Walk up the layer tree and hit-test any render_surfaces and any layer | 1840 // Walk up the layer tree and hit-test any render_surfaces and any layer |
1864 // clip rects that are active. | 1841 // clip rects that are active. |
1865 return PointIsClippedByAncestorClipNode(screen_space_point, layer); | 1842 return PointIsClippedByAncestorClipNode(screen_space_point, layer); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 | 2097 |
2121 void LayerTreeImpl::ResetAllChangeTracking() { | 2098 void LayerTreeImpl::ResetAllChangeTracking() { |
2122 layers_that_should_push_properties_.clear(); | 2099 layers_that_should_push_properties_.clear(); |
2123 // Iterate over all layers, including masks. | 2100 // Iterate over all layers, including masks. |
2124 for (auto& layer : *layers_) | 2101 for (auto& layer : *layers_) |
2125 layer->ResetChangeTracking(); | 2102 layer->ResetChangeTracking(); |
2126 property_trees_.ResetAllChangeTracking(); | 2103 property_trees_.ResetAllChangeTracking(); |
2127 } | 2104 } |
2128 | 2105 |
2129 } // namespace cc | 2106 } // namespace cc |
OLD | NEW |