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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 debug_rects_.push_back( | 156 debug_rects_.push_back( |
157 DebugRect(REPLICA_SCREEN_SPACE_RECT_TYPE, | 157 DebugRect(REPLICA_SCREEN_SPACE_RECT_TYPE, |
158 MathUtil::MapEnclosingClippedRect( | 158 MathUtil::MapEnclosingClippedRect( |
159 render_surface->replica_screen_space_transform(), | 159 render_surface->replica_screen_space_transform(), |
160 render_surface->content_rect()))); | 160 render_surface->content_rect()))); |
161 } | 161 } |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) { | 165 void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) { |
166 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 166 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
167 layer, | 167 SaveTouchEventHandlerRectsCallback(layer); |
168 base::Bind(&DebugRectHistory::SaveTouchEventHandlerRectsCallback, | 168 }); |
169 base::Unretained(this))); | |
170 } | 169 } |
171 | 170 |
172 void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) { | 171 void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) { |
173 for (Region::Iterator iter(layer->touch_event_handler_region()); | 172 for (Region::Iterator iter(layer->touch_event_handler_region()); |
174 iter.has_rect(); | 173 iter.has_rect(); |
175 iter.next()) { | 174 iter.next()) { |
176 gfx::Rect touch_rect = gfx::ScaleToEnclosingRect( | 175 gfx::Rect touch_rect = gfx::ScaleToEnclosingRect( |
177 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); | 176 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); |
178 debug_rects_.push_back( | 177 debug_rects_.push_back( |
179 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE, | 178 DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE, |
180 MathUtil::MapEnclosingClippedRect( | 179 MathUtil::MapEnclosingClippedRect( |
181 layer->screen_space_transform(), touch_rect))); | 180 layer->screen_space_transform(), touch_rect))); |
182 } | 181 } |
183 } | 182 } |
184 | 183 |
185 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) { | 184 void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) { |
186 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 185 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
187 layer, | 186 SaveWheelEventHandlerRectsCallback(layer); |
188 base::Bind(&DebugRectHistory::SaveWheelEventHandlerRectsCallback, | 187 }); |
189 base::Unretained(this))); | |
190 } | 188 } |
191 | 189 |
192 void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) { | 190 void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) { |
193 if (!layer->have_wheel_event_handlers()) | 191 if (!layer->have_wheel_event_handlers()) |
194 return; | 192 return; |
195 | 193 |
196 gfx::Rect wheel_rect = | 194 gfx::Rect wheel_rect = |
197 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), | 195 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), |
198 layer->contents_scale_x(), | 196 layer->contents_scale_x(), |
199 layer->contents_scale_y()); | 197 layer->contents_scale_y()); |
200 debug_rects_.push_back( | 198 debug_rects_.push_back( |
201 DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE, | 199 DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE, |
202 MathUtil::MapEnclosingClippedRect( | 200 MathUtil::MapEnclosingClippedRect( |
203 layer->screen_space_transform(), wheel_rect))); | 201 layer->screen_space_transform(), wheel_rect))); |
204 } | 202 } |
205 | 203 |
206 void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) { | 204 void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) { |
207 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 205 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
208 layer, | 206 SaveScrollEventHandlerRectsCallback(layer); |
209 base::Bind(&DebugRectHistory::SaveScrollEventHandlerRectsCallback, | 207 }); |
210 base::Unretained(this))); | |
211 } | 208 } |
212 | 209 |
213 void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) { | 210 void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) { |
214 if (!layer->have_scroll_event_handlers()) | 211 if (!layer->have_scroll_event_handlers()) |
215 return; | 212 return; |
216 | 213 |
217 gfx::Rect scroll_rect = | 214 gfx::Rect scroll_rect = |
218 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), | 215 gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()), |
219 layer->contents_scale_x(), | 216 layer->contents_scale_x(), |
220 layer->contents_scale_y()); | 217 layer->contents_scale_y()); |
221 debug_rects_.push_back( | 218 debug_rects_.push_back( |
222 DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE, | 219 DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE, |
223 MathUtil::MapEnclosingClippedRect( | 220 MathUtil::MapEnclosingClippedRect( |
224 layer->screen_space_transform(), scroll_rect))); | 221 layer->screen_space_transform(), scroll_rect))); |
225 } | 222 } |
226 | 223 |
227 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) { | 224 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) { |
228 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>( | 225 LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) { |
229 layer, | 226 SaveNonFastScrollableRectsCallback(layer); |
230 base::Bind(&DebugRectHistory::SaveNonFastScrollableRectsCallback, | 227 }); |
231 base::Unretained(this))); | |
232 } | 228 } |
233 | 229 |
234 void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) { | 230 void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) { |
235 for (Region::Iterator iter(layer->non_fast_scrollable_region()); | 231 for (Region::Iterator iter(layer->non_fast_scrollable_region()); |
236 iter.has_rect(); | 232 iter.has_rect(); |
237 iter.next()) { | 233 iter.next()) { |
238 gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect( | 234 gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect( |
239 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); | 235 iter.rect(), layer->contents_scale_x(), layer->contents_scale_y()); |
240 debug_rects_.push_back( | 236 debug_rects_.push_back( |
241 DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE, | 237 DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE, |
(...skipping 21 matching lines...) Expand all Loading... |
263 debug_rects_.push_back( | 259 debug_rects_.push_back( |
264 DebugRect(ANIMATION_BOUNDS_RECT_TYPE, | 260 DebugRect(ANIMATION_BOUNDS_RECT_TYPE, |
265 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(), | 261 gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(), |
266 inflated_bounds.y(), | 262 inflated_bounds.y(), |
267 inflated_bounds.width(), | 263 inflated_bounds.width(), |
268 inflated_bounds.height())))); | 264 inflated_bounds.height())))); |
269 } | 265 } |
270 } | 266 } |
271 | 267 |
272 } // namespace cc | 268 } // namespace cc |
OLD | NEW |