| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 root_layer_scroll_offset_delegate_, | 527 root_layer_scroll_offset_delegate_, |
| 528 this)); | 528 this)); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void LayerTreeImpl::ClearViewportLayers() { | 531 void LayerTreeImpl::ClearViewportLayers() { |
| 532 page_scale_layer_ = NULL; | 532 page_scale_layer_ = NULL; |
| 533 inner_viewport_scroll_layer_ = NULL; | 533 inner_viewport_scroll_layer_ = NULL; |
| 534 outer_viewport_scroll_layer_ = NULL; | 534 outer_viewport_scroll_layer_ = NULL; |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool LayerTreeImpl::UpdateDrawProperties() { | 537 bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) { |
| 538 if (!needs_update_draw_properties_) | 538 if (!needs_update_draw_properties_) |
| 539 return true; | 539 return true; |
| 540 | 540 |
| 541 // For max_texture_size. | 541 // For max_texture_size. |
| 542 if (!layer_tree_host_impl_->renderer()) | 542 if (!layer_tree_host_impl_->renderer()) |
| 543 return false; | 543 return false; |
| 544 | 544 |
| 545 if (!root_layer()) | 545 if (!root_layer()) |
| 546 return false; | 546 return false; |
| 547 | 547 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 | 642 |
| 643 occlusion_tracker.LeaveLayer(it); | 643 occlusion_tracker.LeaveLayer(it); |
| 644 } | 644 } |
| 645 | 645 |
| 646 unoccluded_screen_space_region_ = | 646 unoccluded_screen_space_region_ = |
| 647 occlusion_tracker.ComputeVisibleRegionInScreen(); | 647 occlusion_tracker.ComputeVisibleRegionInScreen(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 // It'd be ideal if this could be done earlier, but when the raster source |
| 651 // is updated from the main thread during push properties, update draw |
| 652 // properties has not occurred yet and so it's not clear whether or not the |
| 653 // layer can or cannot use lcd text. So, this is the cleanup pass to |
| 654 // determine if the raster source needs to be replaced with a non-lcd |
| 655 // raster source due to draw properties. |
| 656 if (update_lcd_text) { |
| 657 // TODO(enne): Make LTHI::sync_tree return this value. |
| 658 LayerTreeImpl* sync_tree = |
| 659 layer_tree_host_impl_->proxy()->CommitToActiveTree() |
| 660 ? layer_tree_host_impl_->active_tree() |
| 661 : layer_tree_host_impl_->pending_tree(); |
| 662 // If this is not the sync tree, then it is not safe to update lcd text |
| 663 // as it causes invalidations and the tiles may be in use. |
| 664 DCHECK_EQ(this, sync_tree); |
| 665 for (const auto& layer : picture_layers_) |
| 666 layer->UpdateCanUseLCDTextAfterCommit(); |
| 667 } |
| 668 |
| 650 { | 669 { |
| 651 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", | 670 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
| 652 "IsActive", IsActiveTree(), "SourceFrameNumber", | 671 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 653 source_frame_number_); | 672 source_frame_number_); |
| 654 const bool resourceless_software_draw = | 673 const bool resourceless_software_draw = |
| 655 (layer_tree_host_impl_->GetDrawMode() == | 674 (layer_tree_host_impl_->GetDrawMode() == |
| 656 DRAW_MODE_RESOURCELESS_SOFTWARE); | 675 DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 657 size_t layers_updated_count = 0; | 676 size_t layers_updated_count = 0; |
| 658 bool tile_priorities_updated = false; | 677 bool tile_priorities_updated = false; |
| 659 for (PictureLayerImpl* layer : picture_layers_) { | 678 for (PictureLayerImpl* layer : picture_layers_) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 } | 871 } |
| 853 | 872 |
| 854 bool LayerTreeImpl::IsPendingTree() const { | 873 bool LayerTreeImpl::IsPendingTree() const { |
| 855 return layer_tree_host_impl_->pending_tree() == this; | 874 return layer_tree_host_impl_->pending_tree() == this; |
| 856 } | 875 } |
| 857 | 876 |
| 858 bool LayerTreeImpl::IsRecycleTree() const { | 877 bool LayerTreeImpl::IsRecycleTree() const { |
| 859 return layer_tree_host_impl_->recycle_tree() == this; | 878 return layer_tree_host_impl_->recycle_tree() == this; |
| 860 } | 879 } |
| 861 | 880 |
| 881 bool LayerTreeImpl::IsSyncTree() const { |
| 882 return layer_tree_host_impl_->sync_tree() == this; |
| 883 } |
| 884 |
| 862 LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { | 885 LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { |
| 863 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); | 886 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); |
| 864 if (!tree) | 887 if (!tree) |
| 865 return NULL; | 888 return NULL; |
| 866 return tree->LayerById(id); | 889 return tree->LayerById(id); |
| 867 } | 890 } |
| 868 | 891 |
| 869 LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { | 892 LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { |
| 870 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); | 893 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); |
| 871 if (!tree) | 894 if (!tree) |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || | 1477 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
| 1455 !layer->touch_event_handler_region().IsEmpty() || | 1478 !layer->touch_event_handler_region().IsEmpty() || |
| 1456 layer->have_wheel_event_handlers(); | 1479 layer->have_wheel_event_handlers(); |
| 1457 } | 1480 } |
| 1458 }; | 1481 }; |
| 1459 | 1482 |
| 1460 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( | 1483 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
| 1461 const gfx::PointF& screen_space_point) { | 1484 const gfx::PointF& screen_space_point) { |
| 1462 if (!root_layer()) | 1485 if (!root_layer()) |
| 1463 return NULL; | 1486 return NULL; |
| 1464 if (!UpdateDrawProperties()) | 1487 bool update_lcd_text = false; |
| 1488 if (!UpdateDrawProperties(update_lcd_text)) |
| 1465 return NULL; | 1489 return NULL; |
| 1466 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1490 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1467 FindClosestMatchingLayer(screen_space_point, | 1491 FindClosestMatchingLayer(screen_space_point, |
| 1468 root_layer(), | 1492 root_layer(), |
| 1469 HitTestVisibleScrollableOrTouchableFunctor(), | 1493 HitTestVisibleScrollableOrTouchableFunctor(), |
| 1470 &data_for_recursion); | 1494 &data_for_recursion); |
| 1471 return data_for_recursion.closest_match; | 1495 return data_for_recursion.closest_match; |
| 1472 } | 1496 } |
| 1473 | 1497 |
| 1474 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, | 1498 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1496 struct FindWheelEventLayerFunctor { | 1520 struct FindWheelEventLayerFunctor { |
| 1497 bool operator()(LayerImpl* layer) const { | 1521 bool operator()(LayerImpl* layer) const { |
| 1498 return layer->have_wheel_event_handlers(); | 1522 return layer->have_wheel_event_handlers(); |
| 1499 } | 1523 } |
| 1500 }; | 1524 }; |
| 1501 | 1525 |
| 1502 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( | 1526 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( |
| 1503 const gfx::PointF& screen_space_point) { | 1527 const gfx::PointF& screen_space_point) { |
| 1504 if (!root_layer()) | 1528 if (!root_layer()) |
| 1505 return NULL; | 1529 return NULL; |
| 1506 if (!UpdateDrawProperties()) | 1530 bool update_lcd_text = false; |
| 1531 if (!UpdateDrawProperties(update_lcd_text)) |
| 1507 return NULL; | 1532 return NULL; |
| 1508 FindWheelEventLayerFunctor func; | 1533 FindWheelEventLayerFunctor func; |
| 1509 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1534 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1510 FindClosestMatchingLayer(screen_space_point, root_layer(), func, | 1535 FindClosestMatchingLayer(screen_space_point, root_layer(), func, |
| 1511 &data_for_recursion); | 1536 &data_for_recursion); |
| 1512 return data_for_recursion.closest_match; | 1537 return data_for_recursion.closest_match; |
| 1513 } | 1538 } |
| 1514 | 1539 |
| 1515 struct FindTouchEventLayerFunctor { | 1540 struct FindTouchEventLayerFunctor { |
| 1516 bool operator()(LayerImpl* layer) const { | 1541 bool operator()(LayerImpl* layer) const { |
| 1517 return LayerHasTouchEventHandlersAt(screen_space_point, layer); | 1542 return LayerHasTouchEventHandlersAt(screen_space_point, layer); |
| 1518 } | 1543 } |
| 1519 const gfx::PointF screen_space_point; | 1544 const gfx::PointF screen_space_point; |
| 1520 }; | 1545 }; |
| 1521 | 1546 |
| 1522 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1547 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1523 const gfx::PointF& screen_space_point) { | 1548 const gfx::PointF& screen_space_point) { |
| 1524 if (!root_layer()) | 1549 if (!root_layer()) |
| 1525 return NULL; | 1550 return NULL; |
| 1526 if (!UpdateDrawProperties()) | 1551 bool update_lcd_text = false; |
| 1552 if (!UpdateDrawProperties(update_lcd_text)) |
| 1527 return NULL; | 1553 return NULL; |
| 1528 FindTouchEventLayerFunctor func = {screen_space_point}; | 1554 FindTouchEventLayerFunctor func = {screen_space_point}; |
| 1529 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1555 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1530 FindClosestMatchingLayer( | 1556 FindClosestMatchingLayer( |
| 1531 screen_space_point, root_layer(), func, &data_for_recursion); | 1557 screen_space_point, root_layer(), func, &data_for_recursion); |
| 1532 return data_for_recursion.closest_match; | 1558 return data_for_recursion.closest_match; |
| 1533 } | 1559 } |
| 1534 | 1560 |
| 1535 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, | 1561 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, |
| 1536 const LayerSelectionBound& end) { | 1562 const LayerSelectionBound& end) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1647 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1622 pending_page_scale_animation_ = pending_animation.Pass(); | 1648 pending_page_scale_animation_ = pending_animation.Pass(); |
| 1623 } | 1649 } |
| 1624 | 1650 |
| 1625 scoped_ptr<PendingPageScaleAnimation> | 1651 scoped_ptr<PendingPageScaleAnimation> |
| 1626 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1652 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1627 return pending_page_scale_animation_.Pass(); | 1653 return pending_page_scale_animation_.Pass(); |
| 1628 } | 1654 } |
| 1629 | 1655 |
| 1630 } // namespace cc | 1656 } // namespace cc |
| OLD | NEW |