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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1767 PostSetNeedsCommitToMainThread(); | 1767 PostSetNeedsCommitToMainThread(); |
| 1768 client_.set_bounds(root_layer_->bounds()); | 1768 client_.set_bounds(root_layer_->bounds()); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 1771 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 1772 // Should only do one commit. | 1772 // Should only do one commit. |
| 1773 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); | 1773 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
| 1774 // Device scale factor should come over to impl. | 1774 // Device scale factor should come over to impl. |
| 1775 EXPECT_NEAR(impl->active_tree()->device_scale_factor(), 1.5f, 0.00001f); | 1775 EXPECT_NEAR(impl->active_tree()->device_scale_factor(), 1.5f, 0.00001f); |
| 1776 | 1776 |
| 1777 // Both layers are on impl. | |
| 1778 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); | |
| 1779 | |
| 1780 // Device viewport is scaled. | 1777 // Device viewport is scaled. |
| 1781 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); | 1778 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); |
| 1782 | 1779 |
| 1783 FakePictureLayerImpl* root = | 1780 FakePictureLayerImpl* root = |
| 1784 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); | 1781 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
| 1785 FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( | 1782 FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( |
| 1786 impl->active_tree()->root_layer()->children()[0]); | 1783 impl->active_tree()->LayerById(child_layer_->id())); |
| 1787 | 1784 |
| 1788 // Positions remain in layout pixels. | 1785 // Positions remain in layout pixels. |
| 1789 EXPECT_EQ(gfx::PointF(), root->position()); | 1786 EXPECT_EQ(gfx::PointF(), root->position()); |
| 1790 EXPECT_EQ(gfx::PointF(2.f, 2.f), child->position()); | 1787 EXPECT_EQ(gfx::PointF(2.f, 2.f), child->position()); |
| 1791 | 1788 |
| 1792 // Compute all the layer transforms for the frame. | 1789 // Compute all the layer transforms for the frame. |
| 1793 LayerTreeHostImpl::FrameData frame_data; | 1790 LayerTreeHostImpl::FrameData frame_data; |
| 1794 impl->PrepareToDraw(&frame_data); | 1791 impl->PrepareToDraw(&frame_data); |
| 1795 impl->DidDrawAllLayers(frame_data); | 1792 impl->DidDrawAllLayers(frame_data); |
| 1796 | 1793 |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2866 ++expected_push_properties_child2_impl_; | 2863 ++expected_push_properties_child2_impl_; |
| 2867 ++expected_push_properties_grandchild2_impl_; | 2864 ++expected_push_properties_grandchild2_impl_; |
| 2868 break; | 2865 break; |
| 2869 case 5: | 2866 case 5: |
| 2870 // Tree doesn't change but the one leaf that always pushes is pushed. | 2867 // Tree doesn't change but the one leaf that always pushes is pushed. |
| 2871 ++expected_push_properties_grandchild2_impl_; | 2868 ++expected_push_properties_grandchild2_impl_; |
| 2872 break; | 2869 break; |
| 2873 case 6: | 2870 case 6: |
| 2874 // First child is removed. Structure of the tree changes here so swap | 2871 // First child is removed. Structure of the tree changes here so swap |
| 2875 // some of the values. child_impl becomes child2_impl. | 2872 // some of the values. child_impl becomes child2_impl. |
| 2876 expected_push_properties_child_impl_ = | 2873 // expected_push_properties_child_impl_ = |
| 2877 expected_push_properties_child2_impl_; | 2874 // expected_push_properties_child2_impl_; |
| 2878 expected_push_properties_child2_impl_ = 0; | 2875 expected_push_properties_child_impl_ = 0; |
| 2879 // grandchild_impl becomes grandchild2_impl. | 2876 // grandchild_impl becomes grandchild2_impl. |
| 2880 expected_push_properties_grandchild_impl_ = | 2877 // expected_push_properties_grandchild_impl_ = |
| 2881 expected_push_properties_grandchild2_impl_; | 2878 // expected_push_properties_grandchild2_impl_; |
|
jaydasika
2016/04/20 20:26:09
Remove the commented code and also modify the comm
sunxd
2016/04/21 17:31:15
Done.
| |
| 2882 expected_push_properties_grandchild2_impl_ = 0; | 2879 expected_push_properties_grandchild_impl_ = 0; |
| 2883 | 2880 |
| 2884 // grandchild_impl is now the leaf that always pushes. It is pushed. | 2881 // grandchild_impl is now the leaf that always pushes. It is pushed. |
| 2885 ++expected_push_properties_grandchild_impl_; | 2882 ++expected_push_properties_grandchild2_impl_; |
|
jaydasika
2016/04/20 20:26:09
change the comment to grandchild2_impl
sunxd
2016/04/21 17:31:15
Done.
| |
| 2886 break; | 2883 break; |
| 2887 case 7: | 2884 case 7: |
| 2888 // The leaf that always pushes is pushed. | 2885 // The leaf that always pushes is pushed. |
| 2889 ++expected_push_properties_grandchild_impl_; | 2886 ++expected_push_properties_grandchild2_impl_; |
| 2890 | 2887 |
| 2891 // Child is added back. New layers are initialized. | 2888 // Child is added back. New layers are initialized. |
| 2892 ++expected_push_properties_grandchild2_impl_; | 2889 ++expected_push_properties_grandchild_impl_; |
| 2893 ++expected_push_properties_child2_impl_; | 2890 ++expected_push_properties_child_impl_; |
| 2894 break; | 2891 break; |
| 2895 case 8: | 2892 case 8: |
| 2896 // Leaf is removed. | 2893 // Leaf is removed. |
| 2897 expected_push_properties_grandchild2_impl_ = 0; | 2894 expected_push_properties_grandchild_impl_ = 0; |
| 2898 | 2895 |
| 2899 // Always pushing. | 2896 // Always pushing. |
| 2900 ++expected_push_properties_grandchild_impl_; | 2897 ++expected_push_properties_grandchild2_impl_; |
| 2901 break; | 2898 break; |
| 2902 case 9: | 2899 case 9: |
| 2903 // Leaf is added back | 2900 // Leaf is added back |
| 2904 ++expected_push_properties_grandchild2_impl_; | 2901 ++expected_push_properties_grandchild_impl_; |
| 2905 | 2902 |
| 2906 // The leaf that always pushes is pushed. | 2903 // The leaf that always pushes is pushed. |
| 2907 ++expected_push_properties_grandchild_impl_; | 2904 ++expected_push_properties_grandchild2_impl_; |
| 2908 break; | 2905 break; |
| 2909 case 10: | 2906 case 10: |
| 2910 // The leaf that always pushes is pushed. | 2907 // The leaf that always pushes is pushed. |
| 2911 ++expected_push_properties_grandchild_impl_; | 2908 ++expected_push_properties_grandchild2_impl_; |
| 2912 break; | 2909 break; |
| 2913 case 11: | 2910 case 11: |
| 2914 // The leaf that always pushes is pushed. | 2911 // The leaf that always pushes is pushed. |
| 2915 ++expected_push_properties_grandchild_impl_; | 2912 ++expected_push_properties_grandchild2_impl_; |
| 2916 break; | 2913 break; |
| 2917 case 12: | 2914 case 12: |
| 2918 // The leaf that always pushes is pushed. | 2915 // The leaf that always pushes is pushed. |
| 2919 ++expected_push_properties_grandchild_impl_; | 2916 ++expected_push_properties_grandchild2_impl_; |
| 2920 | 2917 |
| 2921 // This child position was changed. So the subtree needs to push | 2918 // This child position was changed. So the subtree needs to push |
| 2922 // properties. | 2919 // properties. |
| 2923 ++expected_push_properties_child2_impl_; | 2920 ++expected_push_properties_child_impl_; |
| 2924 ++expected_push_properties_grandchild2_impl_; | 2921 ++expected_push_properties_grandchild_impl_; |
| 2925 break; | 2922 break; |
| 2926 case 13: | 2923 case 13: |
| 2927 // The position of this child was changed. | 2924 // The position of this child was changed. |
| 2928 ++expected_push_properties_child_impl_; | 2925 ++expected_push_properties_child2_impl_; |
| 2929 | 2926 |
| 2930 // The leaf that always pushes is pushed. | 2927 // The leaf that always pushes is pushed. |
| 2931 ++expected_push_properties_grandchild_impl_; | 2928 ++expected_push_properties_grandchild2_impl_; |
| 2932 break; | 2929 break; |
| 2933 case 14: | 2930 case 14: |
| 2934 // Second child is removed from tree. Don't discard counts because | 2931 // Second child is removed from tree. Don't discard counts because |
| 2935 // they are added back before commit. | 2932 // they are added back before commit. |
| 2936 | 2933 |
| 2937 // The leaf that always pushes is pushed. | 2934 // The leaf that always pushes is pushed. |
| 2938 ++expected_push_properties_grandchild_impl_; | 2935 ++expected_push_properties_grandchild2_impl_; |
| 2939 | 2936 |
| 2940 // Second child added back. | 2937 // Second child added back. |
| 2941 ++expected_push_properties_child2_impl_; | 2938 ++expected_push_properties_child_impl_; |
| 2942 ++expected_push_properties_grandchild2_impl_; | 2939 ++expected_push_properties_grandchild_impl_; |
| 2943 | 2940 |
| 2944 break; | 2941 break; |
| 2945 case 15: | 2942 case 15: |
| 2946 // The position of this child was changed. | 2943 // The position of this child was changed. |
| 2947 ++expected_push_properties_grandchild2_impl_; | 2944 ++expected_push_properties_grandchild_impl_; |
| 2948 | 2945 |
| 2949 // The leaf that always pushes is pushed. | 2946 // The leaf that always pushes is pushed. |
| 2950 ++expected_push_properties_grandchild_impl_; | 2947 ++expected_push_properties_grandchild2_impl_; |
| 2951 break; | 2948 break; |
| 2952 case 16: | 2949 case 16: |
| 2953 // Second child is invalidated with SetNeedsDisplay | 2950 // Second child is invalidated with SetNeedsDisplay |
| 2954 ++expected_push_properties_child2_impl_; | 2951 ++expected_push_properties_child_impl_; |
| 2955 | 2952 |
| 2956 // The leaf that always pushed is pushed. | 2953 // The leaf that always pushed is pushed. |
| 2957 ++expected_push_properties_grandchild_impl_; | 2954 ++expected_push_properties_grandchild2_impl_; |
| 2958 break; | 2955 break; |
| 2959 } | 2956 } |
| 2960 | 2957 |
| 2961 PushPropertiesCountingLayerImpl* root_impl_ = NULL; | 2958 PushPropertiesCountingLayerImpl* root_impl_ = NULL; |
| 2962 PushPropertiesCountingLayerImpl* child_impl_ = NULL; | 2959 PushPropertiesCountingLayerImpl* child_impl_ = NULL; |
| 2963 PushPropertiesCountingLayerImpl* child2_impl_ = NULL; | 2960 PushPropertiesCountingLayerImpl* child2_impl_ = NULL; |
| 2964 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; | 2961 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; |
| 2965 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; | 2962 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; |
| 2966 | 2963 |
| 2967 // Pull the layers that we need from the tree assuming the same structure | 2964 // Pull the layers that we need from the tree assuming the same structure |
| 2968 // as LayerTreeHostTestLayersPushProperties | 2965 // as LayerTreeHostTestLayersPushProperties |
| 2969 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 2966 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 2970 host_impl->RootLayer()); | 2967 host_impl->RootLayer()); |
| 2971 | 2968 |
| 2972 if (root_impl_ && root_impl_->children().size() > 0) { | 2969 LayerTreeImpl* impl = root_impl_->layer_tree_impl(); |
| 2970 if (impl->LayerById(child_->id())) { | |
| 2973 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 2971 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 2974 root_impl_->children()[0]); | 2972 impl->LayerById(child_->id())); |
| 2975 | 2973 |
| 2976 if (child_impl_ && child_impl_->children().size() > 0) | 2974 if (impl->LayerById(grandchild_->id())) |
| 2977 grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 2975 grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 2978 child_impl_->children()[0]); | 2976 impl->LayerById(grandchild_->id())); |
| 2979 } | 2977 } |
| 2980 | 2978 |
| 2981 if (root_impl_ && root_impl_->children().size() > 1) { | 2979 if (impl->LayerById(child2_->id())) { |
| 2982 child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 2980 child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 2983 root_impl_->children()[1]); | 2981 impl->LayerById(child2_->id())); |
| 2984 | 2982 |
| 2985 if (child2_impl_ && child2_impl_->children().size() > 0) | 2983 if (impl->LayerById(leaf_always_pushing_layer_->id())) |
| 2986 leaf_always_pushing_layer_impl_ = | 2984 leaf_always_pushing_layer_impl_ = |
| 2987 static_cast<PushPropertiesCountingLayerImpl*>( | 2985 static_cast<PushPropertiesCountingLayerImpl*>( |
| 2988 child2_impl_->children()[0]); | 2986 impl->LayerById(leaf_always_pushing_layer_->id())); |
| 2989 } | 2987 } |
| 2990 | 2988 |
| 2991 if (root_impl_) | 2989 if (root_impl_) |
| 2992 EXPECT_EQ(expected_push_properties_root_impl_, | 2990 EXPECT_EQ(expected_push_properties_root_impl_, |
| 2993 root_impl_->push_properties_count()); | 2991 root_impl_->push_properties_count()); |
| 2994 if (child_impl_) | 2992 if (child_impl_) |
| 2995 EXPECT_EQ(expected_push_properties_child_impl_, | 2993 EXPECT_EQ(expected_push_properties_child_impl_, |
| 2996 child_impl_->push_properties_count()); | 2994 child_impl_->push_properties_count()); |
| 2997 if (grandchild_impl_) | 2995 if (grandchild_impl_) |
| 2998 EXPECT_EQ(expected_push_properties_grandchild_impl_, | 2996 EXPECT_EQ(expected_push_properties_grandchild_impl_, |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3695 // The bounds of the child layer were pushed to the impl side. | 3693 // The bounds of the child layer were pushed to the impl side. |
| 3696 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3694 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( |
| 3697 child_layer_.get())); | 3695 child_layer_.get())); |
| 3698 | 3696 |
| 3699 EndTest(); | 3697 EndTest(); |
| 3700 break; | 3698 break; |
| 3701 } | 3699 } |
| 3702 } | 3700 } |
| 3703 | 3701 |
| 3704 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 3702 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 3705 LayerImpl* root = impl->active_tree()->root_layer(); | 3703 LayerImpl* child = impl->active_tree()->LayerById(child_layer_->id()); |
| 3706 LayerImpl* parent = root->children()[0]; | |
| 3707 LayerImpl* child = parent->children()[0]; | |
| 3708 | 3704 |
| 3709 switch (impl->active_tree()->source_frame_number()) { | 3705 switch (impl->active_tree()->source_frame_number()) { |
| 3710 case 1: | 3706 case 1: |
| 3711 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); | 3707 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); |
| 3712 break; | 3708 break; |
| 3713 } | 3709 } |
| 3714 } | 3710 } |
| 3715 | 3711 |
| 3716 void AfterTest() override {} | 3712 void AfterTest() override {} |
| 3717 | 3713 |
| (...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6308 EndTest(); | 6304 EndTest(); |
| 6309 } | 6305 } |
| 6310 | 6306 |
| 6311 void AfterTest() override {} | 6307 void AfterTest() override {} |
| 6312 }; | 6308 }; |
| 6313 | 6309 |
| 6314 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6310 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6315 | 6311 |
| 6316 } // namespace | 6312 } // namespace |
| 6317 } // namespace cc | 6313 } // namespace cc |
| OLD | NEW |