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

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: update 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 SetupDrawPropertiesAndUpdateTiles(active_layer_, 280 SetupDrawPropertiesAndUpdateTiles(active_layer_,
281 contents_scale, 281 contents_scale,
282 device_scale_factor, 282 device_scale_factor,
283 page_scale_factor, 283 page_scale_factor,
284 maximum_animation_contents_scale, 284 maximum_animation_contents_scale,
285 animating_transform); 285 animating_transform);
286 } 286 }
287 287
288 void ResetTilingsAndRasterScales() { 288 void ResetTilingsAndRasterScales() {
289 pending_layer_->ReleaseResources(); 289 if (pending_layer_) {
290 EXPECT_FALSE(pending_layer_->tilings()); 290 pending_layer_->ReleaseResources();
291 pending_layer_->RecreateResources(); 291 EXPECT_FALSE(pending_layer_->tilings());
292 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 292 pending_layer_->RecreateResources();
293 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
294 }
293 295
294 active_layer_->ReleaseResources(); 296 if (active_layer_) {
295 EXPECT_FALSE(active_layer_->tilings()); 297 active_layer_->ReleaseResources();
296 active_layer_->RecreateResources(); 298 EXPECT_FALSE(active_layer_->tilings());
297 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 299 active_layer_->RecreateResources();
300 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
301 }
298 } 302 }
299 303
300 void AssertAllTilesRequired(PictureLayerTiling* tiling) { 304 void AssertAllTilesRequired(PictureLayerTiling* tiling) {
301 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 305 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
302 for (size_t i = 0; i < tiles.size(); ++i) 306 for (size_t i = 0; i < tiles.size(); ++i)
303 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; 307 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i;
304 EXPECT_GT(tiles.size(), 0u); 308 EXPECT_GT(tiles.size(), 0u);
305 } 309 }
306 310
307 void AssertNoTilesRequired(PictureLayerTiling* tiling) { 311 void AssertNoTilesRequired(PictureLayerTiling* tiling) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 401 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
398 402
399 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); 403 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
400 404
401 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 405 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
402 active_layer_->tilings()->num_tilings()); 406 active_layer_->tilings()->num_tilings());
403 407
404 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 408 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
405 EXPECT_GT(tilings->num_tilings(), 0u); 409 EXPECT_GT(tilings->num_tilings(), 0u);
406 for (size_t i = 0; i < tilings->num_tilings(); ++i) 410 for (size_t i = 0; i < tilings->num_tilings(); ++i)
407 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); 411 EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty());
408 } 412 }
409 413
410 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { 414 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) {
411 base::TimeTicks time_ticks; 415 base::TimeTicks time_ticks;
412 time_ticks += base::TimeDelta::FromMilliseconds(1); 416 time_ticks += base::TimeDelta::FromMilliseconds(1);
413 host_impl_.SetCurrentBeginFrameArgs( 417 host_impl_.SetCurrentBeginFrameArgs(
414 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 418 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
415 gfx::Size tile_size(100, 100); 419 gfx::Size tile_size(100, 100);
416 gfx::Size layer_bounds(400, 400); 420 gfx::Size layer_bounds(400, 400);
417 421
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 const PictureLayerTiling* tiling = tilings->tiling_at(i); 679 const PictureLayerTiling* tiling = tilings->tiling_at(i);
676 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( 680 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect(
677 layer_invalidation, 681 layer_invalidation,
678 tiling->contents_scale()); 682 tiling->contents_scale());
679 for (PictureLayerTiling::CoverageIterator iter( 683 for (PictureLayerTiling::CoverageIterator iter(
680 tiling, 684 tiling,
681 tiling->contents_scale(), 685 tiling->contents_scale(),
682 gfx::Rect(tiling->tiling_size())); 686 gfx::Rect(tiling->tiling_size()));
683 iter; 687 iter;
684 ++iter) { 688 ++iter) {
685 EXPECT_TRUE(*iter); 689 // We don't always have a tile, but when we do it's because it was
686 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 690 // invalidated and it has the latest raster source.
687 EXPECT_EQ(pending_pile.get(), iter->raster_source()); 691 if (*iter) {
692 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
693 EXPECT_EQ(pending_pile.get(), iter->raster_source());
694 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation));
695 } else {
696 // We don't create tiles in non-invalidated regions.
697 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation));
698 }
688 } 699 }
689 } 700 }
690 701
691 tilings = active_layer_->tilings(); 702 tilings = active_layer_->tilings();
692 EXPECT_GT(tilings->num_tilings(), 0u); 703 EXPECT_GT(tilings->num_tilings(), 0u);
693 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 704 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
694 const PictureLayerTiling* tiling = tilings->tiling_at(i); 705 const PictureLayerTiling* tiling = tilings->tiling_at(i);
695 gfx::Rect content_invalidation = 706 gfx::Rect content_invalidation =
696 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); 707 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale());
697 for (PictureLayerTiling::CoverageIterator iter( 708 for (PictureLayerTiling::CoverageIterator iter(
698 tiling, 709 tiling,
699 tiling->contents_scale(), 710 tiling->contents_scale(),
700 gfx::Rect(tiling->tiling_size())); 711 gfx::Rect(tiling->tiling_size()));
701 iter; 712 iter;
702 ++iter) { 713 ++iter) {
703 EXPECT_TRUE(*iter); 714 EXPECT_TRUE(*iter);
704 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 715 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
705 if (iter.geometry_rect().Intersects(content_invalidation)) 716 // Pile will be updated upon activation.
706 EXPECT_EQ(active_pile.get(), iter->raster_source()); 717 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 } 718 }
712 } 719 }
713 } 720 }
714 721
715 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { 722 TEST_F(PictureLayerImplTest, CloneFullInvalidation) {
716 gfx::Size tile_size(90, 80); 723 gfx::Size tile_size(90, 80);
717 gfx::Size layer_bounds(300, 500); 724 gfx::Size layer_bounds(300, 500);
718 725
719 scoped_refptr<FakePicturePileImpl> pending_pile = 726 scoped_refptr<FakePicturePileImpl> pending_pile =
720 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 727 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 // This should create new tilings. 1525 // This should create new tilings.
1519 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1526 SetupDrawPropertiesAndUpdateTiles(pending_layer_,
1520 1.f, // ideal contents scale 1527 1.f, // ideal contents scale
1521 1.f, // device scale 1528 1.f, // device scale
1522 1.f, // page scale 1529 1.f, // page scale
1523 1.f, // maximum animation scale 1530 1.f, // maximum animation scale
1524 false); 1531 false);
1525 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); 1532 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
1526 } 1533 }
1527 1534
1528 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { 1535 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
1529 // The default max tile size is larger than 400x400. 1536 // The default max tile size is larger than 400x400.
1530 gfx::Size tile_size(400, 400); 1537 gfx::Size tile_size(400, 400);
1531 gfx::Size layer_bounds(5000, 5000); 1538 gfx::Size layer_bounds(5000, 5000);
1532 1539
1533 scoped_refptr<FakePicturePileImpl> pending_pile = 1540 scoped_refptr<FakePicturePileImpl> pending_pile =
1534 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1541 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1535 scoped_refptr<FakePicturePileImpl> active_pile =
1536 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1537 1542
1538 SetupTrees(pending_pile, active_pile); 1543 SetupPendingTree(pending_pile);
1539 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); 1544 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u);
1540 1545
1541 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1546 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1542 1547
1543 // The default value. 1548 // The default value.
1544 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1549 EXPECT_EQ(gfx::Size(256, 256).ToString(),
1545 host_impl_.settings().default_tile_size.ToString()); 1550 host_impl_.settings().default_tile_size.ToString());
1546 1551
1547 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1552 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1548 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1553 EXPECT_EQ(gfx::Size(256, 256).ToString(),
(...skipping 24 matching lines...) Expand all
1573 // The default max tile size is larger than 400x400. 1578 // The default max tile size is larger than 400x400.
1574 gfx::Size tile_size(400, 400); 1579 gfx::Size tile_size(400, 400);
1575 gfx::Size layer_bounds(500, 500); 1580 gfx::Size layer_bounds(500, 500);
1576 1581
1577 scoped_refptr<FakePicturePileImpl> pending_pile = 1582 scoped_refptr<FakePicturePileImpl> pending_pile =
1578 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1583 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1579 scoped_refptr<FakePicturePileImpl> active_pile = 1584 scoped_refptr<FakePicturePileImpl> active_pile =
1580 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1585 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1581 1586
1582 SetupTrees(pending_pile, active_pile); 1587 SetupTrees(pending_pile, active_pile);
1583 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); 1588 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u);
1584 1589
1585 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1590 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1586 1591
1587 // The default value. The layer is smaller than this. 1592 // The default value. The layer is smaller than this.
1588 EXPECT_EQ(gfx::Size(512, 512).ToString(), 1593 EXPECT_EQ(gfx::Size(512, 512).ToString(),
1589 host_impl_.settings().max_untiled_layer_size.ToString()); 1594 host_impl_.settings().max_untiled_layer_size.ToString());
1590 1595
1591 // There should be a single tile since the layer is small. 1596 // There should be a single tile since the layer is small.
1592 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); 1597 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0);
1593 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); 1598 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size());
1594 1599
1595 ResetTilingsAndRasterScales(); 1600 ResetTilingsAndRasterScales();
1596 1601
1597 // Change the max texture size on the output surface context. 1602 // Change the max texture size on the output surface context.
1598 scoped_ptr<TestWebGraphicsContext3D> context = 1603 scoped_ptr<TestWebGraphicsContext3D> context =
1599 TestWebGraphicsContext3D::Create(); 1604 TestWebGraphicsContext3D::Create();
1600 context->set_max_texture_size(140); 1605 context->set_max_texture_size(140);
1601 host_impl_.DidLoseOutputSurface(); 1606 host_impl_.DidLoseOutputSurface();
1602 host_impl_.InitializeRenderer( 1607 host_impl_.InitializeRenderer(
1603 FakeOutputSurface::Create3d(context.Pass()).Pass()); 1608 FakeOutputSurface::Create3d(context.Pass()).Pass());
1604 1609
1605 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); 1610 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
1606 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); 1611 ASSERT_LE(1u, active_layer_->tilings()->num_tilings());
1607 1612
1608 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1613 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1609 1614
1610 // There should be more than one tile since the max texture size won't cover 1615 // There should be more than one tile since the max texture size won't cover
1611 // the layer. 1616 // the layer.
1612 high_res_tiling = pending_layer_->tilings()->tiling_at(0); 1617 high_res_tiling = active_layer_->tilings()->tiling_at(0);
1613 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); 1618 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size());
1614 1619
1615 // Verify the tiles are not larger than the context's max texture size. 1620 // Verify the tiles are not larger than the context's max texture size.
1616 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1621 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1617 EXPECT_GE(140, tile->content_rect().width()); 1622 EXPECT_GE(140, tile->content_rect().width());
1618 EXPECT_GE(140, tile->content_rect().height()); 1623 EXPECT_GE(140, tile->content_rect().height());
1619 } 1624 }
1620 1625
1621 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { 1626 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) {
1622 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1627 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1623 1628
1624 gfx::Size tile_size(400, 400); 1629 gfx::Size tile_size(400, 400);
1625 gfx::Size layer_bounds(1300, 1900); 1630 gfx::Size layer_bounds(1300, 1900);
1626 1631
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 host_impl_.SetCurrentBeginFrameArgs( 1800 host_impl_.SetCurrentBeginFrameArgs(
1796 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 1801 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
1797 pending_layer_->UpdateTiles(resourceless_software_draw); 1802 pending_layer_->UpdateTiles(resourceless_software_draw);
1798 1803
1799 // Intersect the two rects. Any tile outside should not be required for 1804 // Intersect the two rects. Any tile outside should not be required for
1800 // activation. 1805 // activation.
1801 gfx::Rect viewport_for_tile_priority = 1806 gfx::Rect viewport_for_tile_priority =
1802 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); 1807 pending_layer_->viewport_rect_for_tile_priority_in_content_space();
1803 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); 1808 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect());
1804 1809
1810 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
1811
1805 int num_inside = 0; 1812 int num_inside = 0;
1806 int num_outside = 0; 1813 int num_outside = 0;
1807 for (PictureLayerTiling::CoverageIterator iter( 1814 for (PictureLayerTiling::CoverageIterator iter(active_layer_->HighResTiling(),
1808 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); 1815 1.f, gfx::Rect(layer_bounds));
1809 iter; ++iter) { 1816 iter; ++iter) {
1810 if (!*iter) 1817 if (!*iter)
1811 continue; 1818 continue;
1812 Tile* tile = *iter; 1819 Tile* tile = *iter;
1813 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { 1820 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) {
1814 num_inside++; 1821 num_inside++;
1815 // Mark everything in viewport for tile priority as ready to draw. 1822 // Mark everything in viewport for tile priority as ready to draw.
1816 TileDrawInfo& draw_info = tile->draw_info(); 1823 TileDrawInfo& draw_info = tile->draw_info();
1817 draw_info.SetSolidColorForTesting(SK_ColorRED); 1824 draw_info.SetSolidColorForTesting(SK_ColorRED);
1818 } else { 1825 } else {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 Tile* some_active_tile = 2071 Tile* some_active_tile =
2065 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 2072 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2066 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 2073 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2067 2074
2068 // When high res are required, even if the active tree is not ready, 2075 // When high res are required, even if the active tree is not ready,
2069 // the high res tiles must be ready. 2076 // the high res tiles must be ready.
2070 host_impl_.SetRequiresHighResToDraw(); 2077 host_impl_.SetRequiresHighResToDraw();
2071 2078
2072 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2079 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2073 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2080 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2081 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2082 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2074 2083
2075 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2084 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
2076 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2085 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2086 AssertAllTilesRequired(active_layer_->HighResTiling());
2087 AssertNoTilesRequired(active_layer_->LowResTiling());
2077 } 2088 }
2078 2089
2079 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { 2090 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) {
enne (OOO) 2015/04/13 22:36:02 AllHighResRequiredEvenIfAirquotesSharedAirquotes
vmpstr 2015/04/13 23:52:13 Done.
2080 gfx::Size layer_bounds(400, 400); 2091 gfx::Size layer_bounds(400, 400);
2081 gfx::Size tile_size(100, 100); 2092 gfx::Size tile_size(100, 100);
2082 2093
2083 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); 2094 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
2084 2095
2085 Tile* some_active_tile = 2096 Tile* some_active_tile =
2086 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 2097 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2087 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 2098 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2088 2099
2089 // All tiles shared (no invalidation), so even though the active tree's 2100 // Since there are no invalidations, pending tree should have no tiles.
2090 // tiles aren't ready, the high res tiles are required for activation. 2101 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
2091 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2102 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2092 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2093 2103
2094 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2104 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2095 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2105 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2106
2107 AssertAllTilesRequired(active_layer_->HighResTiling());
2108 AssertNoTilesRequired(active_layer_->LowResTiling());
2096 } 2109 }
2097 2110
2098 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { 2111 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) {
2099 gfx::Size layer_bounds(400, 400); 2112 gfx::Size layer_bounds(400, 400);
2100 gfx::Size tile_size(100, 100); 2113 gfx::Size tile_size(100, 100);
2101 2114
2102 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); 2115 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
2103 2116
2104 Tile* some_active_tile = 2117 Tile* some_active_tile =
2105 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 2118 active_layer_->HighResTiling()->AllTilesForTesting()[0];
2106 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 2119 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
2107 2120
2121 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
2122 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2123 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
2124 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
2108 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); 2125 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
2109 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); 2126 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
2110 2127
2111 // If we disallow required for activation, no tiles can be required. 2128 // If we disallow required for activation, no tiles can be required.
2112 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2129 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2113 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2130 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2114 2131
2115 AssertNoTilesRequired(pending_layer_->HighResTiling()); 2132 AssertNoTilesRequired(active_layer_->HighResTiling());
2116 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2133 AssertNoTilesRequired(active_layer_->LowResTiling());
2117 } 2134 }
2118 2135
2119 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 2136 TEST_F(PictureLayerImplTest, EverythingRequiredIfActiveMissingTiles) {
enne (OOO) 2015/04/13 22:36:02 O_o? This was an optimization to make it possible
vmpstr 2015/04/13 23:52:12 I've changed this back. I'm not sure it's worth it
vmpstr 2015/04/13 23:53:48 I guess in a fast scroll it can happen after a fli
2120 gfx::Size layer_bounds(400, 400); 2137 gfx::Size layer_bounds(400, 400);
2121 gfx::Size tile_size(100, 100); 2138 gfx::Size tile_size(100, 100);
2122 2139
2123 scoped_refptr<FakePicturePileImpl> pending_pile = 2140 scoped_refptr<FakePicturePileImpl> pending_pile =
2124 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2141 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2125 // This pile will create tilings, but has no recordings so will not create any 2142 // 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 2143 // tiles. This is attempting to simulate scrolling past the end of recorded
2127 // content on the active layer, where the recordings are so far away that 2144 // content on the active layer, where the recordings are so far away that
2128 // no tiles are created. 2145 // no tiles are created.
2129 bool is_solid_color = false; 2146 bool is_solid_color = false;
2130 scoped_refptr<FakePicturePileImpl> active_pile = 2147 scoped_refptr<FakePicturePileImpl> active_pile =
2131 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 2148 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
2132 tile_size, layer_bounds, is_solid_color); 2149 tile_size, layer_bounds, is_solid_color);
2133 2150
2134 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 2151 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region());
2135 2152
2136 // Active layer has tilings, but no tiles due to missing recordings. 2153 // Active layer has tilings, but no tiles due to missing recordings.
2137 EXPECT_TRUE(active_layer_->CanHaveTilings()); 2154 EXPECT_TRUE(active_layer_->CanHaveTilings());
2138 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 2155 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
2139 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 2156 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
2140 2157
2141 // Since the active layer has no tiles at all, the pending layer doesn't 2158 // Since the active layer has no tiles at all, the pending layer doesn't
2142 // need content in order to activate. 2159 // need content in order to activate.
2143 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2160 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2144 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2161 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2145 2162
2146 AssertNoTilesRequired(pending_layer_->HighResTiling()); 2163 AssertAllTilesRequired(pending_layer_->HighResTiling());
2147 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2164 AssertNoTilesRequired(pending_layer_->LowResTiling());
2148 } 2165 }
2149 2166
2150 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 2167 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
2151 gfx::Size layer_bounds(400, 400); 2168 gfx::Size layer_bounds(400, 400);
2152 gfx::Size tile_size(100, 100); 2169 gfx::Size tile_size(100, 100);
2153 2170
2154 scoped_refptr<FakePicturePileImpl> pending_pile = 2171 scoped_refptr<FakePicturePileImpl> pending_pile =
2155 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2172 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2156 scoped_refptr<FakePicturePileImpl> active_pile = 2173 scoped_refptr<FakePicturePileImpl> active_pile =
(...skipping 23 matching lines...) Expand all
2180 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); 2197 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds);
2181 scoped_refptr<FakePicturePileImpl> active_pile = 2198 scoped_refptr<FakePicturePileImpl> active_pile =
2182 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); 2199 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds);
2183 2200
2184 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 2201 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region());
2185 2202
2186 // Since the active layer has different bounds, the pending layer needs all 2203 // Since the active layer has different bounds, the pending layer needs all
2187 // high res tiles in order to activate. 2204 // high res tiles in order to activate.
2188 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 2205 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2189 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 2206 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2207 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
2208 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
2190 2209
2191 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2210 AssertAllTilesRequired(pending_layer_->HighResTiling());
2192 AssertNoTilesRequired(pending_layer_->LowResTiling()); 2211 AssertAllTilesRequired(active_layer_->HighResTiling());
2212 AssertNoTilesRequired(active_layer_->LowResTiling());
2213 // Since the test doesn't invalidate the resized region, we expect that the
2214 // same low res tile would exist (which means we don't create a new one of the
2215 // pending tree).
2216 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
2193 } 2217 }
2194 2218
2195 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 2219 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
2196 gfx::Size tile_size(100, 100); 2220 gfx::Size tile_size(100, 100);
2197 gfx::Size layer_bounds(400, 400); 2221 gfx::Size layer_bounds(400, 400);
2198 scoped_refptr<FakePicturePileImpl> pending_pile = 2222 scoped_refptr<FakePicturePileImpl> pending_pile =
2199 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2223 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2200 2224
2201 host_impl_.CreatePendingTree(); 2225 host_impl_.CreatePendingTree();
2202 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 2226 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 // Activate and make a pending tree with an invalidated raster tile 1,1. 2275 // Activate and make a pending tree with an invalidated raster tile 1,1.
2252 ActivateTree(); 2276 ActivateTree();
2253 2277
2254 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); 2278 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate);
2255 2279
2256 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2280 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2257 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2281 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2258 2282
2259 // pending_tiling->CreateAllTilesForTesting(); 2283 // pending_tiling->CreateAllTilesForTesting();
2260 2284
2261 // Tile 0,0 should be shared, but tile 1,1 should not be. 2285 // Tile 0,0 should be shared, but tile 1,1 should not be.
enne (OOO) 2015/04/13 22:36:02 Can you change this comment (and other comments [a
vmpstr 2015/04/13 23:52:12 Done.
2262 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2286 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2263 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); 2287 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2264 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); 2288 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2289 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2290 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2291 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2265 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); 2292 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2266 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); 2293 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2267 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); 2294 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 2295
2271 // Drop the tiles on the active tree and recreate them. The same tiles 2296 // Drop the tiles on the active tree and recreate them. The same tiles
2272 // should be shared or not. 2297 // should be shared or not.
2273 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); 2298 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion());
2274 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); 2299 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty());
2275 active_tiling->CreateAllTilesForTesting(); 2300 active_tiling->CreateAllTilesForTesting();
2276 2301
2277 // Tile 0,0 should be shared, but tile 1,1 should not be. 2302 // 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)); 2303 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2279 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); 2304 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2280 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); 2305 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2306 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2307 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2308 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2281 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); 2309 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2282 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); 2310 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2283 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); 2311 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 } 2312 }
2287 2313
2288 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) { 2314 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) {
2289 SetupDefaultTrees(gfx::Size(1500, 1500)); 2315 SetupDefaultTrees(gfx::Size(1500, 1500));
2290 2316
2291 EXPECT_GE(active_layer_->num_tilings(), 1u); 2317 EXPECT_GE(active_layer_->num_tilings(), 1u);
2292 EXPECT_GE(pending_layer_->num_tilings(), 1u); 2318 EXPECT_GE(pending_layer_->num_tilings(), 1u);
2293 2319
2294 // No invalidation, so all tiles are shared. 2320 // No invalidation, so all tiles are shared.
2295 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2321 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2296 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2322 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2297 ASSERT_TRUE(active_tiling); 2323 ASSERT_TRUE(active_tiling);
2298 ASSERT_TRUE(pending_tiling); 2324 ASSERT_TRUE(pending_tiling);
2299 2325
2300 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2326 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2301 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2327 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2302 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2328 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2303 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2329 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2304 2330
2305 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); 2331 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2306 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); 2332 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2307 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); 2333 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2308 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2334 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 } 2335 }
2319 2336
2320 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { 2337 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) {
2321 gfx::Size tile_size(100, 100); 2338 gfx::Size tile_size(100, 100);
2322 gfx::Size layer_bounds(1500, 1500); 2339 gfx::Size layer_bounds(1500, 1500);
2323 2340
2324 scoped_refptr<FakePicturePileImpl> pending_pile = 2341 scoped_refptr<FakePicturePileImpl> pending_pile =
2325 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2342 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2326 scoped_refptr<FakePicturePileImpl> active_pile = 2343 scoped_refptr<FakePicturePileImpl> active_pile =
2327 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2344 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
(...skipping 13 matching lines...) Expand all
2341 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2358 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2342 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2359 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2343 ASSERT_TRUE(active_tiling); 2360 ASSERT_TRUE(active_tiling);
2344 ASSERT_TRUE(pending_tiling); 2361 ASSERT_TRUE(pending_tiling);
2345 2362
2346 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2363 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2347 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2364 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2348 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2365 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2349 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2366 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2350 2367
2351 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); 2368 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2352 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); 2369 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2353 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); 2370 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2354 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2371 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 } 2372 }
2365 2373
2366 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { 2374 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) {
2367 // Set some invalidation on the pending tree. We should replace raster tiles 2375 // Set some invalidation on the pending tree. We should replace raster tiles
2368 // that touch this. 2376 // that touch this.
2369 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); 2377 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1));
2370 2378
2371 EXPECT_GE(active_layer_->num_tilings(), 1u); 2379 EXPECT_GE(active_layer_->num_tilings(), 1u);
2372 EXPECT_GE(pending_layer_->num_tilings(), 1u); 2380 EXPECT_GE(pending_layer_->num_tilings(), 1u);
2373 2381
2374 // The pending tree invalidation means tiles can not be shared with the 2382 // The pending tree invalidation means tiles can not be shared with the
2375 // active tree. 2383 // active tree.
2376 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2384 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2377 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2385 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2378 ASSERT_TRUE(active_tiling); 2386 ASSERT_TRUE(active_tiling);
2379 ASSERT_TRUE(pending_tiling); 2387 ASSERT_TRUE(pending_tiling);
2380 2388
2381 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2389 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2382 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2390 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2383 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2391 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2384 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2392 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2385 2393
2386 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); 2394 EXPECT_TRUE(pending_tiling->TileAt(0, 0));
2387 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); 2395 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2388 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); 2396 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2389 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2397 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2390 2398
2391 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2399 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 } 2400 }
2401 2401
2402 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { 2402 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) {
2403 base::TimeTicks time_ticks; 2403 base::TimeTicks time_ticks;
2404 time_ticks += base::TimeDelta::FromMilliseconds(1); 2404 time_ticks += base::TimeDelta::FromMilliseconds(1);
2405 host_impl_.SetCurrentBeginFrameArgs( 2405 host_impl_.SetCurrentBeginFrameArgs(
2406 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 2406 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
2407 2407
2408 gfx::Size tile_size(100, 100); 2408 gfx::Size tile_size(100, 100);
2409 gfx::Size layer_bounds(10, 10); 2409 gfx::Size layer_bounds(10, 10);
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 3270
3271 // Make sure some tiles are not shared. 3271 // Make sure some tiles are not shared.
3272 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3272 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3273 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3273 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3274 3274
3275 // All pending layer tiles required are not ready. 3275 // All pending layer tiles required are not ready.
3276 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3276 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3277 3277
3278 // Initialize all low-res tiles. 3278 // Initialize all low-res tiles.
3279 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 3279 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
3280 pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling());
3280 3281
3281 // Low-res tiles should not be enough. 3282 // Low-res tiles should not be enough.
3282 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3283 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3283 3284
3284 // Initialize remaining tiles. 3285 // Initialize remaining tiles.
3285 pending_layer_->SetAllTilesReady(); 3286 pending_layer_->SetAllTilesReady();
3287 active_layer_->SetAllTilesReady();
3286 3288
3287 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 3289 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3288 } 3290 }
3289 3291
3290 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { 3292 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {
3291 gfx::Size tile_size(100, 100); 3293 gfx::Size tile_size(100, 100);
3292 gfx::Size layer_bounds(1000, 1000); 3294 gfx::Size layer_bounds(1000, 1000);
3293 3295
3294 // Make sure some tiles are not shared. 3296 // Make sure some tiles are not shared.
3295 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3297 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3296 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3298 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3297 3299
3298 // All pending layer tiles required are not ready. 3300 // All pending layer tiles required are not ready.
3299 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3301 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3300 3302
3301 // Initialize all high-res tiles. 3303 // Initialize all high-res tiles.
3302 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 3304 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3305 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
3303 3306
3304 // High-res tiles should be enough, since they cover everything visible. 3307 // High-res tiles should be enough, since they cover everything visible.
3305 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 3308 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3306 } 3309 }
3307 3310
3308 TEST_F(PictureLayerImplTest, 3311 TEST_F(PictureLayerImplTest,
3309 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { 3312 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
3310 gfx::Size tile_size(100, 100); 3313 gfx::Size tile_size(100, 100);
3311 gfx::Size layer_bounds(1000, 1000); 3314 gfx::Size layer_bounds(1000, 1000);
3312 3315
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3471 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { 3474 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) {
3472 gfx::Size layer_bounds(400, 400); 3475 gfx::Size layer_bounds(400, 400);
3473 gfx::Size tile_size(100, 100); 3476 gfx::Size tile_size(100, 100);
3474 3477
3475 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); 3478 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
3476 3479
3477 Tile* some_active_tile = 3480 Tile* some_active_tile =
3478 active_layer_->HighResTiling()->AllTilesForTesting()[0]; 3481 active_layer_->HighResTiling()->AllTilesForTesting()[0];
3479 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); 3482 EXPECT_FALSE(some_active_tile->IsReadyToDraw());
3480 3483
3481 // All tiles shared (no invalidation), so even though the active tree's 3484 // Since there is no invalidaiton, pending tree should have no tiles.
3482 // tiles aren't ready, there is nothing required. 3485 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
3483 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3484 if (host_impl_.settings().create_low_res_tiling) 3486 if (host_impl_.settings().create_low_res_tiling)
3485 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 3487 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
3486 3488
3487 AssertAllTilesRequired(pending_layer_->HighResTiling()); 3489 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3488 if (host_impl_.settings().create_low_res_tiling) 3490 if (host_impl_.settings().create_low_res_tiling)
3489 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3491 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3492
3493 AssertAllTilesRequired(active_layer_->HighResTiling());
3494 if (host_impl_.settings().create_low_res_tiling)
3495 AssertNoTilesRequired(active_layer_->LowResTiling());
3490 } 3496 }
3491 3497
3492 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 3498 TEST_F(NoLowResPictureLayerImplTest, EverythingRequiredIfActiveMissingTiles) {
3493 gfx::Size layer_bounds(400, 400); 3499 gfx::Size layer_bounds(400, 400);
3494 gfx::Size tile_size(100, 100); 3500 gfx::Size tile_size(100, 100);
3495 3501
3496 scoped_refptr<FakePicturePileImpl> pending_pile = 3502 scoped_refptr<FakePicturePileImpl> pending_pile =
3497 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3503 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3498 // This pile will create tilings, but has no recordings so will not create any 3504 // This pile will create tilings, but has no recordings so will not create any
3499 // tiles. This is attempting to simulate scrolling past the end of recorded 3505 // tiles. This is attempting to simulate scrolling past the end of recorded
3500 // content on the active layer, where the recordings are so far away that 3506 // content on the active layer, where the recordings are so far away that
3501 // no tiles are created. 3507 // no tiles are created.
3502 bool is_solid_color = false; 3508 bool is_solid_color = false;
3503 scoped_refptr<FakePicturePileImpl> active_pile = 3509 scoped_refptr<FakePicturePileImpl> active_pile =
3504 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 3510 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
3505 tile_size, layer_bounds, is_solid_color); 3511 tile_size, layer_bounds, is_solid_color);
3506 3512
3507 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 3513 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region());
3508 3514
3509 // Active layer has tilings, but no tiles due to missing recordings. 3515 // Active layer has tilings, but no tiles due to missing recordings.
3510 EXPECT_TRUE(active_layer_->CanHaveTilings()); 3516 EXPECT_TRUE(active_layer_->CanHaveTilings());
3511 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 3517 EXPECT_EQ(active_layer_->tilings()->num_tilings(),
3512 host_impl_.settings().create_low_res_tiling ? 2u : 1u); 3518 host_impl_.settings().create_low_res_tiling ? 2u : 1u);
3513 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 3519 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
3514 3520
3515 // Since the active layer has no tiles at all, the pending layer doesn't 3521 // Since the active layer has no tiles at all, the pending layer doesn't
3516 // need content in order to activate. 3522 // need content in order to activate.
3517 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 3523 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
3518 if (host_impl_.settings().create_low_res_tiling) 3524 if (host_impl_.settings().create_low_res_tiling)
3519 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); 3525 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting();
3520 3526
3521 AssertNoTilesRequired(pending_layer_->HighResTiling()); 3527 AssertAllTilesRequired(pending_layer_->HighResTiling());
3522 if (host_impl_.settings().create_low_res_tiling) 3528 if (host_impl_.settings().create_low_res_tiling)
3523 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3529 AssertAllTilesRequired(pending_layer_->LowResTiling());
3524 } 3530 }
3525 3531
3526 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { 3532 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
3527 base::TimeTicks time_ticks; 3533 base::TimeTicks time_ticks;
3528 time_ticks += base::TimeDelta::FromMilliseconds(1); 3534 time_ticks += base::TimeDelta::FromMilliseconds(1);
3529 host_impl_.SetCurrentBeginFrameArgs( 3535 host_impl_.SetCurrentBeginFrameArgs(
3530 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 3536 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
3531 3537
3532 gfx::Size tile_size(100, 100); 3538 gfx::Size tile_size(100, 100);
3533 gfx::Size layer_bounds(400, 400); 3539 gfx::Size layer_bounds(400, 400);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
3865 }; 3871 };
3866 3872
3867 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { 3873 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
3868 public: 3874 public:
3869 OcclusionTrackingPictureLayerImplTest() 3875 OcclusionTrackingPictureLayerImplTest()
3870 : PictureLayerImplTest(OcclusionTrackingSettings()) {} 3876 : PictureLayerImplTest(OcclusionTrackingSettings()) {}
3871 3877
3872 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, 3878 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer,
3873 FakePictureLayerImpl* twin_layer, 3879 FakePictureLayerImpl* twin_layer,
3874 WhichTree tree, 3880 WhichTree tree,
3875 size_t expected_occluded_tile_count) { 3881 size_t expected_occluded_tile_count,
3876 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; 3882 int source_line) {
3877 size_t occluded_tile_count = 0u; 3883 size_t occluded_tile_count = 0u;
3878 Tile* last_tile = nullptr; 3884 Tile* last_tile = nullptr;
3879 std::set<Tile*> shared_tiles;
3880 3885
3881 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( 3886 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue(
3882 layer->picture_layer_tiling_set(), layer && twin_layer)); 3887 layer->picture_layer_tiling_set(), layer && twin_layer));
3883 while (!queue->IsEmpty()) { 3888 while (!queue->IsEmpty()) {
3884 Tile* tile = queue->Top(); 3889 Tile* tile = queue->Top();
3885 if (!last_tile) 3890 if (!last_tile)
3886 last_tile = tile; 3891 last_tile = tile;
3887 if (tile->is_shared())
3888 EXPECT_TRUE(shared_tiles.insert(tile).second);
3889 3892
3890 // The only way we will encounter an occluded tile after an unoccluded 3893 // The only way we will encounter an occluded tile after an unoccluded
3891 // tile is if the priorty bin decreased, the tile is required for 3894 // tile is if the priorty bin decreased, the tile is required for
3892 // activation, or the scale changed. 3895 // activation, or the scale changed.
3893 bool tile_is_occluded = tile->is_occluded(tree); 3896 bool tile_is_occluded = tile->is_occluded(tree);
3894 if (tile_is_occluded) { 3897 if (tile_is_occluded) {
3895 occluded_tile_count++; 3898 occluded_tile_count++;
3896 3899
3897 bool last_tile_is_occluded = last_tile->is_occluded(tree); 3900 bool last_tile_is_occluded = last_tile->is_occluded(tree);
3898 if (!last_tile_is_occluded) { 3901 if (!last_tile_is_occluded) {
3899 TilePriority::PriorityBin tile_priority_bin = 3902 TilePriority::PriorityBin tile_priority_bin =
3900 tile->priority(tree).priority_bin; 3903 tile->priority(tree).priority_bin;
3901 TilePriority::PriorityBin last_tile_priority_bin = 3904 TilePriority::PriorityBin last_tile_priority_bin =
3902 last_tile->priority(tree).priority_bin; 3905 last_tile->priority(tree).priority_bin;
3903 3906
3904 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || 3907 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin ||
3905 tile->required_for_activation() || 3908 tile->required_for_activation() ||
3906 tile->contents_scale() != last_tile->contents_scale()); 3909 tile->contents_scale() != last_tile->contents_scale())
3910 << "line: " << source_line;
3907 } 3911 }
3908 } 3912 }
3909 last_tile = tile; 3913 last_tile = tile;
3910 queue->Pop(); 3914 queue->Pop();
3911 } 3915 }
3912 // Count also shared tiles which are occluded in the tree but which were 3916 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count)
3913 // not returned by the tiling set eviction queue. Those shared tiles 3917 << "line: " << source_line;
3914 // shall be returned by the twin tiling set eviction queue.
3915 queue.reset(new TilingSetEvictionQueue(
3916 twin_layer->picture_layer_tiling_set(), layer && twin_layer));
3917 while (!queue->IsEmpty()) {
3918 Tile* tile = queue->Top();
3919 if (tile->is_shared()) {
3920 EXPECT_TRUE(shared_tiles.insert(tile).second);
3921 if (tile->is_occluded(tree))
3922 ++occluded_tile_count;
3923 // Check the reasons why the shared tile was not returned by
3924 // the first tiling set eviction queue.
3925 const TilePriority& combined_priority = tile->combined_priority();
3926 const TilePriority& priority = tile->priority(tree);
3927 const TilePriority& twin_priority = tile->priority(twin_tree);
3928 // Check if the shared tile was not returned by the first tiling
3929 // set eviction queue because it was out of order for the first
3930 // tiling set eviction queue but not for the twin tiling set
3931 // eviction queue.
3932 if (priority.priority_bin != twin_priority.priority_bin) {
3933 EXPECT_LT(combined_priority.priority_bin, priority.priority_bin);
3934 EXPECT_EQ(combined_priority.priority_bin, twin_priority.priority_bin);
3935 } else if (tile->is_occluded(tree) != tile->is_occluded(twin_tree)) {
3936 EXPECT_TRUE(tile->is_occluded(tree));
3937 EXPECT_FALSE(tile->is_occluded(twin_tree));
3938 EXPECT_FALSE(tile->is_occluded_combined());
3939 } else if (priority.distance_to_visible !=
3940 twin_priority.distance_to_visible) {
3941 EXPECT_LT(combined_priority.distance_to_visible,
3942 priority.distance_to_visible);
3943 EXPECT_EQ(combined_priority.distance_to_visible,
3944 twin_priority.distance_to_visible);
3945 } else {
3946 // Shared tiles having the same active and pending priorities
3947 // should be returned only by a pending tree eviction queue.
3948 EXPECT_EQ(ACTIVE_TREE, tree);
3949 }
3950 }
3951 queue->Pop();
3952 }
3953 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count);
3954 } 3918 }
3955 }; 3919 };
3956 3920
3957 TEST_F(OcclusionTrackingPictureLayerImplTest, 3921 TEST_F(OcclusionTrackingPictureLayerImplTest,
3958 OccludedTilesSkippedDuringRasterization) { 3922 OccludedTilesSkippedDuringRasterization) {
3959 base::TimeTicks time_ticks; 3923 base::TimeTicks time_ticks;
3960 time_ticks += base::TimeDelta::FromMilliseconds(1); 3924 time_ticks += base::TimeDelta::FromMilliseconds(1);
3961 host_impl_.SetCurrentBeginFrameArgs( 3925 host_impl_.SetCurrentBeginFrameArgs(
3962 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 3926 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
3963 3927
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
4368 base::TimeTicks time_ticks; 4332 base::TimeTicks time_ticks;
4369 time_ticks += base::TimeDelta::FromMilliseconds(1); 4333 time_ticks += base::TimeDelta::FromMilliseconds(1);
4370 host_impl_.SetCurrentBeginFrameArgs( 4334 host_impl_.SetCurrentBeginFrameArgs(
4371 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4335 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4372 4336
4373 gfx::Size tile_size(102, 102); 4337 gfx::Size tile_size(102, 102);
4374 gfx::Size layer_bounds(1000, 1000); 4338 gfx::Size layer_bounds(1000, 1000);
4375 gfx::Size viewport_size(1000, 1000); 4339 gfx::Size viewport_size(1000, 1000);
4376 gfx::Point pending_occluding_layer_position(310, 0); 4340 gfx::Point pending_occluding_layer_position(310, 0);
4377 gfx::Point active_occluding_layer_position(0, 310); 4341 gfx::Point active_occluding_layer_position(0, 310);
4378 gfx::Rect invalidation_rect(230, 230, 102, 102); 4342 gfx::Rect invalidation_rect(230, 230, 152, 152);
4379 4343
4380 host_impl_.SetViewportSize(viewport_size); 4344 host_impl_.SetViewportSize(viewport_size);
4381 host_impl_.SetDeviceScaleFactor(2.f); 4345 host_impl_.SetDeviceScaleFactor(2.f);
4382 4346
4383 scoped_refptr<FakePicturePileImpl> pending_pile = 4347 scoped_refptr<FakePicturePileImpl> pending_pile =
4384 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4348 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4385 scoped_refptr<FakePicturePileImpl> active_pile = 4349 scoped_refptr<FakePicturePileImpl> active_pile =
4386 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4350 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4387 4351
4388 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); 4352 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region());
4389 4353
4390 // Partially occlude the active layer. 4354 // Partially occlude the active layer.
4391 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); 4355 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2));
4392 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; 4356 LayerImpl* active_occluding_layer = pending_layer_->children()[0];
4393 active_occluding_layer->SetBounds(layer_bounds); 4357 active_occluding_layer->SetBounds(layer_bounds);
4394 active_occluding_layer->SetContentBounds(layer_bounds); 4358 active_occluding_layer->SetContentBounds(layer_bounds);
4395 active_occluding_layer->SetDrawsContent(true); 4359 active_occluding_layer->SetDrawsContent(true);
4396 active_occluding_layer->SetContentsOpaque(true); 4360 active_occluding_layer->SetContentsOpaque(true);
4397 active_occluding_layer->SetPosition(active_occluding_layer_position); 4361 active_occluding_layer->SetPosition(active_occluding_layer_position);
4398 4362
4399 ActivateTree(); 4363 ActivateTree();
4400 4364
4401 // Partially invalidate the pending layer. Tiles inside the invalidation rect 4365 // Partially invalidate the pending layer. Tiles inside the invalidation rect
4402 // are not shared between trees. 4366 // are created.
4403 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); 4367 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect);
4404 4368
4405 // Partially occlude the pending layer in a different way. 4369 // Partially occlude the pending layer in a different way.
4406 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); 4370 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3));
4407 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; 4371 LayerImpl* pending_occluding_layer = pending_layer_->children()[0];
4408 pending_occluding_layer->SetBounds(layer_bounds); 4372 pending_occluding_layer->SetBounds(layer_bounds);
4409 pending_occluding_layer->SetContentBounds(layer_bounds); 4373 pending_occluding_layer->SetContentBounds(layer_bounds);
4410 pending_occluding_layer->SetDrawsContent(true); 4374 pending_occluding_layer->SetDrawsContent(true);
4411 pending_occluding_layer->SetContentsOpaque(true); 4375 pending_occluding_layer->SetContentsOpaque(true);
4412 pending_occluding_layer->SetPosition(pending_occluding_layer_position); 4376 pending_occluding_layer->SetPosition(pending_occluding_layer_position);
4413 4377
4414 EXPECT_EQ(2u, pending_layer_->num_tilings()); 4378 EXPECT_EQ(2u, pending_layer_->num_tilings());
4415 EXPECT_EQ(2u, active_layer_->num_tilings()); 4379 EXPECT_EQ(2u, active_layer_->num_tilings());
4416 4380
4417 time_ticks += base::TimeDelta::FromMilliseconds(1); 4381 time_ticks += base::TimeDelta::FromMilliseconds(1);
4418 host_impl_.SetCurrentBeginFrameArgs( 4382 host_impl_.SetCurrentBeginFrameArgs(
4419 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); 4383 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
4420 // UpdateDrawProperties with the occluding layer. 4384 // UpdateDrawProperties with the occluding layer.
4421 bool update_lcd_text = false; 4385 bool update_lcd_text = false;
4422 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 4386 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
4423 4387
4424 // The expected number of occluded tiles on each of the 2 tilings for each of 4388 // The expected number of occluded tiles on each of the 2 tilings for each of
4425 // the 3 tree priorities. 4389 // the 3 tree priorities.
4426 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; 4390 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u};
4427 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; 4391 size_t expected_occluded_tile_count_on_active[] = {12u, 1u};
4428 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; 4392 size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u};
4429
4430 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u};
4431 4393
4432 // Verify number of occluded tiles on the pending layer for each tiling. 4394 // Verify number of occluded tiles on the pending layer for each tiling.
4433 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4395 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4434 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4396 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4435 tiling->UpdateAllTilePrioritiesForTesting(); 4397 tiling->UpdateAllTilePrioritiesForTesting();
4436 4398
4437 size_t occluded_tile_count_on_pending = 0u; 4399 size_t occluded_tile_count_on_pending = 0u;
4438 size_t occluded_tile_count_on_active = 0u;
4439 size_t occluded_tile_count_on_both = 0u;
4440 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, 4400 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f,
4441 gfx::Rect(layer_bounds)); 4401 gfx::Rect(layer_bounds));
4442 iter; ++iter) { 4402 iter; ++iter) {
4443 Tile* tile = *iter; 4403 Tile* tile = *iter;
4444 4404
4405 if (invalidation_rect.Intersects(iter.geometry_rect()))
4406 EXPECT_TRUE(tile);
4407 else
4408 EXPECT_FALSE(tile);
4409
4445 if (!tile) 4410 if (!tile)
4446 continue; 4411 continue;
4447 if (tile->is_occluded(PENDING_TREE)) 4412 if (tile->is_occluded(PENDING_TREE))
4448 occluded_tile_count_on_pending++; 4413 occluded_tile_count_on_pending++;
4449 if (tile->is_occluded(ACTIVE_TREE))
4450 occluded_tile_count_on_active++;
4451 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE))
4452 occluded_tile_count_on_both++;
4453 } 4414 }
4454 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], 4415 EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
4455 occluded_tile_count_on_pending) 4416 occluded_tile_count_on_pending)
4456 << tiling->contents_scale(); 4417 << tiling->contents_scale();
4457 EXPECT_EQ(expected_occluded_tile_count_on_active[i],
4458 occluded_tile_count_on_active)
4459 << tiling->contents_scale();
4460 EXPECT_EQ(expected_occluded_tile_count_on_both[i],
4461 occluded_tile_count_on_both)
4462 << tiling->contents_scale();
4463 } 4418 }
4464 4419
4465 // Verify number of occluded tiles on the active layer for each tiling. 4420 // Verify number of occluded tiles on the active layer for each tiling.
4466 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { 4421 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
4467 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); 4422 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
4468 tiling->UpdateAllTilePrioritiesForTesting(); 4423 tiling->UpdateAllTilePrioritiesForTesting();
4469 4424
4470 size_t occluded_tile_count_on_pending = 0u;
4471 size_t occluded_tile_count_on_active = 0u; 4425 size_t occluded_tile_count_on_active = 0u;
4472 size_t occluded_tile_count_on_both = 0u;
4473 for (PictureLayerTiling::CoverageIterator iter( 4426 for (PictureLayerTiling::CoverageIterator iter(
4474 tiling, 4427 tiling,
4475 pending_layer_->contents_scale_x(), 4428 pending_layer_->contents_scale_x(),
4476 gfx::Rect(layer_bounds)); 4429 gfx::Rect(layer_bounds));
4477 iter; 4430 iter;
4478 ++iter) { 4431 ++iter) {
4479 Tile* tile = *iter; 4432 Tile* tile = *iter;
4480 4433
4481 if (!tile) 4434 if (!tile)
4482 continue; 4435 continue;
4483 if (tile->is_occluded(PENDING_TREE))
4484 occluded_tile_count_on_pending++;
4485 if (tile->is_occluded(ACTIVE_TREE)) 4436 if (tile->is_occluded(ACTIVE_TREE))
4486 occluded_tile_count_on_active++; 4437 occluded_tile_count_on_active++;
4487 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE))
4488 occluded_tile_count_on_both++;
4489 } 4438 }
4490 EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
4491 occluded_tile_count_on_pending)
4492 << i;
4493 EXPECT_EQ(expected_occluded_tile_count_on_active[i], 4439 EXPECT_EQ(expected_occluded_tile_count_on_active[i],
4494 occluded_tile_count_on_active) 4440 occluded_tile_count_on_active)
4495 << i; 4441 << i;
4496 EXPECT_EQ(expected_occluded_tile_count_on_both[i],
4497 occluded_tile_count_on_both)
4498 << i;
4499 } 4442 }
4500 4443
4501 std::vector<Tile*> all_tiles; 4444 std::vector<Tile*> all_tiles;
4502 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4445 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4503 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4446 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4504 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 4447 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
4505 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); 4448 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end());
4506 } 4449 }
4450 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
4451 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
4452 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
4453 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end());
4454 }
4507 4455
4508 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 4456 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
4509 4457
4510 VerifyEvictionConsidersOcclusion( 4458 VerifyEvictionConsidersOcclusion(
4511 pending_layer_, active_layer_, PENDING_TREE, 4459 pending_layer_, active_layer_, PENDING_TREE,
4512 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); 4460 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
4513 VerifyEvictionConsidersOcclusion( 4461 VerifyEvictionConsidersOcclusion(
4514 active_layer_, pending_layer_, ACTIVE_TREE, 4462 active_layer_, pending_layer_, ACTIVE_TREE,
4515 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); 4463 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
4516 4464
4517 // Repeat the tests without valid active tree priorities. 4465 // Repeat the tests without valid active tree priorities.
4518 active_layer_->set_has_valid_tile_priorities(false); 4466 active_layer_->set_has_valid_tile_priorities(false);
4519 VerifyEvictionConsidersOcclusion( 4467 VerifyEvictionConsidersOcclusion(
4520 pending_layer_, active_layer_, PENDING_TREE, 4468 pending_layer_, active_layer_, PENDING_TREE,
4521 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); 4469 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
4522 VerifyEvictionConsidersOcclusion( 4470 VerifyEvictionConsidersOcclusion(
4523 active_layer_, pending_layer_, ACTIVE_TREE, 0u); 4471 active_layer_, pending_layer_, ACTIVE_TREE,
4472 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
4524 active_layer_->set_has_valid_tile_priorities(true); 4473 active_layer_->set_has_valid_tile_priorities(true);
4525 4474
4526 // Repeat the tests without valid pending tree priorities. 4475 // Repeat the tests without valid pending tree priorities.
4527 pending_layer_->set_has_valid_tile_priorities(false); 4476 pending_layer_->set_has_valid_tile_priorities(false);
4528 VerifyEvictionConsidersOcclusion( 4477 VerifyEvictionConsidersOcclusion(
4529 active_layer_, pending_layer_, ACTIVE_TREE, 4478 active_layer_, pending_layer_, ACTIVE_TREE,
4530 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); 4479 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
4531 VerifyEvictionConsidersOcclusion( 4480 VerifyEvictionConsidersOcclusion(
4532 pending_layer_, active_layer_, PENDING_TREE, 0u); 4481 pending_layer_, active_layer_, PENDING_TREE,
4482 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
4533 pending_layer_->set_has_valid_tile_priorities(true); 4483 pending_layer_->set_has_valid_tile_priorities(true);
4534 } 4484 }
4535 4485
4536 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { 4486 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) {
4537 gfx::Size tile_size(102, 102); 4487 gfx::Size tile_size(102, 102);
4538 gfx::Size layer_bounds(1000, 1000); 4488 gfx::Size layer_bounds(1000, 1000);
4539 4489
4540 scoped_refptr<FakePicturePileImpl> pile = 4490 scoped_refptr<FakePicturePileImpl> pile =
4541 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4491 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4542 SetupPendingTree(pile); 4492 SetupPendingTree(pile);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
4751 std::vector<Tile*> tiles; 4701 std::vector<Tile*> tiles;
4752 for (PictureLayerTiling::CoverageIterator iter( 4702 for (PictureLayerTiling::CoverageIterator iter(
4753 pending_layer_->HighResTiling(), 4703 pending_layer_->HighResTiling(),
4754 1.f, 4704 1.f,
4755 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); 4705 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting());
4756 iter; 4706 iter;
4757 ++iter) { 4707 ++iter) {
4758 if (*iter) 4708 if (*iter)
4759 tiles.push_back(*iter); 4709 tiles.push_back(*iter);
4760 } 4710 }
4711 for (PictureLayerTiling::CoverageIterator iter(
4712 active_layer_->HighResTiling(), 1.f,
4713 active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting());
4714 iter; ++iter) {
4715 if (*iter)
4716 tiles.push_back(*iter);
4717 }
4761 4718
4762 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4719 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4763 4720
4764 // Ensure we can activate. 4721 // Ensure we can activate.
4765 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 4722 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
4766 } 4723 }
4767 4724
4768 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { 4725 TEST_F(PictureLayerImplTest, CloneMissingRecordings) {
4769 gfx::Size tile_size(100, 100); 4726 gfx::Size tile_size(100, 100);
4770 gfx::Size layer_bounds(400, 400); 4727 gfx::Size layer_bounds(400, 400);
4771 4728
4772 scoped_refptr<FakePicturePileImpl> filled_pile = 4729 scoped_refptr<FakePicturePileImpl> filled_pile =
4773 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4730 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4774 4731
4775 scoped_ptr<FakePicturePile> partial_recording = 4732 scoped_ptr<FakePicturePile> partial_recording =
4776 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); 4733 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds);
4777 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { 4734 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) {
4778 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) 4735 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j)
4779 partial_recording->AddRecordingAt(i, j); 4736 partial_recording->AddRecordingAt(i, j);
4780 } 4737 }
4781 scoped_refptr<FakePicturePileImpl> partial_pile = 4738 scoped_refptr<FakePicturePileImpl> partial_pile =
4782 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); 4739 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr);
4783 4740
4784 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); 4741 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region());
4785 ActivateTree(); 4742 ActivateTree();
4786 4743
4787 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); 4744 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling();
4788 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); 4745 PictureLayerTiling* active_tiling = active_layer_->HighResTiling();
4789 4746
4790 // We should have all tiles in both tile sets. 4747 // We should have all tiles on active, and none on pending.
4791 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); 4748 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size());
4792 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4749 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4793 4750
4794 // Now put a partially-recorded pile on the pending tree (and invalidate 4751 // Now put a partially-recorded pile on the pending tree (and invalidate
4795 // everything, since the main thread PicturePile will invalidate dropped 4752 // everything, since the main thread PicturePile will invalidate dropped
4796 // recordings). This will cause us to be missing some tiles. 4753 // recordings). This will cause us to be missing some tiles.
4797 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, 4754 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size,
4798 Region(gfx::Rect(layer_bounds))); 4755 Region(gfx::Rect(layer_bounds)));
4799 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); 4756 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size());
4800 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); 4757 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
4801 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 4758 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
4802 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); 4759 EXPECT_TRUE(pending_tiling->TileAt(2, 2));
4803 4760
4804 // Active is not affected yet. 4761 // Active is not affected yet.
4805 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4762 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4806 4763
4807 // Activate the tree. The same tiles go missing on the active tree. 4764 // Activate the tree. The same tiles go missing on the active tree.
4808 ActivateTree(); 4765 ActivateTree();
4809 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4766 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4810 EXPECT_FALSE(active_tiling->TileAt(0, 0)); 4767 EXPECT_FALSE(active_tiling->TileAt(0, 0));
4811 EXPECT_FALSE(active_tiling->TileAt(1, 1)); 4768 EXPECT_FALSE(active_tiling->TileAt(1, 1));
4812 EXPECT_TRUE(active_tiling->TileAt(2, 2)); 4769 EXPECT_TRUE(active_tiling->TileAt(2, 2));
4813 4770
4814 // Now put a full recording on the pending tree again. We'll get all our tiles 4771 // Now put a full recording on the pending tree again. We'll get all our tiles
4815 // back. 4772 // back.
4816 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, 4773 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size,
4817 Region(gfx::Rect(layer_bounds))); 4774 Region(gfx::Rect(layer_bounds)));
4818 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); 4775 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
4776 Tile* tile00 = pending_tiling->TileAt(0, 0);
4777 Tile* tile11 = pending_tiling->TileAt(1, 1);
4778 Tile* tile22 = pending_tiling->TileAt(2, 2);
4819 4779
4820 // Active is not affected yet. 4780 // Active is not affected yet.
4821 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4781 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4822 4782
4823 // Activate the tree. The tiles are created and shared on the active tree. 4783 // Activate the tree. The tiles are created and shared on the active tree.
4824 ActivateTree(); 4784 ActivateTree();
4825 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4785 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4826 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); 4786 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0));
4827 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); 4787 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1));
4828 EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared()); 4788 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2));
4829 } 4789 }
4830 4790
4831 class TileSizeSettings : public ImplSidePaintingSettings { 4791 class TileSizeSettings : public ImplSidePaintingSettings {
4832 public: 4792 public:
4833 TileSizeSettings() { 4793 TileSizeSettings() {
4834 default_tile_size = gfx::Size(100, 100); 4794 default_tile_size = gfx::Size(100, 100);
4835 max_untiled_layer_size = gfx::Size(200, 200); 4795 max_untiled_layer_size = gfx::Size(200, 200);
4836 } 4796 }
4837 }; 4797 };
4838 4798
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4891 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4851 result = layer->CalculateTileSize(gfx::Size(447, 400));
4892 EXPECT_EQ(result.width(), 448); 4852 EXPECT_EQ(result.width(), 448);
4893 EXPECT_EQ(result.height(), 448); 4853 EXPECT_EQ(result.height(), 448);
4894 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4854 result = layer->CalculateTileSize(gfx::Size(500, 499));
4895 EXPECT_EQ(result.width(), 512); 4855 EXPECT_EQ(result.width(), 512);
4896 EXPECT_EQ(result.height(), 500 + 2); 4856 EXPECT_EQ(result.height(), 500 + 2);
4897 } 4857 }
4898 4858
4899 } // namespace 4859 } // namespace
4900 } // namespace cc 4860 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698