Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 833243008: Update from https://crrev.com/311145 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl_perftest.cc ('k') | cc/resources/eviction_tile_priority_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 1608
1607 base::TimeTicks time_ticks; 1609 base::TimeTicks time_ticks;
1608 time_ticks += base::TimeDelta::FromMilliseconds(1); 1610 time_ticks += base::TimeDelta::FromMilliseconds(1);
1609 host_impl_.SetCurrentBeginFrameArgs( 1611 host_impl_.SetCurrentBeginFrameArgs(
1610 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 1612 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
1611 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); 1613 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw);
1612 1614
1613 int num_visible = 0; 1615 int num_visible = 0;
1614 int num_offscreen = 0; 1616 int num_offscreen = 0;
1615 1617
1616 scoped_ptr<TilingSetRasterQueue> queue = 1618 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll(
1617 pending_layer_->CreateRasterQueue(false); 1619 pending_layer_->picture_layer_tiling_set(), false));
1618 for (; !queue->IsEmpty(); queue->Pop()) { 1620 for (; !queue->IsEmpty(); queue->Pop()) {
1619 const Tile* tile = queue->Top(); 1621 const Tile* tile = queue->Top();
1620 DCHECK(tile); 1622 DCHECK(tile);
1621 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { 1623 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) {
1622 EXPECT_TRUE(tile->required_for_activation()); 1624 EXPECT_TRUE(tile->required_for_activation());
1623 num_visible++; 1625 num_visible++;
1624 } else { 1626 } else {
1625 EXPECT_FALSE(tile->required_for_activation()); 1627 EXPECT_FALSE(tile->required_for_activation());
1626 num_offscreen++; 1628 num_offscreen++;
1627 } 1629 }
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 } 2739 }
2738 2740
2739 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { 2741 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) {
2740 base::TimeTicks time_ticks; 2742 base::TimeTicks time_ticks;
2741 time_ticks += base::TimeDelta::FromMilliseconds(1); 2743 time_ticks += base::TimeDelta::FromMilliseconds(1);
2742 host_impl_.SetCurrentBeginFrameArgs( 2744 host_impl_.SetCurrentBeginFrameArgs(
2743 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 2745 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2744 2746
2745 host_impl_.SetViewportSize(gfx::Size(500, 500)); 2747 host_impl_.SetViewportSize(gfx::Size(500, 500));
2746 2748
2747 gfx::Size tile_size(100, 100); 2749 gfx::Size recording_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(recording_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 int non_ideal_tile_count = 0u;
2762 size_t low_res_tile_count = 0u; 2761 int low_res_tile_count = 0u;
2763 size_t high_res_tile_count = 0u; 2762 int high_res_tile_count = 0u;
2764 queue = pending_layer_->CreateRasterQueue(false); 2763 int high_res_now_tiles = 0u;
2764 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll(
2765 pending_layer_->picture_layer_tiling_set(), false));
2765 while (!queue->IsEmpty()) { 2766 while (!queue->IsEmpty()) {
2766 Tile* tile = queue->Top(); 2767 Tile* tile = queue->Top();
2767 TilePriority priority = tile->priority(PENDING_TREE); 2768 TilePriority priority = tile->priority(PENDING_TREE);
2768 2769
2769 EXPECT_TRUE(tile); 2770 EXPECT_TRUE(tile);
2770 2771
2771 // Non-high res tiles only get visible tiles. Also, prepaint should only 2772 // Non-high res tiles only get visible tiles. Also, prepaint should only
2772 // come at the end of the iteration. 2773 // come at the end of the iteration.
2773 if (priority.resolution != HIGH_RESOLUTION) 2774 if (priority.resolution != HIGH_RESOLUTION) {
2774 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); 2775 EXPECT_EQ(TilePriority::NOW, priority.priority_bin);
2775 else if (reached_prepaint) 2776 } else if (reached_prepaint) {
2776 EXPECT_NE(TilePriority::NOW, priority.priority_bin); 2777 EXPECT_NE(TilePriority::NOW, priority.priority_bin);
2777 else 2778 } else {
2778 reached_prepaint = priority.priority_bin != TilePriority::NOW; 2779 reached_prepaint = priority.priority_bin != TilePriority::NOW;
2780 if (!reached_prepaint)
2781 ++high_res_now_tiles;
2782 }
2779 2783
2780 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; 2784 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION;
2781 low_res_tile_count += priority.resolution == LOW_RESOLUTION; 2785 low_res_tile_count += priority.resolution == LOW_RESOLUTION;
2782 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; 2786 high_res_tile_count += priority.resolution == HIGH_RESOLUTION;
2783 2787
2784 unique_tiles.insert(tile); 2788 unique_tiles.insert(tile);
2785 queue->Pop(); 2789 queue->Pop();
2786 } 2790 }
2787 2791
2788 EXPECT_TRUE(reached_prepaint); 2792 EXPECT_TRUE(reached_prepaint);
2789 EXPECT_EQ(0u, non_ideal_tile_count); 2793 EXPECT_EQ(0, non_ideal_tile_count);
2790 EXPECT_EQ(0u, low_res_tile_count); 2794 EXPECT_EQ(0, low_res_tile_count);
2791 EXPECT_EQ(16u, high_res_tile_count); 2795
2796 // With layer size being 1000x1000 and default tile size 256x256, we expect to
2797 // see 4 now tiles out of 16 total high res tiles.
2798 EXPECT_EQ(16, high_res_tile_count);
2799 EXPECT_EQ(4, high_res_now_tiles);
2792 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, 2800 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count,
2793 unique_tiles.size()); 2801 static_cast<int>(unique_tiles.size()));
2802
2803 queue.reset(new TilingSetRasterQueueRequired(
2804 pending_layer_->picture_layer_tiling_set(),
2805 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW));
2806 EXPECT_TRUE(queue->IsEmpty());
2807
2808 queue.reset(new TilingSetRasterQueueRequired(
2809 pending_layer_->picture_layer_tiling_set(),
2810 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
2811 EXPECT_FALSE(queue->IsEmpty());
2812 int required_for_activation_count = 0;
2813 while (!queue->IsEmpty()) {
2814 Tile* tile = queue->Top();
2815 EXPECT_TRUE(tile->required_for_activation());
2816 EXPECT_FALSE(tile->IsReadyToDraw());
2817 ++required_for_activation_count;
2818 queue->Pop();
2819 }
2820
2821 // All of the high res tiles should be required for activation, since there is
2822 // no active twin.
2823 EXPECT_EQ(high_res_now_tiles, required_for_activation_count);
2794 2824
2795 // No NOW tiles. 2825 // No NOW tiles.
2796 time_ticks += base::TimeDelta::FromMilliseconds(200); 2826 time_ticks += base::TimeDelta::FromMilliseconds(200);
2797 host_impl_.SetCurrentBeginFrameArgs( 2827 host_impl_.SetCurrentBeginFrameArgs(
2798 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 2828 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2799 2829
2800 pending_layer_->draw_properties().visible_content_rect = 2830 pending_layer_->draw_properties().visible_content_rect =
2801 gfx::Rect(1100, 1100, 500, 500); 2831 gfx::Rect(1100, 1100, 500, 500);
2802 bool resourceless_software_draw = false; 2832 bool resourceless_software_draw = false;
2803 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); 2833 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw);
2804 2834
2805 unique_tiles.clear(); 2835 unique_tiles.clear();
2806 high_res_tile_count = 0u; 2836 high_res_tile_count = 0u;
2807 queue = pending_layer_->CreateRasterQueue(false); 2837 queue.reset(new TilingSetRasterQueueAll(
2838 pending_layer_->picture_layer_tiling_set(), false));
2808 while (!queue->IsEmpty()) { 2839 while (!queue->IsEmpty()) {
2809 Tile* tile = queue->Top(); 2840 Tile* tile = queue->Top();
2810 TilePriority priority = tile->priority(PENDING_TREE); 2841 TilePriority priority = tile->priority(PENDING_TREE);
2811 2842
2812 EXPECT_TRUE(tile); 2843 EXPECT_TRUE(tile);
2813 2844
2814 // Non-high res tiles only get visible tiles. 2845 // Non-high res tiles only get visible tiles.
2815 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); 2846 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution);
2816 EXPECT_NE(TilePriority::NOW, priority.priority_bin); 2847 EXPECT_NE(TilePriority::NOW, priority.priority_bin);
2817 2848
2818 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; 2849 high_res_tile_count += priority.resolution == HIGH_RESOLUTION;
2819 2850
2820 unique_tiles.insert(tile); 2851 unique_tiles.insert(tile);
2821 queue->Pop(); 2852 queue->Pop();
2822 } 2853 }
2823 2854
2824 EXPECT_EQ(16u, high_res_tile_count); 2855 EXPECT_EQ(16, high_res_tile_count);
2825 EXPECT_EQ(high_res_tile_count, unique_tiles.size()); 2856 EXPECT_EQ(high_res_tile_count, static_cast<int>(unique_tiles.size()));
2826 2857
2827 time_ticks += base::TimeDelta::FromMilliseconds(200); 2858 time_ticks += base::TimeDelta::FromMilliseconds(200);
2828 host_impl_.SetCurrentBeginFrameArgs( 2859 host_impl_.SetCurrentBeginFrameArgs(
2829 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 2860 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2830 2861
2831 pending_layer_->draw_properties().visible_content_rect = 2862 pending_layer_->draw_properties().visible_content_rect =
2832 gfx::Rect(0, 0, 500, 500); 2863 gfx::Rect(0, 0, 500, 500);
2833 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); 2864 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw);
2834 2865
2835 std::vector<Tile*> high_res_tiles = 2866 std::vector<Tile*> high_res_tiles =
2836 pending_layer_->HighResTiling()->AllTilesForTesting(); 2867 pending_layer_->HighResTiling()->AllTilesForTesting();
2837 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); 2868 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin();
2838 tile_it != high_res_tiles.end(); 2869 tile_it != high_res_tiles.end();
2839 ++tile_it) { 2870 ++tile_it) {
2840 Tile* tile = *tile_it; 2871 Tile* tile = *tile_it;
2841 TileDrawInfo& draw_info = tile->draw_info(); 2872 TileDrawInfo& draw_info = tile->draw_info();
2842 draw_info.SetSolidColorForTesting(SK_ColorRED); 2873 draw_info.SetSolidColorForTesting(SK_ColorRED);
2843 } 2874 }
2844 2875
2845 non_ideal_tile_count = 0; 2876 non_ideal_tile_count = 0;
2846 low_res_tile_count = 0; 2877 low_res_tile_count = 0;
2847 high_res_tile_count = 0; 2878 high_res_tile_count = 0;
2848 queue = pending_layer_->CreateRasterQueue(true); 2879 queue.reset(new TilingSetRasterQueueAll(
2880 pending_layer_->picture_layer_tiling_set(), true));
2849 while (!queue->IsEmpty()) { 2881 while (!queue->IsEmpty()) {
2850 Tile* tile = queue->Top(); 2882 Tile* tile = queue->Top();
2851 TilePriority priority = tile->priority(PENDING_TREE); 2883 TilePriority priority = tile->priority(PENDING_TREE);
2852 2884
2853 EXPECT_TRUE(tile); 2885 EXPECT_TRUE(tile);
2854 2886
2855 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; 2887 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION;
2856 low_res_tile_count += priority.resolution == LOW_RESOLUTION; 2888 low_res_tile_count += priority.resolution == LOW_RESOLUTION;
2857 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; 2889 high_res_tile_count += priority.resolution == HIGH_RESOLUTION;
2858 queue->Pop(); 2890 queue->Pop();
2859 } 2891 }
2860 2892
2861 EXPECT_EQ(0u, non_ideal_tile_count); 2893 EXPECT_EQ(0, non_ideal_tile_count);
2862 EXPECT_EQ(1u, low_res_tile_count); 2894 EXPECT_EQ(1, low_res_tile_count);
2863 EXPECT_EQ(0u, high_res_tile_count); 2895 EXPECT_EQ(0, high_res_tile_count);
2896 }
2897
2898 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) {
2899 base::TimeTicks time_ticks;
2900 time_ticks += base::TimeDelta::FromMilliseconds(1);
2901 host_impl_.SetCurrentBeginFrameArgs(
2902 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2903
2904 host_impl_.SetViewportSize(gfx::Size(500, 500));
2905
2906 gfx::Size tile_size(100, 100);
2907 gfx::Size layer_bounds(1000, 1000);
2908
2909 scoped_refptr<FakePicturePileImpl> pending_pile =
2910 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2911
2912 SetupPendingTree(pending_pile);
2913 ActivateTree();
2914 EXPECT_EQ(2u, active_layer_->num_tilings());
2915
2916 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueRequired(
2917 active_layer_->picture_layer_tiling_set(),
2918 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW));
2919 EXPECT_FALSE(queue->IsEmpty());
2920 while (!queue->IsEmpty()) {
2921 Tile* tile = queue->Top();
2922 EXPECT_TRUE(tile->required_for_draw());
2923 EXPECT_FALSE(tile->IsReadyToDraw());
2924 queue->Pop();
2925 }
2926
2927 queue.reset(new TilingSetRasterQueueRequired(
2928 active_layer_->picture_layer_tiling_set(),
2929 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
2930 EXPECT_TRUE(queue->IsEmpty());
2864 } 2931 }
2865 2932
2866 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { 2933 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) {
2867 gfx::Size tile_size(100, 100); 2934 gfx::Size tile_size(100, 100);
2868 gfx::Size layer_bounds(1000, 1000); 2935 gfx::Size layer_bounds(1000, 1000);
2869 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 2936 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
2870 2937
2871 host_impl_.SetViewportSize(gfx::Size(500, 500)); 2938 host_impl_.SetViewportSize(gfx::Size(500, 500));
2872 2939
2873 scoped_refptr<FakePicturePileImpl> pending_pile = 2940 scoped_refptr<FakePicturePileImpl> pending_pile =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 } 2975 }
2909 } 2976 }
2910 2977
2911 // Sanity checks. 2978 // Sanity checks.
2912 EXPECT_EQ(17u, all_tiles.size()); 2979 EXPECT_EQ(17u, all_tiles.size());
2913 EXPECT_EQ(17u, all_tiles_set.size()); 2980 EXPECT_EQ(17u, all_tiles_set.size());
2914 EXPECT_GT(number_of_marked_tiles, 1u); 2981 EXPECT_GT(number_of_marked_tiles, 1u);
2915 EXPECT_GT(number_of_unmarked_tiles, 1u); 2982 EXPECT_GT(number_of_unmarked_tiles, 1u);
2916 2983
2917 // Tiles don't have resources yet. 2984 // Tiles don't have resources yet.
2918 scoped_ptr<TilingSetEvictionQueue> queue = 2985 scoped_ptr<TilingSetEvictionQueue> queue(
2919 pending_layer_->CreateEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES); 2986 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set(),
2987 SAME_PRIORITY_FOR_BOTH_TREES, false));
2920 EXPECT_TRUE(queue->IsEmpty()); 2988 EXPECT_TRUE(queue->IsEmpty());
2921 2989
2922 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 2990 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
2923 2991
2924 std::set<Tile*> unique_tiles; 2992 std::set<Tile*> unique_tiles;
2925 float expected_scales[] = {low_res_factor, 1.f}; 2993 float expected_scales[] = {low_res_factor, 1.f};
2926 size_t scale_index = 0; 2994 size_t scale_index = 0;
2927 bool reached_visible = false; 2995 bool reached_visible = false;
2928 Tile* last_tile = nullptr; 2996 Tile* last_tile = nullptr;
2929 size_t distance_decreasing = 0; 2997 size_t distance_decreasing = 0;
2930 size_t distance_increasing = 0; 2998 size_t distance_increasing = 0;
2931 queue = pending_layer_->CreateEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES); 2999 queue.reset(
3000 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set(),
3001 SAME_PRIORITY_FOR_BOTH_TREES, false));
2932 while (!queue->IsEmpty()) { 3002 while (!queue->IsEmpty()) {
2933 Tile* tile = queue->Top(); 3003 Tile* tile = queue->Top();
2934 if (!last_tile) 3004 if (!last_tile)
2935 last_tile = tile; 3005 last_tile = tile;
2936 3006
2937 EXPECT_TRUE(tile); 3007 EXPECT_TRUE(tile);
2938 3008
2939 TilePriority priority = tile->priority(PENDING_TREE); 3009 TilePriority priority = tile->priority(PENDING_TREE);
2940 3010
2941 if (priority.priority_bin == TilePriority::NOW) { 3011 if (priority.priority_bin == TilePriority::NOW) {
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3697 WhichTree tree, 3767 WhichTree tree,
3698 size_t expected_occluded_tile_count) { 3768 size_t expected_occluded_tile_count) {
3699 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; 3769 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE;
3700 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES; 3770 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES;
3701 ++priority_count) { 3771 ++priority_count) {
3702 TreePriority tree_priority = static_cast<TreePriority>(priority_count); 3772 TreePriority tree_priority = static_cast<TreePriority>(priority_count);
3703 size_t occluded_tile_count = 0u; 3773 size_t occluded_tile_count = 0u;
3704 Tile* last_tile = nullptr; 3774 Tile* last_tile = nullptr;
3705 std::set<Tile*> shared_tiles; 3775 std::set<Tile*> shared_tiles;
3706 3776
3707 scoped_ptr<TilingSetEvictionQueue> queue = 3777 scoped_ptr<TilingSetEvictionQueue> queue(
3708 layer->CreateEvictionQueue(tree_priority); 3778 new TilingSetEvictionQueue(layer->picture_layer_tiling_set(),
3779 tree_priority, layer && twin_layer));
3709 while (!queue->IsEmpty()) { 3780 while (!queue->IsEmpty()) {
3710 Tile* tile = queue->Top(); 3781 Tile* tile = queue->Top();
3711 if (!last_tile) 3782 if (!last_tile)
3712 last_tile = tile; 3783 last_tile = tile;
3713 if (tile->is_shared()) 3784 if (tile->is_shared())
3714 EXPECT_TRUE(shared_tiles.insert(tile).second); 3785 EXPECT_TRUE(shared_tiles.insert(tile).second);
3715 3786
3716 // The only way we will encounter an occluded tile after an unoccluded 3787 // The only way we will encounter an occluded tile after an unoccluded
3717 // tile is if the priorty bin decreased, the tile is required for 3788 // tile is if the priorty bin decreased, the tile is required for
3718 // activation, or the scale changed. 3789 // activation, or the scale changed.
(...skipping 13 matching lines...) Expand all
3732 tile->required_for_activation() || 3803 tile->required_for_activation() ||
3733 (tile->contents_scale() != last_tile->contents_scale())); 3804 (tile->contents_scale() != last_tile->contents_scale()));
3734 } 3805 }
3735 } 3806 }
3736 last_tile = tile; 3807 last_tile = tile;
3737 queue->Pop(); 3808 queue->Pop();
3738 } 3809 }
3739 // Count also shared tiles which are occluded in the tree but which were 3810 // Count also shared tiles which are occluded in the tree but which were
3740 // not returned by the tiling set eviction queue. Those shared tiles 3811 // not returned by the tiling set eviction queue. Those shared tiles
3741 // shall be returned by the twin tiling set eviction queue. 3812 // shall be returned by the twin tiling set eviction queue.
3742 queue = twin_layer->CreateEvictionQueue(tree_priority); 3813 queue.reset(
3814 new TilingSetEvictionQueue(twin_layer->picture_layer_tiling_set(),
3815 tree_priority, layer && twin_layer));
3743 while (!queue->IsEmpty()) { 3816 while (!queue->IsEmpty()) {
3744 Tile* tile = queue->Top(); 3817 Tile* tile = queue->Top();
3745 if (tile->is_shared()) { 3818 if (tile->is_shared()) {
3746 EXPECT_TRUE(shared_tiles.insert(tile).second); 3819 EXPECT_TRUE(shared_tiles.insert(tile).second);
3747 if (tile->is_occluded(tree)) 3820 if (tile->is_occluded(tree))
3748 ++occluded_tile_count; 3821 ++occluded_tile_count;
3749 // Check the reasons why the shared tile was not returned by 3822 // Check the reasons why the shared tile was not returned by
3750 // the first tiling set eviction queue. 3823 // the first tiling set eviction queue.
3751 switch (tree_priority) { 3824 switch (tree_priority) {
3752 case SAME_PRIORITY_FOR_BOTH_TREES: { 3825 case SAME_PRIORITY_FOR_BOTH_TREES: {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 gfx::Point occluding_layer_position(310, 0); 3894 gfx::Point occluding_layer_position(310, 0);
3822 3895
3823 host_impl_.SetViewportSize(viewport_size); 3896 host_impl_.SetViewportSize(viewport_size);
3824 3897
3825 scoped_refptr<FakePicturePileImpl> pending_pile = 3898 scoped_refptr<FakePicturePileImpl> pending_pile =
3826 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3899 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3827 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 3900 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region());
3828 3901
3829 // No occlusion. 3902 // No occlusion.
3830 int unoccluded_tile_count = 0; 3903 int unoccluded_tile_count = 0;
3831 scoped_ptr<TilingSetRasterQueue> queue = 3904 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll(
3832 pending_layer_->CreateRasterQueue(false); 3905 pending_layer_->picture_layer_tiling_set(), false));
3833 while (!queue->IsEmpty()) { 3906 while (!queue->IsEmpty()) {
3834 Tile* tile = queue->Top(); 3907 Tile* tile = queue->Top();
3835 3908
3836 // Occluded tiles should not be iterated over. 3909 // Occluded tiles should not be iterated over.
3837 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 3910 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
3838 3911
3839 // Some tiles may not be visible (i.e. outside the viewport). The rest are 3912 // 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. 3913 // visible and at least partially unoccluded, verified by the above expect.
3841 bool tile_is_visible = 3914 bool tile_is_visible =
3842 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); 3915 tile->content_rect().Intersects(pending_layer_->visible_content_rect());
(...skipping 11 matching lines...) Expand all
3854 layer1->SetDrawsContent(true); 3927 layer1->SetDrawsContent(true);
3855 layer1->SetContentsOpaque(true); 3928 layer1->SetContentsOpaque(true);
3856 layer1->SetPosition(occluding_layer_position); 3929 layer1->SetPosition(occluding_layer_position);
3857 3930
3858 time_ticks += base::TimeDelta::FromMilliseconds(200); 3931 time_ticks += base::TimeDelta::FromMilliseconds(200);
3859 host_impl_.SetCurrentBeginFrameArgs( 3932 host_impl_.SetCurrentBeginFrameArgs(
3860 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 3933 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
3861 host_impl_.pending_tree()->UpdateDrawProperties(); 3934 host_impl_.pending_tree()->UpdateDrawProperties();
3862 3935
3863 unoccluded_tile_count = 0; 3936 unoccluded_tile_count = 0;
3864 queue = pending_layer_->CreateRasterQueue(false); 3937 queue.reset(new TilingSetRasterQueueAll(
3938 pending_layer_->picture_layer_tiling_set(), false));
3865 while (!queue->IsEmpty()) { 3939 while (!queue->IsEmpty()) {
3866 Tile* tile = queue->Top(); 3940 Tile* tile = queue->Top();
3867 3941
3868 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 3942 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
3869 3943
3870 bool tile_is_visible = 3944 bool tile_is_visible =
3871 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); 3945 tile->content_rect().Intersects(pending_layer_->visible_content_rect());
3872 if (tile_is_visible) 3946 if (tile_is_visible)
3873 unoccluded_tile_count++; 3947 unoccluded_tile_count++;
3874 queue->Pop(); 3948 queue->Pop();
3875 } 3949 }
3876 EXPECT_EQ(20, unoccluded_tile_count); 3950 EXPECT_EQ(20, unoccluded_tile_count);
3877 3951
3878 // Full occlusion. 3952 // Full occlusion.
3879 layer1->SetPosition(gfx::Point(0, 0)); 3953 layer1->SetPosition(gfx::Point(0, 0));
3880 3954
3881 time_ticks += base::TimeDelta::FromMilliseconds(200); 3955 time_ticks += base::TimeDelta::FromMilliseconds(200);
3882 host_impl_.SetCurrentBeginFrameArgs( 3956 host_impl_.SetCurrentBeginFrameArgs(
3883 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 3957 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
3884 host_impl_.pending_tree()->UpdateDrawProperties(); 3958 host_impl_.pending_tree()->UpdateDrawProperties();
3885 3959
3886 unoccluded_tile_count = 0; 3960 unoccluded_tile_count = 0;
3887 queue = pending_layer_->CreateRasterQueue(false); 3961 queue.reset(new TilingSetRasterQueueAll(
3962 pending_layer_->picture_layer_tiling_set(), false));
3888 while (!queue->IsEmpty()) { 3963 while (!queue->IsEmpty()) {
3889 Tile* tile = queue->Top(); 3964 Tile* tile = queue->Top();
3890 3965
3891 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 3966 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
3892 3967
3893 bool tile_is_visible = 3968 bool tile_is_visible =
3894 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); 3969 tile->content_rect().Intersects(pending_layer_->visible_content_rect());
3895 if (tile_is_visible) 3970 if (tile_is_visible)
3896 unoccluded_tile_count++; 3971 unoccluded_tile_count++;
3897 queue->Pop(); 3972 queue->Pop();
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
4732 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4807 result = layer->CalculateTileSize(gfx::Size(447, 400));
4733 EXPECT_EQ(result.width(), 448); 4808 EXPECT_EQ(result.width(), 448);
4734 EXPECT_EQ(result.height(), 448); 4809 EXPECT_EQ(result.height(), 448);
4735 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4810 result = layer->CalculateTileSize(gfx::Size(500, 499));
4736 EXPECT_EQ(result.width(), 512); 4811 EXPECT_EQ(result.width(), 512);
4737 EXPECT_EQ(result.height(), 500 + 2); 4812 EXPECT_EQ(result.height(), 500 + 2);
4738 } 4813 }
4739 4814
4740 } // namespace 4815 } // namespace
4741 } // namespace cc 4816 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_perftest.cc ('k') | cc/resources/eviction_tile_priority_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698