| 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 3676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3687 // visible and at least partially unoccluded, verified by the above expect. | 3687 // visible and at least partially unoccluded, verified by the above expect. |
| 3688 bool tile_is_visible = | 3688 bool tile_is_visible = |
| 3689 tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); | 3689 tile->content_rect().Intersects(pending_layer()->visible_layer_rect()); |
| 3690 if (tile_is_visible) | 3690 if (tile_is_visible) |
| 3691 unoccluded_tile_count++; | 3691 unoccluded_tile_count++; |
| 3692 queue->Pop(); | 3692 queue->Pop(); |
| 3693 } | 3693 } |
| 3694 EXPECT_EQ(unoccluded_tile_count, 25); | 3694 EXPECT_EQ(unoccluded_tile_count, 25); |
| 3695 | 3695 |
| 3696 // Partial occlusion. | 3696 // Partial occlusion. |
| 3697 pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 1)); | 3697 pending_layer()->test_properties()->AddChild( |
| 3698 LayerImpl::Create(host_impl()->pending_tree(), 1)); |
| 3698 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; | 3699 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; |
| 3699 layer1->SetBounds(layer_bounds); | 3700 layer1->SetBounds(layer_bounds); |
| 3700 layer1->SetDrawsContent(true); | 3701 layer1->SetDrawsContent(true); |
| 3701 layer1->SetContentsOpaque(true); | 3702 layer1->SetContentsOpaque(true); |
| 3702 layer1->SetPosition(occluding_layer_position); | 3703 layer1->SetPosition(occluding_layer_position); |
| 3703 | 3704 |
| 3704 RebuildPropertyTreesOnPendingTree(); | 3705 RebuildPropertyTreesOnPendingTree(); |
| 3705 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 3706 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
| 3706 bool update_lcd_text = false; | 3707 bool update_lcd_text = false; |
| 3707 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 3708 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3782 // Fully occluded tiles are not required for activation. | 3783 // Fully occluded tiles are not required for activation. |
| 3783 if (prioritized_tiles[tile].is_occluded()) { | 3784 if (prioritized_tiles[tile].is_occluded()) { |
| 3784 EXPECT_FALSE(tile->required_for_activation()); | 3785 EXPECT_FALSE(tile->required_for_activation()); |
| 3785 occluded_tile_count++; | 3786 occluded_tile_count++; |
| 3786 } | 3787 } |
| 3787 } | 3788 } |
| 3788 EXPECT_EQ(occluded_tile_count, 0); | 3789 EXPECT_EQ(occluded_tile_count, 0); |
| 3789 } | 3790 } |
| 3790 | 3791 |
| 3791 // Partial occlusion. | 3792 // Partial occlusion. |
| 3792 pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 1)); | 3793 pending_layer()->test_properties()->AddChild( |
| 3794 LayerImpl::Create(host_impl()->pending_tree(), 1)); |
| 3793 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; | 3795 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; |
| 3794 layer1->SetBounds(layer_bounds); | 3796 layer1->SetBounds(layer_bounds); |
| 3795 layer1->SetDrawsContent(true); | 3797 layer1->SetDrawsContent(true); |
| 3796 layer1->SetContentsOpaque(true); | 3798 layer1->SetContentsOpaque(true); |
| 3797 layer1->SetPosition(occluding_layer_position); | 3799 layer1->SetPosition(occluding_layer_position); |
| 3798 | 3800 |
| 3799 RebuildPropertyTreesOnPendingTree(); | 3801 RebuildPropertyTreesOnPendingTree(); |
| 3800 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 3802 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
| 3801 bool update_lcd_text = false; | 3803 bool update_lcd_text = false; |
| 3802 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 3804 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3879 gfx::PointF occluding_layer_position(310.f, 0.f); | 3881 gfx::PointF occluding_layer_position(310.f, 0.f); |
| 3880 | 3882 |
| 3881 scoped_refptr<FakeRasterSource> pending_raster_source = | 3883 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 3882 FakeRasterSource::CreateFilled(layer_bounds); | 3884 FakeRasterSource::CreateFilled(layer_bounds); |
| 3883 | 3885 |
| 3884 host_impl()->SetViewportSize(viewport_size); | 3886 host_impl()->SetViewportSize(viewport_size); |
| 3885 | 3887 |
| 3886 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 3888 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 3887 ASSERT_TRUE(pending_layer()->CanHaveTilings()); | 3889 ASSERT_TRUE(pending_layer()->CanHaveTilings()); |
| 3888 | 3890 |
| 3889 pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 1)); | 3891 pending_layer()->test_properties()->AddChild( |
| 3892 LayerImpl::Create(host_impl()->pending_tree(), 1)); |
| 3890 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; | 3893 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; |
| 3891 layer1->SetBounds(layer_bounds); | 3894 layer1->SetBounds(layer_bounds); |
| 3892 layer1->SetDrawsContent(true); | 3895 layer1->SetDrawsContent(true); |
| 3893 layer1->SetContentsOpaque(true); | 3896 layer1->SetContentsOpaque(true); |
| 3894 layer1->SetPosition(occluding_layer_position); | 3897 layer1->SetPosition(occluding_layer_position); |
| 3895 | 3898 |
| 3896 pending_layer()->tilings()->RemoveAllTilings(); | 3899 pending_layer()->tilings()->RemoveAllTilings(); |
| 3897 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 3900 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 3898 pending_layer()->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); | 3901 pending_layer()->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); |
| 3899 pending_layer()->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); | 3902 pending_layer()->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3954 | 3957 |
| 3955 scoped_refptr<FakeRasterSource> pending_raster_source = | 3958 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 3956 FakeRasterSource::CreateFilled(layer_bounds); | 3959 FakeRasterSource::CreateFilled(layer_bounds); |
| 3957 scoped_refptr<FakeRasterSource> active_raster_source = | 3960 scoped_refptr<FakeRasterSource> active_raster_source = |
| 3958 FakeRasterSource::CreateFilled(layer_bounds); | 3961 FakeRasterSource::CreateFilled(layer_bounds); |
| 3959 | 3962 |
| 3960 host_impl()->SetViewportSize(viewport_size); | 3963 host_impl()->SetViewportSize(viewport_size); |
| 3961 SetupPendingTree(active_raster_source); | 3964 SetupPendingTree(active_raster_source); |
| 3962 | 3965 |
| 3963 // Partially occlude the active layer. | 3966 // Partially occlude the active layer. |
| 3964 pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 2)); | 3967 pending_layer()->test_properties()->AddChild( |
| 3968 LayerImpl::Create(host_impl()->pending_tree(), 2)); |
| 3965 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; | 3969 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; |
| 3966 layer1->SetBounds(layer_bounds); | 3970 layer1->SetBounds(layer_bounds); |
| 3967 layer1->SetDrawsContent(true); | 3971 layer1->SetDrawsContent(true); |
| 3968 layer1->SetContentsOpaque(true); | 3972 layer1->SetContentsOpaque(true); |
| 3969 layer1->SetPosition(occluding_layer_position); | 3973 layer1->SetPosition(occluding_layer_position); |
| 3970 | 3974 |
| 3971 ActivateTree(); | 3975 ActivateTree(); |
| 3972 | 3976 |
| 3973 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { | 3977 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { |
| 3974 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); | 3978 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4048 SetInitialDeviceScaleFactor(2.f); | 4052 SetInitialDeviceScaleFactor(2.f); |
| 4049 | 4053 |
| 4050 scoped_refptr<FakeRasterSource> pending_raster_source = | 4054 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 4051 FakeRasterSource::CreateFilled(layer_bounds); | 4055 FakeRasterSource::CreateFilled(layer_bounds); |
| 4052 scoped_refptr<FakeRasterSource> active_raster_source = | 4056 scoped_refptr<FakeRasterSource> active_raster_source = |
| 4053 FakeRasterSource::CreateFilled(layer_bounds); | 4057 FakeRasterSource::CreateFilled(layer_bounds); |
| 4054 | 4058 |
| 4055 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); | 4059 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); |
| 4056 | 4060 |
| 4057 // Partially occlude the active layer. | 4061 // Partially occlude the active layer. |
| 4058 pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 2)); | 4062 pending_layer()->test_properties()->AddChild( |
| 4063 LayerImpl::Create(host_impl()->pending_tree(), 2)); |
| 4059 LayerImpl* active_occluding_layer = | 4064 LayerImpl* active_occluding_layer = |
| 4060 pending_layer()->test_properties()->children[0]; | 4065 pending_layer()->test_properties()->children[0]; |
| 4061 active_occluding_layer->SetBounds(layer_bounds); | 4066 active_occluding_layer->SetBounds(layer_bounds); |
| 4062 active_occluding_layer->SetDrawsContent(true); | 4067 active_occluding_layer->SetDrawsContent(true); |
| 4063 active_occluding_layer->SetContentsOpaque(true); | 4068 active_occluding_layer->SetContentsOpaque(true); |
| 4064 active_occluding_layer->SetPosition(active_occluding_layer_position); | 4069 active_occluding_layer->SetPosition(active_occluding_layer_position); |
| 4065 | 4070 |
| 4066 ActivateTree(); | 4071 ActivateTree(); |
| 4067 | 4072 |
| 4068 // Partially invalidate the pending layer. Tiles inside the invalidation rect | 4073 // Partially invalidate the pending layer. Tiles inside the invalidation rect |
| 4069 // are created. | 4074 // are created. |
| 4070 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, | 4075 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, |
| 4071 invalidation_rect); | 4076 invalidation_rect); |
| 4072 | 4077 |
| 4073 // Partially occlude the pending layer in a different way. | 4078 // Partially occlude the pending layer in a different way. |
| 4074 pending_layer()->AddChild(LayerImpl::Create(host_impl()->pending_tree(), 3)); | 4079 pending_layer()->test_properties()->AddChild( |
| 4080 LayerImpl::Create(host_impl()->pending_tree(), 3)); |
| 4075 LayerImpl* pending_occluding_layer = | 4081 LayerImpl* pending_occluding_layer = |
| 4076 pending_layer()->test_properties()->children[0]; | 4082 pending_layer()->test_properties()->children[0]; |
| 4077 pending_occluding_layer->SetBounds(layer_bounds); | 4083 pending_occluding_layer->SetBounds(layer_bounds); |
| 4078 pending_occluding_layer->SetDrawsContent(true); | 4084 pending_occluding_layer->SetDrawsContent(true); |
| 4079 pending_occluding_layer->SetContentsOpaque(true); | 4085 pending_occluding_layer->SetContentsOpaque(true); |
| 4080 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4086 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
| 4081 | 4087 |
| 4082 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 4088 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
| 4083 EXPECT_EQ(2u, active_layer()->num_tilings()); | 4089 EXPECT_EQ(2u, active_layer()->num_tilings()); |
| 4084 | 4090 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4762 // New low res tiling. | 4768 // New low res tiling. |
| 4763 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 4769 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
| 4764 | 4770 |
| 4765 // This tiling will be high res now, it won't contain low res content since it | 4771 // This tiling will be high res now, it won't contain low res content since it |
| 4766 // was all destroyed. | 4772 // was all destroyed. |
| 4767 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 4773 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
| 4768 } | 4774 } |
| 4769 | 4775 |
| 4770 } // namespace | 4776 } // namespace |
| 4771 } // namespace cc | 4777 } // namespace cc |
| OLD | NEW |