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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 root_layer_scroll_offset_delegate_, | 530 root_layer_scroll_offset_delegate_, |
531 this)); | 531 this)); |
532 } | 532 } |
533 | 533 |
534 void LayerTreeImpl::ClearViewportLayers() { | 534 void LayerTreeImpl::ClearViewportLayers() { |
535 page_scale_layer_ = NULL; | 535 page_scale_layer_ = NULL; |
536 inner_viewport_scroll_layer_ = NULL; | 536 inner_viewport_scroll_layer_ = NULL; |
537 outer_viewport_scroll_layer_ = NULL; | 537 outer_viewport_scroll_layer_ = NULL; |
538 } | 538 } |
539 | 539 |
540 bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) { | 540 bool LayerTreeImpl::UpdateDrawProperties(bool first_update_after_commit) { |
541 if (!needs_update_draw_properties_) | 541 if (!needs_update_draw_properties_) |
542 return true; | 542 return true; |
543 | 543 |
544 // Calling UpdateDrawProperties must clear this flag, so there can be no | 544 // Calling UpdateDrawProperties must clear this flag, so there can be no |
545 // early outs before this. | 545 // early outs before this. |
546 needs_update_draw_properties_ = false; | 546 needs_update_draw_properties_ = false; |
547 | 547 |
548 // For max_texture_size. When the renderer is re-created in | 548 // For max_texture_size. When the renderer is re-created in |
549 // CreateAndSetRenderer, the needs update draw properties flag is set | 549 // CreateAndSetRenderer, the needs update draw properties flag is set |
550 // again. | 550 // again. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 | 655 |
656 unoccluded_screen_space_region_ = | 656 unoccluded_screen_space_region_ = |
657 occlusion_tracker.ComputeVisibleRegionInScreen(); | 657 occlusion_tracker.ComputeVisibleRegionInScreen(); |
658 } | 658 } |
659 | 659 |
660 // It'd be ideal if this could be done earlier, but when the raster source | 660 // It'd be ideal if this could be done earlier, but when the raster source |
661 // is updated from the main thread during push properties, update draw | 661 // is updated from the main thread during push properties, update draw |
662 // properties has not occurred yet and so it's not clear whether or not the | 662 // properties has not occurred yet and so it's not clear whether or not the |
663 // layer can or cannot use lcd text. So, this is the cleanup pass to | 663 // layer can or cannot use lcd text. So, this is the cleanup pass to |
664 // determine if the raster source needs to be replaced with a non-lcd | 664 // determine if the raster source needs to be replaced with a non-lcd |
665 // raster source due to draw properties. | 665 // raster source due to draw properties. We also check for changes in the |
666 if (update_lcd_text) { | 666 // viewport size here and if using GPU rasterization, notify the layers |
667 // that they need to recalculate the tiling texture size. | |
668 if (first_update_after_commit) { | |
667 // TODO(enne): Make LTHI::sync_tree return this value. | 669 // TODO(enne): Make LTHI::sync_tree return this value. |
668 LayerTreeImpl* sync_tree = | 670 LayerTreeImpl* sync_tree = |
669 layer_tree_host_impl_->proxy()->CommitToActiveTree() | 671 layer_tree_host_impl_->proxy()->CommitToActiveTree() |
670 ? layer_tree_host_impl_->active_tree() | 672 ? layer_tree_host_impl_->active_tree() |
671 : layer_tree_host_impl_->pending_tree(); | 673 : layer_tree_host_impl_->pending_tree(); |
672 // If this is not the sync tree, then it is not safe to update lcd text | 674 // If this is not the sync tree, then it is not safe to update lcd text |
673 // as it causes invalidations and the tiles may be in use. | 675 // as it causes invalidations and the tiles may be in use. |
674 DCHECK_EQ(this, sync_tree); | 676 DCHECK_EQ(this, sync_tree); |
675 for (const auto& layer : picture_layers_) | 677 |
678 bool layersNeedNotificationOfViewportChange = | |
enne (OOO)
2015/03/19 17:55:24
layers_need_notification_etc
| |
679 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid() && | |
enne (OOO)
2015/03/19 17:55:24
This will not work. If you commit to the active t
| |
680 layer_tree_host_impl_->use_gpu_rasterization(); | |
enne (OOO)
2015/03/19 17:55:24
This is leaking implementation details of PictureL
| |
681 | |
682 for (const auto& layer : picture_layers_) { | |
676 layer->UpdateCanUseLCDTextAfterCommit(); | 683 layer->UpdateCanUseLCDTextAfterCommit(); |
684 if (layersNeedNotificationOfViewportChange) | |
685 layer->UpdateViewportAfterCommit(); | |
686 } | |
677 } | 687 } |
678 | 688 |
679 { | 689 { |
680 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", | 690 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
681 "IsActive", IsActiveTree(), "SourceFrameNumber", | 691 "IsActive", IsActiveTree(), "SourceFrameNumber", |
682 source_frame_number_); | 692 source_frame_number_); |
683 const bool resourceless_software_draw = | 693 const bool resourceless_software_draw = |
684 (layer_tree_host_impl_->GetDrawMode() == | 694 (layer_tree_host_impl_->GetDrawMode() == |
685 DRAW_MODE_RESOURCELESS_SOFTWARE); | 695 DRAW_MODE_RESOURCELESS_SOFTWARE); |
686 size_t layers_updated_count = 0; | 696 size_t layers_updated_count = 0; |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1467 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || | 1477 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
1468 !layer->touch_event_handler_region().IsEmpty() || | 1478 !layer->touch_event_handler_region().IsEmpty() || |
1469 layer->have_wheel_event_handlers(); | 1479 layer->have_wheel_event_handlers(); |
1470 } | 1480 } |
1471 }; | 1481 }; |
1472 | 1482 |
1473 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( | 1483 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
1474 const gfx::PointF& screen_space_point) { | 1484 const gfx::PointF& screen_space_point) { |
1475 if (!root_layer()) | 1485 if (!root_layer()) |
1476 return NULL; | 1486 return NULL; |
1477 bool update_lcd_text = false; | 1487 bool first_update_after_commit = false; |
1478 if (!UpdateDrawProperties(update_lcd_text)) | 1488 if (!UpdateDrawProperties(first_update_after_commit)) |
1479 return NULL; | 1489 return NULL; |
1480 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1490 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
1481 FindClosestMatchingLayer(screen_space_point, | 1491 FindClosestMatchingLayer(screen_space_point, |
1482 root_layer(), | 1492 root_layer(), |
1483 HitTestVisibleScrollableOrTouchableFunctor(), | 1493 HitTestVisibleScrollableOrTouchableFunctor(), |
1484 &data_for_recursion); | 1494 &data_for_recursion); |
1485 return data_for_recursion.closest_match; | 1495 return data_for_recursion.closest_match; |
1486 } | 1496 } |
1487 | 1497 |
1488 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... | |
1510 struct FindWheelEventLayerFunctor { | 1520 struct FindWheelEventLayerFunctor { |
1511 bool operator()(LayerImpl* layer) const { | 1521 bool operator()(LayerImpl* layer) const { |
1512 return layer->have_wheel_event_handlers(); | 1522 return layer->have_wheel_event_handlers(); |
1513 } | 1523 } |
1514 }; | 1524 }; |
1515 | 1525 |
1516 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( | 1526 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( |
1517 const gfx::PointF& screen_space_point) { | 1527 const gfx::PointF& screen_space_point) { |
1518 if (!root_layer()) | 1528 if (!root_layer()) |
1519 return NULL; | 1529 return NULL; |
1520 bool update_lcd_text = false; | 1530 bool first_update_after_commit = false; |
1521 if (!UpdateDrawProperties(update_lcd_text)) | 1531 if (!UpdateDrawProperties(first_update_after_commit)) |
1522 return NULL; | 1532 return NULL; |
1523 FindWheelEventLayerFunctor func; | 1533 FindWheelEventLayerFunctor func; |
1524 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1534 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
1525 FindClosestMatchingLayer(screen_space_point, root_layer(), func, | 1535 FindClosestMatchingLayer(screen_space_point, root_layer(), func, |
1526 &data_for_recursion); | 1536 &data_for_recursion); |
1527 return data_for_recursion.closest_match; | 1537 return data_for_recursion.closest_match; |
1528 } | 1538 } |
1529 | 1539 |
1530 struct FindTouchEventLayerFunctor { | 1540 struct FindTouchEventLayerFunctor { |
1531 bool operator()(LayerImpl* layer) const { | 1541 bool operator()(LayerImpl* layer) const { |
1532 return LayerHasTouchEventHandlersAt(screen_space_point, layer); | 1542 return LayerHasTouchEventHandlersAt(screen_space_point, layer); |
1533 } | 1543 } |
1534 const gfx::PointF screen_space_point; | 1544 const gfx::PointF screen_space_point; |
1535 }; | 1545 }; |
1536 | 1546 |
1537 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1547 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
1538 const gfx::PointF& screen_space_point) { | 1548 const gfx::PointF& screen_space_point) { |
1539 if (!root_layer()) | 1549 if (!root_layer()) |
1540 return NULL; | 1550 return NULL; |
1541 bool update_lcd_text = false; | 1551 bool first_update_after_commit = false; |
1542 if (!UpdateDrawProperties(update_lcd_text)) | 1552 if (!UpdateDrawProperties(first_update_after_commit)) |
1543 return NULL; | 1553 return NULL; |
1544 FindTouchEventLayerFunctor func = {screen_space_point}; | 1554 FindTouchEventLayerFunctor func = {screen_space_point}; |
1545 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1555 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
1546 FindClosestMatchingLayer( | 1556 FindClosestMatchingLayer( |
1547 screen_space_point, root_layer(), func, &data_for_recursion); | 1557 screen_space_point, root_layer(), func, &data_for_recursion); |
1548 return data_for_recursion.closest_match; | 1558 return data_for_recursion.closest_match; |
1549 } | 1559 } |
1550 | 1560 |
1551 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, | 1561 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, |
1552 const LayerSelectionBound& end) { | 1562 const LayerSelectionBound& end) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1647 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
1638 pending_page_scale_animation_ = pending_animation.Pass(); | 1648 pending_page_scale_animation_ = pending_animation.Pass(); |
1639 } | 1649 } |
1640 | 1650 |
1641 scoped_ptr<PendingPageScaleAnimation> | 1651 scoped_ptr<PendingPageScaleAnimation> |
1642 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1652 LayerTreeImpl::TakePendingPageScaleAnimation() { |
1643 return pending_page_scale_animation_.Pass(); | 1653 return pending_page_scale_animation_.Pass(); |
1644 } | 1654 } |
1645 | 1655 |
1646 } // namespace cc | 1656 } // namespace cc |
OLD | NEW |