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> |
| 11 | 11 |
| 12 #include "cc/base/math_util.h" | 12 #include "cc/base/math_util.h" |
| 13 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
| 14 #include "cc/layers/picture_layer.h" | 14 #include "cc/layers/picture_layer.h" |
| 15 #include "cc/quads/draw_quad.h" | 15 #include "cc/quads/draw_quad.h" |
| 16 #include "cc/quads/tile_draw_quad.h" | 16 #include "cc/quads/tile_draw_quad.h" |
| 17 #include "cc/resources/tiling_set_raster_queue_all.h" | |
| 18 #include "cc/resources/tiling_set_raster_queue_required.h" | |
| 17 #include "cc/test/begin_frame_args_test.h" | 19 #include "cc/test/begin_frame_args_test.h" |
| 18 #include "cc/test/fake_content_layer_client.h" | 20 #include "cc/test/fake_content_layer_client.h" |
| 19 #include "cc/test/fake_impl_proxy.h" | 21 #include "cc/test/fake_impl_proxy.h" |
| 20 #include "cc/test/fake_layer_tree_host_impl.h" | 22 #include "cc/test/fake_layer_tree_host_impl.h" |
| 21 #include "cc/test/fake_output_surface.h" | 23 #include "cc/test/fake_output_surface.h" |
| 22 #include "cc/test/fake_picture_layer_impl.h" | 24 #include "cc/test/fake_picture_layer_impl.h" |
| 23 #include "cc/test/fake_picture_pile_impl.h" | 25 #include "cc/test/fake_picture_pile_impl.h" |
| 24 #include "cc/test/geometry_test_utils.h" | 26 #include "cc/test/geometry_test_utils.h" |
| 25 #include "cc/test/impl_side_painting_settings.h" | 27 #include "cc/test/impl_side_painting_settings.h" |
| 26 #include "cc/test/layer_test_common.h" | 28 #include "cc/test/layer_test_common.h" |
| (...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2746 | 2748 |
| 2747 gfx::Size tile_size(100, 100); | 2749 gfx::Size tile_size(100, 100); |
| 2748 gfx::Size layer_bounds(1000, 1000); | 2750 gfx::Size layer_bounds(1000, 1000); |
| 2749 | 2751 |
| 2750 scoped_refptr<FakePicturePileImpl> pending_pile = | 2752 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2751 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2753 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2752 | 2754 |
| 2753 SetupPendingTree(pending_pile); | 2755 SetupPendingTree(pending_pile); |
| 2754 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 2756 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 2755 | 2757 |
| 2756 scoped_ptr<TilingSetRasterQueue> queue = | |
| 2757 pending_layer_->CreateRasterQueue(false); | |
| 2758 | |
| 2759 std::set<Tile*> unique_tiles; | 2758 std::set<Tile*> unique_tiles; |
| 2760 bool reached_prepaint = false; | 2759 bool reached_prepaint = false; |
| 2761 size_t non_ideal_tile_count = 0u; | 2760 size_t non_ideal_tile_count = 0u; |
| 2762 size_t low_res_tile_count = 0u; | 2761 size_t low_res_tile_count = 0u; |
| 2763 size_t high_res_tile_count = 0u; | 2762 size_t high_res_tile_count = 0u; |
| 2764 queue = pending_layer_->CreateRasterQueue(false); | 2763 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll( |
| 2764 pending_layer_->picture_layer_tiling_set(), false)); | |
| 2765 while (!queue->IsEmpty()) { | 2765 while (!queue->IsEmpty()) { |
| 2766 Tile* tile = queue->Top(); | 2766 Tile* tile = queue->Top(); |
| 2767 TilePriority priority = tile->priority(PENDING_TREE); | 2767 TilePriority priority = tile->priority(PENDING_TREE); |
| 2768 | 2768 |
| 2769 EXPECT_TRUE(tile); | 2769 EXPECT_TRUE(tile); |
| 2770 | 2770 |
| 2771 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2771 // Non-high res tiles only get visible tiles. Also, prepaint should only |
| 2772 // come at the end of the iteration. | 2772 // come at the end of the iteration. |
| 2773 if (priority.resolution != HIGH_RESOLUTION) | 2773 if (priority.resolution != HIGH_RESOLUTION) |
| 2774 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2774 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2785 queue->Pop(); | 2785 queue->Pop(); |
| 2786 } | 2786 } |
| 2787 | 2787 |
| 2788 EXPECT_TRUE(reached_prepaint); | 2788 EXPECT_TRUE(reached_prepaint); |
| 2789 EXPECT_EQ(0u, non_ideal_tile_count); | 2789 EXPECT_EQ(0u, non_ideal_tile_count); |
| 2790 EXPECT_EQ(0u, low_res_tile_count); | 2790 EXPECT_EQ(0u, low_res_tile_count); |
| 2791 EXPECT_EQ(16u, high_res_tile_count); | 2791 EXPECT_EQ(16u, high_res_tile_count); |
| 2792 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, | 2792 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, |
| 2793 unique_tiles.size()); | 2793 unique_tiles.size()); |
| 2794 | 2794 |
| 2795 queue.reset(new TilingSetRasterQueueRequired( | |
| 2796 pending_layer_->picture_layer_tiling_set(), | |
| 2797 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | |
| 2798 EXPECT_TRUE(queue->IsEmpty()); | |
|
danakj
2015/01/08 23:24:40
test where this would be false?
| |
| 2799 | |
| 2800 queue.reset(new TilingSetRasterQueueRequired( | |
| 2801 pending_layer_->picture_layer_tiling_set(), | |
| 2802 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | |
| 2803 EXPECT_FALSE(queue->IsEmpty()); | |
| 2804 while (!queue->IsEmpty()) { | |
| 2805 Tile* tile = queue->Top(); | |
| 2806 EXPECT_TRUE(tile->required_for_activation()); | |
| 2807 EXPECT_FALSE(tile->IsReadyToDraw()); | |
|
danakj
2015/01/08 23:24:40
can you count them and comment explain where the c
| |
| 2808 queue->Pop(); | |
| 2809 } | |
| 2810 | |
| 2795 // No NOW tiles. | 2811 // No NOW tiles. |
| 2796 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2812 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2797 host_impl_.SetCurrentBeginFrameArgs( | 2813 host_impl_.SetCurrentBeginFrameArgs( |
| 2798 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2814 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2799 | 2815 |
| 2800 pending_layer_->draw_properties().visible_content_rect = | 2816 pending_layer_->draw_properties().visible_content_rect = |
| 2801 gfx::Rect(1100, 1100, 500, 500); | 2817 gfx::Rect(1100, 1100, 500, 500); |
| 2802 bool resourceless_software_draw = false; | 2818 bool resourceless_software_draw = false; |
| 2803 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 2819 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
| 2804 | 2820 |
| 2805 unique_tiles.clear(); | 2821 unique_tiles.clear(); |
| 2806 high_res_tile_count = 0u; | 2822 high_res_tile_count = 0u; |
| 2807 queue = pending_layer_->CreateRasterQueue(false); | 2823 queue.reset(new TilingSetRasterQueueAll( |
| 2824 pending_layer_->picture_layer_tiling_set(), false)); | |
| 2808 while (!queue->IsEmpty()) { | 2825 while (!queue->IsEmpty()) { |
| 2809 Tile* tile = queue->Top(); | 2826 Tile* tile = queue->Top(); |
| 2810 TilePriority priority = tile->priority(PENDING_TREE); | 2827 TilePriority priority = tile->priority(PENDING_TREE); |
| 2811 | 2828 |
| 2812 EXPECT_TRUE(tile); | 2829 EXPECT_TRUE(tile); |
| 2813 | 2830 |
| 2814 // Non-high res tiles only get visible tiles. | 2831 // Non-high res tiles only get visible tiles. |
| 2815 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); | 2832 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); |
| 2816 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2833 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 2817 | 2834 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2838 tile_it != high_res_tiles.end(); | 2855 tile_it != high_res_tiles.end(); |
| 2839 ++tile_it) { | 2856 ++tile_it) { |
| 2840 Tile* tile = *tile_it; | 2857 Tile* tile = *tile_it; |
| 2841 TileDrawInfo& draw_info = tile->draw_info(); | 2858 TileDrawInfo& draw_info = tile->draw_info(); |
| 2842 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2859 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 2843 } | 2860 } |
| 2844 | 2861 |
| 2845 non_ideal_tile_count = 0; | 2862 non_ideal_tile_count = 0; |
| 2846 low_res_tile_count = 0; | 2863 low_res_tile_count = 0; |
| 2847 high_res_tile_count = 0; | 2864 high_res_tile_count = 0; |
| 2848 queue = pending_layer_->CreateRasterQueue(true); | 2865 queue.reset(new TilingSetRasterQueueAll( |
| 2866 pending_layer_->picture_layer_tiling_set(), true)); | |
| 2849 while (!queue->IsEmpty()) { | 2867 while (!queue->IsEmpty()) { |
| 2850 Tile* tile = queue->Top(); | 2868 Tile* tile = queue->Top(); |
| 2851 TilePriority priority = tile->priority(PENDING_TREE); | 2869 TilePriority priority = tile->priority(PENDING_TREE); |
| 2852 | 2870 |
| 2853 EXPECT_TRUE(tile); | 2871 EXPECT_TRUE(tile); |
| 2854 | 2872 |
| 2855 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 2873 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
| 2856 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 2874 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
| 2857 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2875 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 2858 queue->Pop(); | 2876 queue->Pop(); |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3821 gfx::Point occluding_layer_position(310, 0); | 3839 gfx::Point occluding_layer_position(310, 0); |
| 3822 | 3840 |
| 3823 host_impl_.SetViewportSize(viewport_size); | 3841 host_impl_.SetViewportSize(viewport_size); |
| 3824 | 3842 |
| 3825 scoped_refptr<FakePicturePileImpl> pending_pile = | 3843 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3826 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3844 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3827 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 3845 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 3828 | 3846 |
| 3829 // No occlusion. | 3847 // No occlusion. |
| 3830 int unoccluded_tile_count = 0; | 3848 int unoccluded_tile_count = 0; |
| 3831 scoped_ptr<TilingSetRasterQueue> queue = | 3849 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll( |
| 3832 pending_layer_->CreateRasterQueue(false); | 3850 pending_layer_->picture_layer_tiling_set(), false)); |
| 3833 while (!queue->IsEmpty()) { | 3851 while (!queue->IsEmpty()) { |
| 3834 Tile* tile = queue->Top(); | 3852 Tile* tile = queue->Top(); |
| 3835 | 3853 |
| 3836 // Occluded tiles should not be iterated over. | 3854 // Occluded tiles should not be iterated over. |
| 3837 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3855 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 3838 | 3856 |
| 3839 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3857 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 3840 // visible and at least partially unoccluded, verified by the above expect. | 3858 // visible and at least partially unoccluded, verified by the above expect. |
| 3841 bool tile_is_visible = | 3859 bool tile_is_visible = |
| 3842 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3860 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 3854 layer1->SetDrawsContent(true); | 3872 layer1->SetDrawsContent(true); |
| 3855 layer1->SetContentsOpaque(true); | 3873 layer1->SetContentsOpaque(true); |
| 3856 layer1->SetPosition(occluding_layer_position); | 3874 layer1->SetPosition(occluding_layer_position); |
| 3857 | 3875 |
| 3858 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3876 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3859 host_impl_.SetCurrentBeginFrameArgs( | 3877 host_impl_.SetCurrentBeginFrameArgs( |
| 3860 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3878 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3861 host_impl_.pending_tree()->UpdateDrawProperties(); | 3879 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 3862 | 3880 |
| 3863 unoccluded_tile_count = 0; | 3881 unoccluded_tile_count = 0; |
| 3864 queue = pending_layer_->CreateRasterQueue(false); | 3882 queue.reset(new TilingSetRasterQueueAll( |
| 3883 pending_layer_->picture_layer_tiling_set(), false)); | |
| 3865 while (!queue->IsEmpty()) { | 3884 while (!queue->IsEmpty()) { |
| 3866 Tile* tile = queue->Top(); | 3885 Tile* tile = queue->Top(); |
| 3867 | 3886 |
| 3868 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3887 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 3869 | 3888 |
| 3870 bool tile_is_visible = | 3889 bool tile_is_visible = |
| 3871 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3890 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 3872 if (tile_is_visible) | 3891 if (tile_is_visible) |
| 3873 unoccluded_tile_count++; | 3892 unoccluded_tile_count++; |
| 3874 queue->Pop(); | 3893 queue->Pop(); |
| 3875 } | 3894 } |
| 3876 EXPECT_EQ(20, unoccluded_tile_count); | 3895 EXPECT_EQ(20, unoccluded_tile_count); |
| 3877 | 3896 |
| 3878 // Full occlusion. | 3897 // Full occlusion. |
| 3879 layer1->SetPosition(gfx::Point(0, 0)); | 3898 layer1->SetPosition(gfx::Point(0, 0)); |
| 3880 | 3899 |
| 3881 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3900 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3882 host_impl_.SetCurrentBeginFrameArgs( | 3901 host_impl_.SetCurrentBeginFrameArgs( |
| 3883 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3902 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3884 host_impl_.pending_tree()->UpdateDrawProperties(); | 3903 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 3885 | 3904 |
| 3886 unoccluded_tile_count = 0; | 3905 unoccluded_tile_count = 0; |
| 3887 queue = pending_layer_->CreateRasterQueue(false); | 3906 queue.reset(new TilingSetRasterQueueAll( |
| 3907 pending_layer_->picture_layer_tiling_set(), false)); | |
| 3888 while (!queue->IsEmpty()) { | 3908 while (!queue->IsEmpty()) { |
| 3889 Tile* tile = queue->Top(); | 3909 Tile* tile = queue->Top(); |
| 3890 | 3910 |
| 3891 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3911 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 3892 | 3912 |
| 3893 bool tile_is_visible = | 3913 bool tile_is_visible = |
| 3894 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3914 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 3895 if (tile_is_visible) | 3915 if (tile_is_visible) |
| 3896 unoccluded_tile_count++; | 3916 unoccluded_tile_count++; |
| 3897 queue->Pop(); | 3917 queue->Pop(); |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4732 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4752 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4733 EXPECT_EQ(result.width(), 448); | 4753 EXPECT_EQ(result.width(), 448); |
| 4734 EXPECT_EQ(result.height(), 448); | 4754 EXPECT_EQ(result.height(), 448); |
| 4735 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4755 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4736 EXPECT_EQ(result.width(), 512); | 4756 EXPECT_EQ(result.width(), 512); |
| 4737 EXPECT_EQ(result.height(), 500 + 2); | 4757 EXPECT_EQ(result.height(), 500 + 2); |
| 4738 } | 4758 } |
| 4739 | 4759 |
| 4740 } // namespace | 4760 } // namespace |
| 4741 } // namespace cc | 4761 } // namespace cc |
| OLD | NEW |