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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1359 | 1359 |
1360 AppendQuadsData data; | 1360 AppendQuadsData data; |
1361 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); | 1361 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); |
1362 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 1362 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
1363 active_layer_->DidDraw(NULL); | 1363 active_layer_->DidDraw(NULL); |
1364 | 1364 |
1365 ASSERT_EQ(1U, render_pass->quad_list.size()); | 1365 ASSERT_EQ(1U, render_pass->quad_list.size()); |
1366 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); | 1366 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); |
1367 } | 1367 } |
1368 | 1368 |
1369 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { | |
1370 gfx::Size tile_size(100, 100); | |
1371 gfx::Size layer_bounds(1000, 1000); | |
1372 | |
1373 scoped_refptr<FakePicturePileImpl> pending_pile = | |
1374 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
1375 // Layers with entirely empty piles can't get tilings. | |
1376 pending_pile->AddRecordingAt(0, 0); | |
1377 | |
1378 SetupPendingTree(pending_pile); | |
1379 | |
1380 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
1381 pending_layer_->AddTiling(1.0f); | |
1382 pending_layer_->AddTiling(2.0f); | |
1383 | |
1384 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
1385 // on a layer with no recordings. | |
1386 host_impl_.pending_tree()->UpdateDrawProperties(); | |
1387 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1388 } | |
1389 | |
1390 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1369 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
1391 gfx::Size tile_size(100, 100); | 1370 gfx::Size tile_size(100, 100); |
1392 gfx::Size layer_bounds(200, 200); | 1371 gfx::Size layer_bounds(200, 200); |
1393 | 1372 |
1394 scoped_refptr<FakePicturePileImpl> pending_pile = | 1373 scoped_refptr<FakePicturePileImpl> pending_pile = |
1395 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1374 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1396 SetupPendingTree(pending_pile); | 1375 SetupPendingTree(pending_pile); |
1397 | 1376 |
1398 pending_layer_->set_fixed_tile_size(tile_size); | 1377 pending_layer_->set_fixed_tile_size(tile_size); |
1399 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1378 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
1400 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1379 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
1401 host_impl_.pending_tree()->UpdateDrawProperties(); | 1380 host_impl_.pending_tree()->UpdateDrawProperties(); |
1402 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); | |
danakj
2014/08/18 19:29:13
Why not?
| |
1403 | |
1404 pending_layer_->draw_properties().visible_content_rect = | 1381 pending_layer_->draw_properties().visible_content_rect = |
1405 gfx::Rect(0, 0, 100, 200); | 1382 gfx::Rect(0, 0, 100, 200); |
1406 | 1383 base::TimeTicks time_ticks; |
1407 // Fake set priorities. | 1384 time_ticks += base::TimeDelta::FromMilliseconds(16); |
1408 for (PictureLayerTiling::CoverageIterator iter( | 1385 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
1409 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | 1386 pending_layer_->UpdateTiles(NULL); |
1410 iter; | 1387 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); |
1411 ++iter) { | |
1412 if (!*iter) | |
1413 continue; | |
1414 Tile* tile = *iter; | |
1415 TilePriority priority; | |
1416 priority.resolution = HIGH_RESOLUTION; | |
1417 gfx::Rect tile_bounds = iter.geometry_rect(); | |
1418 if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) { | |
1419 priority.priority_bin = TilePriority::NOW; | |
1420 priority.distance_to_visible = 0.f; | |
1421 } else { | |
1422 priority.priority_bin = TilePriority::SOON; | |
1423 priority.distance_to_visible = 1.f; | |
1424 } | |
1425 tile->SetPriority(PENDING_TREE, priority); | |
1426 } | |
1427 | |
1428 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1429 | 1388 |
1430 int num_visible = 0; | 1389 int num_visible = 0; |
1431 int num_offscreen = 0; | 1390 int num_offscreen = 0; |
1432 | 1391 |
1433 for (PictureLayerTiling::CoverageIterator iter( | 1392 for (PictureLayerTiling::TilingRasterTileIterator iter(tiling, PENDING_TREE); |
1434 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | |
1435 iter; | 1393 iter; |
1436 ++iter) { | 1394 ++iter) { |
1437 if (!*iter) | |
1438 continue; | |
1439 const Tile* tile = *iter; | 1395 const Tile* tile = *iter; |
1396 DCHECK(tile); | |
1440 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1397 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
1441 EXPECT_TRUE(tile->required_for_activation()); | 1398 EXPECT_TRUE(tile->required_for_activation()); |
danakj
2014/08/18 19:29:13
Why isn't this doing tiling->IsTileRequiredForActi
vmpstr
2014/08/18 19:49:52
The idea, which is kind of subtle unfortunately is
| |
1442 num_visible++; | 1399 num_visible++; |
1443 } else { | 1400 } else { |
1444 EXPECT_FALSE(tile->required_for_activation()); | 1401 EXPECT_FALSE(tile->required_for_activation()); |
1445 num_offscreen++; | 1402 num_offscreen++; |
1446 } | 1403 } |
1447 } | 1404 } |
1448 | 1405 |
1449 EXPECT_GT(num_visible, 0); | 1406 EXPECT_GT(num_visible, 0); |
1450 EXPECT_GT(num_offscreen, 0); | 1407 EXPECT_GT(num_offscreen, 0); |
1451 } | 1408 } |
1452 | 1409 |
1453 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 1410 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { |
1454 gfx::Size layer_bounds(400, 400); | 1411 gfx::Size layer_bounds(400, 400); |
1455 gfx::Size tile_size(100, 100); | 1412 gfx::Size tile_size(100, 100); |
1456 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1413 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1457 | 1414 |
1458 // No tiles shared. | 1415 // No tiles shared. |
1459 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); | 1416 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); |
1460 | 1417 |
1461 CreateHighLowResAndSetAllTilesVisible(); | 1418 CreateHighLowResAndSetAllTilesVisible(); |
1462 | 1419 |
1463 active_layer_->SetAllTilesReady(); | 1420 active_layer_->SetAllTilesReady(); |
1464 | 1421 |
1465 // No shared tiles and all active tiles ready, so pending can only | 1422 // No shared tiles and all active tiles ready, so pending can only |
1466 // activate with all high res tiles. | 1423 // activate with all high res tiles. |
1467 pending_layer_->MarkVisibleResourcesAsRequired(); | 1424 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1468 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1425 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1426 | |
1427 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1469 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1428 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1470 } | 1429 } |
1471 | 1430 |
1472 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 1431 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
1473 gfx::Size layer_bounds(400, 400); | 1432 gfx::Size layer_bounds(400, 400); |
1474 gfx::Size tile_size(100, 100); | 1433 gfx::Size tile_size(100, 100); |
1475 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1434 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1476 | 1435 |
1477 // All tiles shared (no invalidation). | 1436 // All tiles shared (no invalidation). |
1478 CreateHighLowResAndSetAllTilesVisible(); | 1437 CreateHighLowResAndSetAllTilesVisible(); |
1479 | 1438 |
1480 // Verify active tree not ready. | 1439 // Verify active tree not ready. |
1481 Tile* some_active_tile = | 1440 Tile* some_active_tile = |
1482 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1441 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1483 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1442 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1484 | 1443 |
1485 // When high res are required, even if the active tree is not ready, | 1444 // When high res are required, even if the active tree is not ready, |
1486 // the high res tiles must be ready. | 1445 // the high res tiles must be ready. |
1487 host_impl_.active_tree()->SetRequiresHighResToDraw(); | 1446 host_impl_.active_tree()->SetRequiresHighResToDraw(); |
1488 pending_layer_->MarkVisibleResourcesAsRequired(); | 1447 |
1448 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1489 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1449 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1450 | |
1451 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1490 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1452 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1491 } | 1453 } |
1492 | 1454 |
1493 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { | 1455 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
1494 gfx::Size layer_bounds(400, 400); | 1456 gfx::Size layer_bounds(400, 400); |
1495 gfx::Size tile_size(100, 100); | 1457 gfx::Size tile_size(100, 100); |
1496 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1458 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1497 | 1459 |
1498 CreateHighLowResAndSetAllTilesVisible(); | 1460 CreateHighLowResAndSetAllTilesVisible(); |
1499 | 1461 |
1500 Tile* some_active_tile = | 1462 Tile* some_active_tile = |
1501 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1463 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1502 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1464 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1503 | 1465 |
1504 // All tiles shared (no invalidation), so even though the active tree's | 1466 // All tiles shared (no invalidation), so even though the active tree's |
1505 // tiles aren't ready, there is nothing required. | 1467 // tiles aren't ready, there is nothing required. |
1506 pending_layer_->MarkVisibleResourcesAsRequired(); | 1468 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1507 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1469 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1470 | |
1471 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1508 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1472 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1509 } | 1473 } |
1510 | 1474 |
1511 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 1475 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
1512 gfx::Size layer_bounds(400, 400); | 1476 gfx::Size layer_bounds(400, 400); |
1513 gfx::Size tile_size(100, 100); | 1477 gfx::Size tile_size(100, 100); |
1514 scoped_refptr<FakePicturePileImpl> pending_pile = | 1478 scoped_refptr<FakePicturePileImpl> pending_pile = |
1515 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1479 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1516 // This pile will create tilings, but has no recordings so will not create any | 1480 // This pile will create tilings, but has no recordings so will not create any |
1517 // tiles. This is attempting to simulate scrolling past the end of recorded | 1481 // tiles. This is attempting to simulate scrolling past the end of recorded |
1518 // content on the active layer, where the recordings are so far away that | 1482 // content on the active layer, where the recordings are so far away that |
1519 // no tiles are created. | 1483 // no tiles are created. |
1520 scoped_refptr<FakePicturePileImpl> active_pile = | 1484 scoped_refptr<FakePicturePileImpl> active_pile = |
1521 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1485 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1522 tile_size, layer_bounds); | 1486 tile_size, layer_bounds); |
1523 SetupTrees(pending_pile, active_pile); | 1487 SetupTrees(pending_pile, active_pile); |
1524 pending_layer_->set_fixed_tile_size(tile_size); | 1488 pending_layer_->set_fixed_tile_size(tile_size); |
1525 active_layer_->set_fixed_tile_size(tile_size); | 1489 active_layer_->set_fixed_tile_size(tile_size); |
1526 | 1490 |
1527 CreateHighLowResAndSetAllTilesVisible(); | 1491 CreateHighLowResAndSetAllTilesVisible(); |
1528 | 1492 |
1529 // Active layer has tilings, but no tiles due to missing recordings. | 1493 // Active layer has tilings, but no tiles due to missing recordings. |
1530 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1494 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
1531 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 1495 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
1532 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 1496 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
1533 | 1497 |
1534 // Since the active layer has no tiles at all, the pending layer doesn't | 1498 // Since the active layer has no tiles at all, the pending layer doesn't |
1535 // need content in order to activate. | 1499 // need content in order to activate. |
1536 pending_layer_->MarkVisibleResourcesAsRequired(); | 1500 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1537 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1501 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1502 | |
1503 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1538 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1504 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1539 } | 1505 } |
1540 | 1506 |
1541 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1507 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
1542 gfx::Size layer_bounds(400, 400); | 1508 gfx::Size layer_bounds(400, 400); |
1543 gfx::Size tile_size(100, 100); | 1509 gfx::Size tile_size(100, 100); |
1544 scoped_refptr<FakePicturePileImpl> pending_pile = | 1510 scoped_refptr<FakePicturePileImpl> pending_pile = |
1545 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1511 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1546 scoped_refptr<FakePicturePileImpl> active_pile = | 1512 scoped_refptr<FakePicturePileImpl> active_pile = |
1547 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1513 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
1548 SetupTrees(pending_pile, active_pile); | 1514 SetupTrees(pending_pile, active_pile); |
1549 pending_layer_->set_fixed_tile_size(tile_size); | 1515 pending_layer_->set_fixed_tile_size(tile_size); |
1550 active_layer_->set_fixed_tile_size(tile_size); | 1516 active_layer_->set_fixed_tile_size(tile_size); |
1551 | 1517 |
1552 CreateHighLowResAndSetAllTilesVisible(); | 1518 CreateHighLowResAndSetAllTilesVisible(); |
1553 | 1519 |
1554 // Active layer can't have tiles. | 1520 // Active layer can't have tiles. |
1555 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1521 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
1556 | 1522 |
1557 // All high res tiles required. This should be considered identical | 1523 // All high res tiles required. This should be considered identical |
1558 // to the case where there is no active layer, to avoid flashing content. | 1524 // to the case where there is no active layer, to avoid flashing content. |
1559 // This can happen if a layer exists for a while and switches from | 1525 // This can happen if a layer exists for a while and switches from |
1560 // not being able to have content to having content. | 1526 // not being able to have content to having content. |
1561 pending_layer_->MarkVisibleResourcesAsRequired(); | 1527 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1562 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1528 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1529 | |
1530 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1563 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1531 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1564 } | 1532 } |
1565 | 1533 |
1566 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { | 1534 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
1567 gfx::Size layer_bounds(200, 200); | 1535 gfx::Size layer_bounds(200, 200); |
1568 gfx::Size tile_size(100, 100); | 1536 gfx::Size tile_size(100, 100); |
1569 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1537 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1570 | 1538 |
1571 gfx::Size pending_layer_bounds(400, 400); | 1539 gfx::Size pending_layer_bounds(400, 400); |
1572 pending_layer_->SetBounds(pending_layer_bounds); | 1540 pending_layer_->SetBounds(pending_layer_bounds); |
1573 | 1541 |
1574 CreateHighLowResAndSetAllTilesVisible(); | 1542 CreateHighLowResAndSetAllTilesVisible(); |
1543 pending_layer_->HighResTiling()->UpdateTilePriorities( | |
danakj
2014/08/18 19:29:13
Can you explain why this is needed here but Update
vmpstr
2014/08/18 19:49:52
This is for the tiling to get new bounds. All othe
| |
1544 PENDING_TREE, | |
1545 gfx::Rect(pending_layer_bounds), | |
1546 1.f, | |
1547 1.f, | |
1548 NULL, | |
1549 NULL, | |
1550 gfx::Transform()); | |
1551 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1575 | 1552 |
1576 active_layer_->SetAllTilesReady(); | 1553 active_layer_->SetAllTilesReady(); |
1577 | 1554 |
1578 // Since the active layer has different bounds, the pending layer needs all | 1555 // Since the active layer has different bounds, the pending layer needs all |
1579 // high res tiles in order to activate. | 1556 // high res tiles in order to activate. |
1580 pending_layer_->MarkVisibleResourcesAsRequired(); | 1557 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1581 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1558 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1559 | |
1560 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
1582 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1561 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1583 } | 1562 } |
1584 | 1563 |
1585 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 1564 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
1586 gfx::Size tile_size(100, 100); | 1565 gfx::Size tile_size(100, 100); |
1587 gfx::Size layer_bounds(400, 400); | 1566 gfx::Size layer_bounds(400, 400); |
1588 scoped_refptr<FakePicturePileImpl> pending_pile = | 1567 scoped_refptr<FakePicturePileImpl> pending_pile = |
1589 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1568 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1590 | 1569 |
1591 host_impl_.CreatePendingTree(); | 1570 host_impl_.CreatePendingTree(); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2259 for (size_t i = 0; i < tilings.size(); ++i) { | 2238 for (size_t i = 0; i < tilings.size(); ++i) { |
2260 PictureLayerTiling* tiling = tilings.at(i); | 2239 PictureLayerTiling* tiling = tilings.at(i); |
2261 for (PictureLayerTiling::CoverageIterator iter( | 2240 for (PictureLayerTiling::CoverageIterator iter( |
2262 tiling, | 2241 tiling, |
2263 pending_layer_->contents_scale_x(), | 2242 pending_layer_->contents_scale_x(), |
2264 pending_layer_->visible_content_rect()); | 2243 pending_layer_->visible_content_rect()); |
2265 iter; | 2244 iter; |
2266 ++iter) { | 2245 ++iter) { |
2267 if (mark_required) { | 2246 if (mark_required) { |
2268 number_of_marked_tiles++; | 2247 number_of_marked_tiles++; |
2269 iter->MarkRequiredForActivation(); | 2248 iter->set_required_for_activation(true); |
2270 } else { | 2249 } else { |
2271 number_of_unmarked_tiles++; | 2250 number_of_unmarked_tiles++; |
2272 } | 2251 } |
2273 mark_required = !mark_required; | 2252 mark_required = !mark_required; |
2274 } | 2253 } |
2275 } | 2254 } |
2276 | 2255 |
2277 // Sanity checks. | 2256 // Sanity checks. |
2278 EXPECT_EQ(91u, all_tiles.size()); | 2257 EXPECT_EQ(91u, all_tiles.size()); |
2279 EXPECT_EQ(91u, all_tiles_set.size()); | 2258 EXPECT_EQ(91u, all_tiles_set.size()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2474 gfx::Size tile_size(100, 100); | 2453 gfx::Size tile_size(100, 100); |
2475 gfx::Size layer_bounds(1000, 1000); | 2454 gfx::Size layer_bounds(1000, 1000); |
2476 | 2455 |
2477 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2456 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2478 | 2457 |
2479 // Make sure some tiles are not shared. | 2458 // Make sure some tiles are not shared. |
2480 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 2459 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
2481 | 2460 |
2482 CreateHighLowResAndSetAllTilesVisible(); | 2461 CreateHighLowResAndSetAllTilesVisible(); |
2483 active_layer_->SetAllTilesReady(); | 2462 active_layer_->SetAllTilesReady(); |
2484 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2485 | 2463 |
2486 // All pending layer tiles required are not ready. | 2464 // All pending layer tiles required are not ready. |
2487 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2465 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2488 | 2466 |
2489 // Initialize all low-res tiles. | 2467 // Initialize all low-res tiles. |
2490 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 2468 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
2491 | 2469 |
2492 // Low-res tiles should not be enough. | 2470 // Low-res tiles should not be enough. |
2493 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2471 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2494 | 2472 |
2495 // Initialize remaining tiles. | 2473 // Initialize remaining tiles. |
2496 pending_layer_->SetAllTilesReady(); | 2474 pending_layer_->SetAllTilesReady(); |
2497 | 2475 |
2498 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2476 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2499 } | 2477 } |
2500 | 2478 |
2501 TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { | 2479 TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { |
2502 gfx::Size tile_size(100, 100); | 2480 gfx::Size tile_size(100, 100); |
2503 gfx::Size layer_bounds(1000, 1000); | 2481 gfx::Size layer_bounds(1000, 1000); |
2504 | 2482 |
2505 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2483 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2506 | 2484 |
2507 // Make sure some tiles are not shared. | 2485 // Make sure some tiles are not shared. |
2508 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 2486 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
2509 | 2487 |
2510 CreateHighLowResAndSetAllTilesVisible(); | 2488 CreateHighLowResAndSetAllTilesVisible(); |
2511 active_layer_->SetAllTilesReady(); | 2489 active_layer_->SetAllTilesReady(); |
2512 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2513 | 2490 |
2514 // All pending layer tiles required are not ready. | 2491 // All pending layer tiles required are not ready. |
2515 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2492 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2516 | 2493 |
2517 // Initialize all high-res tiles. | 2494 // Initialize all high-res tiles. |
2518 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 2495 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
2519 | 2496 |
2520 // High-res tiles should not be enough. | 2497 // High-res tiles is enough. |
2521 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2498 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2522 | 2499 |
2523 // Initialize remaining tiles. | 2500 // Initialize remaining tiles. |
2524 pending_layer_->SetAllTilesReady(); | 2501 pending_layer_->SetAllTilesReady(); |
2525 | 2502 |
2526 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2503 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2527 } | 2504 } |
2528 | 2505 |
2529 class NoLowResTilingsSettings : public ImplSidePaintingSettings { | 2506 class NoLowResTilingsSettings : public ImplSidePaintingSettings { |
2530 public: | 2507 public: |
2531 NoLowResTilingsSettings() { create_low_res_tiling = false; } | 2508 NoLowResTilingsSettings() { create_low_res_tiling = false; } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2590 7.26f, // ideal contents scale | 2567 7.26f, // ideal contents scale |
2591 2.2f, // device scale | 2568 2.2f, // device scale |
2592 3.3f, // page scale | 2569 3.3f, // page scale |
2593 1.f, // maximum animation scale | 2570 1.f, // maximum animation scale |
2594 false); | 2571 false); |
2595 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 2572 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
2596 EXPECT_FLOAT_EQ(7.26f, | 2573 EXPECT_FLOAT_EQ(7.26f, |
2597 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2574 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
2598 } | 2575 } |
2599 | 2576 |
2600 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { | |
2601 gfx::Size tile_size(100, 100); | |
2602 gfx::Size layer_bounds(1000, 1000); | |
2603 | |
2604 scoped_refptr<FakePicturePileImpl> pending_pile = | |
2605 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
2606 // Layers with entirely empty piles can't get tilings. | |
2607 pending_pile->AddRecordingAt(0, 0); | |
2608 | |
2609 SetupPendingTree(pending_pile); | |
2610 | |
2611 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
2612 pending_layer_->AddTiling(1.0f); | |
2613 pending_layer_->AddTiling(2.0f); | |
2614 | |
2615 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
2616 // on a layer with no recordings. | |
2617 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2618 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2619 } | |
2620 | |
2621 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { | 2577 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
2622 gfx::Size layer_bounds(400, 400); | 2578 gfx::Size layer_bounds(400, 400); |
2623 gfx::Size tile_size(100, 100); | 2579 gfx::Size tile_size(100, 100); |
2624 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2580 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2625 | 2581 |
2626 CreateHighLowResAndSetAllTilesVisible(); | 2582 CreateHighLowResAndSetAllTilesVisible(); |
2627 | 2583 |
2628 Tile* some_active_tile = | 2584 Tile* some_active_tile = |
2629 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2585 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
2630 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2586 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
2631 | 2587 |
2632 // All tiles shared (no invalidation), so even though the active tree's | 2588 // All tiles shared (no invalidation), so even though the active tree's |
2633 // tiles aren't ready, there is nothing required. | 2589 // tiles aren't ready, there is nothing required. |
2634 pending_layer_->MarkVisibleResourcesAsRequired(); | 2590 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
2635 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2591 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2636 if (host_impl_.settings().create_low_res_tiling) { | 2592 if (host_impl_.settings().create_low_res_tiling) { |
2593 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
2637 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2594 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2638 } | 2595 } |
2639 } | 2596 } |
2640 | 2597 |
2641 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2598 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
2642 gfx::Size layer_bounds(400, 400); | 2599 gfx::Size layer_bounds(400, 400); |
2643 gfx::Size tile_size(100, 100); | 2600 gfx::Size tile_size(100, 100); |
2644 scoped_refptr<FakePicturePileImpl> pending_pile = | 2601 scoped_refptr<FakePicturePileImpl> pending_pile = |
2645 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2602 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2646 // This pile will create tilings, but has no recordings so will not create any | 2603 // This pile will create tilings, but has no recordings so will not create any |
(...skipping 10 matching lines...) Expand all Loading... | |
2657 CreateHighLowResAndSetAllTilesVisible(); | 2614 CreateHighLowResAndSetAllTilesVisible(); |
2658 | 2615 |
2659 // Active layer has tilings, but no tiles due to missing recordings. | 2616 // Active layer has tilings, but no tiles due to missing recordings. |
2660 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 2617 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
2661 EXPECT_EQ(active_layer_->tilings()->num_tilings(), | 2618 EXPECT_EQ(active_layer_->tilings()->num_tilings(), |
2662 host_impl_.settings().create_low_res_tiling ? 2u : 1u); | 2619 host_impl_.settings().create_low_res_tiling ? 2u : 1u); |
2663 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 2620 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
2664 | 2621 |
2665 // Since the active layer has no tiles at all, the pending layer doesn't | 2622 // Since the active layer has no tiles at all, the pending layer doesn't |
2666 // need content in order to activate. | 2623 // need content in order to activate. |
2667 pending_layer_->MarkVisibleResourcesAsRequired(); | 2624 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
2668 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2625 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2669 if (host_impl_.settings().create_low_res_tiling) | 2626 if (host_impl_.settings().create_low_res_tiling) { |
2627 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
2670 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2628 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2629 } | |
2671 } | 2630 } |
2672 | 2631 |
2673 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 2632 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
2674 base::TimeTicks time_ticks; | 2633 base::TimeTicks time_ticks; |
2675 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2634 time_ticks += base::TimeDelta::FromMilliseconds(1); |
2676 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 2635 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
2677 | 2636 |
2678 gfx::Size tile_size(100, 100); | 2637 gfx::Size tile_size(100, 100); |
2679 gfx::Size layer_bounds(400, 400); | 2638 gfx::Size layer_bounds(400, 400); |
2680 | 2639 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3304 layer1->SetDrawsContent(true); | 3263 layer1->SetDrawsContent(true); |
3305 layer1->SetContentsOpaque(true); | 3264 layer1->SetContentsOpaque(true); |
3306 layer1->SetPosition(occluding_layer_position); | 3265 layer1->SetPosition(occluding_layer_position); |
3307 | 3266 |
3308 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3267 time_ticks += base::TimeDelta::FromMilliseconds(200); |
3309 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 3268 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
3310 host_impl_.pending_tree()->UpdateDrawProperties(); | 3269 host_impl_.pending_tree()->UpdateDrawProperties(); |
3311 | 3270 |
3312 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3271 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3313 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3272 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
3273 tiling->UpdateAllTilePrioritiesForTesting(); | |
3314 | 3274 |
3315 occluded_tile_count = 0; | 3275 occluded_tile_count = 0; |
3316 for (PictureLayerTiling::CoverageIterator iter( | 3276 for (PictureLayerTiling::CoverageIterator iter( |
3317 tiling, | 3277 tiling, |
3318 pending_layer_->contents_scale_x(), | 3278 pending_layer_->contents_scale_x(), |
3319 gfx::Rect(layer_bounds)); | 3279 gfx::Rect(layer_bounds)); |
3320 iter; | 3280 iter; |
3321 ++iter) { | 3281 ++iter) { |
3322 if (!*iter) | 3282 if (!*iter) |
3323 continue; | 3283 continue; |
3324 const Tile* tile = *iter; | 3284 const Tile* tile = *iter; |
3325 | 3285 |
3326 if (tile->is_occluded(PENDING_TREE)) { | 3286 if (tile->is_occluded(PENDING_TREE)) { |
3327 EXPECT_FALSE(tile->required_for_activation()); | 3287 EXPECT_FALSE(tile->required_for_activation()); |
3328 occluded_tile_count++; | 3288 occluded_tile_count++; |
3329 } | 3289 } |
3330 } | 3290 } |
3331 switch (i) { | 3291 switch (i) { |
3332 case 0: | 3292 case 0: |
3333 EXPECT_EQ(occluded_tile_count, 5); | 3293 EXPECT_EQ(5, occluded_tile_count); |
3334 break; | 3294 break; |
3335 case 1: | 3295 case 1: |
3336 EXPECT_EQ(occluded_tile_count, 2); | 3296 EXPECT_EQ(2, occluded_tile_count); |
3337 break; | 3297 break; |
3338 default: | 3298 default: |
3339 NOTREACHED(); | 3299 NOTREACHED(); |
3340 } | 3300 } |
3341 } | 3301 } |
3342 | 3302 |
3343 // Full occlusion. | 3303 // Full occlusion. |
3344 layer1->SetPosition(gfx::PointF(0, 0)); | 3304 layer1->SetPosition(gfx::PointF(0, 0)); |
3345 | 3305 |
3346 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3306 time_ticks += base::TimeDelta::FromMilliseconds(200); |
3347 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 3307 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
3348 host_impl_.pending_tree()->UpdateDrawProperties(); | 3308 host_impl_.pending_tree()->UpdateDrawProperties(); |
3349 | 3309 |
3350 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3310 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3351 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3311 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
3312 tiling->UpdateAllTilePrioritiesForTesting(); | |
3352 | 3313 |
3353 occluded_tile_count = 0; | 3314 occluded_tile_count = 0; |
3354 for (PictureLayerTiling::CoverageIterator iter( | 3315 for (PictureLayerTiling::CoverageIterator iter( |
3355 tiling, | 3316 tiling, |
3356 pending_layer_->contents_scale_x(), | 3317 pending_layer_->contents_scale_x(), |
3357 gfx::Rect(layer_bounds)); | 3318 gfx::Rect(layer_bounds)); |
3358 iter; | 3319 iter; |
3359 ++iter) { | 3320 ++iter) { |
3360 if (!*iter) | 3321 if (!*iter) |
3361 continue; | 3322 continue; |
3362 const Tile* tile = *iter; | 3323 const Tile* tile = *iter; |
3363 | 3324 |
3364 if (tile->is_occluded(PENDING_TREE)) { | 3325 if (tile->is_occluded(PENDING_TREE)) { |
3365 EXPECT_FALSE(tile->required_for_activation()); | 3326 EXPECT_FALSE(tile->required_for_activation()); |
3366 occluded_tile_count++; | 3327 occluded_tile_count++; |
3367 } | 3328 } |
3368 } | 3329 } |
3369 switch (i) { | 3330 switch (i) { |
3370 case 0: | 3331 case 0: |
3371 EXPECT_EQ(occluded_tile_count, 25); | 3332 EXPECT_EQ(25, occluded_tile_count); |
3372 break; | 3333 break; |
3373 case 1: | 3334 case 1: |
3374 EXPECT_EQ(occluded_tile_count, 4); | 3335 EXPECT_EQ(4, occluded_tile_count); |
3375 break; | 3336 break; |
3376 default: | 3337 default: |
3377 NOTREACHED(); | 3338 NOTREACHED(); |
3378 } | 3339 } |
3379 } | 3340 } |
3380 } | 3341 } |
3381 | 3342 |
3382 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { | 3343 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { |
3383 gfx::Size tile_size(102, 102); | 3344 gfx::Size tile_size(102, 102); |
3384 gfx::Size layer_bounds(1000, 1000); | 3345 gfx::Size layer_bounds(1000, 1000); |
(...skipping 26 matching lines...) Expand all Loading... | |
3411 | 3372 |
3412 host_impl_.SetViewportSize(viewport_size); | 3373 host_impl_.SetViewportSize(viewport_size); |
3413 host_impl_.pending_tree()->UpdateDrawProperties(); | 3374 host_impl_.pending_tree()->UpdateDrawProperties(); |
3414 | 3375 |
3415 int tiling_count = 0; | 3376 int tiling_count = 0; |
3416 int occluded_tile_count = 0; | 3377 int occluded_tile_count = 0; |
3417 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 3378 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
3418 tilings.begin(); | 3379 tilings.begin(); |
3419 tiling_iterator != tilings.end(); | 3380 tiling_iterator != tilings.end(); |
3420 ++tiling_iterator) { | 3381 ++tiling_iterator) { |
3382 (*tiling_iterator)->UpdateAllTilePrioritiesForTesting(); | |
3421 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 3383 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
3422 | 3384 |
3423 occluded_tile_count = 0; | 3385 occluded_tile_count = 0; |
3424 for (size_t i = 0; i < tiles.size(); ++i) { | 3386 for (size_t i = 0; i < tiles.size(); ++i) { |
3425 if (tiles[i]->is_occluded(PENDING_TREE)) { | 3387 if (tiles[i]->is_occluded(PENDING_TREE)) { |
3426 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 3388 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
3427 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); | 3389 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); |
3428 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 3390 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
3429 occluded_tile_count++; | 3391 occluded_tile_count++; |
3430 } | 3392 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3478 // Partially invalidate the pending layer. | 3440 // Partially invalidate the pending layer. |
3479 pending_layer_->set_invalidation(invalidation_rect); | 3441 pending_layer_->set_invalidation(invalidation_rect); |
3480 | 3442 |
3481 host_impl_.SetViewportSize(viewport_size); | 3443 host_impl_.SetViewportSize(viewport_size); |
3482 | 3444 |
3483 active_layer_->CreateDefaultTilingsAndTiles(); | 3445 active_layer_->CreateDefaultTilingsAndTiles(); |
3484 pending_layer_->CreateDefaultTilingsAndTiles(); | 3446 pending_layer_->CreateDefaultTilingsAndTiles(); |
3485 | 3447 |
3486 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3448 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3487 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3449 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
3450 tiling->UpdateAllTilePrioritiesForTesting(); | |
3488 | 3451 |
3489 for (PictureLayerTiling::CoverageIterator iter( | 3452 for (PictureLayerTiling::CoverageIterator iter( |
3490 tiling, | 3453 tiling, |
3491 pending_layer_->contents_scale_x(), | 3454 pending_layer_->contents_scale_x(), |
3492 gfx::Rect(layer_bounds)); | 3455 gfx::Rect(layer_bounds)); |
3493 iter; | 3456 iter; |
3494 ++iter) { | 3457 ++iter) { |
3495 if (!*iter) | 3458 if (!*iter) |
3496 continue; | 3459 continue; |
3497 const Tile* tile = *iter; | 3460 const Tile* tile = *iter; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3622 // The total expected number of occluded tiles on all tilings for each of the | 3585 // The total expected number of occluded tiles on all tilings for each of the |
3623 // 3 tree priorities. | 3586 // 3 tree priorities. |
3624 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u}; | 3587 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u}; |
3625 | 3588 |
3626 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES); | 3589 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES); |
3627 | 3590 |
3628 // Verify number of occluded tiles on the pending layer for each tiling. | 3591 // Verify number of occluded tiles on the pending layer for each tiling. |
3629 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3592 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3630 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3593 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
3631 tiling->CreateAllTilesForTesting(); | 3594 tiling->CreateAllTilesForTesting(); |
3595 tiling->UpdateAllTilePrioritiesForTesting(); | |
3632 | 3596 |
3633 size_t occluded_tile_count_on_pending = 0u; | 3597 size_t occluded_tile_count_on_pending = 0u; |
3634 size_t occluded_tile_count_on_active = 0u; | 3598 size_t occluded_tile_count_on_active = 0u; |
3635 size_t occluded_tile_count_on_both = 0u; | 3599 size_t occluded_tile_count_on_both = 0u; |
3636 for (PictureLayerTiling::CoverageIterator iter( | 3600 for (PictureLayerTiling::CoverageIterator iter( |
3637 tiling, | 3601 tiling, |
3638 pending_layer_->contents_scale_x(), | 3602 pending_layer_->contents_scale_x(), |
3639 gfx::Rect(layer_bounds)); | 3603 gfx::Rect(layer_bounds)); |
3640 iter; | 3604 iter; |
3641 ++iter) { | 3605 ++iter) { |
(...skipping 14 matching lines...) Expand all Loading... | |
3656 << i; | 3620 << i; |
3657 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | 3621 EXPECT_EQ(expected_occluded_tile_count_on_both[i], |
3658 occluded_tile_count_on_both) | 3622 occluded_tile_count_on_both) |
3659 << i; | 3623 << i; |
3660 } | 3624 } |
3661 | 3625 |
3662 // Verify number of occluded tiles on the active layer for each tiling. | 3626 // Verify number of occluded tiles on the active layer for each tiling. |
3663 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 3627 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
3664 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 3628 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
3665 tiling->CreateAllTilesForTesting(); | 3629 tiling->CreateAllTilesForTesting(); |
3630 tiling->UpdateAllTilePrioritiesForTesting(); | |
3666 | 3631 |
3667 size_t occluded_tile_count_on_pending = 0u; | 3632 size_t occluded_tile_count_on_pending = 0u; |
3668 size_t occluded_tile_count_on_active = 0u; | 3633 size_t occluded_tile_count_on_active = 0u; |
3669 size_t occluded_tile_count_on_both = 0u; | 3634 size_t occluded_tile_count_on_both = 0u; |
3670 for (PictureLayerTiling::CoverageIterator iter( | 3635 for (PictureLayerTiling::CoverageIterator iter( |
3671 tiling, | 3636 tiling, |
3672 pending_layer_->contents_scale_x(), | 3637 pending_layer_->contents_scale_x(), |
3673 gfx::Rect(layer_bounds)); | 3638 gfx::Rect(layer_bounds)); |
3674 iter; | 3639 iter; |
3675 ++iter) { | 3640 ++iter) { |
(...skipping 28 matching lines...) Expand all Loading... | |
3704 | 3669 |
3705 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3670 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3706 | 3671 |
3707 VerifyEvictionConsidersOcclusion(pending_layer_, | 3672 VerifyEvictionConsidersOcclusion(pending_layer_, |
3708 total_expected_occluded_tile_count); | 3673 total_expected_occluded_tile_count); |
3709 VerifyEvictionConsidersOcclusion(active_layer_, | 3674 VerifyEvictionConsidersOcclusion(active_layer_, |
3710 total_expected_occluded_tile_count); | 3675 total_expected_occluded_tile_count); |
3711 } | 3676 } |
3712 } // namespace | 3677 } // namespace |
3713 } // namespace cc | 3678 } // namespace cc |
OLD | NEW |