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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 pending_layer()->viewport_rect_for_tile_priority_in_content_space()); | 1652 pending_layer()->viewport_rect_for_tile_priority_in_content_space()); |
1653 | 1653 |
1654 base::TimeTicks time_ticks; | 1654 base::TimeTicks time_ticks; |
1655 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1655 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1656 pending_layer()->UpdateTiles(); | 1656 pending_layer()->UpdateTiles(); |
1657 | 1657 |
1658 int num_visible = 0; | 1658 int num_visible = 0; |
1659 int num_offscreen = 0; | 1659 int num_offscreen = 0; |
1660 | 1660 |
1661 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 1661 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
1662 pending_layer()->picture_layer_tiling_set(), false)); | 1662 pending_layer()->picture_layer_tiling_set(), false, false)); |
1663 for (; !queue->IsEmpty(); queue->Pop()) { | 1663 for (; !queue->IsEmpty(); queue->Pop()) { |
1664 const PrioritizedTile& prioritized_tile = queue->Top(); | 1664 const PrioritizedTile& prioritized_tile = queue->Top(); |
1665 DCHECK(prioritized_tile.tile()); | 1665 DCHECK(prioritized_tile.tile()); |
1666 if (prioritized_tile.priority().distance_to_visible == 0.f) { | 1666 if (prioritized_tile.priority().distance_to_visible == 0.f) { |
1667 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); | 1667 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
1668 num_visible++; | 1668 num_visible++; |
1669 } else { | 1669 } else { |
1670 EXPECT_FALSE(prioritized_tile.tile()->required_for_activation()); | 1670 EXPECT_FALSE(prioritized_tile.tile()->required_for_activation()); |
1671 num_offscreen++; | 1671 num_offscreen++; |
1672 } | 1672 } |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 SetupPendingTree(pending_raster_source); | 2746 SetupPendingTree(pending_raster_source); |
2747 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 2747 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
2748 | 2748 |
2749 std::set<Tile*> unique_tiles; | 2749 std::set<Tile*> unique_tiles; |
2750 bool reached_prepaint = false; | 2750 bool reached_prepaint = false; |
2751 int non_ideal_tile_count = 0u; | 2751 int non_ideal_tile_count = 0u; |
2752 int low_res_tile_count = 0u; | 2752 int low_res_tile_count = 0u; |
2753 int high_res_tile_count = 0u; | 2753 int high_res_tile_count = 0u; |
2754 int high_res_now_tiles = 0u; | 2754 int high_res_now_tiles = 0u; |
2755 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 2755 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
2756 pending_layer()->picture_layer_tiling_set(), false)); | 2756 pending_layer()->picture_layer_tiling_set(), false, false)); |
2757 while (!queue->IsEmpty()) { | 2757 while (!queue->IsEmpty()) { |
2758 PrioritizedTile prioritized_tile = queue->Top(); | 2758 PrioritizedTile prioritized_tile = queue->Top(); |
2759 TilePriority priority = prioritized_tile.priority(); | 2759 TilePriority priority = prioritized_tile.priority(); |
2760 | 2760 |
2761 EXPECT_TRUE(prioritized_tile.tile()); | 2761 EXPECT_TRUE(prioritized_tile.tile()); |
2762 | 2762 |
2763 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2763 // Non-high res tiles only get visible tiles. Also, prepaint should only |
2764 // come at the end of the iteration. | 2764 // come at the end of the iteration. |
2765 if (priority.resolution != HIGH_RESOLUTION) { | 2765 if (priority.resolution != HIGH_RESOLUTION) { |
2766 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2766 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 // No NOW tiles. | 2817 // No NOW tiles. |
2818 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 2818 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
2819 | 2819 |
2820 pending_layer()->draw_properties().visible_layer_rect = | 2820 pending_layer()->draw_properties().visible_layer_rect = |
2821 gfx::Rect(1100, 1100, 500, 500); | 2821 gfx::Rect(1100, 1100, 500, 500); |
2822 pending_layer()->UpdateTiles(); | 2822 pending_layer()->UpdateTiles(); |
2823 | 2823 |
2824 unique_tiles.clear(); | 2824 unique_tiles.clear(); |
2825 high_res_tile_count = 0u; | 2825 high_res_tile_count = 0u; |
2826 queue.reset(new TilingSetRasterQueueAll( | 2826 queue.reset(new TilingSetRasterQueueAll( |
2827 pending_layer()->picture_layer_tiling_set(), false)); | 2827 pending_layer()->picture_layer_tiling_set(), false, false)); |
2828 while (!queue->IsEmpty()) { | 2828 while (!queue->IsEmpty()) { |
2829 PrioritizedTile prioritized_tile = queue->Top(); | 2829 PrioritizedTile prioritized_tile = queue->Top(); |
2830 TilePriority priority = prioritized_tile.priority(); | 2830 TilePriority priority = prioritized_tile.priority(); |
2831 | 2831 |
2832 EXPECT_TRUE(prioritized_tile.tile()); | 2832 EXPECT_TRUE(prioritized_tile.tile()); |
2833 | 2833 |
2834 // Non-high res tiles only get visible tiles. | 2834 // Non-high res tiles only get visible tiles. |
2835 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); | 2835 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); |
2836 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2836 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
2837 | 2837 |
(...skipping 16 matching lines...) Expand all Loading... |
2854 pending_layer()->HighResTiling()->AllTilesForTesting(); | 2854 pending_layer()->HighResTiling()->AllTilesForTesting(); |
2855 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); | 2855 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); |
2856 tile_it != high_res_tiles.end(); | 2856 tile_it != high_res_tiles.end(); |
2857 ++tile_it) { | 2857 ++tile_it) { |
2858 Tile* tile = *tile_it; | 2858 Tile* tile = *tile_it; |
2859 TileDrawInfo& draw_info = tile->draw_info(); | 2859 TileDrawInfo& draw_info = tile->draw_info(); |
2860 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2860 draw_info.SetSolidColorForTesting(SK_ColorRED); |
2861 } | 2861 } |
2862 | 2862 |
2863 queue.reset(new TilingSetRasterQueueAll( | 2863 queue.reset(new TilingSetRasterQueueAll( |
2864 pending_layer()->picture_layer_tiling_set(), true)); | 2864 pending_layer()->picture_layer_tiling_set(), true, false)); |
2865 EXPECT_TRUE(queue->IsEmpty()); | 2865 EXPECT_TRUE(queue->IsEmpty()); |
2866 } | 2866 } |
2867 | 2867 |
2868 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) { | 2868 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) { |
2869 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 2869 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
2870 | 2870 |
2871 host_impl()->SetViewportSize(gfx::Size(500, 500)); | 2871 host_impl()->SetViewportSize(gfx::Size(500, 500)); |
2872 | 2872 |
2873 gfx::Size layer_bounds(1000, 1000); | 2873 gfx::Size layer_bounds(1000, 1000); |
2874 | 2874 |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3708 | 3708 |
3709 host_impl()->SetViewportSize(viewport_size); | 3709 host_impl()->SetViewportSize(viewport_size); |
3710 | 3710 |
3711 scoped_refptr<FakeRasterSource> pending_raster_source = | 3711 scoped_refptr<FakeRasterSource> pending_raster_source = |
3712 FakeRasterSource::CreateFilled(layer_bounds); | 3712 FakeRasterSource::CreateFilled(layer_bounds); |
3713 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 3713 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
3714 | 3714 |
3715 // No occlusion. | 3715 // No occlusion. |
3716 int unoccluded_tile_count = 0; | 3716 int unoccluded_tile_count = 0; |
3717 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 3717 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
3718 pending_layer()->picture_layer_tiling_set(), false)); | 3718 pending_layer()->picture_layer_tiling_set(), false, false)); |
3719 while (!queue->IsEmpty()) { | 3719 while (!queue->IsEmpty()) { |
3720 PrioritizedTile prioritized_tile = queue->Top(); | 3720 PrioritizedTile prioritized_tile = queue->Top(); |
3721 Tile* tile = prioritized_tile.tile(); | 3721 Tile* tile = prioritized_tile.tile(); |
3722 | 3722 |
3723 // Occluded tiles should not be iterated over. | 3723 // Occluded tiles should not be iterated over. |
3724 EXPECT_FALSE(prioritized_tile.is_occluded()); | 3724 EXPECT_FALSE(prioritized_tile.is_occluded()); |
3725 | 3725 |
3726 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3726 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
3727 // visible and at least partially unoccluded, verified by the above expect. | 3727 // visible and at least partially unoccluded, verified by the above expect. |
3728 bool tile_is_visible = | 3728 bool tile_is_visible = |
(...skipping 13 matching lines...) Expand all Loading... |
3742 layer1->SetContentsOpaque(true); | 3742 layer1->SetContentsOpaque(true); |
3743 layer1->SetPosition(occluding_layer_position); | 3743 layer1->SetPosition(occluding_layer_position); |
3744 | 3744 |
3745 RebuildPropertyTreesOnPendingTree(); | 3745 RebuildPropertyTreesOnPendingTree(); |
3746 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 3746 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
3747 bool update_lcd_text = false; | 3747 bool update_lcd_text = false; |
3748 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 3748 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
3749 | 3749 |
3750 unoccluded_tile_count = 0; | 3750 unoccluded_tile_count = 0; |
3751 queue.reset(new TilingSetRasterQueueAll( | 3751 queue.reset(new TilingSetRasterQueueAll( |
3752 pending_layer()->picture_layer_tiling_set(), false)); | 3752 pending_layer()->picture_layer_tiling_set(), false, false)); |
3753 while (!queue->IsEmpty()) { | 3753 while (!queue->IsEmpty()) { |
3754 PrioritizedTile prioritized_tile = queue->Top(); | 3754 PrioritizedTile prioritized_tile = queue->Top(); |
3755 Tile* tile = prioritized_tile.tile(); | 3755 Tile* tile = prioritized_tile.tile(); |
3756 | 3756 |
3757 EXPECT_FALSE(prioritized_tile.is_occluded()); | 3757 EXPECT_FALSE(prioritized_tile.is_occluded()); |
3758 | 3758 |
3759 bool tile_is_visible = | 3759 bool tile_is_visible = |
3760 tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); | 3760 tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); |
3761 if (tile_is_visible) | 3761 if (tile_is_visible) |
3762 unoccluded_tile_count++; | 3762 unoccluded_tile_count++; |
3763 queue->Pop(); | 3763 queue->Pop(); |
3764 } | 3764 } |
3765 EXPECT_EQ(20, unoccluded_tile_count); | 3765 EXPECT_EQ(20, unoccluded_tile_count); |
3766 | 3766 |
3767 // Full occlusion. | 3767 // Full occlusion. |
3768 layer1->SetPosition(gfx::PointF()); | 3768 layer1->SetPosition(gfx::PointF()); |
3769 layer1->NoteLayerPropertyChanged(); | 3769 layer1->NoteLayerPropertyChanged(); |
3770 | 3770 |
3771 RebuildPropertyTreesOnPendingTree(); | 3771 RebuildPropertyTreesOnPendingTree(); |
3772 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 3772 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
3773 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 3773 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
3774 | 3774 |
3775 unoccluded_tile_count = 0; | 3775 unoccluded_tile_count = 0; |
3776 queue.reset(new TilingSetRasterQueueAll( | 3776 queue.reset(new TilingSetRasterQueueAll( |
3777 pending_layer()->picture_layer_tiling_set(), false)); | 3777 pending_layer()->picture_layer_tiling_set(), false, false)); |
3778 while (!queue->IsEmpty()) { | 3778 while (!queue->IsEmpty()) { |
3779 PrioritizedTile prioritized_tile = queue->Top(); | 3779 PrioritizedTile prioritized_tile = queue->Top(); |
3780 Tile* tile = prioritized_tile.tile(); | 3780 Tile* tile = prioritized_tile.tile(); |
3781 | 3781 |
3782 EXPECT_FALSE(prioritized_tile.is_occluded()); | 3782 EXPECT_FALSE(prioritized_tile.is_occluded()); |
3783 | 3783 |
3784 bool tile_is_visible = | 3784 bool tile_is_visible = |
3785 tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); | 3785 tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); |
3786 if (tile_is_visible) | 3786 if (tile_is_visible) |
3787 unoccluded_tile_count++; | 3787 unoccluded_tile_count++; |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5144 EXPECT_EQ(gfx::AxisTransform2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), | 5144 EXPECT_EQ(gfx::AxisTransform2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), |
5145 tiling->raster_transform()); | 5145 tiling->raster_transform()); |
5146 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | 5146 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
5147 for (auto* tile : tiling->AllTilesForTesting()) | 5147 for (auto* tile : tiling->AllTilesForTesting()) |
5148 EXPECT_EQ(tile->raster_transform(), tiling->raster_transform()); | 5148 EXPECT_EQ(tile->raster_transform(), tiling->raster_transform()); |
5149 } | 5149 } |
5150 } | 5150 } |
5151 | 5151 |
5152 } // namespace | 5152 } // namespace |
5153 } // namespace cc | 5153 } // namespace cc |
OLD | NEW |