Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 367833003: cc: Start using raster/eviction iterators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/memory_history.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 1381
1382 AppendQuadsData data; 1382 AppendQuadsData data;
1383 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); 1383 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL);
1384 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); 1384 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
1385 active_layer_->DidDraw(NULL); 1385 active_layer_->DidDraw(NULL);
1386 1386
1387 ASSERT_EQ(1U, render_pass->quad_list.size()); 1387 ASSERT_EQ(1U, render_pass->quad_list.size());
1388 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); 1388 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material);
1389 } 1389 }
1390 1390
1391 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) {
1392 gfx::Size tile_size(100, 100);
1393 gfx::Size layer_bounds(1000, 1000);
1394
1395 scoped_refptr<FakePicturePileImpl> pending_pile =
1396 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1397 // Layers with entirely empty piles can't get tilings.
1398 pending_pile->AddRecordingAt(0, 0);
1399
1400 SetupPendingTree(pending_pile);
1401
1402 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1403 pending_layer_->AddTiling(1.0f);
1404 pending_layer_->AddTiling(2.0f);
1405
1406 // It should be safe to call this (and MarkVisibleResourcesAsRequired)
1407 // on a layer with no recordings.
1408 host_impl_.pending_tree()->UpdateDrawProperties();
1409 pending_layer_->MarkVisibleResourcesAsRequired();
1410 }
1411
1412 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { 1391 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) {
1413 gfx::Size tile_size(100, 100); 1392 gfx::Size tile_size(100, 100);
1414 gfx::Size layer_bounds(200, 200); 1393 gfx::Size layer_bounds(200, 200);
1415 1394
1416 scoped_refptr<FakePicturePileImpl> pending_pile = 1395 scoped_refptr<FakePicturePileImpl> pending_pile =
1417 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1396 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1418 SetupPendingTree(pending_pile); 1397 SetupPendingTree(pending_pile);
1419 1398
1420 pending_layer_->set_fixed_tile_size(tile_size); 1399 pending_layer_->set_fixed_tile_size(tile_size);
1421 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 1400 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1422 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); 1401 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
1423 host_impl_.pending_tree()->UpdateDrawProperties(); 1402 host_impl_.pending_tree()->UpdateDrawProperties();
1424 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION);
1425
1426 pending_layer_->draw_properties().visible_content_rect = 1403 pending_layer_->draw_properties().visible_content_rect =
1427 gfx::Rect(0, 0, 100, 200); 1404 gfx::Rect(0, 0, 100, 200);
1428 1405 base::TimeTicks time_ticks;
1429 // Fake set priorities. 1406 time_ticks += base::TimeDelta::FromMilliseconds(16);
1430 for (PictureLayerTiling::CoverageIterator iter( 1407 host_impl_.SetCurrentBeginFrameArgs(
1431 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); 1408 CreateBeginFrameArgsForTesting(time_ticks));
1432 iter; 1409 pending_layer_->UpdateTiles(Occlusion());
1433 ++iter) { 1410 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution());
1434 if (!*iter)
1435 continue;
1436 Tile* tile = *iter;
1437 TilePriority priority;
1438 priority.resolution = HIGH_RESOLUTION;
1439 gfx::Rect tile_bounds = iter.geometry_rect();
1440 if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) {
1441 priority.priority_bin = TilePriority::NOW;
1442 priority.distance_to_visible = 0.f;
1443 } else {
1444 priority.priority_bin = TilePriority::SOON;
1445 priority.distance_to_visible = 1.f;
1446 }
1447 tile->SetPriority(PENDING_TREE, priority);
1448 }
1449
1450 pending_layer_->MarkVisibleResourcesAsRequired();
1451 1411
1452 int num_visible = 0; 1412 int num_visible = 0;
1453 int num_offscreen = 0; 1413 int num_offscreen = 0;
1454 1414
1455 for (PictureLayerTiling::CoverageIterator iter( 1415 for (PictureLayerTiling::TilingRasterTileIterator iter(tiling, PENDING_TREE);
1456 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
1457 iter; 1416 iter;
1458 ++iter) { 1417 ++iter) {
1459 if (!*iter)
1460 continue;
1461 const Tile* tile = *iter; 1418 const Tile* tile = *iter;
1419 DCHECK(tile);
1462 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { 1420 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) {
1463 EXPECT_TRUE(tile->required_for_activation()); 1421 EXPECT_TRUE(tile->required_for_activation());
1464 num_visible++; 1422 num_visible++;
1465 } else { 1423 } else {
1466 EXPECT_FALSE(tile->required_for_activation()); 1424 EXPECT_FALSE(tile->required_for_activation());
1467 num_offscreen++; 1425 num_offscreen++;
1468 } 1426 }
1469 } 1427 }
1470 1428
1471 EXPECT_GT(num_visible, 0); 1429 EXPECT_GT(num_visible, 0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 host_impl_.pending_tree()->UpdateDrawProperties(); 1466 host_impl_.pending_tree()->UpdateDrawProperties();
1509 1467
1510 // Set visible content rect that is different from 1468 // Set visible content rect that is different from
1511 // external_viewport_for_tile_priority. 1469 // external_viewport_for_tile_priority.
1512 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; 1470 pending_layer_->draw_properties().visible_content_rect = visible_content_rect;
1513 time_ticks += base::TimeDelta::FromMilliseconds(200); 1471 time_ticks += base::TimeDelta::FromMilliseconds(200);
1514 host_impl_.SetCurrentBeginFrameArgs( 1472 host_impl_.SetCurrentBeginFrameArgs(
1515 CreateBeginFrameArgsForTesting(time_ticks)); 1473 CreateBeginFrameArgsForTesting(time_ticks));
1516 pending_layer_->UpdateTiles(Occlusion()); 1474 pending_layer_->UpdateTiles(Occlusion());
1517 1475
1518 pending_layer_->MarkVisibleResourcesAsRequired();
1519
1520 // Intersect the two rects. Any tile outside should not be required for 1476 // Intersect the two rects. Any tile outside should not be required for
1521 // activation. 1477 // activation.
1522 gfx::Rect viewport_for_tile_priority = 1478 gfx::Rect viewport_for_tile_priority =
1523 pending_layer_->GetViewportForTilePriorityInContentSpace(); 1479 pending_layer_->GetViewportForTilePriorityInContentSpace();
1524 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); 1480 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect());
1525 1481
1526 int num_inside = 0; 1482 int num_inside = 0;
1527 int num_outside = 0; 1483 int num_outside = 0;
1528 for (PictureLayerTiling::CoverageIterator iter( 1484 for (PictureLayerTiling::CoverageIterator iter(
1529 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); 1485 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 1676
1721 // No tiles shared. 1677 // No tiles shared.
1722 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); 1678 pending_layer_->set_invalidation(gfx::Rect(layer_bounds));
1723 1679
1724 CreateHighLowResAndSetAllTilesVisible(); 1680 CreateHighLowResAndSetAllTilesVisible();
1725 1681
1726 active_layer_->SetAllTilesReady(); 1682 active_layer_->SetAllTilesReady();
1727 1683
1728 // No shared tiles and all active tiles ready, so pending can only 1684 // No shared tiles and all active tiles ready, so pending can only
1729 // activate with all high res tiles. 1685 // activate with all high res tiles.
1730 pending_layer_->MarkVisibleResourcesAsRequired(); 1686 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1731 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1687 AssertAllTilesRequired(pending_layer_->HighResTiling());
1688
1689 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1732 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1690 AssertNoTilesRequired(pending_layer_->LowResTiling());
1733 } 1691 }
1734 1692
1735 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { 1693 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) {
1736 gfx::Size layer_bounds(400, 400); 1694 gfx::Size layer_bounds(400, 400);
1737 gfx::Size tile_size(100, 100); 1695 gfx::Size tile_size(100, 100);
1738 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1696 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1739 1697
1740 // All tiles shared (no invalidation). 1698 // All tiles shared (no invalidation).
1741 CreateHighLowResAndSetAllTilesVisible(); 1699 CreateHighLowResAndSetAllTilesVisible();
1742 1700
1743 // Verify active tree not ready. 1701 // Verify active tree not ready.
1744 Tile* some_active_tile = 1702 Tile* some_active_tile =
1745 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 1703 active_layer_->HighResTiling()->AllTilesForTesting()[0];
1746 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 1704 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
1747 1705
1748 // When high res are required, even if the active tree is not ready, 1706 // When high res are required, even if the active tree is not ready,
1749 // the high res tiles must be ready. 1707 // the high res tiles must be ready.
1750 host_impl_.active_tree()->SetRequiresHighResToDraw(); 1708 host_impl_.active_tree()->SetRequiresHighResToDraw();
1751 pending_layer_->MarkVisibleResourcesAsRequired(); 1709
1710 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1752 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1711 AssertAllTilesRequired(pending_layer_->HighResTiling());
1712
1713 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1753 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1714 AssertNoTilesRequired(pending_layer_->LowResTiling());
1754 } 1715 }
1755 1716
1756 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { 1717 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) {
1757 gfx::Size layer_bounds(400, 400); 1718 gfx::Size layer_bounds(400, 400);
1758 gfx::Size tile_size(100, 100); 1719 gfx::Size tile_size(100, 100);
1759 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1720 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1760 1721
1761 CreateHighLowResAndSetAllTilesVisible(); 1722 CreateHighLowResAndSetAllTilesVisible();
1762 1723
1763 Tile* some_active_tile = 1724 Tile* some_active_tile =
1764 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 1725 active_layer_->HighResTiling()->AllTilesForTesting()[0];
1765 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 1726 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
1766 1727
1767 // All tiles shared (no invalidation), so even though the active tree's 1728 // All tiles shared (no invalidation), so even though the active tree's
1768 // tiles aren't ready, there is nothing required. 1729 // tiles aren't ready, there is nothing required.
1769 pending_layer_->MarkVisibleResourcesAsRequired(); 1730 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1770 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1731 AssertNoTilesRequired(pending_layer_->HighResTiling());
1732
1733 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1771 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1734 AssertNoTilesRequired(pending_layer_->LowResTiling());
1772 } 1735 }
1773 1736
1774 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 1737 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
1775 gfx::Size layer_bounds(400, 400); 1738 gfx::Size layer_bounds(400, 400);
1776 gfx::Size tile_size(100, 100); 1739 gfx::Size tile_size(100, 100);
1777 scoped_refptr<FakePicturePileImpl> pending_pile = 1740 scoped_refptr<FakePicturePileImpl> pending_pile =
1778 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1741 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1779 // This pile will create tilings, but has no recordings so will not create any 1742 // This pile will create tilings, but has no recordings so will not create any
1780 // tiles. This is attempting to simulate scrolling past the end of recorded 1743 // tiles. This is attempting to simulate scrolling past the end of recorded
1781 // content on the active layer, where the recordings are so far away that 1744 // content on the active layer, where the recordings are so far away that
1782 // no tiles are created. 1745 // no tiles are created.
1783 scoped_refptr<FakePicturePileImpl> active_pile = 1746 scoped_refptr<FakePicturePileImpl> active_pile =
1784 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 1747 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
1785 tile_size, layer_bounds); 1748 tile_size, layer_bounds);
1786 SetupTrees(pending_pile, active_pile); 1749 SetupTrees(pending_pile, active_pile);
1787 pending_layer_->set_fixed_tile_size(tile_size); 1750 pending_layer_->set_fixed_tile_size(tile_size);
1788 active_layer_->set_fixed_tile_size(tile_size); 1751 active_layer_->set_fixed_tile_size(tile_size);
1789 1752
1790 CreateHighLowResAndSetAllTilesVisible(); 1753 CreateHighLowResAndSetAllTilesVisible();
1791 1754
1792 // Active layer has tilings, but no tiles due to missing recordings. 1755 // Active layer has tilings, but no tiles due to missing recordings.
1793 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1756 EXPECT_TRUE(active_layer_->CanHaveTilings());
1794 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 1757 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
1795 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 1758 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
1796 1759
1797 // Since the active layer has no tiles at all, the pending layer doesn't 1760 // Since the active layer has no tiles at all, the pending layer doesn't
1798 // need content in order to activate. 1761 // need content in order to activate.
1799 pending_layer_->MarkVisibleResourcesAsRequired(); 1762 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1800 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1763 AssertNoTilesRequired(pending_layer_->HighResTiling());
1764
1765 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1801 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1766 AssertNoTilesRequired(pending_layer_->LowResTiling());
1802 } 1767 }
1803 1768
1804 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 1769 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
1805 gfx::Size layer_bounds(400, 400); 1770 gfx::Size layer_bounds(400, 400);
1806 gfx::Size tile_size(100, 100); 1771 gfx::Size tile_size(100, 100);
1807 scoped_refptr<FakePicturePileImpl> pending_pile = 1772 scoped_refptr<FakePicturePileImpl> pending_pile =
1808 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1773 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1809 scoped_refptr<FakePicturePileImpl> active_pile = 1774 scoped_refptr<FakePicturePileImpl> active_pile =
1810 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 1775 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1811 SetupTrees(pending_pile, active_pile); 1776 SetupTrees(pending_pile, active_pile);
1812 pending_layer_->set_fixed_tile_size(tile_size); 1777 pending_layer_->set_fixed_tile_size(tile_size);
1813 active_layer_->set_fixed_tile_size(tile_size); 1778 active_layer_->set_fixed_tile_size(tile_size);
1814 1779
1815 CreateHighLowResAndSetAllTilesVisible(); 1780 CreateHighLowResAndSetAllTilesVisible();
1816 1781
1817 // Active layer can't have tiles. 1782 // Active layer can't have tiles.
1818 EXPECT_FALSE(active_layer_->CanHaveTilings()); 1783 EXPECT_FALSE(active_layer_->CanHaveTilings());
1819 1784
1820 // All high res tiles required. This should be considered identical 1785 // All high res tiles required. This should be considered identical
1821 // to the case where there is no active layer, to avoid flashing content. 1786 // to the case where there is no active layer, to avoid flashing content.
1822 // This can happen if a layer exists for a while and switches from 1787 // This can happen if a layer exists for a while and switches from
1823 // not being able to have content to having content. 1788 // not being able to have content to having content.
1824 pending_layer_->MarkVisibleResourcesAsRequired(); 1789 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1825 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1790 AssertAllTilesRequired(pending_layer_->HighResTiling());
1791
1792 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1826 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1793 AssertNoTilesRequired(pending_layer_->LowResTiling());
1827 } 1794 }
1828 1795
1829 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { 1796 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) {
1830 gfx::Size layer_bounds(200, 200); 1797 gfx::Size layer_bounds(200, 200);
1831 gfx::Size tile_size(100, 100); 1798 gfx::Size tile_size(100, 100);
1832 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1799 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1833 1800
1834 gfx::Size pending_layer_bounds(400, 400); 1801 gfx::Size pending_layer_bounds(400, 400);
1835 pending_layer_->SetBounds(pending_layer_bounds); 1802 pending_layer_->SetBounds(pending_layer_bounds);
1836 1803
1837 CreateHighLowResAndSetAllTilesVisible(); 1804 CreateHighLowResAndSetAllTilesVisible();
1805 pending_layer_->HighResTiling()->UpdateTilePriorities(
1806 PENDING_TREE, gfx::Rect(pending_layer_bounds), 1.f, 1.f, Occlusion());
1807 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1838 1808
1839 active_layer_->SetAllTilesReady(); 1809 active_layer_->SetAllTilesReady();
1840 1810
1841 // Since the active layer has different bounds, the pending layer needs all 1811 // Since the active layer has different bounds, the pending layer needs all
1842 // high res tiles in order to activate. 1812 // high res tiles in order to activate.
1843 pending_layer_->MarkVisibleResourcesAsRequired(); 1813 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1844 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1814 AssertAllTilesRequired(pending_layer_->HighResTiling());
1815
1816 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1845 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1817 AssertNoTilesRequired(pending_layer_->LowResTiling());
1846 } 1818 }
1847 1819
1848 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 1820 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
1849 gfx::Size tile_size(100, 100); 1821 gfx::Size tile_size(100, 100);
1850 gfx::Size layer_bounds(400, 400); 1822 gfx::Size layer_bounds(400, 400);
1851 scoped_refptr<FakePicturePileImpl> pending_pile = 1823 scoped_refptr<FakePicturePileImpl> pending_pile =
1852 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1824 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1853 1825
1854 host_impl_.CreatePendingTree(); 1826 host_impl_.CreatePendingTree();
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 for (size_t i = 0; i < tilings.size(); ++i) { 2656 for (size_t i = 0; i < tilings.size(); ++i) {
2685 PictureLayerTiling* tiling = tilings.at(i); 2657 PictureLayerTiling* tiling = tilings.at(i);
2686 for (PictureLayerTiling::CoverageIterator iter( 2658 for (PictureLayerTiling::CoverageIterator iter(
2687 tiling, 2659 tiling,
2688 pending_layer_->contents_scale_x(), 2660 pending_layer_->contents_scale_x(),
2689 pending_layer_->visible_content_rect()); 2661 pending_layer_->visible_content_rect());
2690 iter; 2662 iter;
2691 ++iter) { 2663 ++iter) {
2692 if (mark_required) { 2664 if (mark_required) {
2693 number_of_marked_tiles++; 2665 number_of_marked_tiles++;
2694 iter->MarkRequiredForActivation(); 2666 iter->set_required_for_activation(true);
2695 } else { 2667 } else {
2696 number_of_unmarked_tiles++; 2668 number_of_unmarked_tiles++;
2697 } 2669 }
2698 mark_required = !mark_required; 2670 mark_required = !mark_required;
2699 } 2671 }
2700 } 2672 }
2701 2673
2702 // Sanity checks. 2674 // Sanity checks.
2703 EXPECT_EQ(91u, all_tiles.size()); 2675 EXPECT_EQ(91u, all_tiles.size());
2704 EXPECT_EQ(91u, all_tiles_set.size()); 2676 EXPECT_EQ(91u, all_tiles_set.size());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 gfx::Size tile_size(100, 100); 2871 gfx::Size tile_size(100, 100);
2900 gfx::Size layer_bounds(1000, 1000); 2872 gfx::Size layer_bounds(1000, 1000);
2901 2873
2902 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2874 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2903 2875
2904 // Make sure some tiles are not shared. 2876 // Make sure some tiles are not shared.
2905 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2877 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
2906 2878
2907 CreateHighLowResAndSetAllTilesVisible(); 2879 CreateHighLowResAndSetAllTilesVisible();
2908 active_layer_->SetAllTilesReady(); 2880 active_layer_->SetAllTilesReady();
2909 pending_layer_->MarkVisibleResourcesAsRequired();
2910 2881
2911 // All pending layer tiles required are not ready. 2882 // All pending layer tiles required are not ready.
2912 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2883 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2913 2884
2914 // Initialize all low-res tiles. 2885 // Initialize all low-res tiles.
2915 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 2886 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
2916 2887
2917 // Low-res tiles should not be enough. 2888 // Low-res tiles should not be enough.
2918 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2889 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2919 2890
2920 // Initialize remaining tiles. 2891 // Initialize remaining tiles.
2921 pending_layer_->SetAllTilesReady(); 2892 pending_layer_->SetAllTilesReady();
2922 2893
2923 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2894 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2924 } 2895 }
2925 2896
2926 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { 2897 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {
2927 gfx::Size tile_size(100, 100); 2898 gfx::Size tile_size(100, 100);
2928 gfx::Size layer_bounds(1000, 1000); 2899 gfx::Size layer_bounds(1000, 1000);
2929 2900
2930 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2901 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2931 2902
2932 // Make sure some tiles are not shared. 2903 // Make sure some tiles are not shared.
2933 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2904 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
2934 2905
2935 CreateHighLowResAndSetAllTilesVisible(); 2906 CreateHighLowResAndSetAllTilesVisible();
2936 active_layer_->SetAllTilesReady(); 2907 active_layer_->SetAllTilesReady();
2937 pending_layer_->MarkVisibleResourcesAsRequired();
2938 2908
2939 // All pending layer tiles required are not ready. 2909 // All pending layer tiles required are not ready.
2940 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2910 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2941 2911
2942 // Initialize all high-res tiles. 2912 // Initialize all high-res tiles.
2943 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 2913 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
2944 2914
2945 // High-res tiles should be enough, since they cover everything visible. 2915 // High-res tiles should be enough, since they cover everything visible.
2946 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2916 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2947 } 2917 }
2948 2918
2949 TEST_F(PictureLayerImplTest, 2919 TEST_F(PictureLayerImplTest,
2950 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { 2920 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
2951 gfx::Size tile_size(100, 100); 2921 gfx::Size tile_size(100, 100);
2952 gfx::Size layer_bounds(1000, 1000); 2922 gfx::Size layer_bounds(1000, 1000);
2953 2923
2954 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2924 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2955 2925
2956 // Make sure some tiles are not shared. 2926 // Make sure some tiles are not shared.
2957 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2927 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
2958 2928
2959 CreateHighLowResAndSetAllTilesVisible(); 2929 CreateHighLowResAndSetAllTilesVisible();
2960 2930
2961 // Initialize all high-res tiles in the active layer. 2931 // Initialize all high-res tiles in the active layer.
2962 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); 2932 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
2963 // And all the low-res tiles in the pending layer. 2933 // And all the low-res tiles in the pending layer.
2964 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 2934 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
2965 2935
2966 pending_layer_->MarkVisibleResourcesAsRequired();
2967
2968 // The unshared high-res tiles are not ready, so we cannot activate. 2936 // The unshared high-res tiles are not ready, so we cannot activate.
2969 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2937 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2970 2938
2971 // When the unshared pending high-res tiles are ready, we can activate. 2939 // When the unshared pending high-res tiles are ready, we can activate.
2972 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 2940 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
2973 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2941 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2974 } 2942 }
2975 2943
2976 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { 2944 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) {
2977 gfx::Size tile_size(100, 100); 2945 gfx::Size tile_size(100, 100);
2978 gfx::Size layer_bounds(1000, 1000); 2946 gfx::Size layer_bounds(1000, 1000);
2979 2947
2980 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2948 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2981 2949
2982 // Make sure some tiles are not shared. 2950 // Make sure some tiles are not shared.
2983 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2951 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
2984 2952
2985 CreateHighLowResAndSetAllTilesVisible(); 2953 CreateHighLowResAndSetAllTilesVisible();
2986 2954
2987 // Initialize all high-res tiles in the active layer. 2955 // Initialize all high-res tiles in the active layer.
2988 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); 2956 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
2989 2957
2990 pending_layer_->MarkVisibleResourcesAsRequired();
2991
2992 // The unshared high-res tiles are not ready, so we cannot activate. 2958 // The unshared high-res tiles are not ready, so we cannot activate.
2993 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2959 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2994 2960
2995 // When the unshared pending high-res tiles are ready, we can activate. 2961 // When the unshared pending high-res tiles are ready, we can activate.
2996 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 2962 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
2997 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2963 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2998 } 2964 }
2999 2965
3000 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { 2966 class NoLowResPictureLayerImplTest : public PictureLayerImplTest {
3001 public: 2967 public:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 7.26f, // ideal contents scale 3022 7.26f, // ideal contents scale
3057 2.2f, // device scale 3023 2.2f, // device scale
3058 3.3f, // page scale 3024 3.3f, // page scale
3059 1.f, // maximum animation scale 3025 1.f, // maximum animation scale
3060 false); 3026 false);
3061 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); 3027 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings());
3062 EXPECT_FLOAT_EQ(7.26f, 3028 EXPECT_FLOAT_EQ(7.26f,
3063 pending_layer_->tilings()->tiling_at(0)->contents_scale()); 3029 pending_layer_->tilings()->tiling_at(0)->contents_scale());
3064 } 3030 }
3065 3031
3066 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) {
3067 gfx::Size tile_size(100, 100);
3068 gfx::Size layer_bounds(1000, 1000);
3069
3070 scoped_refptr<FakePicturePileImpl> pending_pile =
3071 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
3072 // Layers with entirely empty piles can't get tilings.
3073 pending_pile->AddRecordingAt(0, 0);
3074
3075 SetupPendingTree(pending_pile);
3076
3077 ASSERT_TRUE(pending_layer_->CanHaveTilings());
3078 pending_layer_->AddTiling(1.0f);
3079 pending_layer_->AddTiling(2.0f);
3080
3081 // It should be safe to call this (and MarkVisibleResourcesAsRequired)
3082 // on a layer with no recordings.
3083 host_impl_.pending_tree()->UpdateDrawProperties();
3084 pending_layer_->MarkVisibleResourcesAsRequired();
3085 }
3086
3087 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { 3032 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) {
3088 gfx::Size layer_bounds(400, 400); 3033 gfx::Size layer_bounds(400, 400);
3089 gfx::Size tile_size(100, 100); 3034 gfx::Size tile_size(100, 100);
3090 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 3035 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
3091 3036
3092 CreateHighLowResAndSetAllTilesVisible(); 3037 CreateHighLowResAndSetAllTilesVisible();
3093 3038
3094 Tile* some_active_tile = 3039 Tile* some_active_tile =
3095 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 3040 active_layer_->HighResTiling()->AllTilesForTesting()[0];
3096 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 3041 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
3097 3042
3098 // All tiles shared (no invalidation), so even though the active tree's 3043 // All tiles shared (no invalidation), so even though the active tree's
3099 // tiles aren't ready, there is nothing required. 3044 // tiles aren't ready, there is nothing required.
3100 pending_layer_->MarkVisibleResourcesAsRequired(); 3045 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3101 AssertNoTilesRequired(pending_layer_->HighResTiling()); 3046 AssertNoTilesRequired(pending_layer_->HighResTiling());
3102 if (host_impl_.settings().create_low_res_tiling) { 3047 if (host_impl_.settings().create_low_res_tiling) {
3048 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3103 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3049 AssertNoTilesRequired(pending_layer_->LowResTiling());
3104 } 3050 }
3105 } 3051 }
3106 3052
3107 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 3053 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
3108 gfx::Size layer_bounds(400, 400); 3054 gfx::Size layer_bounds(400, 400);
3109 gfx::Size tile_size(100, 100); 3055 gfx::Size tile_size(100, 100);
3110 scoped_refptr<FakePicturePileImpl> pending_pile = 3056 scoped_refptr<FakePicturePileImpl> pending_pile =
3111 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3057 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3112 // This pile will create tilings, but has no recordings so will not create any 3058 // This pile will create tilings, but has no recordings so will not create any
(...skipping 10 matching lines...) Expand all
3123 CreateHighLowResAndSetAllTilesVisible(); 3069 CreateHighLowResAndSetAllTilesVisible();
3124 3070
3125 // Active layer has tilings, but no tiles due to missing recordings. 3071 // Active layer has tilings, but no tiles due to missing recordings.
3126 EXPECT_TRUE(active_layer_->CanHaveTilings()); 3072 EXPECT_TRUE(active_layer_->CanHaveTilings());
3127 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 3073 EXPECT_EQ(active_layer_->tilings()->num_tilings(),
3128 host_impl_.settings().create_low_res_tiling ? 2u : 1u); 3074 host_impl_.settings().create_low_res_tiling ? 2u : 1u);
3129 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 3075 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
3130 3076
3131 // Since the active layer has no tiles at all, the pending layer doesn't 3077 // Since the active layer has no tiles at all, the pending layer doesn't
3132 // need content in order to activate. 3078 // need content in order to activate.
3133 pending_layer_->MarkVisibleResourcesAsRequired(); 3079 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3134 AssertNoTilesRequired(pending_layer_->HighResTiling()); 3080 AssertNoTilesRequired(pending_layer_->HighResTiling());
3135 if (host_impl_.settings().create_low_res_tiling) 3081 if (host_impl_.settings().create_low_res_tiling) {
3082 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3136 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3083 AssertNoTilesRequired(pending_layer_->LowResTiling());
3084 }
3137 } 3085 }
3138 3086
3139 TEST_F(NoLowResPictureLayerImplTest, 3087 TEST_F(NoLowResPictureLayerImplTest,
3140 ResourcelessSoftwareDrawHasValidViewportForTilePriority) { 3088 ResourcelessSoftwareDrawHasValidViewportForTilePriority) {
3141 base::TimeTicks time_ticks; 3089 base::TimeTicks time_ticks;
3142 time_ticks += base::TimeDelta::FromMilliseconds(1); 3090 time_ticks += base::TimeDelta::FromMilliseconds(1);
3143 host_impl_.SetCurrentBeginFrameArgs( 3091 host_impl_.SetCurrentBeginFrameArgs(
3144 CreateBeginFrameArgsForTesting(time_ticks)); 3092 CreateBeginFrameArgsForTesting(time_ticks));
3145 3093
3146 gfx::Size tile_size(100, 100); 3094 gfx::Size tile_size(100, 100);
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 ++it) { 3650 ++it) {
3703 Tile* tile = *it; 3651 Tile* tile = *it;
3704 3652
3705 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 3653 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
3706 3654
3707 bool tile_is_visible = 3655 bool tile_is_visible =
3708 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); 3656 tile->content_rect().Intersects(pending_layer_->visible_content_rect());
3709 if (tile_is_visible) 3657 if (tile_is_visible)
3710 unoccluded_tile_count++; 3658 unoccluded_tile_count++;
3711 } 3659 }
3712 EXPECT_EQ(unoccluded_tile_count, 20 + 2); 3660 EXPECT_EQ(20 + 2, unoccluded_tile_count);
3713 3661
3714 // Full occlusion. 3662 // Full occlusion.
3715 layer1->SetPosition(gfx::Point(0, 0)); 3663 layer1->SetPosition(gfx::Point(0, 0));
3716 3664
3717 time_ticks += base::TimeDelta::FromMilliseconds(200); 3665 time_ticks += base::TimeDelta::FromMilliseconds(200);
3718 host_impl_.SetCurrentBeginFrameArgs( 3666 host_impl_.SetCurrentBeginFrameArgs(
3719 CreateBeginFrameArgsForTesting(time_ticks)); 3667 CreateBeginFrameArgsForTesting(time_ticks));
3720 host_impl_.pending_tree()->UpdateDrawProperties(); 3668 host_impl_.pending_tree()->UpdateDrawProperties();
3721 3669
3722 unoccluded_tile_count = 0; 3670 unoccluded_tile_count = 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3790 layer1->SetContentsOpaque(true); 3738 layer1->SetContentsOpaque(true);
3791 layer1->SetPosition(occluding_layer_position); 3739 layer1->SetPosition(occluding_layer_position);
3792 3740
3793 time_ticks += base::TimeDelta::FromMilliseconds(200); 3741 time_ticks += base::TimeDelta::FromMilliseconds(200);
3794 host_impl_.SetCurrentBeginFrameArgs( 3742 host_impl_.SetCurrentBeginFrameArgs(
3795 CreateBeginFrameArgsForTesting(time_ticks)); 3743 CreateBeginFrameArgsForTesting(time_ticks));
3796 host_impl_.pending_tree()->UpdateDrawProperties(); 3744 host_impl_.pending_tree()->UpdateDrawProperties();
3797 3745
3798 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3746 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3799 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3747 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3748 tiling->UpdateAllTilePrioritiesForTesting();
3800 3749
3801 occluded_tile_count = 0; 3750 occluded_tile_count = 0;
3802 for (PictureLayerTiling::CoverageIterator iter( 3751 for (PictureLayerTiling::CoverageIterator iter(
3803 tiling, 3752 tiling,
3804 pending_layer_->contents_scale_x(), 3753 pending_layer_->contents_scale_x(),
3805 gfx::Rect(layer_bounds)); 3754 gfx::Rect(layer_bounds));
3806 iter; 3755 iter;
3807 ++iter) { 3756 ++iter) {
3808 if (!*iter) 3757 if (!*iter)
3809 continue; 3758 continue;
(...skipping 19 matching lines...) Expand all
3829 // Full occlusion. 3778 // Full occlusion.
3830 layer1->SetPosition(gfx::PointF(0, 0)); 3779 layer1->SetPosition(gfx::PointF(0, 0));
3831 3780
3832 time_ticks += base::TimeDelta::FromMilliseconds(200); 3781 time_ticks += base::TimeDelta::FromMilliseconds(200);
3833 host_impl_.SetCurrentBeginFrameArgs( 3782 host_impl_.SetCurrentBeginFrameArgs(
3834 CreateBeginFrameArgsForTesting(time_ticks)); 3783 CreateBeginFrameArgsForTesting(time_ticks));
3835 host_impl_.pending_tree()->UpdateDrawProperties(); 3784 host_impl_.pending_tree()->UpdateDrawProperties();
3836 3785
3837 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3786 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3838 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3787 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3788 tiling->UpdateAllTilePrioritiesForTesting();
3789 tiling->UpdateAllTilePrioritiesForTesting();
reveman 2014/09/17 15:44:45 2 calls to UpdateAllTilePrioritiesForTesting inten
3839 3790
3840 occluded_tile_count = 0; 3791 occluded_tile_count = 0;
3841 for (PictureLayerTiling::CoverageIterator iter( 3792 for (PictureLayerTiling::CoverageIterator iter(
3842 tiling, 3793 tiling,
3843 pending_layer_->contents_scale_x(), 3794 pending_layer_->contents_scale_x(),
3844 gfx::Rect(layer_bounds)); 3795 gfx::Rect(layer_bounds));
3845 iter; 3796 iter;
3846 ++iter) { 3797 ++iter) {
3847 if (!*iter) 3798 if (!*iter)
3848 continue; 3799 continue;
3849 const Tile* tile = *iter; 3800 const Tile* tile = *iter;
3850 3801
3851 if (tile->is_occluded(PENDING_TREE)) { 3802 if (tile->is_occluded(PENDING_TREE)) {
3852 EXPECT_FALSE(tile->required_for_activation()); 3803 EXPECT_FALSE(tile->required_for_activation());
3853 occluded_tile_count++; 3804 occluded_tile_count++;
3854 } 3805 }
3855 } 3806 }
3856 switch (i) { 3807 switch (i) {
3857 case 0: 3808 case 0:
3858 EXPECT_EQ(occluded_tile_count, 25); 3809 EXPECT_EQ(25, occluded_tile_count);
3859 break; 3810 break;
3860 case 1: 3811 case 1:
3861 EXPECT_EQ(occluded_tile_count, 4); 3812 EXPECT_EQ(4, occluded_tile_count);
3862 break; 3813 break;
3863 default: 3814 default:
3864 NOTREACHED(); 3815 NOTREACHED();
3865 } 3816 }
3866 } 3817 }
3867 } 3818 }
3868 3819
3869 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { 3820 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) {
3870 gfx::Size tile_size(102, 102); 3821 gfx::Size tile_size(102, 102);
3871 gfx::Size layer_bounds(1000, 1000); 3822 gfx::Size layer_bounds(1000, 1000);
(...skipping 26 matching lines...) Expand all
3898 3849
3899 host_impl_.SetViewportSize(viewport_size); 3850 host_impl_.SetViewportSize(viewport_size);
3900 host_impl_.pending_tree()->UpdateDrawProperties(); 3851 host_impl_.pending_tree()->UpdateDrawProperties();
3901 3852
3902 int tiling_count = 0; 3853 int tiling_count = 0;
3903 int occluded_tile_count = 0; 3854 int occluded_tile_count = 0;
3904 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = 3855 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator =
3905 tilings.begin(); 3856 tilings.begin();
3906 tiling_iterator != tilings.end(); 3857 tiling_iterator != tilings.end();
3907 ++tiling_iterator) { 3858 ++tiling_iterator) {
3859 (*tiling_iterator)->UpdateAllTilePrioritiesForTesting();
3908 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); 3860 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting();
3909 3861
3910 occluded_tile_count = 0; 3862 occluded_tile_count = 0;
3911 for (size_t i = 0; i < tiles.size(); ++i) { 3863 for (size_t i = 0; i < tiles.size(); ++i) {
3912 if (tiles[i]->is_occluded(PENDING_TREE)) { 3864 if (tiles[i]->is_occluded(PENDING_TREE)) {
3913 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( 3865 gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
3914 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); 3866 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale());
3915 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); 3867 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x());
3916 occluded_tile_count++; 3868 occluded_tile_count++;
3917 } 3869 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 // Partially invalidate the pending layer. 3917 // Partially invalidate the pending layer.
3966 pending_layer_->set_invalidation(invalidation_rect); 3918 pending_layer_->set_invalidation(invalidation_rect);
3967 3919
3968 host_impl_.SetViewportSize(viewport_size); 3920 host_impl_.SetViewportSize(viewport_size);
3969 3921
3970 active_layer_->CreateDefaultTilingsAndTiles(); 3922 active_layer_->CreateDefaultTilingsAndTiles();
3971 pending_layer_->CreateDefaultTilingsAndTiles(); 3923 pending_layer_->CreateDefaultTilingsAndTiles();
3972 3924
3973 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3925 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3974 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3926 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3927 tiling->UpdateAllTilePrioritiesForTesting();
3975 3928
3976 for (PictureLayerTiling::CoverageIterator iter( 3929 for (PictureLayerTiling::CoverageIterator iter(
3977 tiling, 3930 tiling,
3978 pending_layer_->contents_scale_x(), 3931 pending_layer_->contents_scale_x(),
3979 gfx::Rect(layer_bounds)); 3932 gfx::Rect(layer_bounds));
3980 iter; 3933 iter;
3981 ++iter) { 3934 ++iter) {
3982 if (!*iter) 3935 if (!*iter)
3983 continue; 3936 continue;
3984 const Tile* tile = *iter; 3937 const Tile* tile = *iter;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4109 // The total expected number of occluded tiles on all tilings for each of the 4062 // The total expected number of occluded tiles on all tilings for each of the
4110 // 3 tree priorities. 4063 // 3 tree priorities.
4111 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u}; 4064 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u};
4112 4065
4113 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES); 4066 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES);
4114 4067
4115 // Verify number of occluded tiles on the pending layer for each tiling. 4068 // Verify number of occluded tiles on the pending layer for each tiling.
4116 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4069 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4117 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4070 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4118 tiling->CreateAllTilesForTesting(); 4071 tiling->CreateAllTilesForTesting();
4072 tiling->UpdateAllTilePrioritiesForTesting();
4119 4073
4120 size_t occluded_tile_count_on_pending = 0u; 4074 size_t occluded_tile_count_on_pending = 0u;
4121 size_t occluded_tile_count_on_active = 0u; 4075 size_t occluded_tile_count_on_active = 0u;
4122 size_t occluded_tile_count_on_both = 0u; 4076 size_t occluded_tile_count_on_both = 0u;
4123 for (PictureLayerTiling::CoverageIterator iter( 4077 for (PictureLayerTiling::CoverageIterator iter(
4124 tiling, 4078 tiling,
4125 pending_layer_->contents_scale_x(), 4079 pending_layer_->contents_scale_x(),
4126 gfx::Rect(layer_bounds)); 4080 gfx::Rect(layer_bounds));
4127 iter; 4081 iter;
4128 ++iter) { 4082 ++iter) {
(...skipping 14 matching lines...) Expand all
4143 << i; 4097 << i;
4144 EXPECT_EQ(expected_occluded_tile_count_on_both[i], 4098 EXPECT_EQ(expected_occluded_tile_count_on_both[i],
4145 occluded_tile_count_on_both) 4099 occluded_tile_count_on_both)
4146 << i; 4100 << i;
4147 } 4101 }
4148 4102
4149 // Verify number of occluded tiles on the active layer for each tiling. 4103 // Verify number of occluded tiles on the active layer for each tiling.
4150 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { 4104 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
4151 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); 4105 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
4152 tiling->CreateAllTilesForTesting(); 4106 tiling->CreateAllTilesForTesting();
4107 tiling->UpdateAllTilePrioritiesForTesting();
4153 4108
4154 size_t occluded_tile_count_on_pending = 0u; 4109 size_t occluded_tile_count_on_pending = 0u;
4155 size_t occluded_tile_count_on_active = 0u; 4110 size_t occluded_tile_count_on_active = 0u;
4156 size_t occluded_tile_count_on_both = 0u; 4111 size_t occluded_tile_count_on_both = 0u;
4157 for (PictureLayerTiling::CoverageIterator iter( 4112 for (PictureLayerTiling::CoverageIterator iter(
4158 tiling, 4113 tiling,
4159 pending_layer_->contents_scale_x(), 4114 pending_layer_->contents_scale_x(),
4160 gfx::Rect(layer_bounds)); 4115 gfx::Rect(layer_bounds));
4161 iter; 4116 iter;
4162 ++iter) { 4117 ++iter) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4217 ActivateTree(); 4172 ActivateTree();
4218 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); 4173 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer());
4219 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); 4174 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer());
4220 4175
4221 host_impl_.ResetRecycleTreeForTesting(); 4176 host_impl_.ResetRecycleTreeForTesting();
4222 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); 4177 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
4223 } 4178 }
4224 4179
4225 } // namespace 4180 } // namespace
4226 } // namespace cc 4181 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/memory_history.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698