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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 482 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
483 | 483 |
484 for (PictureLayerTiling::CoverageIterator | 484 for (PictureLayerTiling::CoverageIterator |
485 iter(tiling, | 485 iter(tiling, |
486 tiling->contents_scale(), | 486 tiling->contents_scale(), |
487 tiling->ContentRect()); | 487 tiling->ContentRect()); |
488 iter; | 488 iter; |
489 ++iter) { | 489 ++iter) { |
490 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); | 490 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); |
491 // Ensure there is a recording for this tile. | 491 // Ensure there is a recording for this tile. |
492 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 492 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), |
493 iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale()); | 493 iter.full_tile_geometry_rect()); |
494 layer_rect.Intersect(gfx::Rect(layer_bounds)); | 494 bool in_active = active_pile->CanRaster(tiling->contents_scale(), |
495 | 495 iter.full_tile_geometry_rect()); |
496 bool in_pending = pending_pile->recorded_region().Contains(layer_rect); | |
497 bool in_active = active_pile->recorded_region().Contains(layer_rect); | |
498 | 496 |
499 if (in_pending && !in_active) | 497 if (in_pending && !in_active) |
500 EXPECT_EQ(pending_pile, iter->picture_pile()); | 498 EXPECT_EQ(pending_pile, iter->picture_pile()); |
501 else if (in_active) | 499 else if (in_active) |
502 EXPECT_EQ(active_pile, iter->picture_pile()); | 500 EXPECT_EQ(active_pile, iter->picture_pile()); |
503 else | 501 else |
504 EXPECT_FALSE(*iter); | 502 EXPECT_FALSE(*iter); |
505 } | 503 } |
506 } | 504 } |
507 } | 505 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 } | 625 } |
628 | 626 |
629 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 627 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
630 // This test makes sure that if a layer can have tilings, then a commit makes | 628 // This test makes sure that if a layer can have tilings, then a commit makes |
631 // it not able to have tilings (empty size), and then a future commit that | 629 // it not able to have tilings (empty size), and then a future commit that |
632 // makes it valid again should be able to create tilings. | 630 // makes it valid again should be able to create tilings. |
633 gfx::Size tile_size(400, 400); | 631 gfx::Size tile_size(400, 400); |
634 gfx::Size layer_bounds(1300, 1900); | 632 gfx::Size layer_bounds(1300, 1900); |
635 | 633 |
636 scoped_refptr<FakePicturePileImpl> empty_pile = | 634 scoped_refptr<FakePicturePileImpl> empty_pile = |
637 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 0)); | 635 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
638 scoped_refptr<FakePicturePileImpl> valid_pile = | 636 scoped_refptr<FakePicturePileImpl> valid_pile = |
639 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 637 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
640 | 638 |
641 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 639 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
642 EXPECT_LT(low_res_factor, 1.f); | 640 EXPECT_LT(low_res_factor, 1.f); |
643 | 641 |
644 float high_res_scale = 1.3f; | 642 float high_res_scale = 1.3f; |
645 float low_res_scale = high_res_scale * low_res_factor; | 643 float low_res_scale = high_res_scale * low_res_factor; |
646 float device_scale = 1.7f; | 644 float device_scale = 1.7f; |
647 float page_scale = 3.2f; | 645 float page_scale = 3.2f; |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 pending_layer_->MarkVisibleResourcesAsRequired(); | 1312 pending_layer_->MarkVisibleResourcesAsRequired(); |
1315 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1313 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1316 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1314 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1317 } | 1315 } |
1318 | 1316 |
1319 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 1317 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
1320 gfx::Size layer_bounds(400, 400); | 1318 gfx::Size layer_bounds(400, 400); |
1321 gfx::Size tile_size(100, 100); | 1319 gfx::Size tile_size(100, 100); |
1322 scoped_refptr<FakePicturePileImpl> pending_pile = | 1320 scoped_refptr<FakePicturePileImpl> pending_pile = |
1323 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1321 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1324 // An arbitrary bogus outside the layer recording. Enough for the layer to | 1322 // This pile will create tilings, but has no recordings so will not create any |
1325 // think it can create tiles, but not in bounds so all tiles are null. | 1323 // tiles. This is attempting to simulate scrolling past the end of recorded |
1326 Region active_recorded_region; | 1324 // content on the active layer, where the recordings are so far away that |
1327 active_recorded_region.Union(gfx::Rect(1000, 1000, 1, 1)); | 1325 // no tiles are created. |
1328 scoped_refptr<FakePicturePileImpl> active_pile = | 1326 scoped_refptr<FakePicturePileImpl> active_pile = |
1329 FakePicturePileImpl::CreatePileWithRecordedRegion( | 1327 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1330 tile_size, layer_bounds, active_recorded_region); | 1328 tile_size, layer_bounds); |
1331 SetupTrees(pending_pile, active_pile); | 1329 SetupTrees(pending_pile, active_pile); |
1332 pending_layer_->set_fixed_tile_size(tile_size); | 1330 pending_layer_->set_fixed_tile_size(tile_size); |
1333 active_layer_->set_fixed_tile_size(tile_size); | 1331 active_layer_->set_fixed_tile_size(tile_size); |
1334 | 1332 |
1335 CreateHighLowResAndSetAllTilesVisible(); | 1333 CreateHighLowResAndSetAllTilesVisible(); |
1336 | 1334 |
1337 // Active layer has tilings, but no tiles due to missing recordings. | 1335 // Active layer has tilings, but no tiles due to missing recordings. |
1338 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1336 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
1339 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 1337 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
1340 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 1338 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
1341 | 1339 |
1342 // Since the active layer has no tiles at all, the pending layer doesn't | 1340 // Since the active layer has no tiles at all, the pending layer doesn't |
1343 // need content in order to activate. This is attempting to simulate | 1341 // need content in order to activate. |
1344 // scrolling past the end of recorded content on the active layer. | |
1345 pending_layer_->MarkVisibleResourcesAsRequired(); | 1342 pending_layer_->MarkVisibleResourcesAsRequired(); |
1346 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1343 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1347 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1344 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1348 } | 1345 } |
1349 | 1346 |
1350 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1347 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
1351 gfx::Size layer_bounds(400, 400); | 1348 gfx::Size layer_bounds(400, 400); |
1352 gfx::Size tile_size(100, 100); | 1349 gfx::Size tile_size(100, 100); |
1353 scoped_refptr<FakePicturePileImpl> pending_pile = | 1350 scoped_refptr<FakePicturePileImpl> pending_pile = |
1354 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1351 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 // Should still have the high-res tiling. | 1605 // Should still have the high-res tiling. |
1609 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1606 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
1610 pending_layer_->CalculateContentsScale( | 1607 pending_layer_->CalculateContentsScale( |
1611 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1608 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
1612 // Should still only have the high-res tiling. | 1609 // Should still only have the high-res tiling. |
1613 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1610 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
1614 } | 1611 } |
1615 | 1612 |
1616 } // namespace | 1613 } // namespace |
1617 } // namespace cc | 1614 } // namespace cc |
OLD | NEW |