Chromium Code Reviews| 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 // | |
| 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 == sync_tree && update_lcd_text) { | |
|
danakj
2015/02/18 21:51:46
Can DCHECK this == sync_tree when update_lcd_text
enne (OOO)
2015/02/18 22:16:07
Done.
| |
| 663 for (const auto& layer : picture_layers_) | |
| 664 layer->UpdateCanUseLCDTextAfterCommit(); | |
| 665 } | |
| 666 | |
| 650 { | 667 { |
| 651 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", | 668 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
| 652 "IsActive", IsActiveTree(), "SourceFrameNumber", | 669 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 653 source_frame_number_); | 670 source_frame_number_); |
| 654 const bool resourceless_software_draw = | 671 const bool resourceless_software_draw = |
| 655 (layer_tree_host_impl_->GetDrawMode() == | 672 (layer_tree_host_impl_->GetDrawMode() == |
| 656 DRAW_MODE_RESOURCELESS_SOFTWARE); | 673 DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 657 size_t layers_updated_count = 0; | 674 size_t layers_updated_count = 0; |
| 658 bool tile_priorities_updated = false; | 675 bool tile_priorities_updated = false; |
| 659 for (PictureLayerImpl* layer : picture_layers_) { | 676 for (PictureLayerImpl* layer : picture_layers_) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 } | 869 } |
| 853 | 870 |
| 854 bool LayerTreeImpl::IsPendingTree() const { | 871 bool LayerTreeImpl::IsPendingTree() const { |
| 855 return layer_tree_host_impl_->pending_tree() == this; | 872 return layer_tree_host_impl_->pending_tree() == this; |
| 856 } | 873 } |
| 857 | 874 |
| 858 bool LayerTreeImpl::IsRecycleTree() const { | 875 bool LayerTreeImpl::IsRecycleTree() const { |
| 859 return layer_tree_host_impl_->recycle_tree() == this; | 876 return layer_tree_host_impl_->recycle_tree() == this; |
| 860 } | 877 } |
| 861 | 878 |
| 879 bool LayerTreeImpl::IsSyncTree() const { | |
| 880 return layer_tree_host_impl_->sync_tree() == this; | |
| 881 } | |
| 882 | |
| 862 LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { | 883 LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { |
| 863 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); | 884 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); |
| 864 if (!tree) | 885 if (!tree) |
| 865 return NULL; | 886 return NULL; |
| 866 return tree->LayerById(id); | 887 return tree->LayerById(id); |
| 867 } | 888 } |
| 868 | 889 |
| 869 LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { | 890 LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { |
| 870 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); | 891 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); |
| 871 if (!tree) | 892 if (!tree) |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1454 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || | 1475 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
| 1455 !layer->touch_event_handler_region().IsEmpty() || | 1476 !layer->touch_event_handler_region().IsEmpty() || |
| 1456 layer->have_wheel_event_handlers(); | 1477 layer->have_wheel_event_handlers(); |
| 1457 } | 1478 } |
| 1458 }; | 1479 }; |
| 1459 | 1480 |
| 1460 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( | 1481 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
| 1461 const gfx::PointF& screen_space_point) { | 1482 const gfx::PointF& screen_space_point) { |
| 1462 if (!root_layer()) | 1483 if (!root_layer()) |
| 1463 return NULL; | 1484 return NULL; |
| 1464 if (!UpdateDrawProperties()) | 1485 bool update_lcd_text = false; |
| 1486 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1465 return NULL; | 1487 return NULL; |
| 1466 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1488 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1467 FindClosestMatchingLayer(screen_space_point, | 1489 FindClosestMatchingLayer(screen_space_point, |
| 1468 root_layer(), | 1490 root_layer(), |
| 1469 HitTestVisibleScrollableOrTouchableFunctor(), | 1491 HitTestVisibleScrollableOrTouchableFunctor(), |
| 1470 &data_for_recursion); | 1492 &data_for_recursion); |
| 1471 return data_for_recursion.closest_match; | 1493 return data_for_recursion.closest_match; |
| 1472 } | 1494 } |
| 1473 | 1495 |
| 1474 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, | 1496 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1496 struct FindWheelEventLayerFunctor { | 1518 struct FindWheelEventLayerFunctor { |
| 1497 bool operator()(LayerImpl* layer) const { | 1519 bool operator()(LayerImpl* layer) const { |
| 1498 return layer->have_wheel_event_handlers(); | 1520 return layer->have_wheel_event_handlers(); |
| 1499 } | 1521 } |
| 1500 }; | 1522 }; |
| 1501 | 1523 |
| 1502 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( | 1524 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( |
| 1503 const gfx::PointF& screen_space_point) { | 1525 const gfx::PointF& screen_space_point) { |
| 1504 if (!root_layer()) | 1526 if (!root_layer()) |
| 1505 return NULL; | 1527 return NULL; |
| 1506 if (!UpdateDrawProperties()) | 1528 bool update_lcd_text = false; |
| 1529 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1507 return NULL; | 1530 return NULL; |
| 1508 FindWheelEventLayerFunctor func; | 1531 FindWheelEventLayerFunctor func; |
| 1509 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1532 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1510 FindClosestMatchingLayer(screen_space_point, root_layer(), func, | 1533 FindClosestMatchingLayer(screen_space_point, root_layer(), func, |
| 1511 &data_for_recursion); | 1534 &data_for_recursion); |
| 1512 return data_for_recursion.closest_match; | 1535 return data_for_recursion.closest_match; |
| 1513 } | 1536 } |
| 1514 | 1537 |
| 1515 struct FindTouchEventLayerFunctor { | 1538 struct FindTouchEventLayerFunctor { |
| 1516 bool operator()(LayerImpl* layer) const { | 1539 bool operator()(LayerImpl* layer) const { |
| 1517 return LayerHasTouchEventHandlersAt(screen_space_point, layer); | 1540 return LayerHasTouchEventHandlersAt(screen_space_point, layer); |
| 1518 } | 1541 } |
| 1519 const gfx::PointF screen_space_point; | 1542 const gfx::PointF screen_space_point; |
| 1520 }; | 1543 }; |
| 1521 | 1544 |
| 1522 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1545 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1523 const gfx::PointF& screen_space_point) { | 1546 const gfx::PointF& screen_space_point) { |
| 1524 if (!root_layer()) | 1547 if (!root_layer()) |
| 1525 return NULL; | 1548 return NULL; |
| 1526 if (!UpdateDrawProperties()) | 1549 bool update_lcd_text = false; |
| 1550 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1527 return NULL; | 1551 return NULL; |
| 1528 FindTouchEventLayerFunctor func = {screen_space_point}; | 1552 FindTouchEventLayerFunctor func = {screen_space_point}; |
| 1529 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1553 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1530 FindClosestMatchingLayer( | 1554 FindClosestMatchingLayer( |
| 1531 screen_space_point, root_layer(), func, &data_for_recursion); | 1555 screen_space_point, root_layer(), func, &data_for_recursion); |
| 1532 return data_for_recursion.closest_match; | 1556 return data_for_recursion.closest_match; |
| 1533 } | 1557 } |
| 1534 | 1558 |
| 1535 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, | 1559 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, |
| 1536 const LayerSelectionBound& end) { | 1560 const LayerSelectionBound& end) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1621 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1645 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1622 pending_page_scale_animation_ = pending_animation.Pass(); | 1646 pending_page_scale_animation_ = pending_animation.Pass(); |
| 1623 } | 1647 } |
| 1624 | 1648 |
| 1625 scoped_ptr<PendingPageScaleAnimation> | 1649 scoped_ptr<PendingPageScaleAnimation> |
| 1626 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1650 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1627 return pending_page_scale_animation_.Pass(); | 1651 return pending_page_scale_animation_.Pass(); |
| 1628 } | 1652 } |
| 1629 | 1653 |
| 1630 } // namespace cc | 1654 } // namespace cc |
| OLD | NEW |