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