| 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_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 while (render_surface_layer_list->back() != layer_to_remove) { | 762 while (render_surface_layer_list->back() != layer_to_remove) { |
| 763 render_surface_layer_list->back()->ClearRenderSurface(); | 763 render_surface_layer_list->back()->ClearRenderSurface(); |
| 764 render_surface_layer_list->pop_back(); | 764 render_surface_layer_list->pop_back(); |
| 765 } | 765 } |
| 766 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); | 766 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); |
| 767 render_surface_layer_list->pop_back(); | 767 render_surface_layer_list->pop_back(); |
| 768 layer_to_remove->ClearRenderSurface(); | 768 layer_to_remove->ClearRenderSurface(); |
| 769 } | 769 } |
| 770 | 770 |
| 771 struct PreCalculateMetaInformationRecursiveData { | 771 struct PreCalculateMetaInformationRecursiveData { |
| 772 bool layer_or_descendent_has_copy_request; | 772 bool layer_or_descendant_has_copy_request; |
| 773 | 773 |
| 774 PreCalculateMetaInformationRecursiveData() | 774 PreCalculateMetaInformationRecursiveData() |
| 775 : layer_or_descendent_has_copy_request(false) {} | 775 : layer_or_descendant_has_copy_request(false) {} |
| 776 |
| 777 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
| 778 layer_or_descendant_has_copy_request |= |
| 779 data.layer_or_descendant_has_copy_request; |
| 780 } |
| 776 }; | 781 }; |
| 777 | 782 |
| 778 // Recursively walks the layer tree to compute any information that is needed | 783 // Recursively walks the layer tree to compute any information that is needed |
| 779 // before doing the main recursion. | 784 // before doing the main recursion. |
| 780 template <typename LayerType> | 785 template <typename LayerType> |
| 781 static void PreCalculateMetaInformation( | 786 static void PreCalculateMetaInformation( |
| 782 LayerType* layer, | 787 LayerType* layer, |
| 783 PreCalculateMetaInformationRecursiveData* recursive_data) { | 788 PreCalculateMetaInformationRecursiveData* recursive_data) { |
| 784 bool has_delegated_content = layer->HasDelegatedContent(); | 789 bool has_delegated_content = layer->HasDelegatedContent(); |
| 785 int num_descendants_that_draw_content = 0; | 790 int num_descendants_that_draw_content = 0; |
| 786 bool descendants_can_clip_selves = true; | 791 bool descendants_can_clip_selves = true; |
| 787 | 792 |
| 788 if (has_delegated_content) { | 793 if (has_delegated_content) { |
| 789 // Layers with delegated content need to be treated as if they have as | 794 // Layers with delegated content need to be treated as if they have as |
| 790 // many children as the number of layers they own delegated quads for. | 795 // many children as the number of layers they own delegated quads for. |
| 791 // Since we don't know this number right now, we choose one that acts like | 796 // Since we don't know this number right now, we choose one that acts like |
| 792 // infinity for our purposes. | 797 // infinity for our purposes. |
| 793 num_descendants_that_draw_content = 1000; | 798 num_descendants_that_draw_content = 1000; |
| 794 descendants_can_clip_selves = false; | 799 descendants_can_clip_selves = false; |
| 795 } | 800 } |
| 796 | 801 |
| 797 for (size_t i = 0; i < layer->children().size(); ++i) { | 802 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 798 LayerType* child_layer = | 803 LayerType* child_layer = |
| 799 LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); | 804 LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); |
| 800 PreCalculateMetaInformation<LayerType>(child_layer, recursive_data); | 805 |
| 806 PreCalculateMetaInformationRecursiveData data_for_child; |
| 807 PreCalculateMetaInformation(child_layer, &data_for_child); |
| 801 | 808 |
| 802 if (!has_delegated_content) { | 809 if (!has_delegated_content) { |
| 803 bool sublayer_transform_prevents_clip = | 810 bool sublayer_transform_prevents_clip = |
| 804 !layer->sublayer_transform().IsPositiveScaleOrTranslation(); | 811 !layer->sublayer_transform().IsPositiveScaleOrTranslation(); |
| 805 | 812 |
| 806 num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; | 813 num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; |
| 807 num_descendants_that_draw_content += | 814 num_descendants_that_draw_content += |
| 808 child_layer->draw_properties().num_descendants_that_draw_content; | 815 child_layer->draw_properties().num_descendants_that_draw_content; |
| 809 | 816 |
| 810 if ((child_layer->DrawsContent() && !child_layer->CanClipSelf()) || | 817 if ((child_layer->DrawsContent() && !child_layer->CanClipSelf()) || |
| 811 !child_layer->draw_properties().descendants_can_clip_selves || | 818 !child_layer->draw_properties().descendants_can_clip_selves || |
| 812 sublayer_transform_prevents_clip || | 819 sublayer_transform_prevents_clip || |
| 813 !child_layer->transform().IsPositiveScaleOrTranslation()) | 820 !child_layer->transform().IsPositiveScaleOrTranslation()) |
| 814 descendants_can_clip_selves = false; | 821 descendants_can_clip_selves = false; |
| 815 } | 822 } |
| 823 |
| 824 recursive_data->Merge(data_for_child); |
| 816 } | 825 } |
| 817 | 826 |
| 818 if (layer->HasCopyRequest()) | 827 if (layer->HasCopyRequest()) |
| 819 recursive_data->layer_or_descendent_has_copy_request = true; | 828 recursive_data->layer_or_descendant_has_copy_request = true; |
| 820 | 829 |
| 821 layer->draw_properties().num_descendants_that_draw_content = | 830 layer->draw_properties().num_descendants_that_draw_content = |
| 822 num_descendants_that_draw_content; | 831 num_descendants_that_draw_content; |
| 823 layer->draw_properties().descendants_can_clip_selves = | 832 layer->draw_properties().descendants_can_clip_selves = |
| 824 descendants_can_clip_selves; | 833 descendants_can_clip_selves; |
| 825 layer->draw_properties().layer_or_descendant_has_copy_request = | 834 layer->draw_properties().layer_or_descendant_has_copy_request = |
| 826 recursive_data->layer_or_descendent_has_copy_request; | 835 recursive_data->layer_or_descendant_has_copy_request; |
| 827 } | 836 } |
| 828 | 837 |
| 829 static void RoundTranslationComponents(gfx::Transform* transform) { | 838 static void RoundTranslationComponents(gfx::Transform* transform) { |
| 830 transform->matrix(). | 839 transform->matrix(). |
| 831 setDouble(0, 3, MathUtil::Round(transform->matrix().getDouble(0, 3))); | 840 setDouble(0, 3, MathUtil::Round(transform->matrix().getDouble(0, 3))); |
| 832 transform->matrix(). | 841 transform->matrix(). |
| 833 setDouble(1, 3, MathUtil::Round(transform->matrix().getDouble(1, 3))); | 842 setDouble(1, 3, MathUtil::Round(transform->matrix().getDouble(1, 3))); |
| 834 } | 843 } |
| 835 | 844 |
| 836 // Recursively walks the layer tree starting at the given node and computes all | 845 // Recursively walks the layer tree starting at the given node and computes all |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 // initial clip rect. | 1611 // initial clip rect. |
| 1603 bool subtree_should_be_clipped = true; | 1612 bool subtree_should_be_clipped = true; |
| 1604 gfx::Rect device_viewport_rect(device_viewport_size); | 1613 gfx::Rect device_viewport_rect(device_viewport_size); |
| 1605 bool in_subtree_of_page_scale_application_layer = false; | 1614 bool in_subtree_of_page_scale_application_layer = false; |
| 1606 bool subtree_is_visible = true; | 1615 bool subtree_is_visible = true; |
| 1607 | 1616 |
| 1608 // This function should have received a root layer. | 1617 // This function should have received a root layer. |
| 1609 DCHECK(IsRootLayer(root_layer)); | 1618 DCHECK(IsRootLayer(root_layer)); |
| 1610 | 1619 |
| 1611 PreCalculateMetaInformationRecursiveData recursive_data; | 1620 PreCalculateMetaInformationRecursiveData recursive_data; |
| 1612 PreCalculateMetaInformation<Layer>(root_layer, &recursive_data); | 1621 PreCalculateMetaInformation(root_layer, &recursive_data); |
| 1613 | 1622 |
| 1614 CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( | 1623 CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( |
| 1615 root_layer, | 1624 root_layer, |
| 1616 scaled_device_transform, | 1625 scaled_device_transform, |
| 1617 identity_matrix, | 1626 identity_matrix, |
| 1618 identity_matrix, | 1627 identity_matrix, |
| 1619 root_layer, | 1628 root_layer, |
| 1620 device_viewport_rect, | 1629 device_viewport_rect, |
| 1621 device_viewport_rect, | 1630 device_viewport_rect, |
| 1622 subtree_should_be_clipped, | 1631 subtree_should_be_clipped, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 // initial clip rect. | 1672 // initial clip rect. |
| 1664 bool subtree_should_be_clipped = true; | 1673 bool subtree_should_be_clipped = true; |
| 1665 gfx::Rect device_viewport_rect(device_viewport_size); | 1674 gfx::Rect device_viewport_rect(device_viewport_size); |
| 1666 bool in_subtree_of_page_scale_application_layer = false; | 1675 bool in_subtree_of_page_scale_application_layer = false; |
| 1667 bool subtree_is_visible = true; | 1676 bool subtree_is_visible = true; |
| 1668 | 1677 |
| 1669 // This function should have received a root layer. | 1678 // This function should have received a root layer. |
| 1670 DCHECK(IsRootLayer(root_layer)); | 1679 DCHECK(IsRootLayer(root_layer)); |
| 1671 | 1680 |
| 1672 PreCalculateMetaInformationRecursiveData recursive_data; | 1681 PreCalculateMetaInformationRecursiveData recursive_data; |
| 1673 PreCalculateMetaInformation<LayerImpl>(root_layer, &recursive_data); | 1682 PreCalculateMetaInformation(root_layer, &recursive_data); |
| 1674 | 1683 |
| 1675 CalculateDrawPropertiesInternal<LayerImpl, | 1684 CalculateDrawPropertiesInternal<LayerImpl, |
| 1676 LayerImplList, | 1685 LayerImplList, |
| 1677 RenderSurfaceImpl>( | 1686 RenderSurfaceImpl>( |
| 1678 root_layer, | 1687 root_layer, |
| 1679 scaled_device_transform, | 1688 scaled_device_transform, |
| 1680 identity_matrix, | 1689 identity_matrix, |
| 1681 identity_matrix, | 1690 identity_matrix, |
| 1682 root_layer, | 1691 root_layer, |
| 1683 device_viewport_rect, | 1692 device_viewport_rect, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 // At this point, we think the point does hit the touch event handler region | 1898 // At this point, we think the point does hit the touch event handler region |
| 1890 // on the layer, but we need to walk up the parents to ensure that the layer | 1899 // on the layer, but we need to walk up the parents to ensure that the layer |
| 1891 // was not clipped in such a way that the hit point actually should not hit | 1900 // was not clipped in such a way that the hit point actually should not hit |
| 1892 // the layer. | 1901 // the layer. |
| 1893 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1902 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 1894 return false; | 1903 return false; |
| 1895 | 1904 |
| 1896 return true; | 1905 return true; |
| 1897 } | 1906 } |
| 1898 } // namespace cc | 1907 } // namespace cc |
| OLD | NEW |