OLD | NEW |
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 <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 root_layer_scroll_offset_delegate_, | 431 root_layer_scroll_offset_delegate_, |
432 this)); | 432 this)); |
433 } | 433 } |
434 | 434 |
435 void LayerTreeImpl::ClearViewportLayers() { | 435 void LayerTreeImpl::ClearViewportLayers() { |
436 page_scale_layer_ = NULL; | 436 page_scale_layer_ = NULL; |
437 inner_viewport_scroll_layer_ = NULL; | 437 inner_viewport_scroll_layer_ = NULL; |
438 outer_viewport_scroll_layer_ = NULL; | 438 outer_viewport_scroll_layer_ = NULL; |
439 } | 439 } |
440 | 440 |
441 void LayerTreeImpl::UpdateDrawProperties() { | 441 bool LayerTreeImpl::UpdateDrawProperties() { |
| 442 if (!needs_update_draw_properties_) |
| 443 return true; |
| 444 |
| 445 // For max_texture_size. |
| 446 if (!layer_tree_host_impl_->renderer()) |
| 447 return false; |
| 448 |
| 449 if (!root_layer()) |
| 450 return false; |
| 451 |
442 needs_update_draw_properties_ = false; | 452 needs_update_draw_properties_ = false; |
443 render_surface_layer_list_.clear(); | 453 render_surface_layer_list_.clear(); |
444 | 454 |
445 // For max_texture_size. | |
446 if (!layer_tree_host_impl_->renderer()) | |
447 return; | |
448 | |
449 if (!root_layer()) | |
450 return; | |
451 | |
452 { | 455 { |
453 TRACE_EVENT2("cc", | 456 TRACE_EVENT2("cc", |
454 "LayerTreeImpl::UpdateDrawProperties", | 457 "LayerTreeImpl::UpdateDrawProperties", |
455 "IsActive", | 458 "IsActive", |
456 IsActiveTree(), | 459 IsActiveTree(), |
457 "SourceFrameNumber", | 460 "SourceFrameNumber", |
458 source_frame_number_); | 461 source_frame_number_); |
459 LayerImpl* page_scale_layer = | 462 LayerImpl* page_scale_layer = |
460 page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); | 463 page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); |
461 bool can_render_to_separate_surface = | 464 bool can_render_to_separate_surface = |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 506 |
504 if (layer->mask_layer()) | 507 if (layer->mask_layer()) |
505 layer->mask_layer()->UpdateTilePriorities(); | 508 layer->mask_layer()->UpdateTilePriorities(); |
506 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) | 509 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
507 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); | 510 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); |
508 } | 511 } |
509 } | 512 } |
510 | 513 |
511 DCHECK(!needs_update_draw_properties_) << | 514 DCHECK(!needs_update_draw_properties_) << |
512 "CalcDrawProperties should not set_needs_update_draw_properties()"; | 515 "CalcDrawProperties should not set_needs_update_draw_properties()"; |
| 516 return true; |
513 } | 517 } |
514 | 518 |
515 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { | 519 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { |
516 // If this assert triggers, then the list is dirty. | 520 // If this assert triggers, then the list is dirty. |
517 DCHECK(!needs_update_draw_properties_); | 521 DCHECK(!needs_update_draw_properties_); |
518 return render_surface_layer_list_; | 522 return render_surface_layer_list_; |
519 } | 523 } |
520 | 524 |
521 gfx::Size LayerTreeImpl::ScrollableSize() const { | 525 gfx::Size LayerTreeImpl::ScrollableSize() const { |
522 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 526 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 bool operator()(LayerImpl* layer) const { | 1226 bool operator()(LayerImpl* layer) const { |
1223 return layer->IsDrawnRenderSurfaceLayerListMember() || | 1227 return layer->IsDrawnRenderSurfaceLayerListMember() || |
1224 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || | 1228 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
1225 !layer->touch_event_handler_region().IsEmpty() || | 1229 !layer->touch_event_handler_region().IsEmpty() || |
1226 layer->have_wheel_event_handlers(); | 1230 layer->have_wheel_event_handlers(); |
1227 } | 1231 } |
1228 }; | 1232 }; |
1229 | 1233 |
1230 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( | 1234 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
1231 const gfx::PointF& screen_space_point) { | 1235 const gfx::PointF& screen_space_point) { |
| 1236 if (!root_layer()) |
| 1237 return NULL; |
| 1238 if (!UpdateDrawProperties()) |
| 1239 return NULL; |
1232 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1240 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
1233 FindClosestMatchingLayer(screen_space_point, | 1241 FindClosestMatchingLayer(screen_space_point, |
1234 root_layer(), | 1242 root_layer(), |
1235 HitTestVisibleScrollableOrTouchableFunctor(), | 1243 HitTestVisibleScrollableOrTouchableFunctor(), |
1236 &data_for_recursion); | 1244 &data_for_recursion); |
1237 return data_for_recursion.closest_match; | 1245 return data_for_recursion.closest_match; |
1238 } | 1246 } |
1239 | 1247 |
1240 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, | 1248 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, |
1241 LayerImpl* layer_impl) { | 1249 LayerImpl* layer_impl) { |
(...skipping 19 matching lines...) Expand all Loading... |
1261 | 1269 |
1262 struct FindTouchEventLayerFunctor { | 1270 struct FindTouchEventLayerFunctor { |
1263 bool operator()(LayerImpl* layer) const { | 1271 bool operator()(LayerImpl* layer) const { |
1264 return LayerHasTouchEventHandlersAt(screen_space_point, layer); | 1272 return LayerHasTouchEventHandlersAt(screen_space_point, layer); |
1265 } | 1273 } |
1266 const gfx::PointF screen_space_point; | 1274 const gfx::PointF screen_space_point; |
1267 }; | 1275 }; |
1268 | 1276 |
1269 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1277 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
1270 const gfx::PointF& screen_space_point) { | 1278 const gfx::PointF& screen_space_point) { |
| 1279 if (!root_layer()) |
| 1280 return NULL; |
| 1281 if (!UpdateDrawProperties()) |
| 1282 return NULL; |
1271 FindTouchEventLayerFunctor func = {screen_space_point}; | 1283 FindTouchEventLayerFunctor func = {screen_space_point}; |
1272 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1284 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
1273 FindClosestMatchingLayer( | 1285 FindClosestMatchingLayer( |
1274 screen_space_point, root_layer(), func, &data_for_recursion); | 1286 screen_space_point, root_layer(), func, &data_for_recursion); |
1275 return data_for_recursion.closest_match; | 1287 return data_for_recursion.closest_match; |
1276 } | 1288 } |
1277 | 1289 |
1278 } // namespace cc | 1290 } // namespace cc |
OLD | NEW |