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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 scoped_ptr<FakePictureLayerImpl> pending_layer; | 241 scoped_ptr<FakePictureLayerImpl> pending_layer; |
242 DCHECK(!pending_root || pending_root->id() == root_id_); | 242 DCHECK(!pending_root || pending_root->id() == root_id_); |
243 if (!pending_root) { | 243 if (!pending_root) { |
244 pending_root = LayerImpl::Create(pending_tree, root_id_); | 244 pending_root = LayerImpl::Create(pending_tree, root_id_); |
245 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); | 245 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); |
246 if (!tile_size.IsEmpty()) | 246 if (!tile_size.IsEmpty()) |
247 pending_layer->set_fixed_tile_size(tile_size); | 247 pending_layer->set_fixed_tile_size(tile_size); |
248 pending_layer->SetDrawsContent(true); | 248 pending_layer->SetDrawsContent(true); |
249 } else { | 249 } else { |
250 pending_layer.reset(static_cast<FakePictureLayerImpl*>( | 250 pending_layer.reset(static_cast<FakePictureLayerImpl*>( |
251 pending_root->RemoveChild(pending_root->children()[0]).release())); | 251 pending_root->RemoveChild(pending_root->children()[0].get()) |
| 252 .release())); |
252 if (!tile_size.IsEmpty()) | 253 if (!tile_size.IsEmpty()) |
253 pending_layer->set_fixed_tile_size(tile_size); | 254 pending_layer->set_fixed_tile_size(tile_size); |
254 } | 255 } |
255 pending_root->SetHasRenderSurface(true); | 256 pending_root->SetHasRenderSurface(true); |
256 // The bounds() just mirror the raster source size. | 257 // The bounds() just mirror the raster source size. |
257 pending_layer->SetBounds(raster_source->GetSize()); | 258 pending_layer->SetBounds(raster_source->GetSize()); |
258 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); | 259 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); |
259 | 260 |
260 pending_root->AddChild(pending_layer.Pass()); | 261 pending_root->AddChild(pending_layer.Pass()); |
261 pending_tree->SetRootLayer(pending_root.Pass()); | 262 pending_tree->SetRootLayer(pending_root.Pass()); |
(...skipping 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3967 bool tile_is_visible = | 3968 bool tile_is_visible = |
3968 tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); | 3969 tile->content_rect().Intersects(pending_layer_->visible_layer_rect()); |
3969 if (tile_is_visible) | 3970 if (tile_is_visible) |
3970 unoccluded_tile_count++; | 3971 unoccluded_tile_count++; |
3971 queue->Pop(); | 3972 queue->Pop(); |
3972 } | 3973 } |
3973 EXPECT_EQ(unoccluded_tile_count, 25); | 3974 EXPECT_EQ(unoccluded_tile_count, 25); |
3974 | 3975 |
3975 // Partial occlusion. | 3976 // Partial occlusion. |
3976 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 3977 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
3977 LayerImpl* layer1 = pending_layer_->children()[0]; | 3978 LayerImpl* layer1 = pending_layer_->children()[0].get(); |
3978 layer1->SetBounds(layer_bounds); | 3979 layer1->SetBounds(layer_bounds); |
3979 layer1->SetDrawsContent(true); | 3980 layer1->SetDrawsContent(true); |
3980 layer1->SetContentsOpaque(true); | 3981 layer1->SetContentsOpaque(true); |
3981 layer1->SetPosition(occluding_layer_position); | 3982 layer1->SetPosition(occluding_layer_position); |
3982 | 3983 |
3983 RebuildPropertyTreesOnPendingTree(); | 3984 RebuildPropertyTreesOnPendingTree(); |
3984 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 3985 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
3985 bool update_lcd_text = false; | 3986 bool update_lcd_text = false; |
3986 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 3987 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
3987 | 3988 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 if (prioritized_tiles[tile].is_occluded()) { | 4062 if (prioritized_tiles[tile].is_occluded()) { |
4062 EXPECT_FALSE(tile->required_for_activation()); | 4063 EXPECT_FALSE(tile->required_for_activation()); |
4063 occluded_tile_count++; | 4064 occluded_tile_count++; |
4064 } | 4065 } |
4065 } | 4066 } |
4066 EXPECT_EQ(occluded_tile_count, 0); | 4067 EXPECT_EQ(occluded_tile_count, 0); |
4067 } | 4068 } |
4068 | 4069 |
4069 // Partial occlusion. | 4070 // Partial occlusion. |
4070 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 4071 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
4071 LayerImpl* layer1 = pending_layer_->children()[0]; | 4072 LayerImpl* layer1 = pending_layer_->children()[0].get(); |
4072 layer1->SetBounds(layer_bounds); | 4073 layer1->SetBounds(layer_bounds); |
4073 layer1->SetDrawsContent(true); | 4074 layer1->SetDrawsContent(true); |
4074 layer1->SetContentsOpaque(true); | 4075 layer1->SetContentsOpaque(true); |
4075 layer1->SetPosition(occluding_layer_position); | 4076 layer1->SetPosition(occluding_layer_position); |
4076 | 4077 |
4077 RebuildPropertyTreesOnPendingTree(); | 4078 RebuildPropertyTreesOnPendingTree(); |
4078 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 4079 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
4079 bool update_lcd_text = false; | 4080 bool update_lcd_text = false; |
4080 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4081 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
4081 | 4082 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4157 | 4158 |
4158 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 4159 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
4159 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 4160 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
4160 | 4161 |
4161 host_impl_.SetViewportSize(viewport_size); | 4162 host_impl_.SetViewportSize(viewport_size); |
4162 | 4163 |
4163 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 4164 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
4164 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 4165 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
4165 | 4166 |
4166 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 4167 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
4167 LayerImpl* layer1 = pending_layer_->children()[0]; | 4168 LayerImpl* layer1 = pending_layer_->children()[0].get(); |
4168 layer1->SetBounds(layer_bounds); | 4169 layer1->SetBounds(layer_bounds); |
4169 layer1->SetDrawsContent(true); | 4170 layer1->SetDrawsContent(true); |
4170 layer1->SetContentsOpaque(true); | 4171 layer1->SetContentsOpaque(true); |
4171 layer1->SetPosition(occluding_layer_position); | 4172 layer1->SetPosition(occluding_layer_position); |
4172 | 4173 |
4173 pending_layer_->tilings()->RemoveAllTilings(); | 4174 pending_layer_->tilings()->RemoveAllTilings(); |
4174 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 4175 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
4175 pending_layer_->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); | 4176 pending_layer_->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); |
4176 pending_layer_->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); | 4177 pending_layer_->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); |
4177 pending_layer_->AddTiling(0.7f)->set_resolution(HIGH_RESOLUTION); | 4178 pending_layer_->AddTiling(0.7f)->set_resolution(HIGH_RESOLUTION); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4232 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 4233 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
4233 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 4234 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
4234 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = | 4235 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = |
4235 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 4236 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
4236 | 4237 |
4237 host_impl_.SetViewportSize(viewport_size); | 4238 host_impl_.SetViewportSize(viewport_size); |
4238 SetupPendingTree(active_raster_source); | 4239 SetupPendingTree(active_raster_source); |
4239 | 4240 |
4240 // Partially occlude the active layer. | 4241 // Partially occlude the active layer. |
4241 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4242 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
4242 LayerImpl* layer1 = pending_layer_->children()[0]; | 4243 LayerImpl* layer1 = pending_layer_->children()[0].get(); |
4243 layer1->SetBounds(layer_bounds); | 4244 layer1->SetBounds(layer_bounds); |
4244 layer1->SetDrawsContent(true); | 4245 layer1->SetDrawsContent(true); |
4245 layer1->SetContentsOpaque(true); | 4246 layer1->SetContentsOpaque(true); |
4246 layer1->SetPosition(occluding_layer_position); | 4247 layer1->SetPosition(occluding_layer_position); |
4247 | 4248 |
4248 ActivateTree(); | 4249 ActivateTree(); |
4249 | 4250 |
4250 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4251 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
4251 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4252 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
4252 auto prioritized_tiles = | 4253 auto prioritized_tiles = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4325 | 4326 |
4326 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 4327 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
4327 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 4328 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
4328 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = | 4329 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = |
4329 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 4330 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
4330 | 4331 |
4331 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); | 4332 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region()); |
4332 | 4333 |
4333 // Partially occlude the active layer. | 4334 // Partially occlude the active layer. |
4334 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4335 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
4335 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; | 4336 LayerImpl* active_occluding_layer = pending_layer_->children()[0].get(); |
4336 active_occluding_layer->SetBounds(layer_bounds); | 4337 active_occluding_layer->SetBounds(layer_bounds); |
4337 active_occluding_layer->SetDrawsContent(true); | 4338 active_occluding_layer->SetDrawsContent(true); |
4338 active_occluding_layer->SetContentsOpaque(true); | 4339 active_occluding_layer->SetContentsOpaque(true); |
4339 active_occluding_layer->SetPosition(active_occluding_layer_position); | 4340 active_occluding_layer->SetPosition(active_occluding_layer_position); |
4340 | 4341 |
4341 ActivateTree(); | 4342 ActivateTree(); |
4342 | 4343 |
4343 // Partially invalidate the pending layer. Tiles inside the invalidation rect | 4344 // Partially invalidate the pending layer. Tiles inside the invalidation rect |
4344 // are created. | 4345 // are created. |
4345 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, | 4346 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, |
4346 invalidation_rect); | 4347 invalidation_rect); |
4347 | 4348 |
4348 // Partially occlude the pending layer in a different way. | 4349 // Partially occlude the pending layer in a different way. |
4349 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); | 4350 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); |
4350 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; | 4351 LayerImpl* pending_occluding_layer = pending_layer_->children()[0].get(); |
4351 pending_occluding_layer->SetBounds(layer_bounds); | 4352 pending_occluding_layer->SetBounds(layer_bounds); |
4352 pending_occluding_layer->SetDrawsContent(true); | 4353 pending_occluding_layer->SetDrawsContent(true); |
4353 pending_occluding_layer->SetContentsOpaque(true); | 4354 pending_occluding_layer->SetContentsOpaque(true); |
4354 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4355 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
4355 | 4356 |
4356 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 4357 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
4357 EXPECT_EQ(2u, active_layer_->num_tilings()); | 4358 EXPECT_EQ(2u, active_layer_->num_tilings()); |
4358 | 4359 |
4359 RebuildPropertyTreesOnPendingTree(); | 4360 RebuildPropertyTreesOnPendingTree(); |
4360 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 4361 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5040 // New low res tiling. | 5041 // New low res tiling. |
5041 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 5042 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
5042 | 5043 |
5043 // This tiling will be high res now, it won't contain low res content since it | 5044 // This tiling will be high res now, it won't contain low res content since it |
5044 // was all destroyed. | 5045 // was all destroyed. |
5045 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 5046 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
5046 } | 5047 } |
5047 | 5048 |
5048 } // namespace | 5049 } // namespace |
5049 } // namespace cc | 5050 } // namespace cc |
OLD | NEW |