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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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/cc_unittests.isolate ('k') | cc/debug/invalidation_benchmark.h » ('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 "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/layers/layer_impl.h" 8 #include "cc/layers/layer_impl.h"
9 #include "cc/layers/layer_iterator.h" 9 #include "cc/layers/layer_iterator.h"
10 #include "cc/layers/layer_utils.h" 10 #include "cc/layers/layer_utils.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (debug_state.show_layer_animation_bounds_rects) 61 if (debug_state.show_layer_animation_bounds_rects)
62 SaveLayerAnimationBoundsRects(render_surface_layer_list); 62 SaveLayerAnimationBoundsRects(render_surface_layer_list);
63 } 63 }
64 64
65 void DebugRectHistory::SavePaintRects(LayerImpl* layer) { 65 void DebugRectHistory::SavePaintRects(LayerImpl* layer) {
66 // We would like to visualize where any layer's paint rect (update rect) has 66 // We would like to visualize where any layer's paint rect (update rect) has
67 // changed, regardless of whether this layer is skipped for actual drawing or 67 // changed, regardless of whether this layer is skipped for actual drawing or
68 // not. Therefore we traverse recursively over all layers, not just the render 68 // not. Therefore we traverse recursively over all layers, not just the render
69 // surface list. 69 // surface list.
70 70
71 if (!layer->update_rect().IsEmpty() && layer->DrawsContent()) { 71 Region invalidation_region = layer->GetInvalidationRegion();
72 if (!invalidation_region.IsEmpty() && layer->DrawsContent()) {
72 float width_scale = layer->content_bounds().width() / 73 float width_scale = layer->content_bounds().width() /
73 static_cast<float>(layer->bounds().width()); 74 static_cast<float>(layer->bounds().width());
74 float height_scale = layer->content_bounds().height() / 75 float height_scale = layer->content_bounds().height() /
75 static_cast<float>(layer->bounds().height()); 76 static_cast<float>(layer->bounds().height());
76 gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect( 77
77 layer->update_rect(), width_scale, height_scale); 78 for (Region::Iterator it(invalidation_region); it.has_rect(); it.next()) {
78 debug_rects_.push_back( 79 gfx::Rect update_content_rect =
79 DebugRect(PAINT_RECT_TYPE, 80 gfx::ScaleToEnclosingRect(it.rect(), width_scale, height_scale);
80 MathUtil::MapEnclosingClippedRect( 81 debug_rects_.push_back(
81 layer->screen_space_transform(), update_content_rect))); 82 DebugRect(PAINT_RECT_TYPE,
83 MathUtil::MapEnclosingClippedRect(
84 layer->screen_space_transform(), update_content_rect)));
85 }
82 } 86 }
83 87
84 for (unsigned i = 0; i < layer->children().size(); ++i) 88 for (unsigned i = 0; i < layer->children().size(); ++i)
85 SavePaintRects(layer->children()[i]); 89 SavePaintRects(layer->children()[i]);
86 } 90 }
87 91
88 void DebugRectHistory::SavePropertyChangedRects( 92 void DebugRectHistory::SavePropertyChangedRects(
89 const LayerImplList& render_surface_layer_list, 93 const LayerImplList& render_surface_layer_list,
90 LayerImpl* hud_layer) { 94 LayerImpl* hud_layer) {
91 for (int surface_index = render_surface_layer_list.size() - 1; 95 for (int surface_index = render_surface_layer_list.size() - 1;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 debug_rects_.push_back( 160 debug_rects_.push_back(
157 DebugRect(REPLICA_SCREEN_SPACE_RECT_TYPE, 161 DebugRect(REPLICA_SCREEN_SPACE_RECT_TYPE,
158 MathUtil::MapEnclosingClippedRect( 162 MathUtil::MapEnclosingClippedRect(
159 render_surface->replica_screen_space_transform(), 163 render_surface->replica_screen_space_transform(),
160 render_surface->content_rect()))); 164 render_surface->content_rect())));
161 } 165 }
162 } 166 }
163 } 167 }
164 168
165 void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) { 169 void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) {
166 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( 170 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
167 layer, 171 SaveTouchEventHandlerRectsCallback(layer);
168 base::Bind(&DebugRectHistory::SaveTouchEventHandlerRectsCallback, 172 });
169 base::Unretained(this)));
170 } 173 }
171 174
172 void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) { 175 void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) {
173 for (Region::Iterator iter(layer->touch_event_handler_region()); 176 for (Region::Iterator iter(layer->touch_event_handler_region());
174 iter.has_rect(); 177 iter.has_rect();
175 iter.next()) { 178 iter.next()) {
176 gfx::Rect touch_rect = gfx::ScaleToEnclosingRect( 179 gfx::Rect touch_rect = gfx::ScaleToEnclosingRect(
177 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); 180 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y());
178 debug_rects_.push_back( 181 debug_rects_.push_back(
179 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE, 182 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE,
180 MathUtil::MapEnclosingClippedRect( 183 MathUtil::MapEnclosingClippedRect(
181 layer->screen_space_transform(), touch_rect))); 184 layer->screen_space_transform(), touch_rect)));
182 } 185 }
183 } 186 }
184 187
185 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) { 188 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) {
186 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( 189 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
187 layer, 190 SaveWheelEventHandlerRectsCallback(layer);
188 base::Bind(&DebugRectHistory::SaveWheelEventHandlerRectsCallback, 191 });
189 base::Unretained(this)));
190 } 192 }
191 193
192 void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) { 194 void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) {
193 if (!layer->have_wheel_event_handlers()) 195 if (!layer->have_wheel_event_handlers())
194 return; 196 return;
195 197
196 gfx::Rect wheel_rect = 198 gfx::Rect wheel_rect =
197 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), 199 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()),
198 layer->contents_scale_x(), 200 layer->contents_scale_x(),
199 layer->contents_scale_y()); 201 layer->contents_scale_y());
200 debug_rects_.push_back( 202 debug_rects_.push_back(
201 DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE, 203 DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE,
202 MathUtil::MapEnclosingClippedRect( 204 MathUtil::MapEnclosingClippedRect(
203 layer->screen_space_transform(), wheel_rect))); 205 layer->screen_space_transform(), wheel_rect)));
204 } 206 }
205 207
206 void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) { 208 void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) {
207 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( 209 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
208 layer, 210 SaveScrollEventHandlerRectsCallback(layer);
209 base::Bind(&DebugRectHistory::SaveScrollEventHandlerRectsCallback, 211 });
210 base::Unretained(this)));
211 } 212 }
212 213
213 void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) { 214 void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) {
214 if (!layer->have_scroll_event_handlers()) 215 if (!layer->have_scroll_event_handlers())
215 return; 216 return;
216 217
217 gfx::Rect scroll_rect = 218 gfx::Rect scroll_rect =
218 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), 219 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()),
219 layer->contents_scale_x(), 220 layer->contents_scale_x(),
220 layer->contents_scale_y()); 221 layer->contents_scale_y());
221 debug_rects_.push_back( 222 debug_rects_.push_back(
222 DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE, 223 DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE,
223 MathUtil::MapEnclosingClippedRect( 224 MathUtil::MapEnclosingClippedRect(
224 layer->screen_space_transform(), scroll_rect))); 225 layer->screen_space_transform(), scroll_rect)));
225 } 226 }
226 227
227 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) { 228 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) {
228 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( 229 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
229 layer, 230 SaveNonFastScrollableRectsCallback(layer);
230 base::Bind(&DebugRectHistory::SaveNonFastScrollableRectsCallback, 231 });
231 base::Unretained(this)));
232 } 232 }
233 233
234 void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) { 234 void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) {
235 for (Region::Iterator iter(layer->non_fast_scrollable_region()); 235 for (Region::Iterator iter(layer->non_fast_scrollable_region());
236 iter.has_rect(); 236 iter.has_rect();
237 iter.next()) { 237 iter.next()) {
238 gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect( 238 gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect(
239 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); 239 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y());
240 debug_rects_.push_back( 240 debug_rects_.push_back(
241 DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE, 241 DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE,
(...skipping 21 matching lines...) Expand all
263 debug_rects_.push_back( 263 debug_rects_.push_back(
264 DebugRect(ANIMATION_BOUNDS_RECT_TYPE, 264 DebugRect(ANIMATION_BOUNDS_RECT_TYPE,
265 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(), 265 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(),
266 inflated_bounds.y(), 266 inflated_bounds.y(),
267 inflated_bounds.width(), 267 inflated_bounds.width(),
268 inflated_bounds.height())))); 268 inflated_bounds.height()))));
269 } 269 }
270 } 270 }
271 271
272 } // namespace cc 272 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc_unittests.isolate ('k') | cc/debug/invalidation_benchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698