| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 652 |
| 649 scoped_refptr<FakePicturePileImpl> pending_pile = | 653 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 650 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 654 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 651 scoped_refptr<FakePicturePileImpl> active_pile = | 655 scoped_refptr<FakePicturePileImpl> active_pile = |
| 652 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 656 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 653 scoped_refptr<FakePicturePileImpl> lost_pile = | 657 scoped_refptr<FakePicturePileImpl> lost_pile = |
| 654 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 658 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 655 | 659 |
| 656 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); | 660 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); |
| 657 ActivateTree(); | 661 ActivateTree(); |
| 658 // Add a non-shared tiling on the active tree. | 662 // Add a unique tiling on the active tree. |
| 659 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); | 663 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); |
| 660 tiling->CreateAllTilesForTesting(); | 664 tiling->CreateAllTilesForTesting(); |
| 661 | 665 |
| 662 // Ensure UpdateTiles won't remove any tilings. | 666 // Ensure UpdateTiles won't remove any tilings. |
| 663 active_layer_->MarkAllTilingsUsed(); | 667 active_layer_->MarkAllTilingsUsed(); |
| 664 | 668 |
| 665 // Then setup a new pending tree and activate it. | 669 // Then setup a new pending tree and activate it. |
| 666 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), | 670 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), |
| 667 layer_invalidation); | 671 layer_invalidation); |
| 668 | 672 |
| 669 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 673 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 670 EXPECT_EQ(3u, active_layer_->num_tilings()); | 674 EXPECT_EQ(3u, active_layer_->num_tilings()); |
| 671 | 675 |
| 672 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 676 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 673 EXPECT_GT(tilings->num_tilings(), 0u); | 677 EXPECT_GT(tilings->num_tilings(), 0u); |
| 674 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 678 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), | 2034 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), |
| 2028 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) | 2035 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) |
| 2029 ->tex_coord_rect.size()); | 2036 ->tex_coord_rect.size()); |
| 2030 | 2037 |
| 2031 // Neither the high res nor the ideal tiles were considered as incomplete. | 2038 // Neither the high res nor the ideal tiles were considered as incomplete. |
| 2032 EXPECT_EQ(0u, data.num_missing_tiles); | 2039 EXPECT_EQ(0u, data.num_missing_tiles); |
| 2033 EXPECT_EQ(0u, data.num_incomplete_tiles); | 2040 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 2034 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 2041 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 2035 } | 2042 } |
| 2036 | 2043 |
| 2037 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 2044 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveAllReady) { |
| 2038 gfx::Size layer_bounds(400, 400); | 2045 gfx::Size layer_bounds(400, 400); |
| 2039 gfx::Size tile_size(100, 100); | 2046 gfx::Size tile_size(100, 100); |
| 2040 | 2047 |
| 2041 // No tiles shared. | |
| 2042 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, | 2048 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, |
| 2043 gfx::Rect(layer_bounds)); | 2049 gfx::Rect(layer_bounds)); |
| 2044 | 2050 |
| 2045 active_layer_->SetAllTilesReady(); | 2051 active_layer_->SetAllTilesReady(); |
| 2046 | 2052 |
| 2047 // No shared tiles and all active tiles ready, so pending can only | 2053 // All active tiles ready, so pending can only activate with all high res |
| 2048 // activate with all high res tiles. | 2054 // tiles. |
| 2049 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2055 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2050 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2056 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2051 | 2057 |
| 2052 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2058 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 2053 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2059 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| 2054 } | 2060 } |
| 2055 | 2061 |
| 2056 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 2062 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
| 2057 gfx::Size layer_bounds(400, 400); | 2063 gfx::Size layer_bounds(400, 400); |
| 2058 gfx::Size tile_size(100, 100); | 2064 gfx::Size tile_size(100, 100); |
| 2059 | 2065 |
| 2060 // All tiles shared (no invalidation). | 2066 // No invalidation. |
| 2061 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2067 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2062 | 2068 |
| 2063 // Verify active tree not ready. | 2069 // Verify active tree not ready. |
| 2064 Tile* some_active_tile = | 2070 Tile* some_active_tile = |
| 2065 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2071 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2066 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2072 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2067 | 2073 |
| 2068 // When high res are required, even if the active tree is not ready, | 2074 // When high res are required, all tiles in active high res tiling should be |
| 2069 // the high res tiles must be ready. | 2075 // required for activation. |
| 2070 host_impl_.SetRequiresHighResToDraw(); | 2076 host_impl_.SetRequiresHighResToDraw(); |
| 2071 | 2077 |
| 2072 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2078 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2073 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2079 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2080 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2081 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2074 | 2082 |
| 2075 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2083 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2076 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2084 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2085 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2086 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2077 } | 2087 } |
| 2078 | 2088 |
| 2079 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 2089 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 2080 gfx::Size layer_bounds(400, 400); | 2090 gfx::Size layer_bounds(400, 400); |
| 2081 gfx::Size tile_size(100, 100); | 2091 gfx::Size tile_size(100, 100); |
| 2082 | 2092 |
| 2083 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2093 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2084 | 2094 |
| 2085 Tile* some_active_tile = | 2095 Tile* some_active_tile = |
| 2086 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2096 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2087 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2097 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2088 | 2098 |
| 2089 // All tiles shared (no invalidation), so even though the active tree's | 2099 // Since there are no invalidations, pending tree should have no tiles. |
| 2090 // tiles aren't ready, the high res tiles are required for activation. | 2100 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2091 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2101 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2092 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 2093 | 2102 |
| 2094 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2103 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2095 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2104 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2105 |
| 2106 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2107 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2096 } | 2108 } |
| 2097 | 2109 |
| 2098 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { | 2110 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { |
| 2099 gfx::Size layer_bounds(400, 400); | 2111 gfx::Size layer_bounds(400, 400); |
| 2100 gfx::Size tile_size(100, 100); | 2112 gfx::Size tile_size(100, 100); |
| 2101 | 2113 |
| 2102 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2114 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2103 | 2115 |
| 2104 Tile* some_active_tile = | 2116 Tile* some_active_tile = |
| 2105 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2117 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2106 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2118 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2107 | 2119 |
| 2120 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2121 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2122 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
| 2123 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
| 2108 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); | 2124 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
| 2109 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); | 2125 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
| 2110 | 2126 |
| 2111 // If we disallow required for activation, no tiles can be required. | 2127 // If we disallow required for activation, no tiles can be required. |
| 2112 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2128 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2113 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2129 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2114 | 2130 |
| 2115 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2131 AssertNoTilesRequired(active_layer_->HighResTiling()); |
| 2116 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2132 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2117 } | 2133 } |
| 2118 | 2134 |
| 2119 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2135 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 2120 gfx::Size layer_bounds(400, 400); | 2136 gfx::Size layer_bounds(400, 400); |
| 2121 gfx::Size tile_size(100, 100); | 2137 gfx::Size tile_size(100, 100); |
| 2122 | 2138 |
| 2123 scoped_refptr<FakePicturePileImpl> pending_pile = | 2139 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2124 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2140 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2125 // This pile will create tilings, but has no recordings so will not create any | 2141 // 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 | 2142 // tiles. This is attempting to simulate scrolling past the end of recorded |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); | 2196 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); |
| 2181 scoped_refptr<FakePicturePileImpl> active_pile = | 2197 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2182 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); | 2198 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); |
| 2183 | 2199 |
| 2184 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2200 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
| 2185 | 2201 |
| 2186 // Since the active layer has different bounds, the pending layer needs all | 2202 // Since the active layer has different bounds, the pending layer needs all |
| 2187 // high res tiles in order to activate. | 2203 // high res tiles in order to activate. |
| 2188 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2204 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2189 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2205 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2206 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2207 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2190 | 2208 |
| 2191 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2209 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 2192 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2210 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2211 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2212 // Since the test doesn't invalidate the resized region, we expect that the |
| 2213 // same low res tile would exist (which means we don't create a new one of the |
| 2214 // pending tree). |
| 2215 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2193 } | 2216 } |
| 2194 | 2217 |
| 2195 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 2218 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
| 2196 gfx::Size tile_size(100, 100); | 2219 gfx::Size tile_size(100, 100); |
| 2197 gfx::Size layer_bounds(400, 400); | 2220 gfx::Size layer_bounds(400, 400); |
| 2198 scoped_refptr<FakePicturePileImpl> pending_pile = | 2221 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2199 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2222 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2200 | 2223 |
| 2201 host_impl_.CreatePendingTree(); | 2224 host_impl_.CreatePendingTree(); |
| 2202 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 2225 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2251 // Activate and make a pending tree with an invalidated raster tile 1,1. | 2274 // Activate and make a pending tree with an invalidated raster tile 1,1. |
| 2252 ActivateTree(); | 2275 ActivateTree(); |
| 2253 | 2276 |
| 2254 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); | 2277 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); |
| 2255 | 2278 |
| 2256 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2279 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2257 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2280 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2258 | 2281 |
| 2259 // pending_tiling->CreateAllTilesForTesting(); | 2282 // pending_tiling->CreateAllTilesForTesting(); |
| 2260 | 2283 |
| 2261 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2284 // Tile 0,0 not exist on pending, but tile 1,1 should. |
| 2262 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2285 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2263 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2286 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2264 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2287 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2288 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2289 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2290 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2265 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2291 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2266 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2292 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2267 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2293 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 | 2294 |
| 2271 // Drop the tiles on the active tree and recreate them. The same tiles | 2295 // Drop the tiles on the active tree and recreate them. |
| 2272 // should be shared or not. | |
| 2273 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); | 2296 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); |
| 2274 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); | 2297 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); |
| 2275 active_tiling->CreateAllTilesForTesting(); | 2298 active_tiling->CreateAllTilesForTesting(); |
| 2276 | 2299 |
| 2277 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2300 // Tile 0,0 not exist on pending, but tile 1,1 should. |
| 2278 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2301 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2279 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2302 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2280 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2303 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2304 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2305 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2306 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2281 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2307 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2282 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2308 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2283 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2309 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 } | 2310 } |
| 2287 | 2311 |
| 2288 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) { | 2312 TEST_F(PictureLayerImplTest, PendingHasNoTilesWithNoInvalidation) { |
| 2289 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2313 SetupDefaultTrees(gfx::Size(1500, 1500)); |
| 2290 | 2314 |
| 2291 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2315 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2292 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2316 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2293 | 2317 |
| 2294 // No invalidation, so all tiles are shared. | 2318 // No invalidation. |
| 2295 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2319 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2296 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2320 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2297 ASSERT_TRUE(active_tiling); | 2321 ASSERT_TRUE(active_tiling); |
| 2298 ASSERT_TRUE(pending_tiling); | 2322 ASSERT_TRUE(pending_tiling); |
| 2299 | 2323 |
| 2300 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2324 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2301 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2325 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2302 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2326 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2303 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2327 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2304 | 2328 |
| 2305 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2329 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2306 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2330 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2307 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2331 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2308 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2332 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 } | 2333 } |
| 2319 | 2334 |
| 2320 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { | 2335 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { |
| 2321 gfx::Size tile_size(100, 100); | 2336 gfx::Size tile_size(100, 100); |
| 2322 gfx::Size layer_bounds(1500, 1500); | 2337 gfx::Size layer_bounds(1500, 1500); |
| 2323 | 2338 |
| 2324 scoped_refptr<FakePicturePileImpl> pending_pile = | 2339 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2325 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2340 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2326 scoped_refptr<FakePicturePileImpl> active_pile = | 2341 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2327 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2342 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2328 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); | 2343 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); |
| 2329 // Activate the invalidation. | 2344 // Activate the invalidation. |
| 2330 ActivateTree(); | 2345 ActivateTree(); |
| 2331 // Make another pending tree without any invalidation in it. | 2346 // Make another pending tree without any invalidation in it. |
| 2332 scoped_refptr<FakePicturePileImpl> pending_pile2 = | 2347 scoped_refptr<FakePicturePileImpl> pending_pile2 = |
| 2333 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2348 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2334 SetupPendingTree(pending_pile2); | 2349 SetupPendingTree(pending_pile2); |
| 2335 | 2350 |
| 2336 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2351 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2337 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2352 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2338 | 2353 |
| 2339 // The active tree invalidation was handled by the active tiles, so they | 2354 // The active tree invalidation was handled by the active tiles. |
| 2340 // can be shared with the pending tree. | |
| 2341 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2355 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2342 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2356 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2343 ASSERT_TRUE(active_tiling); | 2357 ASSERT_TRUE(active_tiling); |
| 2344 ASSERT_TRUE(pending_tiling); | 2358 ASSERT_TRUE(pending_tiling); |
| 2345 | 2359 |
| 2346 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2360 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2347 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2361 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2348 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2362 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2349 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2363 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2350 | 2364 |
| 2351 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2365 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2352 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2366 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2353 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2367 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2354 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2368 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 } | 2369 } |
| 2365 | 2370 |
| 2366 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { | 2371 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { |
| 2367 // Set some invalidation on the pending tree. We should replace raster tiles | 2372 // Set some invalidation on the pending tree. We should replace raster tiles |
| 2368 // that touch this. | 2373 // that touch this. |
| 2369 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); | 2374 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); |
| 2370 | 2375 |
| 2371 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2376 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2372 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2377 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2373 | 2378 |
| 2374 // The pending tree invalidation means tiles can not be shared with the | 2379 // The pending tree invalidation creates tiles on the pending tree. |
| 2375 // active tree. | |
| 2376 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2380 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2377 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2381 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2378 ASSERT_TRUE(active_tiling); | 2382 ASSERT_TRUE(active_tiling); |
| 2379 ASSERT_TRUE(pending_tiling); | 2383 ASSERT_TRUE(pending_tiling); |
| 2380 | 2384 |
| 2381 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2385 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2382 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2386 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2383 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2387 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2384 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2388 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2385 | 2389 |
| 2386 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2390 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
| 2387 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2391 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2388 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2392 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2389 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2393 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2390 | 2394 |
| 2391 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2395 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 } | 2396 } |
| 2401 | 2397 |
| 2402 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { | 2398 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { |
| 2403 base::TimeTicks time_ticks; | 2399 base::TimeTicks time_ticks; |
| 2404 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2400 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 2405 host_impl_.SetCurrentBeginFrameArgs( | 2401 host_impl_.SetCurrentBeginFrameArgs( |
| 2406 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2402 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2407 | 2403 |
| 2408 gfx::Size tile_size(100, 100); | 2404 gfx::Size tile_size(100, 100); |
| 2409 gfx::Size layer_bounds(10, 10); | 2405 gfx::Size layer_bounds(10, 10); |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3261 page_scale, | 3257 page_scale, |
| 3262 maximum_animation_scale, | 3258 maximum_animation_scale, |
| 3263 animating_transform); | 3259 animating_transform); |
| 3264 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3260 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 3265 } | 3261 } |
| 3266 | 3262 |
| 3267 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3263 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3268 gfx::Size tile_size(100, 100); | 3264 gfx::Size tile_size(100, 100); |
| 3269 gfx::Size layer_bounds(1000, 1000); | 3265 gfx::Size layer_bounds(1000, 1000); |
| 3270 | 3266 |
| 3271 // Make sure some tiles are not shared. | 3267 // Make sure pending tree has tiles. |
| 3272 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3268 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3273 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3269 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3274 | 3270 |
| 3275 // All pending layer tiles required are not ready. | 3271 // All pending layer tiles required are not ready. |
| 3276 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3272 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3277 | 3273 |
| 3278 // Initialize all low-res tiles. | 3274 // Initialize all low-res tiles. |
| 3279 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3275 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3276 pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling()); |
| 3280 | 3277 |
| 3281 // Low-res tiles should not be enough. | 3278 // Low-res tiles should not be enough. |
| 3282 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3279 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3283 | 3280 |
| 3284 // Initialize remaining tiles. | 3281 // Initialize remaining tiles. |
| 3285 pending_layer_->SetAllTilesReady(); | 3282 pending_layer_->SetAllTilesReady(); |
| 3283 active_layer_->SetAllTilesReady(); |
| 3286 | 3284 |
| 3287 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3285 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3288 } | 3286 } |
| 3289 | 3287 |
| 3290 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { | 3288 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
| 3291 gfx::Size tile_size(100, 100); | 3289 gfx::Size tile_size(100, 100); |
| 3292 gfx::Size layer_bounds(1000, 1000); | 3290 gfx::Size layer_bounds(1000, 1000); |
| 3293 | 3291 |
| 3294 // Make sure some tiles are not shared. | 3292 // Make sure pending tree has tiles. |
| 3295 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3293 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3296 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3294 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3297 | 3295 |
| 3298 // All pending layer tiles required are not ready. | 3296 // All pending layer tiles required are not ready. |
| 3299 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3297 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3300 | 3298 |
| 3301 // Initialize all high-res tiles. | 3299 // Initialize all high-res tiles. |
| 3302 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3300 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3301 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3303 | 3302 |
| 3304 // High-res tiles should be enough, since they cover everything visible. | 3303 // High-res tiles should be enough, since they cover everything visible. |
| 3305 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3304 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3306 } | 3305 } |
| 3307 | 3306 |
| 3308 TEST_F(PictureLayerImplTest, | 3307 TEST_F(PictureLayerImplTest, |
| 3309 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { | 3308 ActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
| 3310 gfx::Size tile_size(100, 100); | 3309 gfx::Size tile_size(100, 100); |
| 3311 gfx::Size layer_bounds(1000, 1000); | 3310 gfx::Size layer_bounds(1000, 1000); |
| 3312 | 3311 |
| 3313 // Make sure some tiles are not shared. | 3312 // Make sure pending tree has tiles. |
| 3314 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3313 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3315 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3314 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3316 | 3315 |
| 3317 // Initialize all high-res tiles in the active layer. | 3316 // Initialize all high-res tiles in the active layer. |
| 3318 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3317 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3319 // And all the low-res tiles in the pending layer. | 3318 // And all the low-res tiles in the pending layer. |
| 3320 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3319 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3321 | 3320 |
| 3322 // The unshared high-res tiles are not ready, so we cannot activate. | 3321 // The pending high-res tiles are not ready, so we cannot activate. |
| 3323 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3322 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3324 | 3323 |
| 3325 // When the unshared pending high-res tiles are ready, we can activate. | 3324 // When the pending high-res tiles are ready, we can activate. |
| 3326 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3325 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3327 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3326 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3328 } | 3327 } |
| 3329 | 3328 |
| 3330 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { | 3329 TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) { |
| 3331 gfx::Size tile_size(100, 100); | 3330 gfx::Size tile_size(100, 100); |
| 3332 gfx::Size layer_bounds(1000, 1000); | 3331 gfx::Size layer_bounds(1000, 1000); |
| 3333 | 3332 |
| 3334 // Make sure some tiles are not shared. | 3333 // Make sure pending tree has tiles. |
| 3335 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3334 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3336 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3335 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3337 | 3336 |
| 3338 // Initialize all high-res tiles in the active layer. | 3337 // Initialize all high-res tiles in the active layer. |
| 3339 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3338 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3340 | 3339 |
| 3341 // The unshared high-res tiles are not ready, so we cannot activate. | 3340 // The pending high-res tiles are not ready, so we cannot activate. |
| 3342 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3341 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3343 | 3342 |
| 3344 // When the unshared pending high-res tiles are ready, we can activate. | 3343 // When the pending pending high-res tiles are ready, we can activate. |
| 3345 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3344 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3346 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3345 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3347 } | 3346 } |
| 3348 | 3347 |
| 3349 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { | 3348 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 3350 gfx::Size tile_size(400, 400); | 3349 gfx::Size tile_size(400, 400); |
| 3351 gfx::Size layer_bounds(1300, 1900); | 3350 gfx::Size layer_bounds(1300, 1900); |
| 3352 | 3351 |
| 3353 scoped_refptr<FakePicturePileImpl> pending_pile = | 3352 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3354 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3353 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3461 7.26f, // ideal contents scale | 3460 7.26f, // ideal contents scale |
| 3462 2.2f, // device scale | 3461 2.2f, // device scale |
| 3463 3.3f, // page scale | 3462 3.3f, // page scale |
| 3464 1.f, // maximum animation scale | 3463 1.f, // maximum animation scale |
| 3465 false); | 3464 false); |
| 3466 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3465 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3467 EXPECT_FLOAT_EQ(7.26f, | 3466 EXPECT_FLOAT_EQ(7.26f, |
| 3468 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3467 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3469 } | 3468 } |
| 3470 | 3469 |
| 3471 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 3470 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 3472 gfx::Size layer_bounds(400, 400); | 3471 gfx::Size layer_bounds(400, 400); |
| 3473 gfx::Size tile_size(100, 100); | 3472 gfx::Size tile_size(100, 100); |
| 3474 | 3473 |
| 3475 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 3474 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 3476 | 3475 |
| 3477 Tile* some_active_tile = | 3476 Tile* some_active_tile = |
| 3478 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 3477 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 3479 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 3478 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 3480 | 3479 |
| 3481 // All tiles shared (no invalidation), so even though the active tree's | 3480 // Since there is no invalidaiton, pending tree should have no tiles. |
| 3482 // tiles aren't ready, there is nothing required. | 3481 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 3483 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 3484 if (host_impl_.settings().create_low_res_tiling) | 3482 if (host_impl_.settings().create_low_res_tiling) |
| 3485 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 3483 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 3486 | 3484 |
| 3487 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 3485 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 3488 if (host_impl_.settings().create_low_res_tiling) | 3486 if (host_impl_.settings().create_low_res_tiling) |
| 3489 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 3487 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 3488 |
| 3489 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 3490 if (host_impl_.settings().create_low_res_tiling) |
| 3491 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 3490 } | 3492 } |
| 3491 | 3493 |
| 3492 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 3494 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 3493 gfx::Size layer_bounds(400, 400); | 3495 gfx::Size layer_bounds(400, 400); |
| 3494 gfx::Size tile_size(100, 100); | 3496 gfx::Size tile_size(100, 100); |
| 3495 | 3497 |
| 3496 scoped_refptr<FakePicturePileImpl> pending_pile = | 3498 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3497 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3499 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3498 // This pile will create tilings, but has no recordings so will not create any | 3500 // 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 | 3501 // tiles. This is attempting to simulate scrolling past the end of recorded |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3865 }; | 3867 }; |
| 3866 | 3868 |
| 3867 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3869 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
| 3868 public: | 3870 public: |
| 3869 OcclusionTrackingPictureLayerImplTest() | 3871 OcclusionTrackingPictureLayerImplTest() |
| 3870 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3872 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
| 3871 | 3873 |
| 3872 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3874 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
| 3873 FakePictureLayerImpl* twin_layer, | 3875 FakePictureLayerImpl* twin_layer, |
| 3874 WhichTree tree, | 3876 WhichTree tree, |
| 3875 size_t expected_occluded_tile_count) { | 3877 size_t expected_occluded_tile_count, |
| 3876 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 3878 int source_line) { |
| 3877 size_t occluded_tile_count = 0u; | 3879 size_t occluded_tile_count = 0u; |
| 3878 Tile* last_tile = nullptr; | 3880 Tile* last_tile = nullptr; |
| 3879 std::set<Tile*> shared_tiles; | |
| 3880 | 3881 |
| 3881 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 3882 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
| 3882 layer->picture_layer_tiling_set(), layer && twin_layer)); | 3883 layer->picture_layer_tiling_set(), layer && twin_layer)); |
| 3883 while (!queue->IsEmpty()) { | 3884 while (!queue->IsEmpty()) { |
| 3884 Tile* tile = queue->Top(); | 3885 Tile* tile = queue->Top(); |
| 3885 if (!last_tile) | 3886 if (!last_tile) |
| 3886 last_tile = tile; | 3887 last_tile = tile; |
| 3887 if (tile->is_shared()) | |
| 3888 EXPECT_TRUE(shared_tiles.insert(tile).second); | |
| 3889 | 3888 |
| 3890 // The only way we will encounter an occluded tile after an unoccluded | 3889 // 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 | 3890 // tile is if the priorty bin decreased, the tile is required for |
| 3892 // activation, or the scale changed. | 3891 // activation, or the scale changed. |
| 3893 bool tile_is_occluded = tile->is_occluded(tree); | 3892 bool tile_is_occluded = tile->is_occluded(tree); |
| 3894 if (tile_is_occluded) { | 3893 if (tile_is_occluded) { |
| 3895 occluded_tile_count++; | 3894 occluded_tile_count++; |
| 3896 | 3895 |
| 3897 bool last_tile_is_occluded = last_tile->is_occluded(tree); | 3896 bool last_tile_is_occluded = last_tile->is_occluded(tree); |
| 3898 if (!last_tile_is_occluded) { | 3897 if (!last_tile_is_occluded) { |
| 3899 TilePriority::PriorityBin tile_priority_bin = | 3898 TilePriority::PriorityBin tile_priority_bin = |
| 3900 tile->priority(tree).priority_bin; | 3899 tile->priority(tree).priority_bin; |
| 3901 TilePriority::PriorityBin last_tile_priority_bin = | 3900 TilePriority::PriorityBin last_tile_priority_bin = |
| 3902 last_tile->priority(tree).priority_bin; | 3901 last_tile->priority(tree).priority_bin; |
| 3903 | 3902 |
| 3904 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || | 3903 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
| 3905 tile->required_for_activation() || | 3904 tile->required_for_activation() || |
| 3906 tile->contents_scale() != last_tile->contents_scale()); | 3905 tile->contents_scale() != last_tile->contents_scale()) |
| 3906 << "line: " << source_line; |
| 3907 } | 3907 } |
| 3908 } | 3908 } |
| 3909 last_tile = tile; | 3909 last_tile = tile; |
| 3910 queue->Pop(); | 3910 queue->Pop(); |
| 3911 } | 3911 } |
| 3912 // Count also shared tiles which are occluded in the tree but which were | 3912 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) |
| 3913 // not returned by the tiling set eviction queue. Those shared tiles | 3913 << "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 } | 3914 } |
| 3955 }; | 3915 }; |
| 3956 | 3916 |
| 3957 TEST_F(OcclusionTrackingPictureLayerImplTest, | 3917 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 3958 OccludedTilesSkippedDuringRasterization) { | 3918 OccludedTilesSkippedDuringRasterization) { |
| 3959 base::TimeTicks time_ticks; | 3919 base::TimeTicks time_ticks; |
| 3960 time_ticks += base::TimeDelta::FromMilliseconds(1); | 3920 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 3961 host_impl_.SetCurrentBeginFrameArgs( | 3921 host_impl_.SetCurrentBeginFrameArgs( |
| 3962 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3922 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3963 | 3923 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4278 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4238 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4279 LayerImpl* layer1 = pending_layer_->children()[0]; | 4239 LayerImpl* layer1 = pending_layer_->children()[0]; |
| 4280 layer1->SetBounds(layer_bounds); | 4240 layer1->SetBounds(layer_bounds); |
| 4281 layer1->SetContentBounds(layer_bounds); | 4241 layer1->SetContentBounds(layer_bounds); |
| 4282 layer1->SetDrawsContent(true); | 4242 layer1->SetDrawsContent(true); |
| 4283 layer1->SetContentsOpaque(true); | 4243 layer1->SetContentsOpaque(true); |
| 4284 layer1->SetPosition(occluding_layer_position); | 4244 layer1->SetPosition(occluding_layer_position); |
| 4285 | 4245 |
| 4286 ActivateTree(); | 4246 ActivateTree(); |
| 4287 | 4247 |
| 4248 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4249 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4250 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4251 |
| 4252 for ( |
| 4253 PictureLayerTiling::CoverageIterator iter( |
| 4254 tiling, active_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
| 4255 iter; ++iter) { |
| 4256 if (!*iter) |
| 4257 continue; |
| 4258 const Tile* tile = *iter; |
| 4259 |
| 4260 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4261 tile->content_rect(), 1.0f / tile->contents_scale()); |
| 4262 // Tiles are occluded on the active tree iff they lie beneath the |
| 4263 // occluding layer. |
| 4264 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), |
| 4265 scaled_content_rect.x() >= occluding_layer_position.x()); |
| 4266 } |
| 4267 } |
| 4268 |
| 4288 // Partially invalidate the pending layer. | 4269 // Partially invalidate the pending layer. |
| 4289 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); | 4270 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); |
| 4290 | 4271 |
| 4291 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4272 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4292 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4273 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4293 tiling->UpdateAllTilePrioritiesForTesting(); | 4274 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4294 | 4275 |
| 4295 for (PictureLayerTiling::CoverageIterator iter( | 4276 for (PictureLayerTiling::CoverageIterator iter( |
| 4296 tiling, | 4277 tiling, |
| 4297 pending_layer_->contents_scale_x(), | |
| 4298 gfx::Rect(layer_bounds)); | |
| 4299 iter; | |
| 4300 ++iter) { | |
| 4301 if (!*iter) | |
| 4302 continue; | |
| 4303 const Tile* tile = *iter; | |
| 4304 | |
| 4305 // All tiles are unoccluded on the pending tree. | |
| 4306 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | |
| 4307 | |
| 4308 Tile* twin_tile = pending_layer_->GetPendingOrActiveTwinTiling(tiling) | |
| 4309 ->TileAt(iter.i(), iter.j()); | |
| 4310 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | |
| 4311 tile->content_rect(), 1.0f / tile->contents_scale()); | |
| 4312 | |
| 4313 if (scaled_content_rect.Intersects(invalidation_rect)) { | |
| 4314 // Tiles inside the invalidation rect are only on the pending tree. | |
| 4315 EXPECT_NE(tile, twin_tile); | |
| 4316 | |
| 4317 // Unshared tiles should be unoccluded on the active tree by default. | |
| 4318 EXPECT_FALSE(tile->is_occluded(ACTIVE_TREE)); | |
| 4319 } else { | |
| 4320 // Tiles outside the invalidation rect are shared between both trees. | |
| 4321 EXPECT_EQ(tile, twin_tile); | |
| 4322 // Shared tiles are occluded on the active tree iff they lie beneath the | |
| 4323 // occluding layer. | |
| 4324 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | |
| 4325 scaled_content_rect.x() >= occluding_layer_position.x()); | |
| 4326 } | |
| 4327 } | |
| 4328 } | |
| 4329 | |
| 4330 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | |
| 4331 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | |
| 4332 | |
| 4333 for (PictureLayerTiling::CoverageIterator iter( | |
| 4334 tiling, | |
| 4335 active_layer_->contents_scale_x(), | 4278 active_layer_->contents_scale_x(), |
| 4336 gfx::Rect(layer_bounds)); | 4279 gfx::Rect(layer_bounds)); |
| 4337 iter; | 4280 iter; |
| 4338 ++iter) { | 4281 ++iter) { |
| 4339 if (!*iter) | 4282 if (!*iter) |
| 4340 continue; | 4283 continue; |
| 4341 const Tile* tile = *iter; | 4284 const Tile* tile = *iter; |
| 4342 | 4285 |
| 4286 // All tiles are unoccluded, because the pending tree has no occlusion. |
| 4287 EXPECT_FALSE(tile->is_occluded(ACTIVE_TREE)); |
| 4288 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
| 4289 |
| 4343 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) | 4290 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) |
| 4344 ->TileAt(iter.i(), iter.j()); | 4291 ->TileAt(iter.i(), iter.j()); |
| 4345 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4292 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4346 tile->content_rect(), 1.0f / tile->contents_scale()); | 4293 tile->content_rect(), 1.0f / tile->contents_scale()); |
| 4347 | 4294 |
| 4348 // Since we've already checked the shared tiles, only consider tiles in | |
| 4349 // the invalidation rect. | |
| 4350 if (scaled_content_rect.Intersects(invalidation_rect)) { | 4295 if (scaled_content_rect.Intersects(invalidation_rect)) { |
| 4351 // Tiles inside the invalidation rect are only on the active tree. | 4296 // Tiles inside the invalidation rect exist on both trees. |
| 4297 EXPECT_TRUE(tile); |
| 4298 EXPECT_TRUE(twin_tile); |
| 4352 EXPECT_NE(tile, twin_tile); | 4299 EXPECT_NE(tile, twin_tile); |
| 4353 | 4300 } else { |
| 4354 // Unshared tiles should be unoccluded on the pending tree by default. | 4301 // Tiles outside the invalidation rect only exist on the active tree. |
| 4355 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4302 EXPECT_TRUE(tile); |
| 4356 | 4303 EXPECT_FALSE(twin_tile); |
| 4357 // Unshared tiles are occluded on the active tree iff they lie beneath | |
| 4358 // the occluding layer. | |
| 4359 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | |
| 4360 scaled_content_rect.x() >= occluding_layer_position.x()); | |
| 4361 } | 4304 } |
| 4362 } | 4305 } |
| 4363 } | 4306 } |
| 4364 } | 4307 } |
| 4365 | 4308 |
| 4366 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4309 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 4367 OccludedTilesConsideredDuringEviction) { | 4310 OccludedTilesConsideredDuringEviction) { |
| 4368 base::TimeTicks time_ticks; | 4311 base::TimeTicks time_ticks; |
| 4369 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4312 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4370 host_impl_.SetCurrentBeginFrameArgs( | 4313 host_impl_.SetCurrentBeginFrameArgs( |
| 4371 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4314 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4372 | 4315 |
| 4373 gfx::Size tile_size(102, 102); | 4316 gfx::Size tile_size(102, 102); |
| 4374 gfx::Size layer_bounds(1000, 1000); | 4317 gfx::Size layer_bounds(1000, 1000); |
| 4375 gfx::Size viewport_size(1000, 1000); | 4318 gfx::Size viewport_size(1000, 1000); |
| 4376 gfx::Point pending_occluding_layer_position(310, 0); | 4319 gfx::Point pending_occluding_layer_position(310, 0); |
| 4377 gfx::Point active_occluding_layer_position(0, 310); | 4320 gfx::Point active_occluding_layer_position(0, 310); |
| 4378 gfx::Rect invalidation_rect(230, 230, 102, 102); | 4321 gfx::Rect invalidation_rect(230, 230, 152, 152); |
| 4379 | 4322 |
| 4380 host_impl_.SetViewportSize(viewport_size); | 4323 host_impl_.SetViewportSize(viewport_size); |
| 4381 host_impl_.SetDeviceScaleFactor(2.f); | 4324 host_impl_.SetDeviceScaleFactor(2.f); |
| 4382 | 4325 |
| 4383 scoped_refptr<FakePicturePileImpl> pending_pile = | 4326 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4384 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4327 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4385 scoped_refptr<FakePicturePileImpl> active_pile = | 4328 scoped_refptr<FakePicturePileImpl> active_pile = |
| 4386 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4329 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4387 | 4330 |
| 4388 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); | 4331 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); |
| 4389 | 4332 |
| 4390 // Partially occlude the active layer. | 4333 // Partially occlude the active layer. |
| 4391 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4334 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4392 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; | 4335 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; |
| 4393 active_occluding_layer->SetBounds(layer_bounds); | 4336 active_occluding_layer->SetBounds(layer_bounds); |
| 4394 active_occluding_layer->SetContentBounds(layer_bounds); | 4337 active_occluding_layer->SetContentBounds(layer_bounds); |
| 4395 active_occluding_layer->SetDrawsContent(true); | 4338 active_occluding_layer->SetDrawsContent(true); |
| 4396 active_occluding_layer->SetContentsOpaque(true); | 4339 active_occluding_layer->SetContentsOpaque(true); |
| 4397 active_occluding_layer->SetPosition(active_occluding_layer_position); | 4340 active_occluding_layer->SetPosition(active_occluding_layer_position); |
| 4398 | 4341 |
| 4399 ActivateTree(); | 4342 ActivateTree(); |
| 4400 | 4343 |
| 4401 // Partially invalidate the pending layer. Tiles inside the invalidation rect | 4344 // Partially invalidate the pending layer. Tiles inside the invalidation rect |
| 4402 // are not shared between trees. | 4345 // are created. |
| 4403 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); | 4346 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); |
| 4404 | 4347 |
| 4405 // Partially occlude the pending layer in a different way. | 4348 // Partially occlude the pending layer in a different way. |
| 4406 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); | 4349 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); |
| 4407 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; | 4350 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; |
| 4408 pending_occluding_layer->SetBounds(layer_bounds); | 4351 pending_occluding_layer->SetBounds(layer_bounds); |
| 4409 pending_occluding_layer->SetContentBounds(layer_bounds); | 4352 pending_occluding_layer->SetContentBounds(layer_bounds); |
| 4410 pending_occluding_layer->SetDrawsContent(true); | 4353 pending_occluding_layer->SetDrawsContent(true); |
| 4411 pending_occluding_layer->SetContentsOpaque(true); | 4354 pending_occluding_layer->SetContentsOpaque(true); |
| 4412 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4355 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
| 4413 | 4356 |
| 4414 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 4357 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 4415 EXPECT_EQ(2u, active_layer_->num_tilings()); | 4358 EXPECT_EQ(2u, active_layer_->num_tilings()); |
| 4416 | 4359 |
| 4417 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4360 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4418 host_impl_.SetCurrentBeginFrameArgs( | 4361 host_impl_.SetCurrentBeginFrameArgs( |
| 4419 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4362 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4420 // UpdateDrawProperties with the occluding layer. | 4363 // UpdateDrawProperties with the occluding layer. |
| 4421 bool update_lcd_text = false; | 4364 bool update_lcd_text = false; |
| 4422 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4365 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4423 | 4366 |
| 4424 // The expected number of occluded tiles on each of the 2 tilings for each of | 4367 // The expected number of occluded tiles on each of the 2 tilings for each of |
| 4425 // the 3 tree priorities. | 4368 // the 3 tree priorities. |
| 4426 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; | 4369 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u}; |
| 4427 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; | 4370 size_t expected_occluded_tile_count_on_active[] = {12u, 1u}; |
| 4428 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; | 4371 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 | 4372 |
| 4432 // Verify number of occluded tiles on the pending layer for each tiling. | 4373 // Verify number of occluded tiles on the pending layer for each tiling. |
| 4433 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4374 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4434 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4375 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4435 tiling->UpdateAllTilePrioritiesForTesting(); | 4376 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4436 | 4377 |
| 4437 size_t occluded_tile_count_on_pending = 0u; | 4378 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, | 4379 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
| 4441 gfx::Rect(layer_bounds)); | 4380 gfx::Rect(layer_bounds)); |
| 4442 iter; ++iter) { | 4381 iter; ++iter) { |
| 4443 Tile* tile = *iter; | 4382 Tile* tile = *iter; |
| 4444 | 4383 |
| 4384 if (invalidation_rect.Intersects(iter.geometry_rect())) |
| 4385 EXPECT_TRUE(tile); |
| 4386 else |
| 4387 EXPECT_FALSE(tile); |
| 4388 |
| 4445 if (!tile) | 4389 if (!tile) |
| 4446 continue; | 4390 continue; |
| 4447 if (tile->is_occluded(PENDING_TREE)) | 4391 if (tile->is_occluded(PENDING_TREE)) |
| 4448 occluded_tile_count_on_pending++; | 4392 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 } | 4393 } |
| 4454 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4394 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
| 4455 occluded_tile_count_on_pending) | 4395 occluded_tile_count_on_pending) |
| 4456 << tiling->contents_scale(); | 4396 << 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 } | 4397 } |
| 4464 | 4398 |
| 4465 // Verify number of occluded tiles on the active layer for each tiling. | 4399 // Verify number of occluded tiles on the active layer for each tiling. |
| 4466 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4400 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4467 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4401 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4468 tiling->UpdateAllTilePrioritiesForTesting(); | 4402 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4469 | 4403 |
| 4470 size_t occluded_tile_count_on_pending = 0u; | |
| 4471 size_t occluded_tile_count_on_active = 0u; | 4404 size_t occluded_tile_count_on_active = 0u; |
| 4472 size_t occluded_tile_count_on_both = 0u; | |
| 4473 for (PictureLayerTiling::CoverageIterator iter( | 4405 for (PictureLayerTiling::CoverageIterator iter( |
| 4474 tiling, | 4406 tiling, |
| 4475 pending_layer_->contents_scale_x(), | 4407 pending_layer_->contents_scale_x(), |
| 4476 gfx::Rect(layer_bounds)); | 4408 gfx::Rect(layer_bounds)); |
| 4477 iter; | 4409 iter; |
| 4478 ++iter) { | 4410 ++iter) { |
| 4479 Tile* tile = *iter; | 4411 Tile* tile = *iter; |
| 4480 | 4412 |
| 4481 if (!tile) | 4413 if (!tile) |
| 4482 continue; | 4414 continue; |
| 4483 if (tile->is_occluded(PENDING_TREE)) | |
| 4484 occluded_tile_count_on_pending++; | |
| 4485 if (tile->is_occluded(ACTIVE_TREE)) | 4415 if (tile->is_occluded(ACTIVE_TREE)) |
| 4486 occluded_tile_count_on_active++; | 4416 occluded_tile_count_on_active++; |
| 4487 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | |
| 4488 occluded_tile_count_on_both++; | |
| 4489 } | 4417 } |
| 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], | 4418 EXPECT_EQ(expected_occluded_tile_count_on_active[i], |
| 4494 occluded_tile_count_on_active) | 4419 occluded_tile_count_on_active) |
| 4495 << i; | 4420 << i; |
| 4496 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | |
| 4497 occluded_tile_count_on_both) | |
| 4498 << i; | |
| 4499 } | 4421 } |
| 4500 | 4422 |
| 4501 std::vector<Tile*> all_tiles; | 4423 std::vector<Tile*> all_tiles; |
| 4502 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4424 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4503 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4425 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4504 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4426 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4505 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); | 4427 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4506 } | 4428 } |
| 4429 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4430 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4431 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4432 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4433 } |
| 4507 | 4434 |
| 4508 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 4435 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 4509 | 4436 |
| 4510 VerifyEvictionConsidersOcclusion( | 4437 VerifyEvictionConsidersOcclusion( |
| 4511 pending_layer_, active_layer_, PENDING_TREE, | 4438 pending_layer_, active_layer_, PENDING_TREE, |
| 4512 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); | 4439 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4513 VerifyEvictionConsidersOcclusion( | 4440 VerifyEvictionConsidersOcclusion( |
| 4514 active_layer_, pending_layer_, ACTIVE_TREE, | 4441 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4515 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); | 4442 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4516 | 4443 |
| 4517 // Repeat the tests without valid active tree priorities. | 4444 // Repeat the tests without valid active tree priorities. |
| 4518 active_layer_->set_has_valid_tile_priorities(false); | 4445 active_layer_->set_has_valid_tile_priorities(false); |
| 4519 VerifyEvictionConsidersOcclusion( | 4446 VerifyEvictionConsidersOcclusion( |
| 4520 pending_layer_, active_layer_, PENDING_TREE, | 4447 pending_layer_, active_layer_, PENDING_TREE, |
| 4521 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); | 4448 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4522 VerifyEvictionConsidersOcclusion( | 4449 VerifyEvictionConsidersOcclusion( |
| 4523 active_layer_, pending_layer_, ACTIVE_TREE, 0u); | 4450 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4451 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4524 active_layer_->set_has_valid_tile_priorities(true); | 4452 active_layer_->set_has_valid_tile_priorities(true); |
| 4525 | 4453 |
| 4526 // Repeat the tests without valid pending tree priorities. | 4454 // Repeat the tests without valid pending tree priorities. |
| 4527 pending_layer_->set_has_valid_tile_priorities(false); | 4455 pending_layer_->set_has_valid_tile_priorities(false); |
| 4528 VerifyEvictionConsidersOcclusion( | 4456 VerifyEvictionConsidersOcclusion( |
| 4529 active_layer_, pending_layer_, ACTIVE_TREE, | 4457 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4530 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); | 4458 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4531 VerifyEvictionConsidersOcclusion( | 4459 VerifyEvictionConsidersOcclusion( |
| 4532 pending_layer_, active_layer_, PENDING_TREE, 0u); | 4460 pending_layer_, active_layer_, PENDING_TREE, |
| 4461 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4533 pending_layer_->set_has_valid_tile_priorities(true); | 4462 pending_layer_->set_has_valid_tile_priorities(true); |
| 4534 } | 4463 } |
| 4535 | 4464 |
| 4536 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { | 4465 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { |
| 4537 gfx::Size tile_size(102, 102); | 4466 gfx::Size tile_size(102, 102); |
| 4538 gfx::Size layer_bounds(1000, 1000); | 4467 gfx::Size layer_bounds(1000, 1000); |
| 4539 | 4468 |
| 4540 scoped_refptr<FakePicturePileImpl> pile = | 4469 scoped_refptr<FakePicturePileImpl> pile = |
| 4541 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4470 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4542 SetupPendingTree(pile); | 4471 SetupPendingTree(pile); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4751 std::vector<Tile*> tiles; | 4680 std::vector<Tile*> tiles; |
| 4752 for (PictureLayerTiling::CoverageIterator iter( | 4681 for (PictureLayerTiling::CoverageIterator iter( |
| 4753 pending_layer_->HighResTiling(), | 4682 pending_layer_->HighResTiling(), |
| 4754 1.f, | 4683 1.f, |
| 4755 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4684 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4756 iter; | 4685 iter; |
| 4757 ++iter) { | 4686 ++iter) { |
| 4758 if (*iter) | 4687 if (*iter) |
| 4759 tiles.push_back(*iter); | 4688 tiles.push_back(*iter); |
| 4760 } | 4689 } |
| 4690 for (PictureLayerTiling::CoverageIterator iter( |
| 4691 active_layer_->HighResTiling(), 1.f, |
| 4692 active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4693 iter; ++iter) { |
| 4694 if (*iter) |
| 4695 tiles.push_back(*iter); |
| 4696 } |
| 4761 | 4697 |
| 4762 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4698 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4763 | 4699 |
| 4764 // Ensure we can activate. | 4700 // Ensure we can activate. |
| 4765 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 4701 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 4766 } | 4702 } |
| 4767 | 4703 |
| 4768 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { | 4704 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { |
| 4769 gfx::Size tile_size(100, 100); | 4705 gfx::Size tile_size(100, 100); |
| 4770 gfx::Size layer_bounds(400, 400); | 4706 gfx::Size layer_bounds(400, 400); |
| 4771 | 4707 |
| 4772 scoped_refptr<FakePicturePileImpl> filled_pile = | 4708 scoped_refptr<FakePicturePileImpl> filled_pile = |
| 4773 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4709 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4774 | 4710 |
| 4775 scoped_ptr<FakePicturePile> partial_recording = | 4711 scoped_ptr<FakePicturePile> partial_recording = |
| 4776 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); | 4712 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); |
| 4777 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { | 4713 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) | 4714 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) |
| 4779 partial_recording->AddRecordingAt(i, j); | 4715 partial_recording->AddRecordingAt(i, j); |
| 4780 } | 4716 } |
| 4781 scoped_refptr<FakePicturePileImpl> partial_pile = | 4717 scoped_refptr<FakePicturePileImpl> partial_pile = |
| 4782 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); | 4718 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); |
| 4783 | 4719 |
| 4784 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); | 4720 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); |
| 4785 ActivateTree(); | 4721 ActivateTree(); |
| 4786 | 4722 |
| 4787 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); | 4723 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); |
| 4788 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); | 4724 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); |
| 4789 | 4725 |
| 4790 // We should have all tiles in both tile sets. | 4726 // We should have all tiles on active, and none on pending. |
| 4791 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4727 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size()); |
| 4792 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4728 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4793 | 4729 |
| 4794 // Now put a partially-recorded pile on the pending tree (and invalidate | 4730 // Now put a partially-recorded pile on the pending tree (and invalidate |
| 4795 // everything, since the main thread PicturePile will invalidate dropped | 4731 // everything, since the main thread PicturePile will invalidate dropped |
| 4796 // recordings). This will cause us to be missing some tiles. | 4732 // recordings). This will cause us to be missing some tiles. |
| 4797 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, | 4733 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, |
| 4798 Region(gfx::Rect(layer_bounds))); | 4734 Region(gfx::Rect(layer_bounds))); |
| 4799 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); | 4735 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); |
| 4800 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); | 4736 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 4801 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); | 4737 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 4802 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); | 4738 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); |
| 4803 | 4739 |
| 4804 // Active is not affected yet. | 4740 // Active is not affected yet. |
| 4805 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4741 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4806 | 4742 |
| 4807 // Activate the tree. The same tiles go missing on the active tree. | 4743 // Activate the tree. The same tiles go missing on the active tree. |
| 4808 ActivateTree(); | 4744 ActivateTree(); |
| 4809 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); | 4745 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); |
| 4810 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 4746 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 4811 EXPECT_FALSE(active_tiling->TileAt(1, 1)); | 4747 EXPECT_FALSE(active_tiling->TileAt(1, 1)); |
| 4812 EXPECT_TRUE(active_tiling->TileAt(2, 2)); | 4748 EXPECT_TRUE(active_tiling->TileAt(2, 2)); |
| 4813 | 4749 |
| 4814 // Now put a full recording on the pending tree again. We'll get all our tiles | 4750 // Now put a full recording on the pending tree again. We'll get all our tiles |
| 4815 // back. | 4751 // back. |
| 4816 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, | 4752 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, |
| 4817 Region(gfx::Rect(layer_bounds))); | 4753 Region(gfx::Rect(layer_bounds))); |
| 4818 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4754 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); |
| 4755 Tile* tile00 = pending_tiling->TileAt(0, 0); |
| 4756 Tile* tile11 = pending_tiling->TileAt(1, 1); |
| 4757 Tile* tile22 = pending_tiling->TileAt(2, 2); |
| 4819 | 4758 |
| 4820 // Active is not affected yet. | 4759 // Active is not affected yet. |
| 4821 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); | 4760 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); |
| 4822 | 4761 |
| 4823 // Activate the tree. The tiles are created and shared on the active tree. | 4762 // Activate the tree. The tiles are moved to the active tree. |
| 4824 ActivateTree(); | 4763 ActivateTree(); |
| 4825 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4764 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4826 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | 4765 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0)); |
| 4827 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | 4766 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1)); |
| 4828 EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared()); | 4767 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2)); |
| 4829 } | 4768 } |
| 4830 | 4769 |
| 4831 class TileSizeSettings : public ImplSidePaintingSettings { | 4770 class TileSizeSettings : public ImplSidePaintingSettings { |
| 4832 public: | 4771 public: |
| 4833 TileSizeSettings() { | 4772 TileSizeSettings() { |
| 4834 default_tile_size = gfx::Size(100, 100); | 4773 default_tile_size = gfx::Size(100, 100); |
| 4835 max_untiled_layer_size = gfx::Size(200, 200); | 4774 max_untiled_layer_size = gfx::Size(200, 200); |
| 4836 } | 4775 } |
| 4837 }; | 4776 }; |
| 4838 | 4777 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4891 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4830 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4892 EXPECT_EQ(result.width(), 448); | 4831 EXPECT_EQ(result.width(), 448); |
| 4893 EXPECT_EQ(result.height(), 448); | 4832 EXPECT_EQ(result.height(), 448); |
| 4894 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4833 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4895 EXPECT_EQ(result.width(), 512); | 4834 EXPECT_EQ(result.width(), 512); |
| 4896 EXPECT_EQ(result.height(), 500 + 2); | 4835 EXPECT_EQ(result.height(), 500 + 2); |
| 4897 } | 4836 } |
| 4898 | 4837 |
| 4899 } // namespace | 4838 } // namespace |
| 4900 } // namespace cc | 4839 } // namespace cc |
| OLD | NEW |