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

Side by Side Diff: cc/debug/debug_rect_history.cc

Issue 2080703005: cc: Remove LayerTreeImpl::root_layer usage outside tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « cc/debug/debug_rect_history.h ('k') | cc/test/layer_tree_json_parser_unittest.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/debug/debug_rect_history.h" 5 #include "cc/debug/debug_rect_history.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 13 matching lines...) Expand all
24 // static 24 // static
25 std::unique_ptr<DebugRectHistory> DebugRectHistory::Create() { 25 std::unique_ptr<DebugRectHistory> DebugRectHistory::Create() {
26 return base::WrapUnique(new DebugRectHistory()); 26 return base::WrapUnique(new DebugRectHistory());
27 } 27 }
28 28
29 DebugRectHistory::DebugRectHistory() {} 29 DebugRectHistory::DebugRectHistory() {}
30 30
31 DebugRectHistory::~DebugRectHistory() {} 31 DebugRectHistory::~DebugRectHistory() {}
32 32
33 void DebugRectHistory::SaveDebugRectsForCurrentFrame( 33 void DebugRectHistory::SaveDebugRectsForCurrentFrame(
34 LayerImpl* root_layer, 34 LayerTreeImpl* tree_impl,
35 LayerImpl* hud_layer, 35 LayerImpl* hud_layer,
36 const LayerImplList& render_surface_layer_list, 36 const LayerImplList& render_surface_layer_list,
37 const LayerTreeDebugState& debug_state) { 37 const LayerTreeDebugState& debug_state) {
38 // For now, clear all rects from previous frames. In the future we may want to 38 // For now, clear all rects from previous frames. In the future we may want to
39 // store all debug rects for a history of many frames. 39 // store all debug rects for a history of many frames.
40 debug_rects_.clear(); 40 debug_rects_.clear();
41 41
42 if (debug_state.show_touch_event_handler_rects) 42 if (debug_state.show_touch_event_handler_rects)
43 SaveTouchEventHandlerRects(root_layer->layer_tree_impl()); 43 SaveTouchEventHandlerRects(tree_impl);
44 44
45 if (debug_state.show_wheel_event_handler_rects) 45 if (debug_state.show_wheel_event_handler_rects)
46 SaveWheelEventHandlerRects(root_layer); 46 SaveWheelEventHandlerRects(tree_impl);
47 47
48 if (debug_state.show_scroll_event_handler_rects) 48 if (debug_state.show_scroll_event_handler_rects)
49 SaveScrollEventHandlerRects(root_layer->layer_tree_impl()); 49 SaveScrollEventHandlerRects(tree_impl);
50 50
51 if (debug_state.show_non_fast_scrollable_rects) 51 if (debug_state.show_non_fast_scrollable_rects)
52 SaveNonFastScrollableRects(root_layer->layer_tree_impl()); 52 SaveNonFastScrollableRects(tree_impl);
53 53
54 if (debug_state.show_paint_rects) 54 if (debug_state.show_paint_rects)
55 SavePaintRects(root_layer); 55 SavePaintRects(tree_impl);
56 56
57 if (debug_state.show_property_changed_rects) 57 if (debug_state.show_property_changed_rects)
58 SavePropertyChangedRects(render_surface_layer_list, hud_layer); 58 SavePropertyChangedRects(render_surface_layer_list, hud_layer);
59 59
60 if (debug_state.show_surface_damage_rects) 60 if (debug_state.show_surface_damage_rects)
61 SaveSurfaceDamageRects(render_surface_layer_list); 61 SaveSurfaceDamageRects(render_surface_layer_list);
62 62
63 if (debug_state.show_screen_space_rects) 63 if (debug_state.show_screen_space_rects)
64 SaveScreenSpaceRects(render_surface_layer_list); 64 SaveScreenSpaceRects(render_surface_layer_list);
65 65
66 if (debug_state.show_layer_animation_bounds_rects) 66 if (debug_state.show_layer_animation_bounds_rects)
67 SaveLayerAnimationBoundsRects(render_surface_layer_list); 67 SaveLayerAnimationBoundsRects(render_surface_layer_list);
68 } 68 }
69 69
70 void DebugRectHistory::SavePaintRects(LayerImpl* root_layer) { 70 void DebugRectHistory::SavePaintRects(LayerTreeImpl* tree_impl) {
71 // We would like to visualize where any layer's paint rect (update rect) has 71 // We would like to visualize where any layer's paint rect (update rect) has
72 // changed, regardless of whether this layer is skipped for actual drawing or 72 // changed, regardless of whether this layer is skipped for actual drawing or
73 // not. Therefore we traverse over all layers, not just the render surface 73 // not. Therefore we traverse over all layers, not just the render surface
74 // list. 74 // list.
75 for (auto* layer : *root_layer->layer_tree_impl()) { 75 for (auto* layer : *tree_impl) {
76 Region invalidation_region = layer->GetInvalidationRegionForDebugging(); 76 Region invalidation_region = layer->GetInvalidationRegionForDebugging();
77 if (invalidation_region.IsEmpty() || !layer->DrawsContent()) 77 if (invalidation_region.IsEmpty() || !layer->DrawsContent())
78 continue; 78 continue;
79 79
80 for (Region::Iterator it(invalidation_region); it.has_rect(); it.next()) { 80 for (Region::Iterator it(invalidation_region); it.has_rect(); it.next()) {
81 debug_rects_.push_back(DebugRect( 81 debug_rects_.push_back(DebugRect(
82 PAINT_RECT_TYPE, MathUtil::MapEnclosingClippedRect( 82 PAINT_RECT_TYPE, MathUtil::MapEnclosingClippedRect(
83 layer->ScreenSpaceTransform(), it.rect()))); 83 layer->ScreenSpaceTransform(), it.rect())));
84 } 84 }
85 } 85 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 for (Region::Iterator iter(layer->touch_event_handler_region()); 167 for (Region::Iterator iter(layer->touch_event_handler_region());
168 iter.has_rect(); 168 iter.has_rect();
169 iter.next()) { 169 iter.next()) {
170 debug_rects_.push_back( 170 debug_rects_.push_back(
171 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE, 171 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE,
172 MathUtil::MapEnclosingClippedRect( 172 MathUtil::MapEnclosingClippedRect(
173 layer->ScreenSpaceTransform(), iter.rect()))); 173 layer->ScreenSpaceTransform(), iter.rect())));
174 } 174 }
175 } 175 }
176 176
177 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* root_layer) { 177 void DebugRectHistory::SaveWheelEventHandlerRects(LayerTreeImpl* tree_impl) {
178 EventListenerProperties event_properties = 178 EventListenerProperties event_properties =
179 root_layer->layer_tree_impl()->event_listener_properties( 179 tree_impl->event_listener_properties(EventListenerClass::kMouseWheel);
180 EventListenerClass::kMouseWheel);
181 if (event_properties == EventListenerProperties::kNone || 180 if (event_properties == EventListenerProperties::kNone ||
182 event_properties == EventListenerProperties::kPassive) { 181 event_properties == EventListenerProperties::kPassive) {
183 return; 182 return;
184 } 183 }
185 184
186 // Since the wheel event handlers property is on the entire layer tree just 185 // Since the wheel event handlers property is on the entire layer tree just
187 // mark inner viewport if have listeners. 186 // mark inner viewport if have listeners.
188 LayerImpl* inner_viewport = 187 LayerImpl* inner_viewport = tree_impl->InnerViewportScrollLayer();
189 root_layer->layer_tree_impl()->InnerViewportScrollLayer();
190 if (!inner_viewport) 188 if (!inner_viewport)
191 return; 189 return;
192 debug_rects_.push_back(DebugRect( 190 debug_rects_.push_back(DebugRect(
193 WHEEL_EVENT_HANDLER_RECT_TYPE, 191 WHEEL_EVENT_HANDLER_RECT_TYPE,
194 MathUtil::MapEnclosingClippedRect(inner_viewport->ScreenSpaceTransform(), 192 MathUtil::MapEnclosingClippedRect(inner_viewport->ScreenSpaceTransform(),
195 gfx::Rect(inner_viewport->bounds())))); 193 gfx::Rect(inner_viewport->bounds()))));
196 } 194 }
197 195
198 void DebugRectHistory::SaveScrollEventHandlerRects(LayerTreeImpl* tree_impl) { 196 void DebugRectHistory::SaveScrollEventHandlerRects(LayerTreeImpl* tree_impl) {
199 LayerTreeHostCommon::CallFunctionForEveryLayer( 197 LayerTreeHostCommon::CallFunctionForEveryLayer(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 debug_rects_.push_back( 243 debug_rects_.push_back(
246 DebugRect(ANIMATION_BOUNDS_RECT_TYPE, 244 DebugRect(ANIMATION_BOUNDS_RECT_TYPE,
247 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(), 245 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(),
248 inflated_bounds.y(), 246 inflated_bounds.y(),
249 inflated_bounds.width(), 247 inflated_bounds.width(),
250 inflated_bounds.height())))); 248 inflated_bounds.height()))));
251 } 249 }
252 } 250 }
253 251
254 } // namespace cc 252 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/debug_rect_history.h ('k') | cc/test/layer_tree_json_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698