| 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(bool update_lcd_text) { | 537 bool LayerTreeImpl::UpdateDrawProperties() { |
| 538 if (!needs_update_draw_properties_) | 538 if (!needs_update_draw_properties_) |
| 539 return true; | 539 return true; |
| 540 | 540 |
| 541 // Calling UpdateDrawProperties must clear this flag, so there can be no | 541 // For max_texture_size. |
| 542 // early outs before this. | |
| 543 needs_update_draw_properties_ = false; | |
| 544 | |
| 545 // For max_texture_size. When the renderer is re-created in | |
| 546 // CreateAndSetRenderer, the needs update draw properties flag is set | |
| 547 // again. | |
| 548 if (!layer_tree_host_impl_->renderer()) | 542 if (!layer_tree_host_impl_->renderer()) |
| 549 return false; | 543 return false; |
| 550 | 544 |
| 551 // Clear this after the renderer early out, as it should still be | |
| 552 // possible to hit test even without a renderer. | |
| 553 render_surface_layer_list_.clear(); | |
| 554 | |
| 555 if (!root_layer()) | 545 if (!root_layer()) |
| 556 return false; | 546 return false; |
| 557 | 547 |
| 548 needs_update_draw_properties_ = false; |
| 549 render_surface_layer_list_.clear(); |
| 550 |
| 558 { | 551 { |
| 559 TRACE_EVENT2( | 552 TRACE_EVENT2( |
| 560 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties", | 553 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties", |
| 561 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_); | 554 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_); |
| 562 LayerImpl* page_scale_layer = | 555 LayerImpl* page_scale_layer = |
| 563 page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); | 556 page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); |
| 564 bool can_render_to_separate_surface = | 557 bool can_render_to_separate_surface = |
| 565 (layer_tree_host_impl_->GetDrawMode() != | 558 (layer_tree_host_impl_->GetDrawMode() != |
| 566 DRAW_MODE_RESOURCELESS_SOFTWARE); | 559 DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 567 | 560 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 640 } |
| 648 } | 641 } |
| 649 | 642 |
| 650 occlusion_tracker.LeaveLayer(it); | 643 occlusion_tracker.LeaveLayer(it); |
| 651 } | 644 } |
| 652 | 645 |
| 653 unoccluded_screen_space_region_ = | 646 unoccluded_screen_space_region_ = |
| 654 occlusion_tracker.ComputeVisibleRegionInScreen(); | 647 occlusion_tracker.ComputeVisibleRegionInScreen(); |
| 655 } | 648 } |
| 656 | 649 |
| 657 // It'd be ideal if this could be done earlier, but when the raster source | |
| 658 // is updated from the main thread during push properties, update draw | |
| 659 // properties has not occurred yet and so it's not clear whether or not the | |
| 660 // layer can or cannot use lcd text. So, this is the cleanup pass to | |
| 661 // determine if the raster source needs to be replaced with a non-lcd | |
| 662 // raster source due to draw properties. | |
| 663 if (update_lcd_text) { | |
| 664 // TODO(enne): Make LTHI::sync_tree return this value. | |
| 665 LayerTreeImpl* sync_tree = | |
| 666 layer_tree_host_impl_->proxy()->CommitToActiveTree() | |
| 667 ? layer_tree_host_impl_->active_tree() | |
| 668 : layer_tree_host_impl_->pending_tree(); | |
| 669 // If this is not the sync tree, then it is not safe to update lcd text | |
| 670 // as it causes invalidations and the tiles may be in use. | |
| 671 DCHECK_EQ(this, sync_tree); | |
| 672 for (const auto& layer : picture_layers_) | |
| 673 layer->UpdateCanUseLCDTextAfterCommit(); | |
| 674 } | |
| 675 | |
| 676 { | 650 { |
| 677 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", | 651 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
| 678 "IsActive", IsActiveTree(), "SourceFrameNumber", | 652 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 679 source_frame_number_); | 653 source_frame_number_); |
| 680 const bool resourceless_software_draw = | 654 const bool resourceless_software_draw = |
| 681 (layer_tree_host_impl_->GetDrawMode() == | 655 (layer_tree_host_impl_->GetDrawMode() == |
| 682 DRAW_MODE_RESOURCELESS_SOFTWARE); | 656 DRAW_MODE_RESOURCELESS_SOFTWARE); |
| 683 size_t layers_updated_count = 0; | 657 size_t layers_updated_count = 0; |
| 684 bool tile_priorities_updated = false; | 658 bool tile_priorities_updated = false; |
| 685 for (PictureLayerImpl* layer : picture_layers_) { | 659 for (PictureLayerImpl* layer : picture_layers_) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 } | 852 } |
| 879 | 853 |
| 880 bool LayerTreeImpl::IsPendingTree() const { | 854 bool LayerTreeImpl::IsPendingTree() const { |
| 881 return layer_tree_host_impl_->pending_tree() == this; | 855 return layer_tree_host_impl_->pending_tree() == this; |
| 882 } | 856 } |
| 883 | 857 |
| 884 bool LayerTreeImpl::IsRecycleTree() const { | 858 bool LayerTreeImpl::IsRecycleTree() const { |
| 885 return layer_tree_host_impl_->recycle_tree() == this; | 859 return layer_tree_host_impl_->recycle_tree() == this; |
| 886 } | 860 } |
| 887 | 861 |
| 888 bool LayerTreeImpl::IsSyncTree() const { | |
| 889 return layer_tree_host_impl_->sync_tree() == this; | |
| 890 } | |
| 891 | |
| 892 LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { | 862 LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { |
| 893 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); | 863 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); |
| 894 if (!tree) | 864 if (!tree) |
| 895 return NULL; | 865 return NULL; |
| 896 return tree->LayerById(id); | 866 return tree->LayerById(id); |
| 897 } | 867 } |
| 898 | 868 |
| 899 LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { | 869 LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { |
| 900 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); | 870 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); |
| 901 if (!tree) | 871 if (!tree) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 LayerTreeImpl::CreateScrollbarAnimationController(LayerImpl* scrolling_layer) { | 905 LayerTreeImpl::CreateScrollbarAnimationController(LayerImpl* scrolling_layer) { |
| 936 DCHECK(settings().scrollbar_fade_delay_ms); | 906 DCHECK(settings().scrollbar_fade_delay_ms); |
| 937 DCHECK(settings().scrollbar_fade_duration_ms); | 907 DCHECK(settings().scrollbar_fade_duration_ms); |
| 938 base::TimeDelta delay = | 908 base::TimeDelta delay = |
| 939 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); | 909 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); |
| 940 base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( | 910 base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( |
| 941 settings().scrollbar_fade_resize_delay_ms); | 911 settings().scrollbar_fade_resize_delay_ms); |
| 942 base::TimeDelta duration = | 912 base::TimeDelta duration = |
| 943 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); | 913 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); |
| 944 switch (settings().scrollbar_animator) { | 914 switch (settings().scrollbar_animator) { |
| 945 case LayerTreeSettings::LINEAR_FADE: { | 915 case LayerTreeSettings::LinearFade: { |
| 946 return ScrollbarAnimationControllerLinearFade::Create( | 916 return ScrollbarAnimationControllerLinearFade::Create( |
| 947 scrolling_layer, | 917 scrolling_layer, |
| 948 layer_tree_host_impl_, | 918 layer_tree_host_impl_, |
| 949 delay, | 919 delay, |
| 950 resize_delay, | 920 resize_delay, |
| 951 duration); | 921 duration); |
| 952 } | 922 } |
| 953 case LayerTreeSettings::THINNING: { | 923 case LayerTreeSettings::Thinning: { |
| 954 return ScrollbarAnimationControllerThinning::Create(scrolling_layer, | 924 return ScrollbarAnimationControllerThinning::Create(scrolling_layer, |
| 955 layer_tree_host_impl_, | 925 layer_tree_host_impl_, |
| 956 delay, | 926 delay, |
| 957 resize_delay, | 927 resize_delay, |
| 958 duration); | 928 duration); |
| 959 } | 929 } |
| 960 case LayerTreeSettings::NO_ANIMATOR: | 930 case LayerTreeSettings::NoAnimator: |
| 961 NOTREACHED(); | 931 NOTREACHED(); |
| 962 break; | 932 break; |
| 963 } | 933 } |
| 964 return nullptr; | 934 return nullptr; |
| 965 } | 935 } |
| 966 | 936 |
| 967 void LayerTreeImpl::DidAnimateScrollOffset() { | 937 void LayerTreeImpl::DidAnimateScrollOffset() { |
| 968 layer_tree_host_impl_->DidAnimateScrollOffset(); | 938 layer_tree_host_impl_->DidAnimateScrollOffset(); |
| 969 } | 939 } |
| 970 | 940 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 return layer_tree_host_impl_->ResourceIdForUIResource(uid); | 1154 return layer_tree_host_impl_->ResourceIdForUIResource(uid); |
| 1185 } | 1155 } |
| 1186 | 1156 |
| 1187 bool LayerTreeImpl::IsUIResourceOpaque(UIResourceId uid) const { | 1157 bool LayerTreeImpl::IsUIResourceOpaque(UIResourceId uid) const { |
| 1188 return layer_tree_host_impl_->IsUIResourceOpaque(uid); | 1158 return layer_tree_host_impl_->IsUIResourceOpaque(uid); |
| 1189 } | 1159 } |
| 1190 | 1160 |
| 1191 void LayerTreeImpl::ProcessUIResourceRequestQueue() { | 1161 void LayerTreeImpl::ProcessUIResourceRequestQueue() { |
| 1192 for (const auto& req : ui_resource_request_queue_) { | 1162 for (const auto& req : ui_resource_request_queue_) { |
| 1193 switch (req.GetType()) { | 1163 switch (req.GetType()) { |
| 1194 case UIResourceRequest::UI_RESOURCE_CREATE: | 1164 case UIResourceRequest::UIResourceCreate: |
| 1195 layer_tree_host_impl_->CreateUIResource(req.GetId(), req.GetBitmap()); | 1165 layer_tree_host_impl_->CreateUIResource(req.GetId(), req.GetBitmap()); |
| 1196 break; | 1166 break; |
| 1197 case UIResourceRequest::UI_RESOURCE_DELETE: | 1167 case UIResourceRequest::UIResourceDelete: |
| 1198 layer_tree_host_impl_->DeleteUIResource(req.GetId()); | 1168 layer_tree_host_impl_->DeleteUIResource(req.GetId()); |
| 1199 break; | 1169 break; |
| 1200 case UIResourceRequest::UI_RESOURCE_INVALID_REQUEST: | 1170 case UIResourceRequest::UIResourceInvalidRequest: |
| 1201 NOTREACHED(); | 1171 NOTREACHED(); |
| 1202 break; | 1172 break; |
| 1203 } | 1173 } |
| 1204 } | 1174 } |
| 1205 ui_resource_request_queue_.clear(); | 1175 ui_resource_request_queue_.clear(); |
| 1206 | 1176 |
| 1207 // If all UI resource evictions were not recreated by processing this queue, | 1177 // If all UI resource evictions were not recreated by processing this queue, |
| 1208 // then another commit is required. | 1178 // then another commit is required. |
| 1209 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 1179 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
| 1210 layer_tree_host_impl_->SetNeedsCommit(); | 1180 layer_tree_host_impl_->SetNeedsCommit(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || | 1454 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
| 1485 !layer->touch_event_handler_region().IsEmpty() || | 1455 !layer->touch_event_handler_region().IsEmpty() || |
| 1486 layer->have_wheel_event_handlers(); | 1456 layer->have_wheel_event_handlers(); |
| 1487 } | 1457 } |
| 1488 }; | 1458 }; |
| 1489 | 1459 |
| 1490 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( | 1460 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
| 1491 const gfx::PointF& screen_space_point) { | 1461 const gfx::PointF& screen_space_point) { |
| 1492 if (!root_layer()) | 1462 if (!root_layer()) |
| 1493 return NULL; | 1463 return NULL; |
| 1494 bool update_lcd_text = false; | 1464 if (!UpdateDrawProperties()) |
| 1495 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1496 return NULL; | 1465 return NULL; |
| 1497 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1466 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1498 FindClosestMatchingLayer(screen_space_point, | 1467 FindClosestMatchingLayer(screen_space_point, |
| 1499 root_layer(), | 1468 root_layer(), |
| 1500 HitTestVisibleScrollableOrTouchableFunctor(), | 1469 HitTestVisibleScrollableOrTouchableFunctor(), |
| 1501 &data_for_recursion); | 1470 &data_for_recursion); |
| 1502 return data_for_recursion.closest_match; | 1471 return data_for_recursion.closest_match; |
| 1503 } | 1472 } |
| 1504 | 1473 |
| 1505 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, | 1474 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1527 struct FindWheelEventLayerFunctor { | 1496 struct FindWheelEventLayerFunctor { |
| 1528 bool operator()(LayerImpl* layer) const { | 1497 bool operator()(LayerImpl* layer) const { |
| 1529 return layer->have_wheel_event_handlers(); | 1498 return layer->have_wheel_event_handlers(); |
| 1530 } | 1499 } |
| 1531 }; | 1500 }; |
| 1532 | 1501 |
| 1533 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( | 1502 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( |
| 1534 const gfx::PointF& screen_space_point) { | 1503 const gfx::PointF& screen_space_point) { |
| 1535 if (!root_layer()) | 1504 if (!root_layer()) |
| 1536 return NULL; | 1505 return NULL; |
| 1537 bool update_lcd_text = false; | 1506 if (!UpdateDrawProperties()) |
| 1538 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1539 return NULL; | 1507 return NULL; |
| 1540 FindWheelEventLayerFunctor func; | 1508 FindWheelEventLayerFunctor func; |
| 1541 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1509 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1542 FindClosestMatchingLayer(screen_space_point, root_layer(), func, | 1510 FindClosestMatchingLayer(screen_space_point, root_layer(), func, |
| 1543 &data_for_recursion); | 1511 &data_for_recursion); |
| 1544 return data_for_recursion.closest_match; | 1512 return data_for_recursion.closest_match; |
| 1545 } | 1513 } |
| 1546 | 1514 |
| 1547 struct FindTouchEventLayerFunctor { | 1515 struct FindTouchEventLayerFunctor { |
| 1548 bool operator()(LayerImpl* layer) const { | 1516 bool operator()(LayerImpl* layer) const { |
| 1549 return LayerHasTouchEventHandlersAt(screen_space_point, layer); | 1517 return LayerHasTouchEventHandlersAt(screen_space_point, layer); |
| 1550 } | 1518 } |
| 1551 const gfx::PointF screen_space_point; | 1519 const gfx::PointF screen_space_point; |
| 1552 }; | 1520 }; |
| 1553 | 1521 |
| 1554 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1522 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1555 const gfx::PointF& screen_space_point) { | 1523 const gfx::PointF& screen_space_point) { |
| 1556 if (!root_layer()) | 1524 if (!root_layer()) |
| 1557 return NULL; | 1525 return NULL; |
| 1558 bool update_lcd_text = false; | 1526 if (!UpdateDrawProperties()) |
| 1559 if (!UpdateDrawProperties(update_lcd_text)) | |
| 1560 return NULL; | 1527 return NULL; |
| 1561 FindTouchEventLayerFunctor func = {screen_space_point}; | 1528 FindTouchEventLayerFunctor func = {screen_space_point}; |
| 1562 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1529 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1563 FindClosestMatchingLayer( | 1530 FindClosestMatchingLayer( |
| 1564 screen_space_point, root_layer(), func, &data_for_recursion); | 1531 screen_space_point, root_layer(), func, &data_for_recursion); |
| 1565 return data_for_recursion.closest_match; | 1532 return data_for_recursion.closest_match; |
| 1566 } | 1533 } |
| 1567 | 1534 |
| 1568 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, | 1535 void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, |
| 1569 const LayerSelectionBound& end) { | 1536 const LayerSelectionBound& end) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1621 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1655 pending_page_scale_animation_ = pending_animation.Pass(); | 1622 pending_page_scale_animation_ = pending_animation.Pass(); |
| 1656 } | 1623 } |
| 1657 | 1624 |
| 1658 scoped_ptr<PendingPageScaleAnimation> | 1625 scoped_ptr<PendingPageScaleAnimation> |
| 1659 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1626 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1660 return pending_page_scale_animation_.Pass(); | 1627 return pending_page_scale_animation_.Pass(); |
| 1661 } | 1628 } |
| 1662 | 1629 |
| 1663 } // namespace cc | 1630 } // namespace cc |
| OLD | NEW |