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

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: rebase Created 6 years, 2 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
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 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 AppendQuadsData data; 1400 AppendQuadsData data;
1401 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); 1401 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL);
1402 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); 1402 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
1403 active_layer_->DidDraw(NULL); 1403 active_layer_->DidDraw(NULL);
1404 1404
1405 ASSERT_EQ(1U, render_pass->quad_list.size()); 1405 ASSERT_EQ(1U, render_pass->quad_list.size());
1406 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, 1406 EXPECT_EQ(DrawQuad::PICTURE_CONTENT,
1407 render_pass->quad_list.front()->material); 1407 render_pass->quad_list.front()->material);
1408 } 1408 }
1409 1409
1410 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) {
1411 gfx::Size tile_size(100, 100);
1412 gfx::Size layer_bounds(1000, 1000);
1413
1414 scoped_refptr<FakePicturePileImpl> pending_pile =
1415 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1416 // Layers with entirely empty piles can't get tilings.
1417 pending_pile->AddRecordingAt(0, 0);
1418
1419 SetupPendingTree(pending_pile);
1420
1421 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1422 pending_layer_->AddTiling(1.0f);
1423 pending_layer_->AddTiling(2.0f);
1424
1425 // It should be safe to call this (and MarkVisibleResourcesAsRequired)
1426 // on a layer with no recordings.
1427 host_impl_.pending_tree()->UpdateDrawProperties();
1428 pending_layer_->MarkVisibleResourcesAsRequired();
1429 }
1430
1431 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { 1410 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) {
1432 gfx::Size tile_size(100, 100); 1411 gfx::Size tile_size(100, 100);
1433 gfx::Size layer_bounds(200, 200); 1412 gfx::Size layer_bounds(200, 200);
1434 1413
1435 scoped_refptr<FakePicturePileImpl> pending_pile = 1414 scoped_refptr<FakePicturePileImpl> pending_pile =
1436 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1415 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1437 SetupPendingTree(pending_pile); 1416 SetupPendingTree(pending_pile);
1438 1417
1439 gfx::Transform transform; 1418 gfx::Transform transform;
1440 gfx::Transform transform_for_tile_priority; 1419 gfx::Transform transform_for_tile_priority;
1441 bool resourceless_software_draw = false; 1420 bool resourceless_software_draw = false;
1442 gfx::Rect viewport(0, 0, 100, 200); 1421 gfx::Rect viewport(0, 0, 100, 200);
1443 host_impl_.SetExternalDrawConstraints(transform, 1422 host_impl_.SetExternalDrawConstraints(transform,
1444 viewport, 1423 viewport,
1445 viewport, 1424 viewport,
1446 viewport, 1425 viewport,
1447 transform, 1426 transform,
1448 resourceless_software_draw); 1427 resourceless_software_draw);
1449 1428
1450 pending_layer_->set_fixed_tile_size(tile_size); 1429 pending_layer_->set_fixed_tile_size(tile_size);
1451 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 1430 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1452 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); 1431 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
1453 host_impl_.pending_tree()->UpdateDrawProperties(); 1432 host_impl_.pending_tree()->UpdateDrawProperties();
1454 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION);
1455 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority()); 1433 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority());
1456 1434
1457 // Fake set priorities. 1435 base::TimeTicks time_ticks;
1458 for (PictureLayerTiling::CoverageIterator iter( 1436 time_ticks += base::TimeDelta::FromMilliseconds(1);
1459 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); 1437 host_impl_.SetCurrentBeginFrameArgs(
1460 iter; 1438 CreateBeginFrameArgsForTesting(time_ticks));
1461 ++iter) { 1439 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw);
1462 if (!*iter) 1440 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution());
1463 continue;
1464 Tile* tile = *iter;
1465 TilePriority priority;
1466 priority.resolution = HIGH_RESOLUTION;
1467 gfx::Rect tile_bounds = iter.geometry_rect();
1468 if (pending_layer_->visible_rect_for_tile_priority().Intersects(
1469 tile_bounds)) {
1470 priority.priority_bin = TilePriority::NOW;
1471 priority.distance_to_visible = 0.f;
1472 } else {
1473 priority.priority_bin = TilePriority::SOON;
1474 priority.distance_to_visible = 1.f;
1475 }
1476 tile->SetPriority(PENDING_TREE, priority);
1477 }
1478
1479 pending_layer_->MarkVisibleResourcesAsRequired();
1480 1441
1481 int num_visible = 0; 1442 int num_visible = 0;
1482 int num_offscreen = 0; 1443 int num_offscreen = 0;
1483 1444
1484 for (PictureLayerTiling::CoverageIterator iter( 1445 for (PictureLayerTiling::TilingRasterTileIterator iter(tiling); iter;
1485 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
1486 iter;
1487 ++iter) { 1446 ++iter) {
1488 if (!*iter)
1489 continue;
1490 const Tile* tile = *iter; 1447 const Tile* tile = *iter;
1448 DCHECK(tile);
1491 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { 1449 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) {
1492 EXPECT_TRUE(tile->required_for_activation()); 1450 EXPECT_TRUE(tile->required_for_activation());
1493 num_visible++; 1451 num_visible++;
1494 } else { 1452 } else {
1495 EXPECT_FALSE(tile->required_for_activation()); 1453 EXPECT_FALSE(tile->required_for_activation());
1496 num_offscreen++; 1454 num_offscreen++;
1497 } 1455 }
1498 } 1456 }
1499 1457
1500 EXPECT_GT(num_visible, 0); 1458 EXPECT_GT(num_visible, 0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 host_impl_.pending_tree()->UpdateDrawProperties(); 1495 host_impl_.pending_tree()->UpdateDrawProperties();
1538 1496
1539 // Set visible content rect that is different from 1497 // Set visible content rect that is different from
1540 // external_viewport_for_tile_priority. 1498 // external_viewport_for_tile_priority.
1541 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; 1499 pending_layer_->draw_properties().visible_content_rect = visible_content_rect;
1542 time_ticks += base::TimeDelta::FromMilliseconds(200); 1500 time_ticks += base::TimeDelta::FromMilliseconds(200);
1543 host_impl_.SetCurrentBeginFrameArgs( 1501 host_impl_.SetCurrentBeginFrameArgs(
1544 CreateBeginFrameArgsForTesting(time_ticks)); 1502 CreateBeginFrameArgsForTesting(time_ticks));
1545 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); 1503 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw);
1546 1504
1547 pending_layer_->MarkVisibleResourcesAsRequired();
1548
1549 // Intersect the two rects. Any tile outside should not be required for 1505 // Intersect the two rects. Any tile outside should not be required for
1550 // activation. 1506 // activation.
1551 gfx::Rect viewport_for_tile_priority = 1507 gfx::Rect viewport_for_tile_priority =
1552 pending_layer_->GetViewportForTilePriorityInContentSpace(); 1508 pending_layer_->GetViewportForTilePriorityInContentSpace();
1553 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); 1509 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect());
1554 1510
1555 int num_inside = 0; 1511 int num_inside = 0;
1556 int num_outside = 0; 1512 int num_outside = 0;
1557 for (PictureLayerTiling::CoverageIterator iter( 1513 for (PictureLayerTiling::CoverageIterator iter(
1558 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); 1514 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 1703
1748 // No tiles shared. 1704 // No tiles shared.
1749 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); 1705 pending_layer_->set_invalidation(gfx::Rect(layer_bounds));
1750 1706
1751 CreateHighLowResAndSetAllTilesVisible(); 1707 CreateHighLowResAndSetAllTilesVisible();
1752 1708
1753 active_layer_->SetAllTilesReady(); 1709 active_layer_->SetAllTilesReady();
1754 1710
1755 // No shared tiles and all active tiles ready, so pending can only 1711 // No shared tiles and all active tiles ready, so pending can only
1756 // activate with all high res tiles. 1712 // activate with all high res tiles.
1757 pending_layer_->MarkVisibleResourcesAsRequired(); 1713 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1714 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1715
1758 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1716 AssertAllTilesRequired(pending_layer_->HighResTiling());
1759 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1717 AssertNoTilesRequired(pending_layer_->LowResTiling());
1760 } 1718 }
1761 1719
1762 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { 1720 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) {
1763 gfx::Size layer_bounds(400, 400); 1721 gfx::Size layer_bounds(400, 400);
1764 gfx::Size tile_size(100, 100); 1722 gfx::Size tile_size(100, 100);
1765 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1723 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1766 1724
1767 // All tiles shared (no invalidation). 1725 // All tiles shared (no invalidation).
1768 CreateHighLowResAndSetAllTilesVisible(); 1726 CreateHighLowResAndSetAllTilesVisible();
1769 1727
1770 // Verify active tree not ready. 1728 // Verify active tree not ready.
1771 Tile* some_active_tile = 1729 Tile* some_active_tile =
1772 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 1730 active_layer_->HighResTiling()->AllTilesForTesting()[0];
1773 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 1731 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
1774 1732
1775 // When high res are required, even if the active tree is not ready, 1733 // When high res are required, even if the active tree is not ready,
1776 // the high res tiles must be ready. 1734 // the high res tiles must be ready.
1777 host_impl_.active_tree()->SetRequiresHighResToDraw(); 1735 host_impl_.active_tree()->SetRequiresHighResToDraw();
1778 pending_layer_->MarkVisibleResourcesAsRequired(); 1736
1737 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1738 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1739
1779 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1740 AssertAllTilesRequired(pending_layer_->HighResTiling());
1780 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1741 AssertNoTilesRequired(pending_layer_->LowResTiling());
1781 } 1742 }
1782 1743
1783 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { 1744 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) {
1784 gfx::Size layer_bounds(400, 400); 1745 gfx::Size layer_bounds(400, 400);
1785 gfx::Size tile_size(100, 100); 1746 gfx::Size tile_size(100, 100);
1786 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1747 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1787 1748
1788 CreateHighLowResAndSetAllTilesVisible(); 1749 CreateHighLowResAndSetAllTilesVisible();
1789 1750
1790 Tile* some_active_tile = 1751 Tile* some_active_tile =
1791 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 1752 active_layer_->HighResTiling()->AllTilesForTesting()[0];
1792 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 1753 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
1793 1754
1794 // All tiles shared (no invalidation), so even though the active tree's 1755 // All tiles shared (no invalidation), so even though the active tree's
1795 // tiles aren't ready, there is nothing required. 1756 // tiles aren't ready, there is nothing required.
1796 pending_layer_->MarkVisibleResourcesAsRequired(); 1757 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1797 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1758 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1759
1760 AssertAllTilesRequired(pending_layer_->HighResTiling());
1798 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1761 AssertNoTilesRequired(pending_layer_->LowResTiling());
1799 } 1762 }
1800 1763
1801 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 1764 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
1802 gfx::Size layer_bounds(400, 400); 1765 gfx::Size layer_bounds(400, 400);
1803 gfx::Size tile_size(100, 100); 1766 gfx::Size tile_size(100, 100);
1804 scoped_refptr<FakePicturePileImpl> pending_pile = 1767 scoped_refptr<FakePicturePileImpl> pending_pile =
1805 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1768 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1806 // This pile will create tilings, but has no recordings so will not create any 1769 // This pile will create tilings, but has no recordings so will not create any
1807 // tiles. This is attempting to simulate scrolling past the end of recorded 1770 // tiles. This is attempting to simulate scrolling past the end of recorded
1808 // content on the active layer, where the recordings are so far away that 1771 // content on the active layer, where the recordings are so far away that
1809 // no tiles are created. 1772 // no tiles are created.
1810 scoped_refptr<FakePicturePileImpl> active_pile = 1773 scoped_refptr<FakePicturePileImpl> active_pile =
1811 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 1774 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
1812 tile_size, layer_bounds); 1775 tile_size, layer_bounds);
1813 SetupTrees(pending_pile, active_pile); 1776 SetupTrees(pending_pile, active_pile);
1814 pending_layer_->set_fixed_tile_size(tile_size); 1777 pending_layer_->set_fixed_tile_size(tile_size);
1815 active_layer_->set_fixed_tile_size(tile_size); 1778 active_layer_->set_fixed_tile_size(tile_size);
1816 1779
1817 CreateHighLowResAndSetAllTilesVisible(); 1780 CreateHighLowResAndSetAllTilesVisible();
1818 1781
1819 // Active layer has tilings, but no tiles due to missing recordings. 1782 // Active layer has tilings, but no tiles due to missing recordings.
1820 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1783 EXPECT_TRUE(active_layer_->CanHaveTilings());
1821 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 1784 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
1822 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 1785 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
1823 1786
1824 // Since the active layer has no tiles at all, the pending layer doesn't 1787 // Since the active layer has no tiles at all, the pending layer doesn't
1825 // need content in order to activate. 1788 // need content in order to activate.
1826 pending_layer_->MarkVisibleResourcesAsRequired(); 1789 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1790 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1791
1827 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1792 AssertNoTilesRequired(pending_layer_->HighResTiling());
1828 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1793 AssertNoTilesRequired(pending_layer_->LowResTiling());
1829 } 1794 }
1830 1795
1831 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 1796 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
1832 gfx::Size layer_bounds(400, 400); 1797 gfx::Size layer_bounds(400, 400);
1833 gfx::Size tile_size(100, 100); 1798 gfx::Size tile_size(100, 100);
1834 scoped_refptr<FakePicturePileImpl> pending_pile = 1799 scoped_refptr<FakePicturePileImpl> pending_pile =
1835 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1800 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1836 scoped_refptr<FakePicturePileImpl> active_pile = 1801 scoped_refptr<FakePicturePileImpl> active_pile =
1837 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 1802 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1838 SetupTrees(pending_pile, active_pile); 1803 SetupTrees(pending_pile, active_pile);
1839 pending_layer_->set_fixed_tile_size(tile_size); 1804 pending_layer_->set_fixed_tile_size(tile_size);
1840 active_layer_->set_fixed_tile_size(tile_size); 1805 active_layer_->set_fixed_tile_size(tile_size);
1841 1806
1842 CreateHighLowResAndSetAllTilesVisible(); 1807 CreateHighLowResAndSetAllTilesVisible();
1843 1808
1844 // Active layer can't have tiles. 1809 // Active layer can't have tiles.
1845 EXPECT_FALSE(active_layer_->CanHaveTilings()); 1810 EXPECT_FALSE(active_layer_->CanHaveTilings());
1846 1811
1847 // All high res tiles required. This should be considered identical 1812 // All high res tiles required. This should be considered identical
1848 // to the case where there is no active layer, to avoid flashing content. 1813 // to the case where there is no active layer, to avoid flashing content.
1849 // This can happen if a layer exists for a while and switches from 1814 // This can happen if a layer exists for a while and switches from
1850 // not being able to have content to having content. 1815 // not being able to have content to having content.
1851 pending_layer_->MarkVisibleResourcesAsRequired(); 1816 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1817 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1818
1852 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1819 AssertAllTilesRequired(pending_layer_->HighResTiling());
1853 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1820 AssertNoTilesRequired(pending_layer_->LowResTiling());
1854 } 1821 }
1855 1822
1856 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { 1823 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) {
1857 gfx::Size layer_bounds(200, 200); 1824 gfx::Size layer_bounds(200, 200);
1858 gfx::Size tile_size(100, 100); 1825 gfx::Size tile_size(100, 100);
1859 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1826 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1860 1827
1861 gfx::Size pending_layer_bounds(400, 400); 1828 gfx::Size pending_layer_bounds(400, 400);
1862 pending_layer_->SetBounds(pending_layer_bounds); 1829 pending_layer_->SetBounds(pending_layer_bounds);
1863 1830
1864 CreateHighLowResAndSetAllTilesVisible(); 1831 CreateHighLowResAndSetAllTilesVisible();
1832 // TODO(vmpstr): This is confusing. Rework the test to create different bounds
1833 // on different trees instead of fudging tilings.
1834 pending_layer_->HighResTiling()->ComputeTilePriorityRects(
1835 PENDING_TREE, gfx::Rect(pending_layer_bounds), 1.f, 1.f, Occlusion());
1865 1836
1837 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1866 active_layer_->SetAllTilesReady(); 1838 active_layer_->SetAllTilesReady();
1867 1839
1868 // Since the active layer has different bounds, the pending layer needs all 1840 // Since the active layer has different bounds, the pending layer needs all
1869 // high res tiles in order to activate. 1841 // high res tiles in order to activate.
1870 pending_layer_->MarkVisibleResourcesAsRequired(); 1842 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
1843 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
1844
1871 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1845 AssertAllTilesRequired(pending_layer_->HighResTiling());
1872 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1846 AssertNoTilesRequired(pending_layer_->LowResTiling());
1873 } 1847 }
1874 1848
1875 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 1849 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
1876 gfx::Size tile_size(100, 100); 1850 gfx::Size tile_size(100, 100);
1877 gfx::Size layer_bounds(400, 400); 1851 gfx::Size layer_bounds(400, 400);
1878 scoped_refptr<FakePicturePileImpl> pending_pile = 1852 scoped_refptr<FakePicturePileImpl> pending_pile =
1879 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1853 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1880 1854
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 for (size_t i = 0; i < tilings.size(); ++i) { 2683 for (size_t i = 0; i < tilings.size(); ++i) {
2710 PictureLayerTiling* tiling = tilings.at(i); 2684 PictureLayerTiling* tiling = tilings.at(i);
2711 for (PictureLayerTiling::CoverageIterator iter( 2685 for (PictureLayerTiling::CoverageIterator iter(
2712 tiling, 2686 tiling,
2713 pending_layer_->contents_scale_x(), 2687 pending_layer_->contents_scale_x(),
2714 pending_layer_->visible_content_rect()); 2688 pending_layer_->visible_content_rect());
2715 iter; 2689 iter;
2716 ++iter) { 2690 ++iter) {
2717 if (mark_required) { 2691 if (mark_required) {
2718 number_of_marked_tiles++; 2692 number_of_marked_tiles++;
2719 iter->MarkRequiredForActivation(); 2693 iter->set_required_for_activation(true);
2720 } else { 2694 } else {
2721 number_of_unmarked_tiles++; 2695 number_of_unmarked_tiles++;
2722 } 2696 }
2723 mark_required = !mark_required; 2697 mark_required = !mark_required;
2724 } 2698 }
2725 } 2699 }
2726 2700
2727 // Sanity checks. 2701 // Sanity checks.
2728 EXPECT_EQ(91u, all_tiles.size()); 2702 EXPECT_EQ(91u, all_tiles.size());
2729 EXPECT_EQ(91u, all_tiles_set.size()); 2703 EXPECT_EQ(91u, all_tiles_set.size());
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 gfx::Size tile_size(100, 100); 2895 gfx::Size tile_size(100, 100);
2922 gfx::Size layer_bounds(1000, 1000); 2896 gfx::Size layer_bounds(1000, 1000);
2923 2897
2924 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2898 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2925 2899
2926 // Make sure some tiles are not shared. 2900 // Make sure some tiles are not shared.
2927 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2901 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
2928 2902
2929 CreateHighLowResAndSetAllTilesVisible(); 2903 CreateHighLowResAndSetAllTilesVisible();
2930 active_layer_->SetAllTilesReady(); 2904 active_layer_->SetAllTilesReady();
2931 pending_layer_->MarkVisibleResourcesAsRequired();
2932 2905
2933 // All pending layer tiles required are not ready. 2906 // All pending layer tiles required are not ready.
2934 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2907 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2935 2908
2936 // Initialize all low-res tiles. 2909 // Initialize all low-res tiles.
2937 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 2910 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
2938 2911
2939 // Low-res tiles should not be enough. 2912 // Low-res tiles should not be enough.
2940 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2913 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2941 2914
2942 // Initialize remaining tiles. 2915 // Initialize remaining tiles.
2943 pending_layer_->SetAllTilesReady(); 2916 pending_layer_->SetAllTilesReady();
2944 2917
2945 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2918 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2946 } 2919 }
2947 2920
2948 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { 2921 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {
2949 gfx::Size tile_size(100, 100); 2922 gfx::Size tile_size(100, 100);
2950 gfx::Size layer_bounds(1000, 1000); 2923 gfx::Size layer_bounds(1000, 1000);
2951 2924
2952 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2925 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2953 2926
2954 // Make sure some tiles are not shared. 2927 // Make sure some tiles are not shared.
2955 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2928 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
2956 2929
2957 CreateHighLowResAndSetAllTilesVisible(); 2930 CreateHighLowResAndSetAllTilesVisible();
2958 active_layer_->SetAllTilesReady(); 2931 active_layer_->SetAllTilesReady();
2959 pending_layer_->MarkVisibleResourcesAsRequired();
2960 2932
2961 // All pending layer tiles required are not ready. 2933 // All pending layer tiles required are not ready.
2962 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2934 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2963 2935
2964 // Initialize all high-res tiles. 2936 // Initialize all high-res tiles.
2965 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 2937 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
2966 2938
2967 // High-res tiles should be enough, since they cover everything visible. 2939 // High-res tiles should be enough, since they cover everything visible.
2968 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2940 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2969 } 2941 }
2970 2942
2971 TEST_F(PictureLayerImplTest, 2943 TEST_F(PictureLayerImplTest,
2972 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { 2944 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
2973 gfx::Size tile_size(100, 100); 2945 gfx::Size tile_size(100, 100);
2974 gfx::Size layer_bounds(1000, 1000); 2946 gfx::Size layer_bounds(1000, 1000);
2975 2947
2976 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2948 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
2977 2949
2978 // Make sure some tiles are not shared. 2950 // Make sure some tiles are not shared.
2979 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));
2980 2952
2981 CreateHighLowResAndSetAllTilesVisible(); 2953 CreateHighLowResAndSetAllTilesVisible();
2982 2954
2983 // Initialize all high-res tiles in the active layer. 2955 // Initialize all high-res tiles in the active layer.
2984 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); 2956 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
2985 // And all the low-res tiles in the pending layer. 2957 // And all the low-res tiles in the pending layer.
2986 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 2958 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
2987 2959
2988 pending_layer_->MarkVisibleResourcesAsRequired();
2989
2990 // The unshared high-res tiles are not ready, so we cannot activate. 2960 // The unshared high-res tiles are not ready, so we cannot activate.
2991 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2961 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2992 2962
2993 // When the unshared pending high-res tiles are ready, we can activate. 2963 // When the unshared pending high-res tiles are ready, we can activate.
2994 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 2964 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
2995 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2965 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
2996 } 2966 }
2997 2967
2998 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { 2968 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) {
2999 gfx::Size tile_size(100, 100); 2969 gfx::Size tile_size(100, 100);
3000 gfx::Size layer_bounds(1000, 1000); 2970 gfx::Size layer_bounds(1000, 1000);
3001 2971
3002 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 2972 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
3003 2973
3004 // Make sure some tiles are not shared. 2974 // Make sure some tiles are not shared.
3005 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); 2975 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size));
3006 2976
3007 CreateHighLowResAndSetAllTilesVisible(); 2977 CreateHighLowResAndSetAllTilesVisible();
3008 2978
3009 // Initialize all high-res tiles in the active layer. 2979 // Initialize all high-res tiles in the active layer.
3010 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); 2980 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
3011 2981
3012 pending_layer_->MarkVisibleResourcesAsRequired();
3013
3014 // The unshared high-res tiles are not ready, so we cannot activate. 2982 // The unshared high-res tiles are not ready, so we cannot activate.
3015 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2983 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
3016 2984
3017 // When the unshared pending high-res tiles are ready, we can activate. 2985 // When the unshared pending high-res tiles are ready, we can activate.
3018 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 2986 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3019 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 2987 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
3020 } 2988 }
3021 2989
3022 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { 2990 class NoLowResPictureLayerImplTest : public PictureLayerImplTest {
3023 public: 2991 public:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 7.26f, // ideal contents scale 3046 7.26f, // ideal contents scale
3079 2.2f, // device scale 3047 2.2f, // device scale
3080 3.3f, // page scale 3048 3.3f, // page scale
3081 1.f, // maximum animation scale 3049 1.f, // maximum animation scale
3082 false); 3050 false);
3083 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); 3051 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings());
3084 EXPECT_FLOAT_EQ(7.26f, 3052 EXPECT_FLOAT_EQ(7.26f,
3085 pending_layer_->tilings()->tiling_at(0)->contents_scale()); 3053 pending_layer_->tilings()->tiling_at(0)->contents_scale());
3086 } 3054 }
3087 3055
3088 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { 3056 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) {
3089 gfx::Size tile_size(100, 100);
3090 gfx::Size layer_bounds(1000, 1000);
3091
3092 scoped_refptr<FakePicturePileImpl> pending_pile =
3093 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
3094 // Layers with entirely empty piles can't get tilings.
3095 pending_pile->AddRecordingAt(0, 0);
3096
3097 SetupPendingTree(pending_pile);
3098
3099 ASSERT_TRUE(pending_layer_->CanHaveTilings());
3100 pending_layer_->AddTiling(1.0f);
3101 pending_layer_->AddTiling(2.0f);
3102
3103 // It should be safe to call this (and MarkVisibleResourcesAsRequired)
3104 // on a layer with no recordings.
3105 host_impl_.pending_tree()->UpdateDrawProperties();
3106 pending_layer_->MarkVisibleResourcesAsRequired();
3107 }
3108
3109 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) {
3110 gfx::Size layer_bounds(400, 400); 3057 gfx::Size layer_bounds(400, 400);
3111 gfx::Size tile_size(100, 100); 3058 gfx::Size tile_size(100, 100);
3112 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 3059 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
3113 3060
3114 CreateHighLowResAndSetAllTilesVisible(); 3061 CreateHighLowResAndSetAllTilesVisible();
3115 3062
3116 Tile* some_active_tile = 3063 Tile* some_active_tile =
3117 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 3064 active_layer_->HighResTiling()->AllTilesForTesting()[0];
3118 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 3065 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
3119 3066
3120 // All tiles shared (no invalidation), so even though the active tree's 3067 // All tiles shared (no invalidation), so even though the active tree's
3121 // tiles aren't ready, there is nothing required. 3068 // tiles aren't ready, there is nothing required.
danakj 2014/10/08 18:46:25 This comment is wrong now, can you explain what is
vmpstr 2014/10/08 22:38:34 Done.
3122 pending_layer_->MarkVisibleResourcesAsRequired(); 3069 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3123 AssertNoTilesRequired(pending_layer_->HighResTiling()); 3070 if (host_impl_.settings().create_low_res_tiling)
3124 if (host_impl_.settings().create_low_res_tiling) { 3071 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3072
3073 AssertAllTilesRequired(pending_layer_->HighResTiling());
3074 if (host_impl_.settings().create_low_res_tiling)
3125 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3075 AssertNoTilesRequired(pending_layer_->LowResTiling());
3126 }
3127 } 3076 }
3128 3077
3129 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 3078 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
3130 gfx::Size layer_bounds(400, 400); 3079 gfx::Size layer_bounds(400, 400);
3131 gfx::Size tile_size(100, 100); 3080 gfx::Size tile_size(100, 100);
3132 scoped_refptr<FakePicturePileImpl> pending_pile = 3081 scoped_refptr<FakePicturePileImpl> pending_pile =
3133 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3082 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3134 // This pile will create tilings, but has no recordings so will not create any 3083 // This pile will create tilings, but has no recordings so will not create any
3135 // tiles. This is attempting to simulate scrolling past the end of recorded 3084 // tiles. This is attempting to simulate scrolling past the end of recorded
3136 // content on the active layer, where the recordings are so far away that 3085 // content on the active layer, where the recordings are so far away that
3137 // no tiles are created. 3086 // no tiles are created.
3138 scoped_refptr<FakePicturePileImpl> active_pile = 3087 scoped_refptr<FakePicturePileImpl> active_pile =
3139 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 3088 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
3140 tile_size, layer_bounds); 3089 tile_size, layer_bounds);
3141 SetupTrees(pending_pile, active_pile); 3090 SetupTrees(pending_pile, active_pile);
3142 pending_layer_->set_fixed_tile_size(tile_size); 3091 pending_layer_->set_fixed_tile_size(tile_size);
3143 active_layer_->set_fixed_tile_size(tile_size); 3092 active_layer_->set_fixed_tile_size(tile_size);
3144 3093
3145 CreateHighLowResAndSetAllTilesVisible(); 3094 CreateHighLowResAndSetAllTilesVisible();
3146 3095
3147 // Active layer has tilings, but no tiles due to missing recordings. 3096 // Active layer has tilings, but no tiles due to missing recordings.
3148 EXPECT_TRUE(active_layer_->CanHaveTilings()); 3097 EXPECT_TRUE(active_layer_->CanHaveTilings());
3149 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 3098 EXPECT_EQ(active_layer_->tilings()->num_tilings(),
3150 host_impl_.settings().create_low_res_tiling ? 2u : 1u); 3099 host_impl_.settings().create_low_res_tiling ? 2u : 1u);
3151 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 3100 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
3152 3101
3153 // Since the active layer has no tiles at all, the pending layer doesn't 3102 // Since the active layer has no tiles at all, the pending layer doesn't
3154 // need content in order to activate. 3103 // need content in order to activate.
3155 pending_layer_->MarkVisibleResourcesAsRequired(); 3104 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3105 if (host_impl_.settings().create_low_res_tiling)
3106 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3107
3156 AssertNoTilesRequired(pending_layer_->HighResTiling()); 3108 AssertNoTilesRequired(pending_layer_->HighResTiling());
3157 if (host_impl_.settings().create_low_res_tiling) 3109 if (host_impl_.settings().create_low_res_tiling)
3158 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3110 AssertNoTilesRequired(pending_layer_->LowResTiling());
3159 } 3111 }
3160 3112
3161 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { 3113 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
3162 base::TimeTicks time_ticks; 3114 base::TimeTicks time_ticks;
3163 time_ticks += base::TimeDelta::FromMilliseconds(1); 3115 time_ticks += base::TimeDelta::FromMilliseconds(1);
3164 host_impl_.SetCurrentBeginFrameArgs( 3116 host_impl_.SetCurrentBeginFrameArgs(
3165 CreateBeginFrameArgsForTesting(time_ticks)); 3117 CreateBeginFrameArgsForTesting(time_ticks));
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
3738 ++it) { 3690 ++it) {
3739 Tile* tile = *it; 3691 Tile* tile = *it;
3740 3692
3741 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 3693 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
3742 3694
3743 bool tile_is_visible = 3695 bool tile_is_visible =
3744 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); 3696 tile->content_rect().Intersects(pending_layer_->visible_content_rect());
3745 if (tile_is_visible) 3697 if (tile_is_visible)
3746 unoccluded_tile_count++; 3698 unoccluded_tile_count++;
3747 } 3699 }
3748 EXPECT_EQ(unoccluded_tile_count, 20 + 2); 3700 EXPECT_EQ(20 + 2, unoccluded_tile_count);
3749 3701
3750 // Full occlusion. 3702 // Full occlusion.
3751 layer1->SetPosition(gfx::Point(0, 0)); 3703 layer1->SetPosition(gfx::Point(0, 0));
3752 3704
3753 time_ticks += base::TimeDelta::FromMilliseconds(200); 3705 time_ticks += base::TimeDelta::FromMilliseconds(200);
3754 host_impl_.SetCurrentBeginFrameArgs( 3706 host_impl_.SetCurrentBeginFrameArgs(
3755 CreateBeginFrameArgsForTesting(time_ticks)); 3707 CreateBeginFrameArgsForTesting(time_ticks));
3756 host_impl_.pending_tree()->UpdateDrawProperties(); 3708 host_impl_.pending_tree()->UpdateDrawProperties();
3757 3709
3758 unoccluded_tile_count = 0; 3710 unoccluded_tile_count = 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 layer1->SetContentsOpaque(true); 3778 layer1->SetContentsOpaque(true);
3827 layer1->SetPosition(occluding_layer_position); 3779 layer1->SetPosition(occluding_layer_position);
3828 3780
3829 time_ticks += base::TimeDelta::FromMilliseconds(200); 3781 time_ticks += base::TimeDelta::FromMilliseconds(200);
3830 host_impl_.SetCurrentBeginFrameArgs( 3782 host_impl_.SetCurrentBeginFrameArgs(
3831 CreateBeginFrameArgsForTesting(time_ticks)); 3783 CreateBeginFrameArgsForTesting(time_ticks));
3832 host_impl_.pending_tree()->UpdateDrawProperties(); 3784 host_impl_.pending_tree()->UpdateDrawProperties();
3833 3785
3834 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3786 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3835 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3787 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3788 tiling->UpdateAllTilePrioritiesForTesting();
3836 3789
3837 occluded_tile_count = 0; 3790 occluded_tile_count = 0;
3838 for (PictureLayerTiling::CoverageIterator iter( 3791 for (PictureLayerTiling::CoverageIterator iter(
3839 tiling, 3792 tiling,
3840 pending_layer_->contents_scale_x(), 3793 pending_layer_->contents_scale_x(),
3841 gfx::Rect(layer_bounds)); 3794 gfx::Rect(layer_bounds));
3842 iter; 3795 iter;
3843 ++iter) { 3796 ++iter) {
3844 if (!*iter) 3797 if (!*iter)
3845 continue; 3798 continue;
(...skipping 19 matching lines...) Expand all
3865 // Full occlusion. 3818 // Full occlusion.
3866 layer1->SetPosition(gfx::PointF(0, 0)); 3819 layer1->SetPosition(gfx::PointF(0, 0));
3867 3820
3868 time_ticks += base::TimeDelta::FromMilliseconds(200); 3821 time_ticks += base::TimeDelta::FromMilliseconds(200);
3869 host_impl_.SetCurrentBeginFrameArgs( 3822 host_impl_.SetCurrentBeginFrameArgs(
3870 CreateBeginFrameArgsForTesting(time_ticks)); 3823 CreateBeginFrameArgsForTesting(time_ticks));
3871 host_impl_.pending_tree()->UpdateDrawProperties(); 3824 host_impl_.pending_tree()->UpdateDrawProperties();
3872 3825
3873 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3826 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3874 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3827 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3828 tiling->UpdateAllTilePrioritiesForTesting();
3875 3829
3876 occluded_tile_count = 0; 3830 occluded_tile_count = 0;
3877 for (PictureLayerTiling::CoverageIterator iter( 3831 for (PictureLayerTiling::CoverageIterator iter(
3878 tiling, 3832 tiling,
3879 pending_layer_->contents_scale_x(), 3833 pending_layer_->contents_scale_x(),
3880 gfx::Rect(layer_bounds)); 3834 gfx::Rect(layer_bounds));
3881 iter; 3835 iter;
3882 ++iter) { 3836 ++iter) {
3883 if (!*iter) 3837 if (!*iter)
3884 continue; 3838 continue;
3885 const Tile* tile = *iter; 3839 const Tile* tile = *iter;
3886 3840
3887 if (tile->is_occluded(PENDING_TREE)) { 3841 if (tile->is_occluded(PENDING_TREE)) {
3888 EXPECT_FALSE(tile->required_for_activation()); 3842 EXPECT_FALSE(tile->required_for_activation());
3889 occluded_tile_count++; 3843 occluded_tile_count++;
3890 } 3844 }
3891 } 3845 }
3892 switch (i) { 3846 switch (i) {
3893 case 0: 3847 case 0:
3894 EXPECT_EQ(occluded_tile_count, 25); 3848 EXPECT_EQ(25, occluded_tile_count);
3895 break; 3849 break;
3896 case 1: 3850 case 1:
3897 EXPECT_EQ(occluded_tile_count, 4); 3851 EXPECT_EQ(4, occluded_tile_count);
3898 break; 3852 break;
3899 default: 3853 default:
3900 NOTREACHED(); 3854 NOTREACHED();
3901 } 3855 }
3902 } 3856 }
3903 } 3857 }
3904 3858
3905 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { 3859 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) {
3906 gfx::Size tile_size(102, 102); 3860 gfx::Size tile_size(102, 102);
3907 gfx::Size layer_bounds(1000, 1000); 3861 gfx::Size layer_bounds(1000, 1000);
(...skipping 26 matching lines...) Expand all
3934 3888
3935 host_impl_.SetViewportSize(viewport_size); 3889 host_impl_.SetViewportSize(viewport_size);
3936 host_impl_.pending_tree()->UpdateDrawProperties(); 3890 host_impl_.pending_tree()->UpdateDrawProperties();
3937 3891
3938 int tiling_count = 0; 3892 int tiling_count = 0;
3939 int occluded_tile_count = 0; 3893 int occluded_tile_count = 0;
3940 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = 3894 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator =
3941 tilings.begin(); 3895 tilings.begin();
3942 tiling_iterator != tilings.end(); 3896 tiling_iterator != tilings.end();
3943 ++tiling_iterator) { 3897 ++tiling_iterator) {
3898 (*tiling_iterator)->UpdateAllTilePrioritiesForTesting();
3944 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); 3899 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting();
3945 3900
3946 occluded_tile_count = 0; 3901 occluded_tile_count = 0;
3947 for (size_t i = 0; i < tiles.size(); ++i) { 3902 for (size_t i = 0; i < tiles.size(); ++i) {
3948 if (tiles[i]->is_occluded(PENDING_TREE)) { 3903 if (tiles[i]->is_occluded(PENDING_TREE)) {
3949 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( 3904 gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
3950 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); 3905 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale());
3951 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); 3906 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x());
3952 occluded_tile_count++; 3907 occluded_tile_count++;
3953 } 3908 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 // Partially invalidate the pending layer. 3956 // Partially invalidate the pending layer.
4002 pending_layer_->set_invalidation(invalidation_rect); 3957 pending_layer_->set_invalidation(invalidation_rect);
4003 3958
4004 host_impl_.SetViewportSize(viewport_size); 3959 host_impl_.SetViewportSize(viewport_size);
4005 3960
4006 active_layer_->CreateDefaultTilingsAndTiles(); 3961 active_layer_->CreateDefaultTilingsAndTiles();
4007 pending_layer_->CreateDefaultTilingsAndTiles(); 3962 pending_layer_->CreateDefaultTilingsAndTiles();
4008 3963
4009 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3964 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4010 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3965 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3966 tiling->UpdateAllTilePrioritiesForTesting();
4011 3967
4012 for (PictureLayerTiling::CoverageIterator iter( 3968 for (PictureLayerTiling::CoverageIterator iter(
4013 tiling, 3969 tiling,
4014 pending_layer_->contents_scale_x(), 3970 pending_layer_->contents_scale_x(),
4015 gfx::Rect(layer_bounds)); 3971 gfx::Rect(layer_bounds));
4016 iter; 3972 iter;
4017 ++iter) { 3973 ++iter) {
4018 if (!*iter) 3974 if (!*iter)
4019 continue; 3975 continue;
4020 const Tile* tile = *iter; 3976 const Tile* tile = *iter;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4145 // The total expected number of occluded tiles on all tilings for each of the 4101 // The total expected number of occluded tiles on all tilings for each of the
4146 // 3 tree priorities. 4102 // 3 tree priorities.
4147 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u}; 4103 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u};
4148 4104
4149 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES); 4105 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES);
4150 4106
4151 // Verify number of occluded tiles on the pending layer for each tiling. 4107 // Verify number of occluded tiles on the pending layer for each tiling.
4152 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4108 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4153 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4109 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4154 tiling->CreateAllTilesForTesting(); 4110 tiling->CreateAllTilesForTesting();
4111 tiling->UpdateAllTilePrioritiesForTesting();
4155 4112
4156 size_t occluded_tile_count_on_pending = 0u; 4113 size_t occluded_tile_count_on_pending = 0u;
4157 size_t occluded_tile_count_on_active = 0u; 4114 size_t occluded_tile_count_on_active = 0u;
4158 size_t occluded_tile_count_on_both = 0u; 4115 size_t occluded_tile_count_on_both = 0u;
4159 for (PictureLayerTiling::CoverageIterator iter( 4116 for (PictureLayerTiling::CoverageIterator iter(
4160 tiling, 4117 tiling,
4161 pending_layer_->contents_scale_x(), 4118 pending_layer_->contents_scale_x(),
4162 gfx::Rect(layer_bounds)); 4119 gfx::Rect(layer_bounds));
4163 iter; 4120 iter;
4164 ++iter) { 4121 ++iter) {
(...skipping 14 matching lines...) Expand all
4179 << i; 4136 << i;
4180 EXPECT_EQ(expected_occluded_tile_count_on_both[i], 4137 EXPECT_EQ(expected_occluded_tile_count_on_both[i],
4181 occluded_tile_count_on_both) 4138 occluded_tile_count_on_both)
4182 << i; 4139 << i;
4183 } 4140 }
4184 4141
4185 // Verify number of occluded tiles on the active layer for each tiling. 4142 // Verify number of occluded tiles on the active layer for each tiling.
4186 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { 4143 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
4187 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); 4144 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
4188 tiling->CreateAllTilesForTesting(); 4145 tiling->CreateAllTilesForTesting();
4146 tiling->UpdateAllTilePrioritiesForTesting();
4189 4147
4190 size_t occluded_tile_count_on_pending = 0u; 4148 size_t occluded_tile_count_on_pending = 0u;
4191 size_t occluded_tile_count_on_active = 0u; 4149 size_t occluded_tile_count_on_active = 0u;
4192 size_t occluded_tile_count_on_both = 0u; 4150 size_t occluded_tile_count_on_both = 0u;
4193 for (PictureLayerTiling::CoverageIterator iter( 4151 for (PictureLayerTiling::CoverageIterator iter(
4194 tiling, 4152 tiling,
4195 pending_layer_->contents_scale_x(), 4153 pending_layer_->contents_scale_x(),
4196 gfx::Rect(layer_bounds)); 4154 gfx::Rect(layer_bounds));
4197 iter; 4155 iter;
4198 ++iter) { 4156 ++iter) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 SetupPendingTree(pending_pile2); 4359 SetupPendingTree(pending_pile2);
4402 ActivateTree(); 4360 ActivateTree();
4403 4361
4404 // We've switched to a solid color, so we should end up with no tilings. 4362 // We've switched to a solid color, so we should end up with no tilings.
4405 ASSERT_TRUE(active_layer_->tilings()); 4363 ASSERT_TRUE(active_layer_->tilings());
4406 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4364 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4407 } 4365 }
4408 4366
4409 } // namespace 4367 } // namespace
4410 } // namespace cc 4368 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698