| 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 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 // closer in this case, counterintuitively. | 1893 // closer in this case, counterintuitively. |
| 1894 float closest_distance; | 1894 float closest_distance; |
| 1895 }; | 1895 }; |
| 1896 | 1896 |
| 1897 template <typename Functor> | 1897 template <typename Functor> |
| 1898 static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point, | 1898 static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point, |
| 1899 LayerImpl* root_layer, | 1899 LayerImpl* root_layer, |
| 1900 const Functor& func, | 1900 const Functor& func, |
| 1901 FindClosestMatchingLayerState* state) { | 1901 FindClosestMatchingLayerState* state) { |
| 1902 // We want to iterate from front to back when hit testing. | 1902 // We want to iterate from front to back when hit testing. |
| 1903 { | 1903 for (auto* layer : base::Reversed(*root_layer->layer_tree_impl())) { |
| 1904 base::ElapsedTimer timer; | 1904 if (!func(layer)) |
| 1905 for (auto* layer : base::Reversed(*root_layer->layer_tree_impl())) { | 1905 continue; |
| 1906 if (!func(layer)) | |
| 1907 continue; | |
| 1908 | 1906 |
| 1909 float distance_to_intersection = 0.f; | 1907 float distance_to_intersection = 0.f; |
| 1910 bool hit = false; | 1908 bool hit = false; |
| 1911 if (layer->Is3dSorted()) | 1909 if (layer->Is3dSorted()) |
| 1912 hit = PointHitsLayer(layer, screen_space_point, | 1910 hit = |
| 1913 &distance_to_intersection); | 1911 PointHitsLayer(layer, screen_space_point, &distance_to_intersection); |
| 1914 else | 1912 else |
| 1915 hit = PointHitsLayer(layer, screen_space_point, nullptr); | 1913 hit = PointHitsLayer(layer, screen_space_point, nullptr); |
| 1916 | 1914 |
| 1917 if (!hit) | 1915 if (!hit) |
| 1918 continue; | 1916 continue; |
| 1919 | 1917 |
| 1920 bool in_front_of_previous_candidate = | 1918 bool in_front_of_previous_candidate = |
| 1921 state->closest_match && | 1919 state->closest_match && |
| 1922 layer->GetSortingContextId() == | 1920 layer->GetSortingContextId() == |
| 1923 state->closest_match->GetSortingContextId() && | 1921 state->closest_match->GetSortingContextId() && |
| 1924 distance_to_intersection > | 1922 distance_to_intersection > |
| 1925 state->closest_distance + std::numeric_limits<float>::epsilon(); | 1923 state->closest_distance + std::numeric_limits<float>::epsilon(); |
| 1926 | 1924 |
| 1927 if (!state->closest_match || in_front_of_previous_candidate) { | 1925 if (!state->closest_match || in_front_of_previous_candidate) { |
| 1928 state->closest_distance = distance_to_intersection; | 1926 state->closest_distance = distance_to_intersection; |
| 1929 state->closest_match = layer; | 1927 state->closest_match = layer; |
| 1930 } | |
| 1931 } | 1928 } |
| 1932 UMA_HISTOGRAM_COUNTS("Compositing.LayerTreeImpl.FindClosestMatchingLayerUs", | |
| 1933 timer.Elapsed().InMicroseconds()); | |
| 1934 } | 1929 } |
| 1935 } | 1930 } |
| 1936 | 1931 |
| 1937 struct FindScrollingLayerOrDrawnScrollbarFunctor { | 1932 struct FindScrollingLayerOrDrawnScrollbarFunctor { |
| 1938 bool operator()(LayerImpl* layer) const { | 1933 bool operator()(LayerImpl* layer) const { |
| 1939 return layer->scrollable() || layer->IsDrawnScrollbar(); | 1934 return layer->scrollable() || layer->IsDrawnScrollbar(); |
| 1940 } | 1935 } |
| 1941 }; | 1936 }; |
| 1942 | 1937 |
| 1943 LayerImpl* | 1938 LayerImpl* |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 | 2112 |
| 2118 void LayerTreeImpl::ResetAllChangeTracking() { | 2113 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2119 layers_that_should_push_properties_.clear(); | 2114 layers_that_should_push_properties_.clear(); |
| 2120 // Iterate over all layers, including masks. | 2115 // Iterate over all layers, including masks. |
| 2121 for (auto& layer : *layers_) | 2116 for (auto& layer : *layers_) |
| 2122 layer->ResetChangeTracking(); | 2117 layer->ResetChangeTracking(); |
| 2123 property_trees_.ResetAllChangeTracking(); | 2118 property_trees_.ResetAllChangeTracking(); |
| 2124 } | 2119 } |
| 2125 | 2120 |
| 2126 } // namespace cc | 2121 } // namespace cc |
| OLD | NEW |