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_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<LayerType>(child_layer, &data_for_child); | |
|
piman
2013/07/11 23:18:25
nit: no need for <LayerType> since it'll guess the
danakj
2013/07/12 18:48:05
Done.
| |
| 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 1052 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 |