Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 2672603007: cc : Add UMA metric for finding closest matching layer to a point (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 // closer in this case, counterintuitively. 1874 // closer in this case, counterintuitively.
1875 float closest_distance; 1875 float closest_distance;
1876 }; 1876 };
1877 1877
1878 template <typename Functor> 1878 template <typename Functor>
1879 static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point, 1879 static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point,
1880 LayerImpl* root_layer, 1880 LayerImpl* root_layer,
1881 const Functor& func, 1881 const Functor& func,
1882 FindClosestMatchingLayerState* state) { 1882 FindClosestMatchingLayerState* state) {
1883 // We want to iterate from front to back when hit testing. 1883 // We want to iterate from front to back when hit testing.
1884 for (auto* layer : base::Reversed(*root_layer->layer_tree_impl())) { 1884 {
1885 if (!func(layer)) 1885 base::ElapsedTimer timer;
1886 continue; 1886 for (auto* layer : base::Reversed(*root_layer->layer_tree_impl())) {
1887 if (!func(layer))
1888 continue;
1887 1889
1888 float distance_to_intersection = 0.f; 1890 float distance_to_intersection = 0.f;
1889 bool hit = false; 1891 bool hit = false;
1890 if (layer->Is3dSorted()) 1892 if (layer->Is3dSorted())
1891 hit = 1893 hit = PointHitsLayer(layer, screen_space_point,
1892 PointHitsLayer(layer, screen_space_point, &distance_to_intersection); 1894 &distance_to_intersection);
1893 else 1895 else
1894 hit = PointHitsLayer(layer, screen_space_point, nullptr); 1896 hit = PointHitsLayer(layer, screen_space_point, nullptr);
1895 1897
1896 if (!hit) 1898 if (!hit)
1897 continue; 1899 continue;
1898 1900
1899 bool in_front_of_previous_candidate = 1901 bool in_front_of_previous_candidate =
1900 state->closest_match && 1902 state->closest_match &&
1901 layer->GetSortingContextId() == 1903 layer->GetSortingContextId() ==
1902 state->closest_match->GetSortingContextId() && 1904 state->closest_match->GetSortingContextId() &&
1903 distance_to_intersection > 1905 distance_to_intersection >
1904 state->closest_distance + std::numeric_limits<float>::epsilon(); 1906 state->closest_distance + std::numeric_limits<float>::epsilon();
1905 1907
1906 if (!state->closest_match || in_front_of_previous_candidate) { 1908 if (!state->closest_match || in_front_of_previous_candidate) {
1907 state->closest_distance = distance_to_intersection; 1909 state->closest_distance = distance_to_intersection;
1908 state->closest_match = layer; 1910 state->closest_match = layer;
1911 }
1909 } 1912 }
1913 UMA_HISTOGRAM_COUNTS("Compositing.LayerTreeImpl.FindClosestMatchingLayerUs",
1914 timer.Elapsed().InMicroseconds());
1910 } 1915 }
1911 } 1916 }
1912 1917
1913 static bool IsScrollableOrDrawnScrollbarLayer(LayerImpl* layer) { 1918 static bool IsScrollableOrDrawnScrollbarLayer(LayerImpl* layer) {
1914 return layer->scrollable() || 1919 return layer->scrollable() ||
1915 (layer->ToScrollbarLayer() && 1920 (layer->ToScrollbarLayer() &&
1916 layer->is_drawn_render_surface_layer_list_member()); 1921 layer->is_drawn_render_surface_layer_list_member());
1917 } 1922 }
1918 1923
1919 struct FindScrollingLayerOrScrollbarLayerFunctor { 1924 struct FindScrollingLayerOrScrollbarLayerFunctor {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 2100
2096 void LayerTreeImpl::ResetAllChangeTracking() { 2101 void LayerTreeImpl::ResetAllChangeTracking() {
2097 layers_that_should_push_properties_.clear(); 2102 layers_that_should_push_properties_.clear();
2098 // Iterate over all layers, including masks. 2103 // Iterate over all layers, including masks.
2099 for (auto& layer : *layers_) 2104 for (auto& layer : *layers_)
2100 layer->ResetChangeTracking(); 2105 layer->ResetChangeTracking();
2101 property_trees_.ResetAllChangeTracking(); 2106 property_trees_.ResetAllChangeTracking();
2102 } 2107 }
2103 2108
2104 } // namespace cc 2109 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698