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

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

Issue 2655853004: cc : Add UMA metric for finding closest matching layer to a point (Closed)
Patch Set: comment Created 3 years, 11 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 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 // closer in this case, counterintuitively. 1875 // closer in this case, counterintuitively.
1876 float closest_distance; 1876 float closest_distance;
1877 }; 1877 };
1878 1878
1879 template <typename Functor> 1879 template <typename Functor>
1880 static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point, 1880 static void FindClosestMatchingLayer(const gfx::PointF& screen_space_point,
1881 LayerImpl* root_layer, 1881 LayerImpl* root_layer,
1882 const Functor& func, 1882 const Functor& func,
1883 FindClosestMatchingLayerState* state) { 1883 FindClosestMatchingLayerState* state) {
1884 // We want to iterate from front to back when hit testing. 1884 // We want to iterate from front to back when hit testing.
1885 for (auto* layer : base::Reversed(*root_layer->layer_tree_impl())) { 1885 {
1886 if (!func(layer)) 1886 base::ElapsedTimer timer;
1887 continue; 1887 for (auto* layer : base::Reversed(*root_layer->layer_tree_impl())) {
1888 if (!func(layer))
1889 continue;
1888 1890
1889 float distance_to_intersection = 0.f; 1891 float distance_to_intersection = 0.f;
1890 bool hit = false; 1892 bool hit = false;
1891 if (layer->Is3dSorted()) 1893 if (layer->Is3dSorted())
1892 hit = 1894 hit = PointHitsLayer(layer, screen_space_point,
1893 PointHitsLayer(layer, screen_space_point, &distance_to_intersection); 1895 &distance_to_intersection);
1894 else 1896 else
1895 hit = PointHitsLayer(layer, screen_space_point, nullptr); 1897 hit = PointHitsLayer(layer, screen_space_point, nullptr);
1896 1898
1897 if (!hit) 1899 if (!hit)
1898 continue; 1900 continue;
1899 1901
1900 bool in_front_of_previous_candidate = 1902 bool in_front_of_previous_candidate =
1901 state->closest_match && 1903 state->closest_match &&
1902 layer->GetSortingContextId() == 1904 layer->GetSortingContextId() ==
1903 state->closest_match->GetSortingContextId() && 1905 state->closest_match->GetSortingContextId() &&
1904 distance_to_intersection > 1906 distance_to_intersection >
1905 state->closest_distance + std::numeric_limits<float>::epsilon(); 1907 state->closest_distance + std::numeric_limits<float>::epsilon();
1906 1908
1907 if (!state->closest_match || in_front_of_previous_candidate) { 1909 if (!state->closest_match || in_front_of_previous_candidate) {
1908 state->closest_distance = distance_to_intersection; 1910 state->closest_distance = distance_to_intersection;
1909 state->closest_match = layer; 1911 state->closest_match = layer;
1912 }
1910 } 1913 }
1914 UMA_HISTOGRAM_COUNTS("Compositing.LayerTreeImpl.FindClosestMatchingLayerUs",
1915 timer.Elapsed().InMicroseconds());
1911 } 1916 }
1912 } 1917 }
1913 1918
1914 static bool IsScrollableOrDrawnScrollbarLayer(LayerImpl* layer) { 1919 static bool IsScrollableOrDrawnScrollbarLayer(LayerImpl* layer) {
1915 return layer->scrollable() || 1920 return layer->scrollable() ||
1916 (layer->ToScrollbarLayer() && 1921 (layer->ToScrollbarLayer() &&
1917 layer->is_drawn_render_surface_layer_list_member()); 1922 layer->is_drawn_render_surface_layer_list_member());
1918 } 1923 }
1919 1924
1920 struct FindScrollingLayerOrScrollbarLayerFunctor { 1925 struct FindScrollingLayerOrScrollbarLayerFunctor {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 2107
2103 void LayerTreeImpl::ResetAllChangeTracking() { 2108 void LayerTreeImpl::ResetAllChangeTracking() {
2104 layers_that_should_push_properties_.clear(); 2109 layers_that_should_push_properties_.clear();
2105 // Iterate over all layers, including masks. 2110 // Iterate over all layers, including masks.
2106 for (auto& layer : *layers_) 2111 for (auto& layer : *layers_)
2107 layer->ResetChangeTracking(); 2112 layer->ResetChangeTracking();
2108 property_trees_.ResetAllChangeTracking(); 2113 property_trees_.ResetAllChangeTracking();
2109 } 2114 }
2110 2115
2111 } // namespace cc 2116 } // 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