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 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2697 | 2697 |
| 2698 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 2698 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
| 2699 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 2699 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
| 2700 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2700 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 2701 | 2701 |
| 2702 unique_tiles.insert(tile); | 2702 unique_tiles.insert(tile); |
| 2703 } | 2703 } |
| 2704 | 2704 |
| 2705 EXPECT_TRUE(reached_prepaint); | 2705 EXPECT_TRUE(reached_prepaint); |
| 2706 EXPECT_EQ(0u, non_ideal_tile_count); | 2706 EXPECT_EQ(0u, non_ideal_tile_count); |
| 2707 EXPECT_EQ(1u, low_res_tile_count); | 2707 EXPECT_EQ(0u, low_res_tile_count); |
| 2708 EXPECT_EQ(16u, high_res_tile_count); | 2708 EXPECT_EQ(16u, high_res_tile_count); |
| 2709 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, | 2709 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, |
| 2710 unique_tiles.size()); | 2710 unique_tiles.size()); |
| 2711 | 2711 |
| 2712 // No NOW tiles. | 2712 // No NOW tiles. |
| 2713 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2713 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2714 host_impl_.SetCurrentBeginFrameArgs( | 2714 host_impl_.SetCurrentBeginFrameArgs( |
| 2715 CreateBeginFrameArgsForTesting(time_ticks)); | 2715 CreateBeginFrameArgsForTesting(time_ticks)); |
| 2716 | 2716 |
| 2717 pending_layer_->draw_properties().visible_content_rect = | 2717 pending_layer_->draw_properties().visible_content_rect = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2754 tile_it != high_res_tiles.end(); | 2754 tile_it != high_res_tiles.end(); |
| 2755 ++tile_it) { | 2755 ++tile_it) { |
| 2756 Tile* tile = *tile_it; | 2756 Tile* tile = *tile_it; |
| 2757 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); | 2757 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
| 2758 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2758 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 2759 } | 2759 } |
| 2760 | 2760 |
| 2761 non_ideal_tile_count = 0; | 2761 non_ideal_tile_count = 0; |
| 2762 low_res_tile_count = 0; | 2762 low_res_tile_count = 0; |
| 2763 high_res_tile_count = 0; | 2763 high_res_tile_count = 0; |
| 2764 for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 2764 for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, true); it; |
| 2765 it; | |
| 2766 ++it) { | 2765 ++it) { |
| 2767 Tile* tile = *it; | 2766 Tile* tile = *it; |
| 2768 TilePriority priority = tile->priority(PENDING_TREE); | 2767 TilePriority priority = tile->priority(PENDING_TREE); |
| 2769 | 2768 |
| 2770 EXPECT_TRUE(tile); | 2769 EXPECT_TRUE(tile); |
| 2771 | 2770 |
| 2772 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 2771 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
| 2773 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 2772 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
| 2774 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2773 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 2775 } | 2774 } |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3787 // Occluded tiles should not be iterated over. | 3786 // Occluded tiles should not be iterated over. |
| 3788 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3787 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 3789 | 3788 |
| 3790 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3789 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 3791 // visible and at least partially unoccluded, verified by the above expect. | 3790 // visible and at least partially unoccluded, verified by the above expect. |
| 3792 bool tile_is_visible = | 3791 bool tile_is_visible = |
| 3793 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3792 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 3794 if (tile_is_visible) | 3793 if (tile_is_visible) |
| 3795 unoccluded_tile_count++; | 3794 unoccluded_tile_count++; |
| 3796 } | 3795 } |
| 3797 EXPECT_EQ(unoccluded_tile_count, 25 + 4); | 3796 EXPECT_EQ(unoccluded_tile_count, 25); |
|
danakj
2014/10/22 14:27:40
LGTM if there's still a test somewhere for the cas
vmpstr
2014/10/22 14:40:17
Yeah, there are some tests for smoothness as well.
| |
| 3798 | 3797 |
| 3799 // Partial occlusion. | 3798 // Partial occlusion. |
| 3800 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 3799 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
| 3801 LayerImpl* layer1 = pending_layer_->children()[0]; | 3800 LayerImpl* layer1 = pending_layer_->children()[0]; |
| 3802 layer1->SetBounds(layer_bounds); | 3801 layer1->SetBounds(layer_bounds); |
| 3803 layer1->SetContentBounds(layer_bounds); | 3802 layer1->SetContentBounds(layer_bounds); |
| 3804 layer1->SetDrawsContent(true); | 3803 layer1->SetDrawsContent(true); |
| 3805 layer1->SetContentsOpaque(true); | 3804 layer1->SetContentsOpaque(true); |
| 3806 layer1->SetPosition(occluding_layer_position); | 3805 layer1->SetPosition(occluding_layer_position); |
| 3807 | 3806 |
| 3808 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3807 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3809 host_impl_.SetCurrentBeginFrameArgs( | 3808 host_impl_.SetCurrentBeginFrameArgs( |
| 3810 CreateBeginFrameArgsForTesting(time_ticks)); | 3809 CreateBeginFrameArgsForTesting(time_ticks)); |
| 3811 host_impl_.pending_tree()->UpdateDrawProperties(); | 3810 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 3812 | 3811 |
| 3813 unoccluded_tile_count = 0; | 3812 unoccluded_tile_count = 0; |
| 3814 for (PictureLayerImpl::LayerRasterTileIterator it = | 3813 for (PictureLayerImpl::LayerRasterTileIterator it = |
| 3815 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 3814 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
| 3816 it; | 3815 it; |
| 3817 ++it) { | 3816 ++it) { |
| 3818 Tile* tile = *it; | 3817 Tile* tile = *it; |
| 3819 | 3818 |
| 3820 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3819 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 3821 | 3820 |
| 3822 bool tile_is_visible = | 3821 bool tile_is_visible = |
| 3823 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3822 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 3824 if (tile_is_visible) | 3823 if (tile_is_visible) |
| 3825 unoccluded_tile_count++; | 3824 unoccluded_tile_count++; |
| 3826 } | 3825 } |
| 3827 EXPECT_EQ(20 + 2, unoccluded_tile_count); | 3826 EXPECT_EQ(20, unoccluded_tile_count); |
| 3828 | 3827 |
| 3829 // Full occlusion. | 3828 // Full occlusion. |
| 3830 layer1->SetPosition(gfx::Point(0, 0)); | 3829 layer1->SetPosition(gfx::Point(0, 0)); |
| 3831 | 3830 |
| 3832 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3831 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3833 host_impl_.SetCurrentBeginFrameArgs( | 3832 host_impl_.SetCurrentBeginFrameArgs( |
| 3834 CreateBeginFrameArgsForTesting(time_ticks)); | 3833 CreateBeginFrameArgsForTesting(time_ticks)); |
| 3835 host_impl_.pending_tree()->UpdateDrawProperties(); | 3834 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 3836 | 3835 |
| 3837 unoccluded_tile_count = 0; | 3836 unoccluded_tile_count = 0; |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4550 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4549 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4551 EXPECT_EQ(result.width(), 448); | 4550 EXPECT_EQ(result.width(), 448); |
| 4552 EXPECT_EQ(result.height(), 448); | 4551 EXPECT_EQ(result.height(), 448); |
| 4553 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4552 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4554 EXPECT_EQ(result.width(), 512); | 4553 EXPECT_EQ(result.width(), 512); |
| 4555 EXPECT_EQ(result.height(), 500 + 2); | 4554 EXPECT_EQ(result.height(), 500 + 2); |
| 4556 } | 4555 } |
| 4557 | 4556 |
| 4558 } // namespace | 4557 } // namespace |
| 4559 } // namespace cc | 4558 } // namespace cc |
| OLD | NEW |