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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 475 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
476 | 476 |
477 for (PictureLayerTiling::CoverageIterator | 477 for (PictureLayerTiling::CoverageIterator |
478 iter(tiling, | 478 iter(tiling, |
479 tiling->contents_scale(), | 479 tiling->contents_scale(), |
480 tiling->ContentRect()); | 480 tiling->ContentRect()); |
481 iter; | 481 iter; |
482 ++iter) { | 482 ++iter) { |
483 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); | 483 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); |
484 // Ensure there is a recording for this tile. | 484 // Ensure there is a recording for this tile. |
485 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), | 485 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
486 iter.full_tile_geometry_rect()); | 486 iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale()); |
487 bool in_active = active_pile->CanRaster(tiling->contents_scale(), | 487 layer_rect.Intersect(gfx::Rect(layer_bounds)); |
488 iter.full_tile_geometry_rect()); | 488 |
| 489 bool in_pending = pending_pile->recorded_region().Contains(layer_rect); |
| 490 bool in_active = active_pile->recorded_region().Contains(layer_rect); |
489 | 491 |
490 if (in_pending && !in_active) | 492 if (in_pending && !in_active) |
491 EXPECT_EQ(pending_pile, iter->picture_pile()); | 493 EXPECT_EQ(pending_pile, iter->picture_pile()); |
492 else if (in_active) | 494 else if (in_active) |
493 EXPECT_EQ(active_pile, iter->picture_pile()); | 495 EXPECT_EQ(active_pile, iter->picture_pile()); |
494 else | 496 else |
495 EXPECT_FALSE(*iter); | 497 EXPECT_FALSE(*iter); |
496 } | 498 } |
497 } | 499 } |
498 } | 500 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 } | 620 } |
619 | 621 |
620 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 622 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
621 // This test makes sure that if a layer can have tilings, then a commit makes | 623 // This test makes sure that if a layer can have tilings, then a commit makes |
622 // it not able to have tilings (empty size), and then a future commit that | 624 // it not able to have tilings (empty size), and then a future commit that |
623 // makes it valid again should be able to create tilings. | 625 // makes it valid again should be able to create tilings. |
624 gfx::Size tile_size(400, 400); | 626 gfx::Size tile_size(400, 400); |
625 gfx::Size layer_bounds(1300, 1900); | 627 gfx::Size layer_bounds(1300, 1900); |
626 | 628 |
627 scoped_refptr<FakePicturePileImpl> empty_pile = | 629 scoped_refptr<FakePicturePileImpl> empty_pile = |
628 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 630 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 0)); |
629 scoped_refptr<FakePicturePileImpl> valid_pile = | 631 scoped_refptr<FakePicturePileImpl> valid_pile = |
630 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 632 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
631 | 633 |
632 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 634 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
633 EXPECT_LT(low_res_factor, 1.f); | 635 EXPECT_LT(low_res_factor, 1.f); |
634 | 636 |
635 float high_res_scale = 1.3f; | 637 float high_res_scale = 1.3f; |
636 float low_res_scale = high_res_scale * low_res_factor; | 638 float low_res_scale = high_res_scale * low_res_factor; |
637 float device_scale = 1.7f; | 639 float device_scale = 1.7f; |
638 float page_scale = 3.2f; | 640 float page_scale = 3.2f; |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 pending_layer_->MarkVisibleResourcesAsRequired(); | 1307 pending_layer_->MarkVisibleResourcesAsRequired(); |
1306 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1308 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1307 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1309 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1308 } | 1310 } |
1309 | 1311 |
1310 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 1312 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
1311 gfx::Size layer_bounds(400, 400); | 1313 gfx::Size layer_bounds(400, 400); |
1312 gfx::Size tile_size(100, 100); | 1314 gfx::Size tile_size(100, 100); |
1313 scoped_refptr<FakePicturePileImpl> pending_pile = | 1315 scoped_refptr<FakePicturePileImpl> pending_pile = |
1314 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1316 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1315 // This pile will create tilings, but has no recordings so will not create any | 1317 // An arbitrary bogus outside the layer recording. Enough for the layer to |
1316 // tiles. This is attempting to simulate scrolling past the end of recorded | 1318 // think it can create tiles, but not in bounds so all tiles are null. |
1317 // content on the active layer, where the recordings are so far away that | 1319 Region active_recorded_region; |
1318 // no tiles are created. | 1320 active_recorded_region.Union(gfx::Rect(1000, 1000, 1, 1)); |
1319 scoped_refptr<FakePicturePileImpl> active_pile = | 1321 scoped_refptr<FakePicturePileImpl> active_pile = |
1320 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1322 FakePicturePileImpl::CreatePileWithRecordedRegion( |
1321 tile_size, layer_bounds); | 1323 tile_size, layer_bounds, active_recorded_region); |
1322 SetupTrees(pending_pile, active_pile); | 1324 SetupTrees(pending_pile, active_pile); |
1323 pending_layer_->set_fixed_tile_size(tile_size); | 1325 pending_layer_->set_fixed_tile_size(tile_size); |
1324 active_layer_->set_fixed_tile_size(tile_size); | 1326 active_layer_->set_fixed_tile_size(tile_size); |
1325 | 1327 |
1326 CreateHighLowResAndSetAllTilesVisible(); | 1328 CreateHighLowResAndSetAllTilesVisible(); |
1327 | 1329 |
1328 // Active layer has tilings, but no tiles due to missing recordings. | 1330 // Active layer has tilings, but no tiles due to missing recordings. |
1329 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1331 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
1330 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 1332 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
1331 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 1333 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
1332 | 1334 |
1333 // Since the active layer has no tiles at all, the pending layer doesn't | 1335 // Since the active layer has no tiles at all, the pending layer doesn't |
1334 // need content in order to activate. | 1336 // need content in order to activate. This is attempting to simulate |
| 1337 // scrolling past the end of recorded content on the active layer. |
1335 pending_layer_->MarkVisibleResourcesAsRequired(); | 1338 pending_layer_->MarkVisibleResourcesAsRequired(); |
1336 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1339 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1337 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1340 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1338 } | 1341 } |
1339 | 1342 |
1340 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1343 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
1341 gfx::Size layer_bounds(400, 400); | 1344 gfx::Size layer_bounds(400, 400); |
1342 gfx::Size tile_size(100, 100); | 1345 gfx::Size tile_size(100, 100); |
1343 scoped_refptr<FakePicturePileImpl> pending_pile = | 1346 scoped_refptr<FakePicturePileImpl> pending_pile = |
1344 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1347 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 TestContextProvider::Create(), NULL)); | 1547 TestContextProvider::Create(), NULL)); |
1545 | 1548 |
1546 // These will crash PictureLayerImpl if this is not true. | 1549 // These will crash PictureLayerImpl if this is not true. |
1547 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 1550 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
1548 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 1551 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
1549 host_impl_.active_tree()->UpdateDrawProperties(); | 1552 host_impl_.active_tree()->UpdateDrawProperties(); |
1550 } | 1553 } |
1551 | 1554 |
1552 } // namespace | 1555 } // namespace |
1553 } // namespace cc | 1556 } // namespace cc |
OLD | NEW |