| OLD | NEW |
| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 void DebugRectHistory::SaveNonOccludingRects( | 179 void DebugRectHistory::SaveNonOccludingRects( |
| 180 const std::vector<gfx::Rect>& non_occluding_rects) { | 180 const std::vector<gfx::Rect>& non_occluding_rects) { |
| 181 for (size_t i = 0; i < non_occluding_rects.size(); ++i) { | 181 for (size_t i = 0; i < non_occluding_rects.size(); ++i) { |
| 182 debug_rects_.push_back( | 182 debug_rects_.push_back( |
| 183 DebugRect(NONOCCLUDING_RECT_TYPE, non_occluding_rects[i])); | 183 DebugRect(NONOCCLUDING_RECT_TYPE, non_occluding_rects[i])); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) { | 187 void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) { |
| 188 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 188 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
| 189 layer, | 189 SaveTouchEventHandlerRectsCallback(layer); |
| 190 base::Bind(&DebugRectHistory::SaveTouchEventHandlerRectsCallback, | 190 }); |
| 191 base::Unretained(this))); | |
| 192 } | 191 } |
| 193 | 192 |
| 194 void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) { | 193 void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) { |
| 195 for (Region::Iterator iter(layer->touch_event_handler_region()); | 194 for (Region::Iterator iter(layer->touch_event_handler_region()); |
| 196 iter.has_rect(); | 195 iter.has_rect(); |
| 197 iter.next()) { | 196 iter.next()) { |
| 198 gfx::Rect touch_rect = gfx::ScaleToEnclosingRect( | 197 gfx::Rect touch_rect = gfx::ScaleToEnclosingRect( |
| 199 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); | 198 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); |
| 200 debug_rects_.push_back( | 199 debug_rects_.push_back( |
| 201 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE, | 200 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE, |
| 202 MathUtil::MapEnclosingClippedRect( | 201 MathUtil::MapEnclosingClippedRect( |
| 203 layer->screen_space_transform(), touch_rect))); | 202 layer->screen_space_transform(), touch_rect))); |
| 204 } | 203 } |
| 205 } | 204 } |
| 206 | 205 |
| 207 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) { | 206 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) { |
| 208 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 207 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
| 209 layer, | 208 SaveWheelEventHandlerRectsCallback(layer); |
| 210 base::Bind(&DebugRectHistory::SaveWheelEventHandlerRectsCallback, | 209 }); |
| 211 base::Unretained(this))); | |
| 212 } | 210 } |
| 213 | 211 |
| 214 void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) { | 212 void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) { |
| 215 if (!layer->have_wheel_event_handlers()) | 213 if (!layer->have_wheel_event_handlers()) |
| 216 return; | 214 return; |
| 217 | 215 |
| 218 gfx::Rect wheel_rect = | 216 gfx::Rect wheel_rect = |
| 219 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), | 217 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), |
| 220 layer->contents_scale_x(), | 218 layer->contents_scale_x(), |
| 221 layer->contents_scale_y()); | 219 layer->contents_scale_y()); |
| 222 debug_rects_.push_back( | 220 debug_rects_.push_back( |
| 223 DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE, | 221 DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE, |
| 224 MathUtil::MapEnclosingClippedRect( | 222 MathUtil::MapEnclosingClippedRect( |
| 225 layer->screen_space_transform(), wheel_rect))); | 223 layer->screen_space_transform(), wheel_rect))); |
| 226 } | 224 } |
| 227 | 225 |
| 228 void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) { | 226 void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) { |
| 229 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 227 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
| 230 layer, | 228 SaveScrollEventHandlerRectsCallback(layer); |
| 231 base::Bind(&DebugRectHistory::SaveScrollEventHandlerRectsCallback, | 229 }); |
| 232 base::Unretained(this))); | |
| 233 } | 230 } |
| 234 | 231 |
| 235 void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) { | 232 void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) { |
| 236 if (!layer->have_scroll_event_handlers()) | 233 if (!layer->have_scroll_event_handlers()) |
| 237 return; | 234 return; |
| 238 | 235 |
| 239 gfx::Rect scroll_rect = | 236 gfx::Rect scroll_rect = |
| 240 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), | 237 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), |
| 241 layer->contents_scale_x(), | 238 layer->contents_scale_x(), |
| 242 layer->contents_scale_y()); | 239 layer->contents_scale_y()); |
| 243 debug_rects_.push_back( | 240 debug_rects_.push_back( |
| 244 DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE, | 241 DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE, |
| 245 MathUtil::MapEnclosingClippedRect( | 242 MathUtil::MapEnclosingClippedRect( |
| 246 layer->screen_space_transform(), scroll_rect))); | 243 layer->screen_space_transform(), scroll_rect))); |
| 247 } | 244 } |
| 248 | 245 |
| 249 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) { | 246 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) { |
| 250 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 247 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
| 251 layer, | 248 SaveNonFastScrollableRectsCallback(layer); |
| 252 base::Bind(&DebugRectHistory::SaveNonFastScrollableRectsCallback, | 249 }); |
| 253 base::Unretained(this))); | |
| 254 } | 250 } |
| 255 | 251 |
| 256 void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) { | 252 void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) { |
| 257 for (Region::Iterator iter(layer->non_fast_scrollable_region()); | 253 for (Region::Iterator iter(layer->non_fast_scrollable_region()); |
| 258 iter.has_rect(); | 254 iter.has_rect(); |
| 259 iter.next()) { | 255 iter.next()) { |
| 260 gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect( | 256 gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect( |
| 261 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); | 257 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); |
| 262 debug_rects_.push_back( | 258 debug_rects_.push_back( |
| 263 DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE, | 259 DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 285 debug_rects_.push_back( | 281 debug_rects_.push_back( |
| 286 DebugRect(ANIMATION_BOUNDS_RECT_TYPE, | 282 DebugRect(ANIMATION_BOUNDS_RECT_TYPE, |
| 287 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(), | 283 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(), |
| 288 inflated_bounds.y(), | 284 inflated_bounds.y(), |
| 289 inflated_bounds.width(), | 285 inflated_bounds.width(), |
| 290 inflated_bounds.height())))); | 286 inflated_bounds.height())))); |
| 291 } | 287 } |
| 292 } | 288 } |
| 293 | 289 |
| 294 } // namespace cc | 290 } // namespace cc |
| OLD | NEW |