Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2802 | 2802 |
| 2803 // No occlusion. | 2803 // No occlusion. |
| 2804 int unoccluded_tile_count = 0; | 2804 int unoccluded_tile_count = 0; |
| 2805 for (PictureLayerImpl::LayerRasterTileIterator it = | 2805 for (PictureLayerImpl::LayerRasterTileIterator it = |
| 2806 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 2806 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
| 2807 it; | 2807 it; |
| 2808 ++it) { | 2808 ++it) { |
| 2809 Tile* tile = *it; | 2809 Tile* tile = *it; |
| 2810 | 2810 |
| 2811 // Occluded tiles should not be iterated over. | 2811 // Occluded tiles should not be iterated over. |
| 2812 EXPECT_FALSE(tile->is_occluded()); | 2812 EXPECT_FALSE(tile->priority(PENDING_TREE).is_occluded); |
| 2813 | 2813 |
| 2814 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 2814 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 2815 // visible and at least partially unoccluded, verified by the above expect. | 2815 // visible and at least partially unoccluded, verified by the above expect. |
| 2816 bool tile_is_visible = | 2816 bool tile_is_visible = |
| 2817 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 2817 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 2818 if (tile_is_visible) | 2818 if (tile_is_visible) |
| 2819 unoccluded_tile_count++; | 2819 unoccluded_tile_count++; |
| 2820 } | 2820 } |
| 2821 EXPECT_EQ(unoccluded_tile_count, 25 + 4); | 2821 EXPECT_EQ(unoccluded_tile_count, 25 + 4); |
| 2822 | 2822 |
| 2823 // Partial occlusion. | 2823 // Partial occlusion. |
| 2824 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 2824 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
| 2825 LayerImpl* layer1 = pending_layer_->children()[0]; | 2825 LayerImpl* layer1 = pending_layer_->children()[0]; |
| 2826 layer1->SetBounds(layer_bounds); | 2826 layer1->SetBounds(layer_bounds); |
| 2827 layer1->SetContentBounds(layer_bounds); | 2827 layer1->SetContentBounds(layer_bounds); |
| 2828 layer1->SetDrawsContent(true); | 2828 layer1->SetDrawsContent(true); |
| 2829 layer1->SetContentsOpaque(true); | 2829 layer1->SetContentsOpaque(true); |
| 2830 layer1->SetPosition(occluding_layer_position); | 2830 layer1->SetPosition(occluding_layer_position); |
| 2831 | 2831 |
| 2832 host_impl_.pending_tree()->UpdateDrawProperties(); | 2832 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2833 | 2833 |
| 2834 unoccluded_tile_count = 0; | 2834 unoccluded_tile_count = 0; |
| 2835 for (PictureLayerImpl::LayerRasterTileIterator it = | 2835 for (PictureLayerImpl::LayerRasterTileIterator it = |
| 2836 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 2836 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
| 2837 it; | 2837 it; |
| 2838 ++it) { | 2838 ++it) { |
| 2839 Tile* tile = *it; | 2839 Tile* tile = *it; |
| 2840 | 2840 |
| 2841 EXPECT_FALSE(tile->is_occluded()); | 2841 EXPECT_FALSE(tile->priority(PENDING_TREE).is_occluded); |
| 2842 | 2842 |
| 2843 bool tile_is_visible = | 2843 bool tile_is_visible = |
| 2844 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 2844 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 2845 if (tile_is_visible) | 2845 if (tile_is_visible) |
| 2846 unoccluded_tile_count++; | 2846 unoccluded_tile_count++; |
| 2847 } | 2847 } |
| 2848 EXPECT_EQ(unoccluded_tile_count, 20 + 2); | 2848 EXPECT_EQ(unoccluded_tile_count, 20 + 2); |
| 2849 | 2849 |
| 2850 // Full occlusion. | 2850 // Full occlusion. |
| 2851 layer1->SetPosition(gfx::Point(0, 0)); | 2851 layer1->SetPosition(gfx::Point(0, 0)); |
| 2852 | 2852 |
| 2853 host_impl_.pending_tree()->UpdateDrawProperties(); | 2853 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2854 | 2854 |
| 2855 unoccluded_tile_count = 0; | 2855 unoccluded_tile_count = 0; |
| 2856 for (PictureLayerImpl::LayerRasterTileIterator it = | 2856 for (PictureLayerImpl::LayerRasterTileIterator it = |
| 2857 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 2857 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
| 2858 it; | 2858 it; |
| 2859 ++it) { | 2859 ++it) { |
| 2860 Tile* tile = *it; | 2860 Tile* tile = *it; |
| 2861 | 2861 |
| 2862 EXPECT_FALSE(tile->is_occluded()); | 2862 EXPECT_FALSE(tile->priority(PENDING_TREE).is_occluded); |
| 2863 | 2863 |
| 2864 bool tile_is_visible = | 2864 bool tile_is_visible = |
| 2865 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 2865 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 2866 if (tile_is_visible) | 2866 if (tile_is_visible) |
| 2867 unoccluded_tile_count++; | 2867 unoccluded_tile_count++; |
| 2868 } | 2868 } |
| 2869 EXPECT_EQ(unoccluded_tile_count, 0); | 2869 EXPECT_EQ(unoccluded_tile_count, 0); |
| 2870 } | 2870 } |
| 2871 | 2871 |
| 2872 TEST_F(OcclusionTrackingPictureLayerImplTest, | 2872 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2896 tiling, | 2896 tiling, |
| 2897 pending_layer_->contents_scale_x(), | 2897 pending_layer_->contents_scale_x(), |
| 2898 gfx::Rect(layer_bounds)); | 2898 gfx::Rect(layer_bounds)); |
| 2899 iter; | 2899 iter; |
| 2900 ++iter) { | 2900 ++iter) { |
| 2901 if (!*iter) | 2901 if (!*iter) |
| 2902 continue; | 2902 continue; |
| 2903 const Tile* tile = *iter; | 2903 const Tile* tile = *iter; |
| 2904 | 2904 |
| 2905 // Fully occluded tiles are not required for activation. | 2905 // Fully occluded tiles are not required for activation. |
| 2906 if (tile->is_occluded()) { | 2906 if (tile->priority(PENDING_TREE).is_occluded) { |
| 2907 EXPECT_FALSE(tile->required_for_activation()); | 2907 EXPECT_FALSE(tile->required_for_activation()); |
| 2908 occluded_tile_count++; | 2908 occluded_tile_count++; |
| 2909 } | 2909 } |
| 2910 } | 2910 } |
| 2911 } | 2911 } |
| 2912 EXPECT_EQ(occluded_tile_count, 0); | 2912 EXPECT_EQ(occluded_tile_count, 0); |
| 2913 | 2913 |
| 2914 // Partial occlusion. | 2914 // Partial occlusion. |
| 2915 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 2915 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
| 2916 LayerImpl* layer1 = pending_layer_->children()[0]; | 2916 LayerImpl* layer1 = pending_layer_->children()[0]; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2929 for (PictureLayerTiling::CoverageIterator iter( | 2929 for (PictureLayerTiling::CoverageIterator iter( |
| 2930 tiling, | 2930 tiling, |
| 2931 pending_layer_->contents_scale_x(), | 2931 pending_layer_->contents_scale_x(), |
| 2932 gfx::Rect(layer_bounds)); | 2932 gfx::Rect(layer_bounds)); |
| 2933 iter; | 2933 iter; |
| 2934 ++iter) { | 2934 ++iter) { |
| 2935 if (!*iter) | 2935 if (!*iter) |
| 2936 continue; | 2936 continue; |
| 2937 const Tile* tile = *iter; | 2937 const Tile* tile = *iter; |
| 2938 | 2938 |
| 2939 if (tile->is_occluded()) { | 2939 if (tile->priority(PENDING_TREE).is_occluded) { |
| 2940 EXPECT_FALSE(tile->required_for_activation()); | 2940 EXPECT_FALSE(tile->required_for_activation()); |
| 2941 occluded_tile_count++; | 2941 occluded_tile_count++; |
| 2942 } | 2942 } |
| 2943 } | 2943 } |
| 2944 } | 2944 } |
| 2945 EXPECT_EQ(occluded_tile_count, 30 + 5 + 2); | 2945 EXPECT_EQ(occluded_tile_count, 30 + 5 + 2); |
| 2946 | 2946 |
| 2947 // Full occlusion. | 2947 // Full occlusion. |
| 2948 layer1->SetPosition(gfx::PointF(0, 0)); | 2948 layer1->SetPosition(gfx::PointF(0, 0)); |
| 2949 | 2949 |
| 2950 host_impl_.pending_tree()->UpdateDrawProperties(); | 2950 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2951 | 2951 |
| 2952 occluded_tile_count = 0; | 2952 occluded_tile_count = 0; |
| 2953 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 2953 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 2954 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 2954 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 2955 | 2955 |
| 2956 for (PictureLayerTiling::CoverageIterator iter( | 2956 for (PictureLayerTiling::CoverageIterator iter( |
| 2957 tiling, | 2957 tiling, |
| 2958 pending_layer_->contents_scale_x(), | 2958 pending_layer_->contents_scale_x(), |
| 2959 gfx::Rect(layer_bounds)); | 2959 gfx::Rect(layer_bounds)); |
| 2960 iter; | 2960 iter; |
| 2961 ++iter) { | 2961 ++iter) { |
| 2962 if (!*iter) | 2962 if (!*iter) |
| 2963 continue; | 2963 continue; |
| 2964 const Tile* tile = *iter; | 2964 const Tile* tile = *iter; |
| 2965 | 2965 |
| 2966 if (tile->is_occluded()) { | 2966 if (tile->priority(PENDING_TREE).is_occluded) { |
| 2967 EXPECT_FALSE(tile->required_for_activation()); | 2967 EXPECT_FALSE(tile->required_for_activation()); |
| 2968 occluded_tile_count++; | 2968 occluded_tile_count++; |
| 2969 } | 2969 } |
| 2970 } | 2970 } |
| 2971 } | 2971 } |
| 2972 EXPECT_EQ(occluded_tile_count, 100 + 25 + 4); | 2972 EXPECT_EQ(occluded_tile_count, 100 + 25 + 4); |
| 2973 } | 2973 } |
| 2974 | |
| 2975 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { | |
| 2976 gfx::Size tile_size(102, 102); | |
| 2977 gfx::Size layer_bounds(1000, 1000); | |
| 2978 gfx::Size viewport_size(1000, 1000); | |
| 2979 | |
| 2980 scoped_refptr<FakePicturePileImpl> pending_pile = | |
| 2981 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 2982 scoped_refptr<FakePicturePileImpl> active_pile = | |
| 2983 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 2984 SetupTrees(pending_pile, active_pile); | |
| 2985 | |
| 2986 // Fully occlude the active layer. | |
| 2987 active_layer_->AddChild(LayerImpl::Create(host_impl_.active_tree(), 2)); | |
| 2988 LayerImpl* layer1 = active_layer_->children()[0]; | |
| 2989 layer1->SetBounds(layer_bounds); | |
| 2990 layer1->SetContentBounds(layer_bounds); | |
| 2991 layer1->SetDrawsContent(true); | |
| 2992 layer1->SetContentsOpaque(true); | |
| 2993 | |
| 2994 host_impl_.SetViewportSize(viewport_size); | |
| 2995 | |
| 2996 host_impl_.pending_tree()->UpdateDrawProperties(); | |
| 2997 host_impl_.active_tree()->UpdateDrawProperties(); | |
| 2998 | |
| 2999 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | |
| 3000 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | |
| 3001 | |
| 3002 for (PictureLayerTiling::CoverageIterator iter( | |
| 3003 tiling, | |
| 3004 pending_layer_->contents_scale_x(), | |
| 3005 gfx::Rect(layer_bounds)); | |
| 3006 iter; | |
| 3007 ++iter) { | |
| 3008 if (!*iter) | |
| 3009 continue; | |
| 3010 const Tile* tile = *iter; | |
|
danakj
2014/06/17 22:29:41
can you show with EXPECT checks that these Tile* a
jbedley
2014/06/18 23:00:39
Actually both loops were doing the same thing beca
| |
| 3011 | |
| 3012 EXPECT_FALSE(tile->priority(PENDING_TREE).is_occluded); | |
| 3013 EXPECT_TRUE(tile->priority(ACTIVE_TREE).is_occluded); | |
| 3014 } | |
| 3015 } | |
| 3016 | |
| 3017 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | |
| 3018 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | |
| 3019 | |
| 3020 for (PictureLayerTiling::CoverageIterator iter( | |
| 3021 tiling, | |
| 3022 active_layer_->contents_scale_x(), | |
| 3023 gfx::Rect(layer_bounds)); | |
| 3024 iter; | |
| 3025 ++iter) { | |
| 3026 if (!*iter) | |
| 3027 continue; | |
| 3028 const Tile* tile = *iter; | |
| 3029 | |
| 3030 EXPECT_FALSE(tile->priority(PENDING_TREE).is_occluded); | |
| 3031 EXPECT_TRUE(tile->priority(ACTIVE_TREE).is_occluded); | |
| 3032 } | |
| 3033 } | |
| 3034 } | |
| 2974 } // namespace | 3035 } // namespace |
| 2975 } // namespace cc | 3036 } // namespace cc |
| OLD | NEW |