| 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 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 | 1663 |
| 1664 base::TimeTicks time_ticks; | 1664 base::TimeTicks time_ticks; |
| 1665 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1665 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1666 host_impl_.SetCurrentBeginFrameArgs( | 1666 host_impl_.SetCurrentBeginFrameArgs( |
| 1667 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1667 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1668 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 1668 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
| 1669 | 1669 |
| 1670 int num_visible = 0; | 1670 int num_visible = 0; |
| 1671 int num_offscreen = 0; | 1671 int num_offscreen = 0; |
| 1672 | 1672 |
| 1673 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll( | 1673 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 1674 pending_layer_->picture_layer_tiling_set(), false)); | 1674 pending_layer_->picture_layer_tiling_set(), false)); |
| 1675 for (; !queue->IsEmpty(); queue->Pop()) { | 1675 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1676 const Tile* tile = queue->Top(); | 1676 const Tile* tile = queue->Top(); |
| 1677 DCHECK(tile); | 1677 DCHECK(tile); |
| 1678 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1678 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
| 1679 EXPECT_TRUE(tile->required_for_activation()); | 1679 EXPECT_TRUE(tile->required_for_activation()); |
| 1680 num_visible++; | 1680 num_visible++; |
| 1681 } else { | 1681 } else { |
| 1682 EXPECT_FALSE(tile->required_for_activation()); | 1682 EXPECT_FALSE(tile->required_for_activation()); |
| 1683 num_offscreen++; | 1683 num_offscreen++; |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2809 | 2809 |
| 2810 SetupPendingTree(pending_pile); | 2810 SetupPendingTree(pending_pile); |
| 2811 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 2811 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 2812 | 2812 |
| 2813 std::set<Tile*> unique_tiles; | 2813 std::set<Tile*> unique_tiles; |
| 2814 bool reached_prepaint = false; | 2814 bool reached_prepaint = false; |
| 2815 int non_ideal_tile_count = 0u; | 2815 int non_ideal_tile_count = 0u; |
| 2816 int low_res_tile_count = 0u; | 2816 int low_res_tile_count = 0u; |
| 2817 int high_res_tile_count = 0u; | 2817 int high_res_tile_count = 0u; |
| 2818 int high_res_now_tiles = 0u; | 2818 int high_res_now_tiles = 0u; |
| 2819 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll( | 2819 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 2820 pending_layer_->picture_layer_tiling_set(), false)); | 2820 pending_layer_->picture_layer_tiling_set(), false)); |
| 2821 while (!queue->IsEmpty()) { | 2821 while (!queue->IsEmpty()) { |
| 2822 Tile* tile = queue->Top(); | 2822 Tile* tile = queue->Top(); |
| 2823 TilePriority priority = tile->priority(PENDING_TREE); | 2823 TilePriority priority = tile->priority(PENDING_TREE); |
| 2824 | 2824 |
| 2825 EXPECT_TRUE(tile); | 2825 EXPECT_TRUE(tile); |
| 2826 | 2826 |
| 2827 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2827 // Non-high res tiles only get visible tiles. Also, prepaint should only |
| 2828 // come at the end of the iteration. | 2828 // come at the end of the iteration. |
| 2829 if (priority.resolution != HIGH_RESOLUTION) { | 2829 if (priority.resolution != HIGH_RESOLUTION) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2848 EXPECT_EQ(0, non_ideal_tile_count); | 2848 EXPECT_EQ(0, non_ideal_tile_count); |
| 2849 EXPECT_EQ(0, low_res_tile_count); | 2849 EXPECT_EQ(0, low_res_tile_count); |
| 2850 | 2850 |
| 2851 // With layer size being 1000x1000 and default tile size 256x256, we expect to | 2851 // With layer size being 1000x1000 and default tile size 256x256, we expect to |
| 2852 // see 4 now tiles out of 16 total high res tiles. | 2852 // see 4 now tiles out of 16 total high res tiles. |
| 2853 EXPECT_EQ(16, high_res_tile_count); | 2853 EXPECT_EQ(16, high_res_tile_count); |
| 2854 EXPECT_EQ(4, high_res_now_tiles); | 2854 EXPECT_EQ(4, high_res_now_tiles); |
| 2855 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, | 2855 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, |
| 2856 static_cast<int>(unique_tiles.size())); | 2856 static_cast<int>(unique_tiles.size())); |
| 2857 | 2857 |
| 2858 queue.reset(new TilingSetRasterQueueRequired( | 2858 scoped_ptr<TilingSetRasterQueueRequired> required_queue( |
| 2859 pending_layer_->picture_layer_tiling_set(), | 2859 new TilingSetRasterQueueRequired( |
| 2860 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 2860 pending_layer_->picture_layer_tiling_set(), |
| 2861 EXPECT_TRUE(queue->IsEmpty()); | 2861 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
| 2862 EXPECT_TRUE(required_queue->IsEmpty()); |
| 2862 | 2863 |
| 2863 queue.reset(new TilingSetRasterQueueRequired( | 2864 required_queue.reset(new TilingSetRasterQueueRequired( |
| 2864 pending_layer_->picture_layer_tiling_set(), | 2865 pending_layer_->picture_layer_tiling_set(), |
| 2865 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 2866 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 2866 EXPECT_FALSE(queue->IsEmpty()); | 2867 EXPECT_FALSE(required_queue->IsEmpty()); |
| 2867 int required_for_activation_count = 0; | 2868 int required_for_activation_count = 0; |
| 2868 while (!queue->IsEmpty()) { | 2869 while (!required_queue->IsEmpty()) { |
| 2869 Tile* tile = queue->Top(); | 2870 Tile* tile = required_queue->Top(); |
| 2870 EXPECT_TRUE(tile->required_for_activation()); | 2871 EXPECT_TRUE(tile->required_for_activation()); |
| 2871 EXPECT_FALSE(tile->IsReadyToDraw()); | 2872 EXPECT_FALSE(tile->IsReadyToDraw()); |
| 2872 ++required_for_activation_count; | 2873 ++required_for_activation_count; |
| 2873 queue->Pop(); | 2874 required_queue->Pop(); |
| 2874 } | 2875 } |
| 2875 | 2876 |
| 2876 // All of the high res tiles should be required for activation, since there is | 2877 // All of the high res tiles should be required for activation, since there is |
| 2877 // no active twin. | 2878 // no active twin. |
| 2878 EXPECT_EQ(high_res_now_tiles, required_for_activation_count); | 2879 EXPECT_EQ(high_res_now_tiles, required_for_activation_count); |
| 2879 | 2880 |
| 2880 // No NOW tiles. | 2881 // No NOW tiles. |
| 2881 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2882 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2882 host_impl_.SetCurrentBeginFrameArgs( | 2883 host_impl_.SetCurrentBeginFrameArgs( |
| 2883 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2884 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2961 gfx::Size tile_size(100, 100); | 2962 gfx::Size tile_size(100, 100); |
| 2962 gfx::Size layer_bounds(1000, 1000); | 2963 gfx::Size layer_bounds(1000, 1000); |
| 2963 | 2964 |
| 2964 scoped_refptr<FakePicturePileImpl> pending_pile = | 2965 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2965 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2966 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2966 | 2967 |
| 2967 SetupPendingTree(pending_pile); | 2968 SetupPendingTree(pending_pile); |
| 2968 ActivateTree(); | 2969 ActivateTree(); |
| 2969 EXPECT_EQ(2u, active_layer_->num_tilings()); | 2970 EXPECT_EQ(2u, active_layer_->num_tilings()); |
| 2970 | 2971 |
| 2971 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueRequired( | 2972 scoped_ptr<TilingSetRasterQueueRequired> queue( |
| 2972 active_layer_->picture_layer_tiling_set(), | 2973 new TilingSetRasterQueueRequired( |
| 2973 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 2974 active_layer_->picture_layer_tiling_set(), |
| 2975 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
| 2974 EXPECT_FALSE(queue->IsEmpty()); | 2976 EXPECT_FALSE(queue->IsEmpty()); |
| 2975 while (!queue->IsEmpty()) { | 2977 while (!queue->IsEmpty()) { |
| 2976 Tile* tile = queue->Top(); | 2978 Tile* tile = queue->Top(); |
| 2977 EXPECT_TRUE(tile->required_for_draw()); | 2979 EXPECT_TRUE(tile->required_for_draw()); |
| 2978 EXPECT_FALSE(tile->IsReadyToDraw()); | 2980 EXPECT_FALSE(tile->IsReadyToDraw()); |
| 2979 queue->Pop(); | 2981 queue->Pop(); |
| 2980 } | 2982 } |
| 2981 | 2983 |
| 2982 queue.reset(new TilingSetRasterQueueRequired( | 2984 queue.reset(new TilingSetRasterQueueRequired( |
| 2983 active_layer_->picture_layer_tiling_set(), | 2985 active_layer_->picture_layer_tiling_set(), |
| 2984 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 2986 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 2985 EXPECT_TRUE(queue->IsEmpty()); | 2987 EXPECT_TRUE(queue->IsEmpty()); |
| 2986 } | 2988 } |
| 2987 | 2989 |
| 2988 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { | 2990 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { |
| 2989 scoped_refptr<FakePicturePileImpl> pending_pile = | 2991 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2990 FakePicturePileImpl::CreateEmptyPile(gfx::Size(256, 256), | 2992 FakePicturePileImpl::CreateEmptyPile(gfx::Size(256, 256), |
| 2991 gfx::Size(1024, 1024)); | 2993 gfx::Size(1024, 1024)); |
| 2992 pending_pile->set_is_solid_color(true); | 2994 pending_pile->set_is_solid_color(true); |
| 2993 | 2995 |
| 2994 SetupPendingTree(pending_pile); | 2996 SetupPendingTree(pending_pile); |
| 2995 EXPECT_FALSE( | 2997 EXPECT_FALSE( |
| 2996 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( | 2998 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( |
| 2997 HIGH_RESOLUTION)); | 2999 HIGH_RESOLUTION)); |
| 2998 | 3000 |
| 2999 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueRequired( | 3001 scoped_ptr<TilingSetRasterQueueRequired> queue( |
| 3000 pending_layer_->picture_layer_tiling_set(), | 3002 new TilingSetRasterQueueRequired( |
| 3001 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 3003 pending_layer_->picture_layer_tiling_set(), |
| 3004 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 3002 EXPECT_TRUE(queue->IsEmpty()); | 3005 EXPECT_TRUE(queue->IsEmpty()); |
| 3003 } | 3006 } |
| 3004 | 3007 |
| 3005 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { | 3008 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { |
| 3006 gfx::Size tile_size(100, 100); | 3009 gfx::Size tile_size(100, 100); |
| 3007 gfx::Size layer_bounds(1000, 1000); | 3010 gfx::Size layer_bounds(1000, 1000); |
| 3008 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3011 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 3009 | 3012 |
| 3010 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 3013 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
| 3011 | 3014 |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3966 gfx::Point occluding_layer_position(310, 0); | 3969 gfx::Point occluding_layer_position(310, 0); |
| 3967 | 3970 |
| 3968 host_impl_.SetViewportSize(viewport_size); | 3971 host_impl_.SetViewportSize(viewport_size); |
| 3969 | 3972 |
| 3970 scoped_refptr<FakePicturePileImpl> pending_pile = | 3973 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3971 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3974 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3972 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 3975 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 3973 | 3976 |
| 3974 // No occlusion. | 3977 // No occlusion. |
| 3975 int unoccluded_tile_count = 0; | 3978 int unoccluded_tile_count = 0; |
| 3976 scoped_ptr<TilingSetRasterQueue> queue(new TilingSetRasterQueueAll( | 3979 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 3977 pending_layer_->picture_layer_tiling_set(), false)); | 3980 pending_layer_->picture_layer_tiling_set(), false)); |
| 3978 while (!queue->IsEmpty()) { | 3981 while (!queue->IsEmpty()) { |
| 3979 Tile* tile = queue->Top(); | 3982 Tile* tile = queue->Top(); |
| 3980 | 3983 |
| 3981 // Occluded tiles should not be iterated over. | 3984 // Occluded tiles should not be iterated over. |
| 3982 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3985 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 3983 | 3986 |
| 3984 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3987 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 3985 // visible and at least partially unoccluded, verified by the above expect. | 3988 // visible and at least partially unoccluded, verified by the above expect. |
| 3986 bool tile_is_visible = | 3989 bool tile_is_visible = |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4879 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4882 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4880 EXPECT_EQ(result.width(), 448); | 4883 EXPECT_EQ(result.width(), 448); |
| 4881 EXPECT_EQ(result.height(), 448); | 4884 EXPECT_EQ(result.height(), 448); |
| 4882 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4885 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4883 EXPECT_EQ(result.width(), 512); | 4886 EXPECT_EQ(result.width(), 512); |
| 4884 EXPECT_EQ(result.height(), 500 + 2); | 4887 EXPECT_EQ(result.height(), 500 + 2); |
| 4885 } | 4888 } |
| 4886 | 4889 |
| 4887 } // namespace | 4890 } // namespace |
| 4888 } // namespace cc | 4891 } // namespace cc |
| OLD | NEW |