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

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

Issue 1051993002: cc: Remove tile sharing from tilings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 397 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
398 398
399 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); 399 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
400 400
401 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 401 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
402 active_layer_->tilings()->num_tilings()); 402 active_layer_->tilings()->num_tilings());
403 403
404 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 404 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
405 EXPECT_GT(tilings->num_tilings(), 0u); 405 EXPECT_GT(tilings->num_tilings(), 0u);
406 for (size_t i = 0; i < tilings->num_tilings(); ++i) 406 for (size_t i = 0; i < tilings->num_tilings(); ++i)
407 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); 407 EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty());
408 } 408 }
409 409
410 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { 410 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) {
411 base::TimeTicks time_ticks; 411 base::TimeTicks time_ticks;
412 time_ticks += base::TimeDelta::FromMilliseconds(1); 412 time_ticks += base::TimeDelta::FromMilliseconds(1);
413 host_impl_.SetCurrentBeginFrameArgs( 413 host_impl_.SetCurrentBeginFrameArgs(
414 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 414 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
415 gfx::Size tile_size(100, 100); 415 gfx::Size tile_size(100, 100);
416 gfx::Size layer_bounds(400, 400); 416 gfx::Size layer_bounds(400, 400);
417 417
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 const PictureLayerTiling* tiling = tilings->tiling_at(i); 675 const PictureLayerTiling* tiling = tilings->tiling_at(i);
676 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( 676 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect(
677 layer_invalidation, 677 layer_invalidation,
678 tiling->contents_scale()); 678 tiling->contents_scale());
679 for (PictureLayerTiling::CoverageIterator iter( 679 for (PictureLayerTiling::CoverageIterator iter(
680 tiling, 680 tiling,
681 tiling->contents_scale(), 681 tiling->contents_scale(),
682 gfx::Rect(tiling->tiling_size())); 682 gfx::Rect(tiling->tiling_size()));
683 iter; 683 iter;
684 ++iter) { 684 ++iter) {
685 EXPECT_TRUE(*iter); 685 if (*iter) {
danakj 2015/04/08 00:13:06 can you add a comment explaining the expectations
vmpstr 2015/04/10 20:25:13 Done.
vmpstr 2015/04/10 20:25:13 Done.
686 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 686 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
687 EXPECT_EQ(pending_pile.get(), iter->raster_source()); 687 EXPECT_EQ(pending_pile.get(), iter->raster_source());
688 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation));
689 } else {
690 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation));
691 }
688 } 692 }
689 } 693 }
690 694
691 tilings = active_layer_->tilings(); 695 tilings = active_layer_->tilings();
692 EXPECT_GT(tilings->num_tilings(), 0u); 696 EXPECT_GT(tilings->num_tilings(), 0u);
693 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 697 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
694 const PictureLayerTiling* tiling = tilings->tiling_at(i); 698 const PictureLayerTiling* tiling = tilings->tiling_at(i);
695 gfx::Rect content_invalidation = 699 gfx::Rect content_invalidation =
696 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); 700 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale());
697 for (PictureLayerTiling::CoverageIterator iter( 701 for (PictureLayerTiling::CoverageIterator iter(
698 tiling, 702 tiling,
699 tiling->contents_scale(), 703 tiling->contents_scale(),
700 gfx::Rect(tiling->tiling_size())); 704 gfx::Rect(tiling->tiling_size()));
701 iter; 705 iter;
702 ++iter) { 706 ++iter) {
703 EXPECT_TRUE(*iter); 707 EXPECT_TRUE(*iter);
704 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 708 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
705 if (iter.geometry_rect().Intersects(content_invalidation)) 709 // Pile will be updated upon activation.
706 EXPECT_EQ(active_pile.get(), iter->raster_source()); 710 EXPECT_EQ(active_pile.get(), iter->raster_source());
707 else if (!active_layer_->GetPendingOrActiveTwinTiling(tiling))
708 EXPECT_EQ(active_pile.get(), iter->raster_source());
709 else
710 EXPECT_EQ(pending_pile.get(), iter->raster_source());
711 } 711 }
712 } 712 }
713 } 713 }
714 714
715 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { 715 TEST_F(PictureLayerImplTest, CloneFullInvalidation) {
716 gfx::Size tile_size(90, 80); 716 gfx::Size tile_size(90, 80);
717 gfx::Size layer_bounds(300, 500); 717 gfx::Size layer_bounds(300, 500);
718 718
719 scoped_refptr<FakePicturePileImpl> pending_pile = 719 scoped_refptr<FakePicturePileImpl> pending_pile =
720 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 720 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { 1528 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) {
1529 // The default max tile size is larger than 400x400. 1529 // The default max tile size is larger than 400x400.
1530 gfx::Size tile_size(400, 400); 1530 gfx::Size tile_size(400, 400);
1531 gfx::Size layer_bounds(5000, 5000); 1531 gfx::Size layer_bounds(5000, 5000);
1532 1532
1533 scoped_refptr<FakePicturePileImpl> pending_pile = 1533 scoped_refptr<FakePicturePileImpl> pending_pile =
1534 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1534 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1535 scoped_refptr<FakePicturePileImpl> active_pile = 1535 scoped_refptr<FakePicturePileImpl> active_pile =
1536 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1536 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1537 1537
1538 SetupTrees(pending_pile, active_pile); 1538 SetupTrees(pending_pile, active_pile);
danakj 2015/04/08 00:13:06 Would it keep these tests simpler to test on the p
vmpstr 2015/04/10 20:25:13 Done.
1539 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); 1539 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u);
1540 1540
1541 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1541 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1542 1542
1543 // The default value. 1543 // The default value.
1544 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1544 EXPECT_EQ(gfx::Size(256, 256).ToString(),
1545 host_impl_.settings().default_tile_size.ToString()); 1545 host_impl_.settings().default_tile_size.ToString());
1546 1546
1547 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1547 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1548 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1548 EXPECT_EQ(gfx::Size(256, 256).ToString(),
1549 tile->content_rect().size().ToString()); 1549 tile->content_rect().size().ToString());
1550 1550
1551 ResetTilingsAndRasterScales(); 1551 ResetTilingsAndRasterScales();
1552 1552
1553 // Change the max texture size on the output surface context. 1553 // Change the max texture size on the output surface context.
1554 scoped_ptr<TestWebGraphicsContext3D> context = 1554 scoped_ptr<TestWebGraphicsContext3D> context =
1555 TestWebGraphicsContext3D::Create(); 1555 TestWebGraphicsContext3D::Create();
1556 context->set_max_texture_size(140); 1556 context->set_max_texture_size(140);
1557 host_impl_.DidLoseOutputSurface(); 1557 host_impl_.DidLoseOutputSurface();
1558 host_impl_.InitializeRenderer( 1558 host_impl_.InitializeRenderer(
1559 FakeOutputSurface::Create3d(context.Pass()).Pass()); 1559 FakeOutputSurface::Create3d(context.Pass()).Pass());
1560 1560
1561 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); 1561 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
1562 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); 1562 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
1563 1563
1564 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1564 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1565 1565
1566 // Verify the tiles are not larger than the context's max texture size. 1566 // Verify the tiles are not larger than the context's max texture size.
1567 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1567 tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1568 EXPECT_GE(140, tile->content_rect().width()); 1568 EXPECT_GE(140, tile->content_rect().width());
1569 EXPECT_GE(140, tile->content_rect().height()); 1569 EXPECT_GE(140, tile->content_rect().height());
1570 } 1570 }
1571 1571
1572 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { 1572 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) {
1573 // The default max tile size is larger than 400x400. 1573 // The default max tile size is larger than 400x400.
1574 gfx::Size tile_size(400, 400); 1574 gfx::Size tile_size(400, 400);
1575 gfx::Size layer_bounds(500, 500); 1575 gfx::Size layer_bounds(500, 500);
1576 1576
1577 scoped_refptr<FakePicturePileImpl> pending_pile = 1577 scoped_refptr<FakePicturePileImpl> pending_pile =
1578 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1578 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1579 scoped_refptr<FakePicturePileImpl> active_pile = 1579 scoped_refptr<FakePicturePileImpl> active_pile =
1580 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1580 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1581 1581
1582 SetupTrees(pending_pile, active_pile); 1582 SetupTrees(pending_pile, active_pile);
1583 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); 1583 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u);
1584 1584
1585 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1585 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1586 1586
1587 // The default value. The layer is smaller than this. 1587 // The default value. The layer is smaller than this.
1588 EXPECT_EQ(gfx::Size(512, 512).ToString(), 1588 EXPECT_EQ(gfx::Size(512, 512).ToString(),
1589 host_impl_.settings().max_untiled_layer_size.ToString()); 1589 host_impl_.settings().max_untiled_layer_size.ToString());
1590 1590
1591 // There should be a single tile since the layer is small. 1591 // There should be a single tile since the layer is small.
1592 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); 1592 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0);
1593 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); 1593 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size());
1594 1594
1595 ResetTilingsAndRasterScales(); 1595 ResetTilingsAndRasterScales();
1596 1596
1597 // Change the max texture size on the output surface context. 1597 // Change the max texture size on the output surface context.
1598 scoped_ptr<TestWebGraphicsContext3D> context = 1598 scoped_ptr<TestWebGraphicsContext3D> context =
1599 TestWebGraphicsContext3D::Create(); 1599 TestWebGraphicsContext3D::Create();
1600 context->set_max_texture_size(140); 1600 context->set_max_texture_size(140);
1601 host_impl_.DidLoseOutputSurface(); 1601 host_impl_.DidLoseOutputSurface();
1602 host_impl_.InitializeRenderer( 1602 host_impl_.InitializeRenderer(
1603 FakeOutputSurface::Create3d(context.Pass()).Pass()); 1603 FakeOutputSurface::Create3d(context.Pass()).Pass());
1604 1604
1605 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); 1605 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
1606 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); 1606 ASSERT_LE(1u, active_layer_->tilings()->num_tilings());
1607 1607
1608 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1608 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1609 1609
1610 // There should be more than one tile since the max texture size won't cover 1610 // There should be more than one tile since the max texture size won't cover
1611 // the layer. 1611 // the layer.
1612 high_res_tiling = pending_layer_->tilings()->tiling_at(0); 1612 high_res_tiling = active_layer_->tilings()->tiling_at(0);
1613 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); 1613 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size());
1614 1614
1615 // Verify the tiles are not larger than the context's max texture size. 1615 // Verify the tiles are not larger than the context's max texture size.
1616 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1616 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1617 EXPECT_GE(140, tile->content_rect().width()); 1617 EXPECT_GE(140, tile->content_rect().width());
1618 EXPECT_GE(140, tile->content_rect().height()); 1618 EXPECT_GE(140, tile->content_rect().height());
1619 } 1619 }
1620 1620
1621 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { 1621 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) {
1622 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1622 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1623 1623
1624 gfx::Size tile_size(400, 400); 1624 gfx::Size tile_size(400, 400);
1625 gfx::Size layer_bounds(1300, 1900); 1625 gfx::Size layer_bounds(1300, 1900);
1626 1626
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 host_impl_.SetCurrentBeginFrameArgs( 1795 host_impl_.SetCurrentBeginFrameArgs(
1796 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 1796 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
1797 pending_layer_->UpdateTiles(resourceless_software_draw); 1797 pending_layer_->UpdateTiles(resourceless_software_draw);
1798 1798
1799 // Intersect the two rects. Any tile outside should not be required for 1799 // Intersect the two rects. Any tile outside should not be required for
1800 // activation. 1800 // activation.
1801 gfx::Rect viewport_for_tile_priority = 1801 gfx::Rect viewport_for_tile_priority =
1802 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); 1802 pending_layer_->viewport_rect_for_tile_priority_in_content_space();
1803 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); 1803 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect());
1804 1804
1805 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
1806
1805 int num_inside = 0; 1807 int num_inside = 0;
1806 int num_outside = 0; 1808 int num_outside = 0;
1807 for (PictureLayerTiling::CoverageIterator iter( 1809 for (PictureLayerTiling::CoverageIterator iter(active_layer_->HighResTiling(),
1808 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); 1810 1.f, gfx::Rect(layer_bounds));
1809 iter; ++iter) { 1811 iter; ++iter) {
1810 if (!*iter) 1812 if (!*iter)
1811 continue; 1813 continue;
1812 Tile* tile = *iter; 1814 Tile* tile = *iter;
1813 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { 1815 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) {
1814 num_inside++; 1816 num_inside++;
1815 // Mark everything in viewport for tile priority as ready to draw. 1817 // Mark everything in viewport for tile priority as ready to draw.
1816 TileDrawInfo& draw_info = tile->draw_info(); 1818 TileDrawInfo& draw_info = tile->draw_info();
1817 draw_info.SetSolidColorForTesting(SK_ColorRED); 1819 draw_info.SetSolidColorForTesting(SK_ColorRED);
1818 } else { 1820 } else {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 Tile* some_active_tile = 2066 Tile* some_active_tile =
2065 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 2067 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2066 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 2068 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2067 2069
2068 // When high res are required, even if the active tree is not ready, 2070 // When high res are required, even if the active tree is not ready,
2069 // the high res tiles must be ready. 2071 // the high res tiles must be ready.
2070 host_impl_.SetRequiresHighResToDraw(); 2072 host_impl_.SetRequiresHighResToDraw();
2071 2073
2072 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2074 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2073 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2075 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2076 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2077 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2074 2078
2075 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2079 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
2076 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2080 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2081 AssertAllTilesRequired(active_layer_->HighResTiling());
2082 AssertNoTilesRequired(active_layer_->LowResTiling());
2077 } 2083 }
2078 2084
2079 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { 2085 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) {
2080 gfx::Size layer_bounds(400, 400); 2086 gfx::Size layer_bounds(400, 400);
2081 gfx::Size tile_size(100, 100); 2087 gfx::Size tile_size(100, 100);
2082 2088
2083 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); 2089 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
2084 2090
2085 Tile* some_active_tile = 2091 Tile* some_active_tile =
2086 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 2092 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2087 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 2093 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2088 2094
2089 // All tiles shared (no invalidation), so even though the active tree's 2095 // Since there are no invalidations, pending tree should have no tiles.
2090 // tiles aren't ready, the high res tiles are required for activation. 2096 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
2091 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2097 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2092 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2093 2098
2094 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2099 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2095 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2100 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2101
2102 AssertAllTilesRequired(active_layer_->HighResTiling());
2103 AssertNoTilesRequired(active_layer_->LowResTiling());
2096 } 2104 }
2097 2105
2098 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { 2106 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) {
2099 gfx::Size layer_bounds(400, 400); 2107 gfx::Size layer_bounds(400, 400);
2100 gfx::Size tile_size(100, 100); 2108 gfx::Size tile_size(100, 100);
2101 2109
2102 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); 2110 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
2103 2111
2104 Tile* some_active_tile = 2112 Tile* some_active_tile =
2105 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 2113 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2106 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 2114 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2107 2115
2116 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
2117 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2118 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
2119 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
2108 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); 2120 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
2109 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); 2121 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
2110 2122
2111 // If we disallow required for activation, no tiles can be required. 2123 // If we disallow required for activation, no tiles can be required.
2112 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2124 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2113 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2125 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2114 2126
2115 AssertNoTilesRequired(pending_layer_->HighResTiling()); 2127 AssertNoTilesRequired(active_layer_->HighResTiling());
2116 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2128 AssertNoTilesRequired(active_layer_->LowResTiling());
2117 } 2129 }
2118 2130
2119 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 2131 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
2120 gfx::Size layer_bounds(400, 400); 2132 gfx::Size layer_bounds(400, 400);
2121 gfx::Size tile_size(100, 100); 2133 gfx::Size tile_size(100, 100);
2122 2134
2123 scoped_refptr<FakePicturePileImpl> pending_pile = 2135 scoped_refptr<FakePicturePileImpl> pending_pile =
2124 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2136 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2125 // This pile will create tilings, but has no recordings so will not create any 2137 // This pile will create tilings, but has no recordings so will not create any
2126 // tiles. This is attempting to simulate scrolling past the end of recorded 2138 // tiles. This is attempting to simulate scrolling past the end of recorded
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); 2192 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds);
2181 scoped_refptr<FakePicturePileImpl> active_pile = 2193 scoped_refptr<FakePicturePileImpl> active_pile =
2182 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); 2194 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds);
2183 2195
2184 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 2196 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region());
2185 2197
2186 // Since the active layer has different bounds, the pending layer needs all 2198 // Since the active layer has different bounds, the pending layer needs all
2187 // high res tiles in order to activate. 2199 // high res tiles in order to activate.
2188 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2200 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2189 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2201 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2202 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2203 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2190 2204
2191 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2205 AssertAllTilesRequired(pending_layer_->HighResTiling());
2192 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2206 AssertAllTilesRequired(active_layer_->HighResTiling());
2207 AssertNoTilesRequired(active_layer_->LowResTiling());
2208 // Since the test doesn't invalidate the resized region, we expect that the
2209 // same low res tile would exist (which means we don't create a new one of the
2210 // pending tree).
2211 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2193 } 2212 }
2194 2213
2195 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 2214 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
2196 gfx::Size tile_size(100, 100); 2215 gfx::Size tile_size(100, 100);
2197 gfx::Size layer_bounds(400, 400); 2216 gfx::Size layer_bounds(400, 400);
2198 scoped_refptr<FakePicturePileImpl> pending_pile = 2217 scoped_refptr<FakePicturePileImpl> pending_pile =
2199 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2218 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2200 2219
2201 host_impl_.CreatePendingTree(); 2220 host_impl_.CreatePendingTree();
2202 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 2221 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 ActivateTree(); 2271 ActivateTree();
2253 2272
2254 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); 2273 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate);
2255 2274
2256 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2275 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2257 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2276 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2258 2277
2259 // pending_tiling->CreateAllTilesForTesting(); 2278 // pending_tiling->CreateAllTilesForTesting();
2260 2279
2261 // Tile 0,0 should be shared, but tile 1,1 should not be. 2280 // Tile 0,0 should be shared, but tile 1,1 should not be.
2262 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2281 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2263 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); 2282 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2264 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); 2283 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2284 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2285 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2286 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2265 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); 2287 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2266 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); 2288 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2267 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); 2289 EXPECT_TRUE(pending_tiling->TileAt(1, 1));
2268 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared());
2269 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared());
2270 2290
2271 // Drop the tiles on the active tree and recreate them. The same tiles 2291 // Drop the tiles on the active tree and recreate them. The same tiles
2272 // should be shared or not. 2292 // should be shared or not.
2273 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); 2293 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion());
2274 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); 2294 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty());
2275 active_tiling->CreateAllTilesForTesting(); 2295 active_tiling->CreateAllTilesForTesting();
2276 2296
2277 // Tile 0,0 should be shared, but tile 1,1 should not be. 2297 // Tile 0,0 should be shared, but tile 1,1 should not be.
2278 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2298 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2279 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); 2299 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2280 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); 2300 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2301 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2302 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2303 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2281 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); 2304 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2282 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); 2305 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2283 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); 2306 EXPECT_TRUE(pending_tiling->TileAt(1, 1));
2284 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared());
2285 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared());
2286 } 2307 }
2287 2308
2288 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) { 2309 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) {
2289 SetupDefaultTrees(gfx::Size(1500, 1500)); 2310 SetupDefaultTrees(gfx::Size(1500, 1500));
2290 2311
2291 EXPECT_GE(active_layer_->num_tilings(), 1u); 2312 EXPECT_GE(active_layer_->num_tilings(), 1u);
2292 EXPECT_GE(pending_layer_->num_tilings(), 1u); 2313 EXPECT_GE(pending_layer_->num_tilings(), 1u);
2293 2314
2294 // No invalidation, so all tiles are shared. 2315 // No invalidation, so all tiles are shared.
2295 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2316 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2296 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2317 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2297 ASSERT_TRUE(active_tiling); 2318 ASSERT_TRUE(active_tiling);
2298 ASSERT_TRUE(pending_tiling); 2319 ASSERT_TRUE(pending_tiling);
2299 2320
2300 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2321 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2301 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2322 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2302 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2323 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2303 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2324 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2304 2325
2305 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); 2326 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2306 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); 2327 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2307 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); 2328 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2308 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2329 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2309
2310 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2311 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared());
2312 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
2313 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared());
2314 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
2315 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared());
2316 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2317 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
2318 } 2330 }
2319 2331
2320 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { 2332 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) {
2321 gfx::Size tile_size(100, 100); 2333 gfx::Size tile_size(100, 100);
2322 gfx::Size layer_bounds(1500, 1500); 2334 gfx::Size layer_bounds(1500, 1500);
2323 2335
2324 scoped_refptr<FakePicturePileImpl> pending_pile = 2336 scoped_refptr<FakePicturePileImpl> pending_pile =
2325 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2337 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2326 scoped_refptr<FakePicturePileImpl> active_pile = 2338 scoped_refptr<FakePicturePileImpl> active_pile =
2327 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2339 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
(...skipping 13 matching lines...) Expand all
2341 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2353 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2342 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2354 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2343 ASSERT_TRUE(active_tiling); 2355 ASSERT_TRUE(active_tiling);
2344 ASSERT_TRUE(pending_tiling); 2356 ASSERT_TRUE(pending_tiling);
2345 2357
2346 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2358 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2347 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2359 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2348 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2360 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2349 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2361 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2350 2362
2351 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); 2363 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2352 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); 2364 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2353 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); 2365 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2354 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2366 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2355
2356 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2357 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared());
2358 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
2359 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared());
2360 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
2361 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared());
2362 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2363 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
2364 } 2367 }
2365 2368
2366 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { 2369 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) {
2367 // Set some invalidation on the pending tree. We should replace raster tiles 2370 // Set some invalidation on the pending tree. We should replace raster tiles
2368 // that touch this. 2371 // that touch this.
2369 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); 2372 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1));
2370 2373
2371 EXPECT_GE(active_layer_->num_tilings(), 1u); 2374 EXPECT_GE(active_layer_->num_tilings(), 1u);
2372 EXPECT_GE(pending_layer_->num_tilings(), 1u); 2375 EXPECT_GE(pending_layer_->num_tilings(), 1u);
2373 2376
2374 // The pending tree invalidation means tiles can not be shared with the 2377 // The pending tree invalidation means tiles can not be shared with the
2375 // active tree. 2378 // active tree.
2376 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2379 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2377 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2380 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2378 ASSERT_TRUE(active_tiling); 2381 ASSERT_TRUE(active_tiling);
2379 ASSERT_TRUE(pending_tiling); 2382 ASSERT_TRUE(pending_tiling);
2380 2383
2381 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2384 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2382 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2385 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2383 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2386 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2384 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2387 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2385 2388
2386 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); 2389 EXPECT_TRUE(pending_tiling->TileAt(0, 0));
2387 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); 2390 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2388 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); 2391 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2389 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2392 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2390 2393
2391 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2394 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2392 EXPECT_FALSE(active_tiling->TileAt(0, 0)->is_shared());
2393 EXPECT_FALSE(pending_tiling->TileAt(0, 0)->is_shared());
2394 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
2395 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared());
2396 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
2397 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
2398 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2399 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
2400 } 2395 }
2401 2396
2402 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { 2397 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) {
2403 base::TimeTicks time_ticks; 2398 base::TimeTicks time_ticks;
2404 time_ticks += base::TimeDelta::FromMilliseconds(1); 2399 time_ticks += base::TimeDelta::FromMilliseconds(1);
2405 host_impl_.SetCurrentBeginFrameArgs( 2400 host_impl_.SetCurrentBeginFrameArgs(
2406 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 2401 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2407 2402
2408 gfx::Size tile_size(100, 100); 2403 gfx::Size tile_size(100, 100);
2409 gfx::Size layer_bounds(10, 10); 2404 gfx::Size layer_bounds(10, 10);
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 3313
3319 // Make sure some tiles are not shared. 3314 // Make sure some tiles are not shared.
3320 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3315 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3321 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3316 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3322 3317
3323 // All pending layer tiles required are not ready. 3318 // All pending layer tiles required are not ready.
3324 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3319 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3325 3320
3326 // Initialize all low-res tiles. 3321 // Initialize all low-res tiles.
3327 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 3322 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
3323 pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling());
3328 3324
3329 // Low-res tiles should not be enough. 3325 // Low-res tiles should not be enough.
3330 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3326 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3331 3327
3332 // Initialize remaining tiles. 3328 // Initialize remaining tiles.
3333 pending_layer_->SetAllTilesReady(); 3329 pending_layer_->SetAllTilesReady();
3330 active_layer_->SetAllTilesReady();
3334 3331
3335 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 3332 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3336 } 3333 }
3337 3334
3338 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { 3335 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {
3339 gfx::Size tile_size(100, 100); 3336 gfx::Size tile_size(100, 100);
3340 gfx::Size layer_bounds(1000, 1000); 3337 gfx::Size layer_bounds(1000, 1000);
3341 3338
3342 // Make sure some tiles are not shared. 3339 // Make sure some tiles are not shared.
3343 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3340 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3344 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3341 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3345 3342
3346 // All pending layer tiles required are not ready. 3343 // All pending layer tiles required are not ready.
3347 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3344 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3348 3345
3349 // Initialize all high-res tiles. 3346 // Initialize all high-res tiles.
3350 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 3347 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3348 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
3351 3349
3352 // High-res tiles should be enough, since they cover everything visible. 3350 // High-res tiles should be enough, since they cover everything visible.
3353 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 3351 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3354 } 3352 }
3355 3353
3356 TEST_F(PictureLayerImplTest, 3354 TEST_F(PictureLayerImplTest,
3357 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { 3355 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
3358 gfx::Size tile_size(100, 100); 3356 gfx::Size tile_size(100, 100);
3359 gfx::Size layer_bounds(1000, 1000); 3357 gfx::Size layer_bounds(1000, 1000);
3360 3358
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { 3517 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) {
3520 gfx::Size layer_bounds(400, 400); 3518 gfx::Size layer_bounds(400, 400);
3521 gfx::Size tile_size(100, 100); 3519 gfx::Size tile_size(100, 100);
3522 3520
3523 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); 3521 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
3524 3522
3525 Tile* some_active_tile = 3523 Tile* some_active_tile =
3526 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 3524 active_layer_->HighResTiling()->AllTilesForTesting()[0];
3527 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 3525 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
3528 3526
3529 // All tiles shared (no invalidation), so even though the active tree's 3527 // Since there is no invalidaiton, pending tree should have no tiles.
3530 // tiles aren't ready, there is nothing required. 3528 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
3531 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3532 if (host_impl_.settings().create_low_res_tiling) 3529 if (host_impl_.settings().create_low_res_tiling)
3533 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 3530 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
3534 3531
3535 AssertAllTilesRequired(pending_layer_->HighResTiling()); 3532 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3536 if (host_impl_.settings().create_low_res_tiling) 3533 if (host_impl_.settings().create_low_res_tiling)
3537 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3534 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3535
3536 AssertAllTilesRequired(active_layer_->HighResTiling());
3537 if (host_impl_.settings().create_low_res_tiling)
3538 AssertNoTilesRequired(active_layer_->LowResTiling());
3538 } 3539 }
3539 3540
3540 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 3541 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
3541 gfx::Size layer_bounds(400, 400); 3542 gfx::Size layer_bounds(400, 400);
3542 gfx::Size tile_size(100, 100); 3543 gfx::Size tile_size(100, 100);
3543 3544
3544 scoped_refptr<FakePicturePileImpl> pending_pile = 3545 scoped_refptr<FakePicturePileImpl> pending_pile =
3545 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3546 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3546 // This pile will create tilings, but has no recordings so will not create any 3547 // This pile will create tilings, but has no recordings so will not create any
3547 // tiles. This is attempting to simulate scrolling past the end of recorded 3548 // tiles. This is attempting to simulate scrolling past the end of recorded
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
4829 std::vector<Tile*> tiles; 4830 std::vector<Tile*> tiles;
4830 for (PictureLayerTiling::CoverageIterator iter( 4831 for (PictureLayerTiling::CoverageIterator iter(
4831 pending_layer_->HighResTiling(), 4832 pending_layer_->HighResTiling(),
4832 1.f, 4833 1.f,
4833 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); 4834 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting());
4834 iter; 4835 iter;
4835 ++iter) { 4836 ++iter) {
4836 if (*iter) 4837 if (*iter)
4837 tiles.push_back(*iter); 4838 tiles.push_back(*iter);
4838 } 4839 }
4840 for (PictureLayerTiling::CoverageIterator iter(
4841 active_layer_->HighResTiling(), 1.f,
4842 active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting());
4843 iter; ++iter) {
4844 if (*iter)
4845 tiles.push_back(*iter);
4846 }
4839 4847
4840 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4848 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4841 4849
4842 // Ensure we can activate. 4850 // Ensure we can activate.
4843 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 4851 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
4844 } 4852 }
4845 4853
4846 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { 4854 TEST_F(PictureLayerImplTest, CloneMissingRecordings) {
4847 gfx::Size tile_size(100, 100); 4855 gfx::Size tile_size(100, 100);
4848 gfx::Size layer_bounds(400, 400); 4856 gfx::Size layer_bounds(400, 400);
4849 4857
4850 scoped_refptr<FakePicturePileImpl> filled_pile = 4858 scoped_refptr<FakePicturePileImpl> filled_pile =
4851 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4859 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4852 4860
4853 scoped_ptr<FakePicturePile> partial_recording = 4861 scoped_ptr<FakePicturePile> partial_recording =
4854 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); 4862 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds);
4855 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { 4863 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) {
4856 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) 4864 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j)
4857 partial_recording->AddRecordingAt(i, j); 4865 partial_recording->AddRecordingAt(i, j);
4858 } 4866 }
4859 scoped_refptr<FakePicturePileImpl> partial_pile = 4867 scoped_refptr<FakePicturePileImpl> partial_pile =
4860 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); 4868 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr);
4861 4869
4862 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); 4870 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region());
4863 ActivateTree(); 4871 ActivateTree();
4864 4872
4865 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); 4873 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling();
4866 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); 4874 PictureLayerTiling* active_tiling = active_layer_->HighResTiling();
4867 4875
4868 // We should have all tiles in both tile sets. 4876 // We should have all tiles on active, and none on pending.
4869 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); 4877 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size());
4870 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4878 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4871 4879
4872 // Now put a partially-recorded pile on the pending tree (and invalidate 4880 // Now put a partially-recorded pile on the pending tree (and invalidate
4873 // everything, since the main thread PicturePile will invalidate dropped 4881 // everything, since the main thread PicturePile will invalidate dropped
4874 // recordings). This will cause us to be missing some tiles. 4882 // recordings). This will cause us to be missing some tiles.
4875 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, 4883 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size,
4876 Region(gfx::Rect(layer_bounds))); 4884 Region(gfx::Rect(layer_bounds)));
4877 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); 4885 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size());
4878 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); 4886 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
4879 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 4887 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
4880 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); 4888 EXPECT_TRUE(pending_tiling->TileAt(2, 2));
4881 4889
4882 // Active is not affected yet. 4890 // Active is not affected yet.
4883 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4891 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4884 4892
4885 // Activate the tree. The same tiles go missing on the active tree. 4893 // Activate the tree. The same tiles go missing on the active tree.
4886 ActivateTree(); 4894 ActivateTree();
4887 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4895 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4888 EXPECT_FALSE(active_tiling->TileAt(0, 0)); 4896 EXPECT_FALSE(active_tiling->TileAt(0, 0));
4889 EXPECT_FALSE(active_tiling->TileAt(1, 1)); 4897 EXPECT_FALSE(active_tiling->TileAt(1, 1));
4890 EXPECT_TRUE(active_tiling->TileAt(2, 2)); 4898 EXPECT_TRUE(active_tiling->TileAt(2, 2));
4891 4899
4892 // Now put a full recording on the pending tree again. We'll get all our tiles 4900 // Now put a full recording on the pending tree again. We'll get all our tiles
4893 // back. 4901 // back.
4894 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, 4902 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size,
4895 Region(gfx::Rect(layer_bounds))); 4903 Region(gfx::Rect(layer_bounds)));
4896 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); 4904 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
4905 Tile* tile00 = pending_tiling->TileAt(0, 0);
4906 Tile* tile11 = pending_tiling->TileAt(1, 1);
4907 Tile* tile22 = pending_tiling->TileAt(2, 2);
4897 4908
4898 // Active is not affected yet. 4909 // Active is not affected yet.
4899 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4910 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4900 4911
4901 // Activate the tree. The tiles are created and shared on the active tree. 4912 // Activate the tree. The tiles are created and shared on the active tree.
4902 ActivateTree(); 4913 ActivateTree();
4903 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4914 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4904 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); 4915 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0));
4905 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); 4916 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1));
4906 EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared()); 4917 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2));
4907 } 4918 }
4908 4919
4909 class TileSizeSettings : public ImplSidePaintingSettings { 4920 class TileSizeSettings : public ImplSidePaintingSettings {
4910 public: 4921 public:
4911 TileSizeSettings() { 4922 TileSizeSettings() {
4912 default_tile_size = gfx::Size(100, 100); 4923 default_tile_size = gfx::Size(100, 100);
4913 max_untiled_layer_size = gfx::Size(200, 200); 4924 max_untiled_layer_size = gfx::Size(200, 200);
4914 } 4925 }
4915 }; 4926 };
4916 4927
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4980 result = layer->CalculateTileSize(gfx::Size(447, 400));
4970 EXPECT_EQ(result.width(), 448); 4981 EXPECT_EQ(result.width(), 448);
4971 EXPECT_EQ(result.height(), 448); 4982 EXPECT_EQ(result.height(), 448);
4972 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4983 result = layer->CalculateTileSize(gfx::Size(500, 499));
4973 EXPECT_EQ(result.width(), 512); 4984 EXPECT_EQ(result.width(), 512);
4974 EXPECT_EQ(result.height(), 500 + 2); 4985 EXPECT_EQ(result.height(), 500 + 2);
4975 } 4986 }
4976 4987
4977 } // namespace 4988 } // namespace
4978 } // namespace cc 4989 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698