| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 282 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 283 contents_scale, | 283 contents_scale, |
| 284 device_scale_factor, | 284 device_scale_factor, |
| 285 page_scale_factor, | 285 page_scale_factor, |
| 286 maximum_animation_contents_scale, | 286 maximum_animation_contents_scale, |
| 287 animating_transform); | 287 animating_transform); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void ResetTilingsAndRasterScales() { | 290 void ResetTilingsAndRasterScales() { |
| 291 pending_layer_->ReleaseResources(); | 291 if (pending_layer_) { |
| 292 EXPECT_FALSE(pending_layer_->tilings()); | 292 pending_layer_->ReleaseResources(); |
| 293 pending_layer_->RecreateResources(); | 293 EXPECT_FALSE(pending_layer_->tilings()); |
| 294 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 294 pending_layer_->RecreateResources(); |
| 295 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 296 } |
| 295 | 297 |
| 296 active_layer_->ReleaseResources(); | 298 if (active_layer_) { |
| 297 EXPECT_FALSE(active_layer_->tilings()); | 299 active_layer_->ReleaseResources(); |
| 298 active_layer_->RecreateResources(); | 300 EXPECT_FALSE(active_layer_->tilings()); |
| 299 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 301 active_layer_->RecreateResources(); |
| 302 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 303 } |
| 300 } | 304 } |
| 301 | 305 |
| 302 size_t NumberOfTilesRequired(PictureLayerTiling* tiling) { | 306 size_t NumberOfTilesRequired(PictureLayerTiling* tiling) { |
| 303 size_t num_required = 0; | 307 size_t num_required = 0; |
| 304 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 308 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 305 for (size_t i = 0; i < tiles.size(); ++i) { | 309 for (size_t i = 0; i < tiles.size(); ++i) { |
| 306 if (tiles[i]->required_for_activation()) | 310 if (tiles[i]->required_for_activation()) |
| 307 num_required++; | 311 num_required++; |
| 308 } | 312 } |
| 309 return num_required; | 313 return num_required; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 413 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 410 | 414 |
| 411 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); | 415 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
| 412 | 416 |
| 413 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | 417 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
| 414 active_layer_->tilings()->num_tilings()); | 418 active_layer_->tilings()->num_tilings()); |
| 415 | 419 |
| 416 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 420 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 417 EXPECT_GT(tilings->num_tilings(), 0u); | 421 EXPECT_GT(tilings->num_tilings(), 0u); |
| 418 for (size_t i = 0; i < tilings->num_tilings(); ++i) | 422 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
| 419 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); | 423 EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty()); |
| 420 } | 424 } |
| 421 | 425 |
| 422 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { | 426 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { |
| 423 base::TimeTicks time_ticks; | 427 base::TimeTicks time_ticks; |
| 424 time_ticks += base::TimeDelta::FromMilliseconds(1); | 428 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 425 host_impl_.SetCurrentBeginFrameArgs( | 429 host_impl_.SetCurrentBeginFrameArgs( |
| 426 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 430 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 427 gfx::Size tile_size(100, 100); | 431 gfx::Size tile_size(100, 100); |
| 428 gfx::Size layer_bounds(400, 400); | 432 gfx::Size layer_bounds(400, 400); |
| 429 | 433 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 664 |
| 661 scoped_refptr<FakePicturePileImpl> pending_pile = | 665 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 662 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 666 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 663 scoped_refptr<FakePicturePileImpl> active_pile = | 667 scoped_refptr<FakePicturePileImpl> active_pile = |
| 664 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 668 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 665 scoped_refptr<FakePicturePileImpl> lost_pile = | 669 scoped_refptr<FakePicturePileImpl> lost_pile = |
| 666 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 670 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 667 | 671 |
| 668 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); | 672 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); |
| 669 ActivateTree(); | 673 ActivateTree(); |
| 670 // Add a non-shared tiling on the active tree. | 674 // Add a unique tiling on the active tree. |
| 671 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); | 675 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); |
| 672 tiling->CreateAllTilesForTesting(); | 676 tiling->CreateAllTilesForTesting(); |
| 673 | 677 |
| 674 // Ensure UpdateTiles won't remove any tilings. | 678 // Ensure UpdateTiles won't remove any tilings. |
| 675 active_layer_->MarkAllTilingsUsed(); | 679 active_layer_->MarkAllTilingsUsed(); |
| 676 | 680 |
| 677 // Then setup a new pending tree and activate it. | 681 // Then setup a new pending tree and activate it. |
| 678 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), | 682 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), |
| 679 layer_invalidation); | 683 layer_invalidation); |
| 680 | 684 |
| 681 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 685 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 682 EXPECT_EQ(3u, active_layer_->num_tilings()); | 686 EXPECT_EQ(3u, active_layer_->num_tilings()); |
| 683 | 687 |
| 684 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 688 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 685 EXPECT_GT(tilings->num_tilings(), 0u); | 689 EXPECT_GT(tilings->num_tilings(), 0u); |
| 686 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 690 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 687 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 691 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 688 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( | 692 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( |
| 689 layer_invalidation, | 693 layer_invalidation, |
| 690 tiling->contents_scale()); | 694 tiling->contents_scale()); |
| 691 for (PictureLayerTiling::CoverageIterator iter( | 695 for (PictureLayerTiling::CoverageIterator iter( |
| 692 tiling, | 696 tiling, |
| 693 tiling->contents_scale(), | 697 tiling->contents_scale(), |
| 694 gfx::Rect(tiling->tiling_size())); | 698 gfx::Rect(tiling->tiling_size())); |
| 695 iter; | 699 iter; |
| 696 ++iter) { | 700 ++iter) { |
| 697 EXPECT_TRUE(*iter); | 701 // We don't always have a tile, but when we do it's because it was |
| 698 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 702 // invalidated and it has the latest raster source. |
| 699 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | 703 if (*iter) { |
| 704 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 705 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
| 706 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); |
| 707 } else { |
| 708 // We don't create tiles in non-invalidated regions. |
| 709 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); |
| 710 } |
| 700 } | 711 } |
| 701 } | 712 } |
| 702 | 713 |
| 703 tilings = active_layer_->tilings(); | 714 tilings = active_layer_->tilings(); |
| 704 EXPECT_GT(tilings->num_tilings(), 0u); | 715 EXPECT_GT(tilings->num_tilings(), 0u); |
| 705 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 716 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 706 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 717 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 707 gfx::Rect content_invalidation = | 718 gfx::Rect content_invalidation = |
| 708 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); | 719 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); |
| 709 for (PictureLayerTiling::CoverageIterator iter( | 720 for (PictureLayerTiling::CoverageIterator iter( |
| 710 tiling, | 721 tiling, |
| 711 tiling->contents_scale(), | 722 tiling->contents_scale(), |
| 712 gfx::Rect(tiling->tiling_size())); | 723 gfx::Rect(tiling->tiling_size())); |
| 713 iter; | 724 iter; |
| 714 ++iter) { | 725 ++iter) { |
| 715 EXPECT_TRUE(*iter); | 726 EXPECT_TRUE(*iter); |
| 716 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 727 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 717 if (iter.geometry_rect().Intersects(content_invalidation)) | 728 // Pile will be updated upon activation. |
| 718 EXPECT_EQ(active_pile.get(), iter->raster_source()); | 729 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
| 719 else if (!active_layer_->GetPendingOrActiveTwinTiling(tiling)) | |
| 720 EXPECT_EQ(active_pile.get(), iter->raster_source()); | |
| 721 else | |
| 722 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | |
| 723 } | 730 } |
| 724 } | 731 } |
| 725 } | 732 } |
| 726 | 733 |
| 727 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { | 734 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { |
| 728 gfx::Size tile_size(90, 80); | 735 gfx::Size tile_size(90, 80); |
| 729 gfx::Size layer_bounds(300, 500); | 736 gfx::Size layer_bounds(300, 500); |
| 730 | 737 |
| 731 scoped_refptr<FakePicturePileImpl> pending_pile = | 738 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 732 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 739 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 // This should create new tilings. | 1537 // This should create new tilings. |
| 1531 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 1538 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 1532 1.f, // ideal contents scale | 1539 1.f, // ideal contents scale |
| 1533 1.f, // device scale | 1540 1.f, // device scale |
| 1534 1.f, // page scale | 1541 1.f, // page scale |
| 1535 1.f, // maximum animation scale | 1542 1.f, // maximum animation scale |
| 1536 false); | 1543 false); |
| 1537 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1544 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1538 } | 1545 } |
| 1539 | 1546 |
| 1540 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1547 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { |
| 1541 // The default max tile size is larger than 400x400. | 1548 // The default max tile size is larger than 400x400. |
| 1542 gfx::Size tile_size(400, 400); | 1549 gfx::Size tile_size(400, 400); |
| 1543 gfx::Size layer_bounds(5000, 5000); | 1550 gfx::Size layer_bounds(5000, 5000); |
| 1544 | 1551 |
| 1545 scoped_refptr<FakePicturePileImpl> pending_pile = | 1552 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1546 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1553 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1547 scoped_refptr<FakePicturePileImpl> active_pile = | |
| 1548 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 1549 | 1554 |
| 1550 SetupTrees(pending_pile, active_pile); | 1555 SetupPendingTree(pending_pile); |
| 1551 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); | 1556 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); |
| 1552 | 1557 |
| 1553 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1558 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1554 | 1559 |
| 1555 // The default value. | 1560 // The default value. |
| 1556 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1561 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1557 host_impl_.settings().default_tile_size.ToString()); | 1562 host_impl_.settings().default_tile_size.ToString()); |
| 1558 | 1563 |
| 1559 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1564 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1560 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1565 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1585 // The default max tile size is larger than 400x400. | 1590 // The default max tile size is larger than 400x400. |
| 1586 gfx::Size tile_size(400, 400); | 1591 gfx::Size tile_size(400, 400); |
| 1587 gfx::Size layer_bounds(500, 500); | 1592 gfx::Size layer_bounds(500, 500); |
| 1588 | 1593 |
| 1589 scoped_refptr<FakePicturePileImpl> pending_pile = | 1594 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1590 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1595 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1591 scoped_refptr<FakePicturePileImpl> active_pile = | 1596 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1592 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1597 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1593 | 1598 |
| 1594 SetupTrees(pending_pile, active_pile); | 1599 SetupTrees(pending_pile, active_pile); |
| 1595 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); | 1600 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u); |
| 1596 | 1601 |
| 1597 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1602 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1598 | 1603 |
| 1599 // The default value. The layer is smaller than this. | 1604 // The default value. The layer is smaller than this. |
| 1600 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1605 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
| 1601 host_impl_.settings().max_untiled_layer_size.ToString()); | 1606 host_impl_.settings().max_untiled_layer_size.ToString()); |
| 1602 | 1607 |
| 1603 // There should be a single tile since the layer is small. | 1608 // There should be a single tile since the layer is small. |
| 1604 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1609 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1605 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1610 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1606 | 1611 |
| 1607 ResetTilingsAndRasterScales(); | 1612 ResetTilingsAndRasterScales(); |
| 1608 | 1613 |
| 1609 // Change the max texture size on the output surface context. | 1614 // Change the max texture size on the output surface context. |
| 1610 scoped_ptr<TestWebGraphicsContext3D> context = | 1615 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1611 TestWebGraphicsContext3D::Create(); | 1616 TestWebGraphicsContext3D::Create(); |
| 1612 context->set_max_texture_size(140); | 1617 context->set_max_texture_size(140); |
| 1613 host_impl_.DidLoseOutputSurface(); | 1618 host_impl_.DidLoseOutputSurface(); |
| 1614 host_impl_.InitializeRenderer( | 1619 host_impl_.InitializeRenderer( |
| 1615 FakeOutputSurface::Create3d(context.Pass()).Pass()); | 1620 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
| 1616 | 1621 |
| 1617 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1622 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1618 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1623 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); |
| 1619 | 1624 |
| 1620 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1625 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1621 | 1626 |
| 1622 // There should be more than one tile since the max texture size won't cover | 1627 // There should be more than one tile since the max texture size won't cover |
| 1623 // the layer. | 1628 // the layer. |
| 1624 high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1629 high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1625 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1630 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1626 | 1631 |
| 1627 // Verify the tiles are not larger than the context's max texture size. | 1632 // Verify the tiles are not larger than the context's max texture size. |
| 1628 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1633 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1629 EXPECT_GE(140, tile->content_rect().width()); | 1634 EXPECT_GE(140, tile->content_rect().width()); |
| 1630 EXPECT_GE(140, tile->content_rect().height()); | 1635 EXPECT_GE(140, tile->content_rect().height()); |
| 1631 } | 1636 } |
| 1632 | 1637 |
| 1633 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { | 1638 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
| 1634 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1639 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1635 | 1640 |
| 1636 gfx::Size tile_size(400, 400); | 1641 gfx::Size tile_size(400, 400); |
| 1637 gfx::Size layer_bounds(1300, 1900); | 1642 gfx::Size layer_bounds(1300, 1900); |
| 1638 | 1643 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 pending_layer_->UpdateTiles(resourceless_software_draw); | 1747 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 1743 | 1748 |
| 1744 int num_visible = 0; | 1749 int num_visible = 0; |
| 1745 int num_offscreen = 0; | 1750 int num_offscreen = 0; |
| 1746 | 1751 |
| 1747 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 1752 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 1748 pending_layer_->picture_layer_tiling_set(), false)); | 1753 pending_layer_->picture_layer_tiling_set(), false)); |
| 1749 for (; !queue->IsEmpty(); queue->Pop()) { | 1754 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1750 const Tile* tile = queue->Top(); | 1755 const Tile* tile = queue->Top(); |
| 1751 DCHECK(tile); | 1756 DCHECK(tile); |
| 1752 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1757 if (tile->priority().distance_to_visible == 0.f) { |
| 1753 EXPECT_TRUE(tile->required_for_activation()); | 1758 EXPECT_TRUE(tile->required_for_activation()); |
| 1754 num_visible++; | 1759 num_visible++; |
| 1755 } else { | 1760 } else { |
| 1756 EXPECT_FALSE(tile->required_for_activation()); | 1761 EXPECT_FALSE(tile->required_for_activation()); |
| 1757 num_offscreen++; | 1762 num_offscreen++; |
| 1758 } | 1763 } |
| 1759 } | 1764 } |
| 1760 | 1765 |
| 1761 EXPECT_GT(num_visible, 0); | 1766 EXPECT_GT(num_visible, 0); |
| 1762 EXPECT_GT(num_offscreen, 0); | 1767 EXPECT_GT(num_offscreen, 0); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 host_impl_.SetCurrentBeginFrameArgs( | 1812 host_impl_.SetCurrentBeginFrameArgs( |
| 1808 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1813 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1809 pending_layer_->UpdateTiles(resourceless_software_draw); | 1814 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 1810 | 1815 |
| 1811 // Intersect the two rects. Any tile outside should not be required for | 1816 // Intersect the two rects. Any tile outside should not be required for |
| 1812 // activation. | 1817 // activation. |
| 1813 gfx::Rect viewport_for_tile_priority = | 1818 gfx::Rect viewport_for_tile_priority = |
| 1814 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); | 1819 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); |
| 1815 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); | 1820 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); |
| 1816 | 1821 |
| 1822 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 1823 |
| 1817 int num_inside = 0; | 1824 int num_inside = 0; |
| 1818 int num_outside = 0; | 1825 int num_outside = 0; |
| 1819 for (PictureLayerTiling::CoverageIterator iter( | 1826 for (PictureLayerTiling::CoverageIterator iter(active_layer_->HighResTiling(), |
| 1820 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); | 1827 1.f, gfx::Rect(layer_bounds)); |
| 1821 iter; ++iter) { | 1828 iter; ++iter) { |
| 1822 if (!*iter) | 1829 if (!*iter) |
| 1823 continue; | 1830 continue; |
| 1824 Tile* tile = *iter; | 1831 Tile* tile = *iter; |
| 1825 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { | 1832 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { |
| 1826 num_inside++; | 1833 num_inside++; |
| 1827 // Mark everything in viewport for tile priority as ready to draw. | 1834 // Mark everything in viewport for tile priority as ready to draw. |
| 1828 TileDrawInfo& draw_info = tile->draw_info(); | 1835 TileDrawInfo& draw_info = tile->draw_info(); |
| 1829 draw_info.SetSolidColorForTesting(SK_ColorRED); | 1836 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 1830 } else { | 1837 } else { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2039 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), | 2046 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), |
| 2040 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) | 2047 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) |
| 2041 ->tex_coord_rect.size()); | 2048 ->tex_coord_rect.size()); |
| 2042 | 2049 |
| 2043 // Neither the high res nor the ideal tiles were considered as incomplete. | 2050 // Neither the high res nor the ideal tiles were considered as incomplete. |
| 2044 EXPECT_EQ(0u, data.num_missing_tiles); | 2051 EXPECT_EQ(0u, data.num_missing_tiles); |
| 2045 EXPECT_EQ(0u, data.num_incomplete_tiles); | 2052 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 2046 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 2053 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 2047 } | 2054 } |
| 2048 | 2055 |
| 2049 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 2056 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveAllReady) { |
| 2050 gfx::Size layer_bounds(400, 400); | 2057 gfx::Size layer_bounds(400, 400); |
| 2051 gfx::Size tile_size(100, 100); | 2058 gfx::Size tile_size(100, 100); |
| 2052 | 2059 |
| 2053 // No tiles shared. | |
| 2054 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, | 2060 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, |
| 2055 gfx::Rect(layer_bounds)); | 2061 gfx::Rect(layer_bounds)); |
| 2056 | 2062 |
| 2057 active_layer_->SetAllTilesReady(); | 2063 active_layer_->SetAllTilesReady(); |
| 2058 | 2064 |
| 2059 // No shared tiles and all active tiles ready, so pending can only | 2065 // All active tiles ready, so pending can only activate with all high res |
| 2060 // activate with all high res tiles. | 2066 // tiles. |
| 2061 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2067 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2062 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2068 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2063 | 2069 |
| 2064 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2070 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 2065 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2071 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| 2066 } | 2072 } |
| 2067 | 2073 |
| 2068 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 2074 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
| 2069 gfx::Size layer_bounds(400, 400); | 2075 gfx::Size layer_bounds(400, 400); |
| 2070 gfx::Size tile_size(100, 100); | 2076 gfx::Size tile_size(100, 100); |
| 2071 | 2077 |
| 2072 // All tiles shared (no invalidation). | 2078 // No invalidation. |
| 2073 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2079 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2074 | 2080 |
| 2075 // Verify active tree not ready. | 2081 // Verify active tree not ready. |
| 2076 Tile* some_active_tile = | 2082 Tile* some_active_tile = |
| 2077 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2083 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2078 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2084 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2079 | 2085 |
| 2080 // When high res are required, even if the active tree is not ready, | 2086 // When high res are required, all tiles in active high res tiling should be |
| 2081 // the high res tiles must be ready. | 2087 // required for activation. |
| 2082 host_impl_.SetRequiresHighResToDraw(); | 2088 host_impl_.SetRequiresHighResToDraw(); |
| 2083 | 2089 |
| 2084 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2090 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2085 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2091 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2092 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2093 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2086 | 2094 |
| 2087 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2095 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2088 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2096 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2097 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2098 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2089 } | 2099 } |
| 2090 | 2100 |
| 2091 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 2101 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 2092 gfx::Size layer_bounds(400, 400); | 2102 gfx::Size layer_bounds(400, 400); |
| 2093 gfx::Size tile_size(100, 100); | 2103 gfx::Size tile_size(100, 100); |
| 2094 | 2104 |
| 2095 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2105 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2096 | 2106 |
| 2097 Tile* some_active_tile = | 2107 Tile* some_active_tile = |
| 2098 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2108 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2099 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2109 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2100 | 2110 |
| 2101 // All tiles shared (no invalidation), so even though the active tree's | 2111 // Since there are no invalidations, pending tree should have no tiles. |
| 2102 // tiles aren't ready, the high res tiles are required for activation. | 2112 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2103 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2113 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2104 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 2105 | 2114 |
| 2106 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2115 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2107 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2116 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2117 |
| 2118 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2119 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2108 } | 2120 } |
| 2109 | 2121 |
| 2110 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { | 2122 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { |
| 2111 gfx::Size layer_bounds(400, 400); | 2123 gfx::Size layer_bounds(400, 400); |
| 2112 gfx::Size tile_size(100, 100); | 2124 gfx::Size tile_size(100, 100); |
| 2113 | 2125 |
| 2114 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2126 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2115 | 2127 |
| 2116 Tile* some_active_tile = | 2128 Tile* some_active_tile = |
| 2117 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2129 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2118 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2130 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2119 | 2131 |
| 2132 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2133 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2134 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
| 2135 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
| 2120 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); | 2136 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
| 2121 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); | 2137 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
| 2122 | 2138 |
| 2123 // If we disallow required for activation, no tiles can be required. | 2139 // If we disallow required for activation, no tiles can be required. |
| 2124 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2140 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2125 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2141 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2126 | 2142 |
| 2127 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2143 AssertNoTilesRequired(active_layer_->HighResTiling()); |
| 2128 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2144 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2129 } | 2145 } |
| 2130 | 2146 |
| 2131 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2147 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 2132 gfx::Size layer_bounds(400, 400); | 2148 gfx::Size layer_bounds(400, 400); |
| 2133 gfx::Size tile_size(100, 100); | 2149 gfx::Size tile_size(100, 100); |
| 2134 | 2150 |
| 2135 scoped_refptr<FakePicturePileImpl> pending_pile = | 2151 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2136 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2152 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2137 // This pile will create tilings, but has no recordings so will not create any | 2153 // This pile will create tilings, but has no recordings so will not create any |
| 2138 // tiles. This is attempting to simulate scrolling past the end of recorded | 2154 // 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... |
| 2192 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); | 2208 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); |
| 2193 scoped_refptr<FakePicturePileImpl> active_pile = | 2209 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2194 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); | 2210 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); |
| 2195 | 2211 |
| 2196 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2212 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
| 2197 | 2213 |
| 2198 // Since the active layer has different bounds, the pending layer needs all | 2214 // Since the active layer has different bounds, the pending layer needs all |
| 2199 // high res tiles in order to activate. | 2215 // high res tiles in order to activate. |
| 2200 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2216 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2201 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2217 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2218 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2219 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2202 | 2220 |
| 2203 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2221 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 2204 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2222 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2223 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2224 // Since the test doesn't invalidate the resized region, we expect that the |
| 2225 // same low res tile would exist (which means we don't create a new one of the |
| 2226 // pending tree). |
| 2227 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2205 } | 2228 } |
| 2206 | 2229 |
| 2207 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 2230 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
| 2208 gfx::Size tile_size(100, 100); | 2231 gfx::Size tile_size(100, 100); |
| 2209 gfx::Size layer_bounds(400, 400); | 2232 gfx::Size layer_bounds(400, 400); |
| 2210 scoped_refptr<FakePicturePileImpl> pending_pile = | 2233 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2211 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2234 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2212 | 2235 |
| 2213 host_impl_.CreatePendingTree(); | 2236 host_impl_.CreatePendingTree(); |
| 2214 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 2237 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 // Activate and make a pending tree with an invalidated raster tile 1,1. | 2286 // Activate and make a pending tree with an invalidated raster tile 1,1. |
| 2264 ActivateTree(); | 2287 ActivateTree(); |
| 2265 | 2288 |
| 2266 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); | 2289 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); |
| 2267 | 2290 |
| 2268 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2291 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2269 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2292 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2270 | 2293 |
| 2271 // pending_tiling->CreateAllTilesForTesting(); | 2294 // pending_tiling->CreateAllTilesForTesting(); |
| 2272 | 2295 |
| 2273 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2296 // Tile 0,0 not exist on pending, but tile 1,1 should. |
| 2274 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2297 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2275 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2298 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2276 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2299 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2300 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2301 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2302 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2277 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2303 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2278 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2304 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2279 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2305 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
| 2280 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | |
| 2281 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | |
| 2282 | 2306 |
| 2283 // Drop the tiles on the active tree and recreate them. The same tiles | 2307 // Drop the tiles on the active tree and recreate them. |
| 2284 // should be shared or not. | |
| 2285 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); | 2308 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); |
| 2286 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); | 2309 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); |
| 2287 active_tiling->CreateAllTilesForTesting(); | 2310 active_tiling->CreateAllTilesForTesting(); |
| 2288 | 2311 |
| 2289 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2312 // Tile 0,0 not exist on pending, but tile 1,1 should. |
| 2290 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2313 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2291 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2314 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2292 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2315 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2316 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2317 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2318 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2293 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2319 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2294 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2320 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2295 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2321 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
| 2296 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | |
| 2297 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | |
| 2298 } | 2322 } |
| 2299 | 2323 |
| 2300 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) { | 2324 TEST_F(PictureLayerImplTest, PendingHasNoTilesWithNoInvalidation) { |
| 2301 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2325 SetupDefaultTrees(gfx::Size(1500, 1500)); |
| 2302 | 2326 |
| 2303 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2327 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2304 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2328 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2305 | 2329 |
| 2306 // No invalidation, so all tiles are shared. | 2330 // No invalidation. |
| 2307 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2331 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2308 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2332 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2309 ASSERT_TRUE(active_tiling); | 2333 ASSERT_TRUE(active_tiling); |
| 2310 ASSERT_TRUE(pending_tiling); | 2334 ASSERT_TRUE(pending_tiling); |
| 2311 | 2335 |
| 2312 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2336 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2313 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2337 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2314 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2338 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2315 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2339 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2316 | 2340 |
| 2317 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2341 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2318 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2342 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2319 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2343 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2320 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2344 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2321 | |
| 2322 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | |
| 2323 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | |
| 2324 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
| 2325 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
| 2326 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
| 2327 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); | |
| 2328 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
| 2329 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2330 } | 2345 } |
| 2331 | 2346 |
| 2332 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { | 2347 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { |
| 2333 gfx::Size tile_size(100, 100); | 2348 gfx::Size tile_size(100, 100); |
| 2334 gfx::Size layer_bounds(1500, 1500); | 2349 gfx::Size layer_bounds(1500, 1500); |
| 2335 | 2350 |
| 2336 scoped_refptr<FakePicturePileImpl> pending_pile = | 2351 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2337 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2352 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2338 scoped_refptr<FakePicturePileImpl> active_pile = | 2353 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2339 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2354 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2340 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); | 2355 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); |
| 2341 // Activate the invalidation. | 2356 // Activate the invalidation. |
| 2342 ActivateTree(); | 2357 ActivateTree(); |
| 2343 // Make another pending tree without any invalidation in it. | 2358 // Make another pending tree without any invalidation in it. |
| 2344 scoped_refptr<FakePicturePileImpl> pending_pile2 = | 2359 scoped_refptr<FakePicturePileImpl> pending_pile2 = |
| 2345 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2360 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2346 SetupPendingTree(pending_pile2); | 2361 SetupPendingTree(pending_pile2); |
| 2347 | 2362 |
| 2348 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2363 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2349 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2364 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2350 | 2365 |
| 2351 // The active tree invalidation was handled by the active tiles, so they | 2366 // The active tree invalidation was handled by the active tiles. |
| 2352 // can be shared with the pending tree. | |
| 2353 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2367 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2354 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2368 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2355 ASSERT_TRUE(active_tiling); | 2369 ASSERT_TRUE(active_tiling); |
| 2356 ASSERT_TRUE(pending_tiling); | 2370 ASSERT_TRUE(pending_tiling); |
| 2357 | 2371 |
| 2358 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2372 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2359 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2373 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2360 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2374 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2361 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2375 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2362 | 2376 |
| 2363 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2377 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2364 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2378 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2365 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2379 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2366 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2380 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2367 | |
| 2368 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | |
| 2369 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | |
| 2370 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
| 2371 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
| 2372 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
| 2373 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); | |
| 2374 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
| 2375 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2376 } | 2381 } |
| 2377 | 2382 |
| 2378 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { | 2383 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { |
| 2379 // Set some invalidation on the pending tree. We should replace raster tiles | 2384 // Set some invalidation on the pending tree. We should replace raster tiles |
| 2380 // that touch this. | 2385 // that touch this. |
| 2381 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); | 2386 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); |
| 2382 | 2387 |
| 2383 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2388 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2384 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2389 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2385 | 2390 |
| 2386 // The pending tree invalidation means tiles can not be shared with the | 2391 // The pending tree invalidation creates tiles on the pending tree. |
| 2387 // active tree. | |
| 2388 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2392 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2389 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2393 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2390 ASSERT_TRUE(active_tiling); | 2394 ASSERT_TRUE(active_tiling); |
| 2391 ASSERT_TRUE(pending_tiling); | 2395 ASSERT_TRUE(pending_tiling); |
| 2392 | 2396 |
| 2393 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2397 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2394 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2398 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2395 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2399 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2396 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2400 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2397 | 2401 |
| 2398 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2402 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
| 2399 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2403 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2400 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2404 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2401 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2405 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2402 | 2406 |
| 2403 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2407 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
| 2404 EXPECT_FALSE(active_tiling->TileAt(0, 0)->is_shared()); | |
| 2405 EXPECT_FALSE(pending_tiling->TileAt(0, 0)->is_shared()); | |
| 2406 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
| 2407 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
| 2408 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
| 2409 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2410 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
| 2411 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2412 } | 2408 } |
| 2413 | 2409 |
| 2414 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { | 2410 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { |
| 2415 base::TimeTicks time_ticks; | 2411 base::TimeTicks time_ticks; |
| 2416 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2412 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 2417 host_impl_.SetCurrentBeginFrameArgs( | 2413 host_impl_.SetCurrentBeginFrameArgs( |
| 2418 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2414 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2419 | 2415 |
| 2420 gfx::Size tile_size(100, 100); | 2416 gfx::Size tile_size(100, 100); |
| 2421 gfx::Size layer_bounds(10, 10); | 2417 gfx::Size layer_bounds(10, 10); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 host_impl_.SetUseGpuRasterization(true); | 2520 host_impl_.SetUseGpuRasterization(true); |
| 2525 | 2521 |
| 2526 gfx::Size viewport_size(1000, 1000); | 2522 gfx::Size viewport_size(1000, 1000); |
| 2527 host_impl_.SetViewportSize(viewport_size); | 2523 host_impl_.SetViewportSize(viewport_size); |
| 2528 | 2524 |
| 2529 gfx::Size layer_bounds(4000, 4000); | 2525 gfx::Size layer_bounds(4000, 4000); |
| 2530 SetupDefaultTrees(layer_bounds); | 2526 SetupDefaultTrees(layer_bounds); |
| 2531 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 2527 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
| 2532 | 2528 |
| 2533 // Should only have the high-res tiling. | 2529 // Should only have the high-res tiling. |
| 2534 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2530 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); |
| 2535 | 2531 |
| 2536 active_layer_->SetAllTilesReady(); | 2532 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2537 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 2538 | 2533 |
| 2539 // High res tiling should have 64 tiles (4x16 tile grid). | 2534 // High res tiling should have 64 tiles (4x16 tile grid). |
| 2540 EXPECT_EQ(64u, pending_layer_->HighResTiling()->AllTilesForTesting().size()); | 2535 EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
| 2541 | 2536 |
| 2542 // Visible viewport should be covered by 4 tiles. No other | 2537 // Visible viewport should be covered by 4 tiles. No other |
| 2543 // tiles should be required for activation. | 2538 // tiles should be required for activation. |
| 2544 EXPECT_EQ(4u, NumberOfTilesRequired(pending_layer_->HighResTiling())); | 2539 EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling())); |
| 2545 } | 2540 } |
| 2546 | 2541 |
| 2547 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 2542 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
| 2548 // Set up layers with tilings. | 2543 // Set up layers with tilings. |
| 2549 SetupDefaultTrees(gfx::Size(10, 10)); | 2544 SetupDefaultTrees(gfx::Size(10, 10)); |
| 2550 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); | 2545 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
| 2551 pending_layer_->PushPropertiesTo(active_layer_); | 2546 pending_layer_->PushPropertiesTo(active_layer_); |
| 2552 EXPECT_TRUE(pending_layer_->DrawsContent()); | 2547 EXPECT_TRUE(pending_layer_->DrawsContent()); |
| 2553 EXPECT_TRUE(pending_layer_->CanHaveTilings()); | 2548 EXPECT_TRUE(pending_layer_->CanHaveTilings()); |
| 2554 EXPECT_GE(pending_layer_->num_tilings(), 0u); | 2549 EXPECT_GE(pending_layer_->num_tilings(), 0u); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2868 std::set<Tile*> unique_tiles; | 2863 std::set<Tile*> unique_tiles; |
| 2869 bool reached_prepaint = false; | 2864 bool reached_prepaint = false; |
| 2870 int non_ideal_tile_count = 0u; | 2865 int non_ideal_tile_count = 0u; |
| 2871 int low_res_tile_count = 0u; | 2866 int low_res_tile_count = 0u; |
| 2872 int high_res_tile_count = 0u; | 2867 int high_res_tile_count = 0u; |
| 2873 int high_res_now_tiles = 0u; | 2868 int high_res_now_tiles = 0u; |
| 2874 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 2869 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 2875 pending_layer_->picture_layer_tiling_set(), false)); | 2870 pending_layer_->picture_layer_tiling_set(), false)); |
| 2876 while (!queue->IsEmpty()) { | 2871 while (!queue->IsEmpty()) { |
| 2877 Tile* tile = queue->Top(); | 2872 Tile* tile = queue->Top(); |
| 2878 TilePriority priority = tile->priority(PENDING_TREE); | 2873 TilePriority priority = tile->priority(); |
| 2879 | 2874 |
| 2880 EXPECT_TRUE(tile); | 2875 EXPECT_TRUE(tile); |
| 2881 | 2876 |
| 2882 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2877 // Non-high res tiles only get visible tiles. Also, prepaint should only |
| 2883 // come at the end of the iteration. | 2878 // come at the end of the iteration. |
| 2884 if (priority.resolution != HIGH_RESOLUTION) { | 2879 if (priority.resolution != HIGH_RESOLUTION) { |
| 2885 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2880 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 2886 } else if (reached_prepaint) { | 2881 } else if (reached_prepaint) { |
| 2887 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2882 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 2888 } else { | 2883 } else { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 gfx::Rect(1100, 1100, 500, 500); | 2937 gfx::Rect(1100, 1100, 500, 500); |
| 2943 bool resourceless_software_draw = false; | 2938 bool resourceless_software_draw = false; |
| 2944 pending_layer_->UpdateTiles(resourceless_software_draw); | 2939 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 2945 | 2940 |
| 2946 unique_tiles.clear(); | 2941 unique_tiles.clear(); |
| 2947 high_res_tile_count = 0u; | 2942 high_res_tile_count = 0u; |
| 2948 queue.reset(new TilingSetRasterQueueAll( | 2943 queue.reset(new TilingSetRasterQueueAll( |
| 2949 pending_layer_->picture_layer_tiling_set(), false)); | 2944 pending_layer_->picture_layer_tiling_set(), false)); |
| 2950 while (!queue->IsEmpty()) { | 2945 while (!queue->IsEmpty()) { |
| 2951 Tile* tile = queue->Top(); | 2946 Tile* tile = queue->Top(); |
| 2952 TilePriority priority = tile->priority(PENDING_TREE); | 2947 TilePriority priority = tile->priority(); |
| 2953 | 2948 |
| 2954 EXPECT_TRUE(tile); | 2949 EXPECT_TRUE(tile); |
| 2955 | 2950 |
| 2956 // Non-high res tiles only get visible tiles. | 2951 // Non-high res tiles only get visible tiles. |
| 2957 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); | 2952 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); |
| 2958 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2953 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 2959 | 2954 |
| 2960 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2955 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 2961 | 2956 |
| 2962 unique_tiles.insert(tile); | 2957 unique_tiles.insert(tile); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2984 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2979 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 2985 } | 2980 } |
| 2986 | 2981 |
| 2987 non_ideal_tile_count = 0; | 2982 non_ideal_tile_count = 0; |
| 2988 low_res_tile_count = 0; | 2983 low_res_tile_count = 0; |
| 2989 high_res_tile_count = 0; | 2984 high_res_tile_count = 0; |
| 2990 queue.reset(new TilingSetRasterQueueAll( | 2985 queue.reset(new TilingSetRasterQueueAll( |
| 2991 pending_layer_->picture_layer_tiling_set(), true)); | 2986 pending_layer_->picture_layer_tiling_set(), true)); |
| 2992 while (!queue->IsEmpty()) { | 2987 while (!queue->IsEmpty()) { |
| 2993 Tile* tile = queue->Top(); | 2988 Tile* tile = queue->Top(); |
| 2994 TilePriority priority = tile->priority(PENDING_TREE); | 2989 TilePriority priority = tile->priority(); |
| 2995 | 2990 |
| 2996 EXPECT_TRUE(tile); | 2991 EXPECT_TRUE(tile); |
| 2997 | 2992 |
| 2998 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 2993 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
| 2999 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 2994 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
| 3000 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2995 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 3001 queue->Pop(); | 2996 queue->Pop(); |
| 3002 } | 2997 } |
| 3003 | 2998 |
| 3004 EXPECT_EQ(0, non_ideal_tile_count); | 2999 EXPECT_EQ(0, non_ideal_tile_count); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 size_t distance_increasing = 0; | 3125 size_t distance_increasing = 0; |
| 3131 queue.reset(new TilingSetEvictionQueue( | 3126 queue.reset(new TilingSetEvictionQueue( |
| 3132 pending_layer_->picture_layer_tiling_set(), false)); | 3127 pending_layer_->picture_layer_tiling_set(), false)); |
| 3133 while (!queue->IsEmpty()) { | 3128 while (!queue->IsEmpty()) { |
| 3134 Tile* tile = queue->Top(); | 3129 Tile* tile = queue->Top(); |
| 3135 if (!last_tile) | 3130 if (!last_tile) |
| 3136 last_tile = tile; | 3131 last_tile = tile; |
| 3137 | 3132 |
| 3138 EXPECT_TRUE(tile); | 3133 EXPECT_TRUE(tile); |
| 3139 | 3134 |
| 3140 TilePriority priority = tile->priority(PENDING_TREE); | 3135 TilePriority priority = tile->priority(); |
| 3141 | 3136 |
| 3142 if (priority.priority_bin == TilePriority::NOW) { | 3137 if (priority.priority_bin == TilePriority::NOW) { |
| 3143 reached_visible = true; | 3138 reached_visible = true; |
| 3144 last_tile = tile; | 3139 last_tile = tile; |
| 3145 break; | 3140 break; |
| 3146 } | 3141 } |
| 3147 | 3142 |
| 3148 EXPECT_FALSE(tile->required_for_activation()); | 3143 EXPECT_FALSE(tile->required_for_activation()); |
| 3149 | 3144 |
| 3150 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3145 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
| 3151 std::numeric_limits<float>::epsilon()) { | 3146 std::numeric_limits<float>::epsilon()) { |
| 3152 ++scale_index; | 3147 ++scale_index; |
| 3153 ASSERT_LT(scale_index, arraysize(expected_scales)); | 3148 ASSERT_LT(scale_index, arraysize(expected_scales)); |
| 3154 } | 3149 } |
| 3155 | 3150 |
| 3156 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 3151 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
| 3157 unique_tiles.insert(tile); | 3152 unique_tiles.insert(tile); |
| 3158 | 3153 |
| 3159 if (tile->required_for_activation() == | 3154 if (tile->required_for_activation() == |
| 3160 last_tile->required_for_activation() && | 3155 last_tile->required_for_activation() && |
| 3161 std::abs(tile->contents_scale() - last_tile->contents_scale()) < | 3156 std::abs(tile->contents_scale() - last_tile->contents_scale()) < |
| 3162 std::numeric_limits<float>::epsilon()) { | 3157 std::numeric_limits<float>::epsilon()) { |
| 3163 if (priority.distance_to_visible <= | 3158 if (priority.distance_to_visible <= |
| 3164 last_tile->priority(PENDING_TREE).distance_to_visible) | 3159 last_tile->priority().distance_to_visible) |
| 3165 ++distance_decreasing; | 3160 ++distance_decreasing; |
| 3166 else | 3161 else |
| 3167 ++distance_increasing; | 3162 ++distance_increasing; |
| 3168 } | 3163 } |
| 3169 | 3164 |
| 3170 last_tile = tile; | 3165 last_tile = tile; |
| 3171 queue->Pop(); | 3166 queue->Pop(); |
| 3172 } | 3167 } |
| 3173 | 3168 |
| 3174 // 4 high res tiles are inside the viewport, the rest are evicted. | 3169 // 4 high res tiles are inside the viewport, the rest are evicted. |
| 3175 EXPECT_TRUE(reached_visible); | 3170 EXPECT_TRUE(reached_visible); |
| 3176 EXPECT_EQ(12u, unique_tiles.size()); | 3171 EXPECT_EQ(12u, unique_tiles.size()); |
| 3177 EXPECT_EQ(1u, distance_increasing); | 3172 EXPECT_EQ(1u, distance_increasing); |
| 3178 EXPECT_EQ(11u, distance_decreasing); | 3173 EXPECT_EQ(11u, distance_decreasing); |
| 3179 | 3174 |
| 3180 scale_index = 0; | 3175 scale_index = 0; |
| 3181 bool reached_required = false; | 3176 bool reached_required = false; |
| 3182 while (!queue->IsEmpty()) { | 3177 while (!queue->IsEmpty()) { |
| 3183 Tile* tile = queue->Top(); | 3178 Tile* tile = queue->Top(); |
| 3184 EXPECT_TRUE(tile); | 3179 EXPECT_TRUE(tile); |
| 3185 | 3180 |
| 3186 TilePriority priority = tile->priority(PENDING_TREE); | 3181 TilePriority priority = tile->priority(); |
| 3187 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 3182 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 3188 | 3183 |
| 3189 if (reached_required) { | 3184 if (reached_required) { |
| 3190 EXPECT_TRUE(tile->required_for_activation()); | 3185 EXPECT_TRUE(tile->required_for_activation()); |
| 3191 } else if (tile->required_for_activation()) { | 3186 } else if (tile->required_for_activation()) { |
| 3192 reached_required = true; | 3187 reached_required = true; |
| 3193 scale_index = 0; | 3188 scale_index = 0; |
| 3194 } | 3189 } |
| 3195 | 3190 |
| 3196 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3191 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3297 page_scale, | 3292 page_scale, |
| 3298 maximum_animation_scale, | 3293 maximum_animation_scale, |
| 3299 animating_transform); | 3294 animating_transform); |
| 3300 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3295 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 3301 } | 3296 } |
| 3302 | 3297 |
| 3303 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3298 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3304 gfx::Size tile_size(100, 100); | 3299 gfx::Size tile_size(100, 100); |
| 3305 gfx::Size layer_bounds(1000, 1000); | 3300 gfx::Size layer_bounds(1000, 1000); |
| 3306 | 3301 |
| 3307 // Make sure some tiles are not shared. | 3302 // Make sure pending tree has tiles. |
| 3308 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3303 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3309 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3304 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3310 | 3305 |
| 3311 // All pending layer tiles required are not ready. | 3306 // All pending layer tiles required are not ready. |
| 3312 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3307 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3313 | 3308 |
| 3314 // Initialize all low-res tiles. | 3309 // Initialize all low-res tiles. |
| 3315 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3310 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3311 pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling()); |
| 3316 | 3312 |
| 3317 // Low-res tiles should not be enough. | 3313 // Low-res tiles should not be enough. |
| 3318 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3314 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3319 | 3315 |
| 3320 // Initialize remaining tiles. | 3316 // Initialize remaining tiles. |
| 3321 pending_layer_->SetAllTilesReady(); | 3317 pending_layer_->SetAllTilesReady(); |
| 3318 active_layer_->SetAllTilesReady(); |
| 3322 | 3319 |
| 3323 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3320 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3324 } | 3321 } |
| 3325 | 3322 |
| 3326 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { | 3323 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
| 3327 gfx::Size tile_size(100, 100); | 3324 gfx::Size tile_size(100, 100); |
| 3328 gfx::Size layer_bounds(1000, 1000); | 3325 gfx::Size layer_bounds(1000, 1000); |
| 3329 | 3326 |
| 3330 // Make sure some tiles are not shared. | 3327 // Make sure pending tree has tiles. |
| 3331 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3328 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3332 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3329 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3333 | 3330 |
| 3334 // All pending layer tiles required are not ready. | 3331 // All pending layer tiles required are not ready. |
| 3335 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3332 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3336 | 3333 |
| 3337 // Initialize all high-res tiles. | 3334 // Initialize all high-res tiles. |
| 3338 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3335 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3336 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3339 | 3337 |
| 3340 // High-res tiles should be enough, since they cover everything visible. | 3338 // High-res tiles should be enough, since they cover everything visible. |
| 3341 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3339 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3342 } | 3340 } |
| 3343 | 3341 |
| 3344 TEST_F(PictureLayerImplTest, | 3342 TEST_F(PictureLayerImplTest, |
| 3345 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { | 3343 ActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
| 3346 gfx::Size tile_size(100, 100); | 3344 gfx::Size tile_size(100, 100); |
| 3347 gfx::Size layer_bounds(1000, 1000); | 3345 gfx::Size layer_bounds(1000, 1000); |
| 3348 | 3346 |
| 3349 // Make sure some tiles are not shared. | 3347 // Make sure pending tree has tiles. |
| 3350 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3348 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3351 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3349 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3352 | 3350 |
| 3353 // Initialize all high-res tiles in the active layer. | 3351 // Initialize all high-res tiles in the active layer. |
| 3354 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3352 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3355 // And all the low-res tiles in the pending layer. | 3353 // And all the low-res tiles in the pending layer. |
| 3356 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3354 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3357 | 3355 |
| 3358 // The unshared high-res tiles are not ready, so we cannot activate. | 3356 // The pending high-res tiles are not ready, so we cannot activate. |
| 3359 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3357 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3360 | 3358 |
| 3361 // When the unshared pending high-res tiles are ready, we can activate. | 3359 // When the pending high-res tiles are ready, we can activate. |
| 3362 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3360 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3363 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3361 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3364 } | 3362 } |
| 3365 | 3363 |
| 3366 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { | 3364 TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) { |
| 3367 gfx::Size tile_size(100, 100); | 3365 gfx::Size tile_size(100, 100); |
| 3368 gfx::Size layer_bounds(1000, 1000); | 3366 gfx::Size layer_bounds(1000, 1000); |
| 3369 | 3367 |
| 3370 // Make sure some tiles are not shared. | 3368 // Make sure pending tree has tiles. |
| 3371 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3369 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3372 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3370 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3373 | 3371 |
| 3374 // Initialize all high-res tiles in the active layer. | 3372 // Initialize all high-res tiles in the active layer. |
| 3375 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3373 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3376 | 3374 |
| 3377 // The unshared high-res tiles are not ready, so we cannot activate. | 3375 // The pending high-res tiles are not ready, so we cannot activate. |
| 3378 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3376 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3379 | 3377 |
| 3380 // When the unshared pending high-res tiles are ready, we can activate. | 3378 // When the pending pending high-res tiles are ready, we can activate. |
| 3381 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3379 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3382 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3380 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3383 } | 3381 } |
| 3384 | 3382 |
| 3385 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { | 3383 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 3386 gfx::Size tile_size(400, 400); | 3384 gfx::Size tile_size(400, 400); |
| 3387 gfx::Size layer_bounds(1300, 1900); | 3385 gfx::Size layer_bounds(1300, 1900); |
| 3388 | 3386 |
| 3389 scoped_refptr<FakePicturePileImpl> pending_pile = | 3387 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3390 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3388 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3497 7.26f, // ideal contents scale | 3495 7.26f, // ideal contents scale |
| 3498 2.2f, // device scale | 3496 2.2f, // device scale |
| 3499 3.3f, // page scale | 3497 3.3f, // page scale |
| 3500 1.f, // maximum animation scale | 3498 1.f, // maximum animation scale |
| 3501 false); | 3499 false); |
| 3502 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3500 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3503 EXPECT_FLOAT_EQ(7.26f, | 3501 EXPECT_FLOAT_EQ(7.26f, |
| 3504 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3502 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3505 } | 3503 } |
| 3506 | 3504 |
| 3507 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 3505 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 3508 gfx::Size layer_bounds(400, 400); | 3506 gfx::Size layer_bounds(400, 400); |
| 3509 gfx::Size tile_size(100, 100); | 3507 gfx::Size tile_size(100, 100); |
| 3510 | 3508 |
| 3511 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 3509 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 3512 | 3510 |
| 3513 Tile* some_active_tile = | 3511 Tile* some_active_tile = |
| 3514 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 3512 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 3515 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 3513 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 3516 | 3514 |
| 3517 // All tiles shared (no invalidation), so even though the active tree's | 3515 // Since there is no invalidation, pending tree should have no tiles. |
| 3518 // tiles aren't ready, there is nothing required. | 3516 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 3519 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 3520 if (host_impl_.settings().create_low_res_tiling) | 3517 if (host_impl_.settings().create_low_res_tiling) |
| 3521 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 3518 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 3522 | 3519 |
| 3523 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 3520 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 3524 if (host_impl_.settings().create_low_res_tiling) | 3521 if (host_impl_.settings().create_low_res_tiling) |
| 3525 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 3522 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 3523 |
| 3524 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 3525 if (host_impl_.settings().create_low_res_tiling) |
| 3526 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 3526 } | 3527 } |
| 3527 | 3528 |
| 3528 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 3529 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 3529 gfx::Size layer_bounds(400, 400); | 3530 gfx::Size layer_bounds(400, 400); |
| 3530 gfx::Size tile_size(100, 100); | 3531 gfx::Size tile_size(100, 100); |
| 3531 | 3532 |
| 3532 scoped_refptr<FakePicturePileImpl> pending_pile = | 3533 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3533 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3534 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3534 // This pile will create tilings, but has no recordings so will not create any | 3535 // This pile will create tilings, but has no recordings so will not create any |
| 3535 // tiles. This is attempting to simulate scrolling past the end of recorded | 3536 // 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... |
| 3901 }; | 3902 }; |
| 3902 | 3903 |
| 3903 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3904 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
| 3904 public: | 3905 public: |
| 3905 OcclusionTrackingPictureLayerImplTest() | 3906 OcclusionTrackingPictureLayerImplTest() |
| 3906 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3907 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
| 3907 | 3908 |
| 3908 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3909 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
| 3909 FakePictureLayerImpl* twin_layer, | 3910 FakePictureLayerImpl* twin_layer, |
| 3910 WhichTree tree, | 3911 WhichTree tree, |
| 3911 size_t expected_occluded_tile_count) { | 3912 size_t expected_occluded_tile_count, |
| 3912 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 3913 int source_line) { |
| 3913 size_t occluded_tile_count = 0u; | 3914 size_t occluded_tile_count = 0u; |
| 3914 Tile* last_tile = nullptr; | 3915 Tile* last_tile = nullptr; |
| 3915 std::set<Tile*> shared_tiles; | |
| 3916 | 3916 |
| 3917 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 3917 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
| 3918 layer->picture_layer_tiling_set(), layer && twin_layer)); | 3918 layer->picture_layer_tiling_set(), layer && twin_layer)); |
| 3919 while (!queue->IsEmpty()) { | 3919 while (!queue->IsEmpty()) { |
| 3920 Tile* tile = queue->Top(); | 3920 Tile* tile = queue->Top(); |
| 3921 if (!last_tile) | 3921 if (!last_tile) |
| 3922 last_tile = tile; | 3922 last_tile = tile; |
| 3923 if (tile->is_shared()) | |
| 3924 EXPECT_TRUE(shared_tiles.insert(tile).second); | |
| 3925 | 3923 |
| 3926 // The only way we will encounter an occluded tile after an unoccluded | 3924 // The only way we will encounter an occluded tile after an unoccluded |
| 3927 // tile is if the priorty bin decreased, the tile is required for | 3925 // tile is if the priorty bin decreased, the tile is required for |
| 3928 // activation, or the scale changed. | 3926 // activation, or the scale changed. |
| 3929 bool tile_is_occluded = tile->is_occluded(tree); | 3927 bool tile_is_occluded = tile->is_occluded(); |
| 3930 if (tile_is_occluded) { | 3928 if (tile_is_occluded) { |
| 3931 occluded_tile_count++; | 3929 occluded_tile_count++; |
| 3932 | 3930 |
| 3933 bool last_tile_is_occluded = last_tile->is_occluded(tree); | 3931 bool last_tile_is_occluded = last_tile->is_occluded(); |
| 3934 if (!last_tile_is_occluded) { | 3932 if (!last_tile_is_occluded) { |
| 3935 TilePriority::PriorityBin tile_priority_bin = | 3933 TilePriority::PriorityBin tile_priority_bin = |
| 3936 tile->priority(tree).priority_bin; | 3934 tile->priority().priority_bin; |
| 3937 TilePriority::PriorityBin last_tile_priority_bin = | 3935 TilePriority::PriorityBin last_tile_priority_bin = |
| 3938 last_tile->priority(tree).priority_bin; | 3936 last_tile->priority().priority_bin; |
| 3939 | 3937 |
| 3940 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || | 3938 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
| 3941 tile->required_for_activation() || | 3939 tile->required_for_activation() || |
| 3942 tile->contents_scale() != last_tile->contents_scale()); | 3940 tile->contents_scale() != last_tile->contents_scale()) |
| 3941 << "line: " << source_line; |
| 3943 } | 3942 } |
| 3944 } | 3943 } |
| 3945 last_tile = tile; | 3944 last_tile = tile; |
| 3946 queue->Pop(); | 3945 queue->Pop(); |
| 3947 } | 3946 } |
| 3948 // Count also shared tiles which are occluded in the tree but which were | 3947 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) |
| 3949 // not returned by the tiling set eviction queue. Those shared tiles | 3948 << "line: " << source_line; |
| 3950 // shall be returned by the twin tiling set eviction queue. | |
| 3951 queue.reset(new TilingSetEvictionQueue( | |
| 3952 twin_layer->picture_layer_tiling_set(), layer && twin_layer)); | |
| 3953 while (!queue->IsEmpty()) { | |
| 3954 Tile* tile = queue->Top(); | |
| 3955 if (tile->is_shared()) { | |
| 3956 EXPECT_TRUE(shared_tiles.insert(tile).second); | |
| 3957 if (tile->is_occluded(tree)) | |
| 3958 ++occluded_tile_count; | |
| 3959 // Check the reasons why the shared tile was not returned by | |
| 3960 // the first tiling set eviction queue. | |
| 3961 const TilePriority& combined_priority = tile->combined_priority(); | |
| 3962 const TilePriority& priority = tile->priority(tree); | |
| 3963 const TilePriority& twin_priority = tile->priority(twin_tree); | |
| 3964 // Check if the shared tile was not returned by the first tiling | |
| 3965 // set eviction queue because it was out of order for the first | |
| 3966 // tiling set eviction queue but not for the twin tiling set | |
| 3967 // eviction queue. | |
| 3968 if (priority.priority_bin != twin_priority.priority_bin) { | |
| 3969 EXPECT_LT(combined_priority.priority_bin, priority.priority_bin); | |
| 3970 EXPECT_EQ(combined_priority.priority_bin, twin_priority.priority_bin); | |
| 3971 } else if (tile->is_occluded(tree) != tile->is_occluded(twin_tree)) { | |
| 3972 EXPECT_TRUE(tile->is_occluded(tree)); | |
| 3973 EXPECT_FALSE(tile->is_occluded(twin_tree)); | |
| 3974 EXPECT_FALSE(tile->is_occluded_combined()); | |
| 3975 } else if (priority.distance_to_visible != | |
| 3976 twin_priority.distance_to_visible) { | |
| 3977 EXPECT_LT(combined_priority.distance_to_visible, | |
| 3978 priority.distance_to_visible); | |
| 3979 EXPECT_EQ(combined_priority.distance_to_visible, | |
| 3980 twin_priority.distance_to_visible); | |
| 3981 } else { | |
| 3982 // Shared tiles having the same active and pending priorities | |
| 3983 // should be returned only by a pending tree eviction queue. | |
| 3984 EXPECT_EQ(ACTIVE_TREE, tree); | |
| 3985 } | |
| 3986 } | |
| 3987 queue->Pop(); | |
| 3988 } | |
| 3989 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count); | |
| 3990 } | 3949 } |
| 3991 }; | 3950 }; |
| 3992 | 3951 |
| 3993 TEST_F(OcclusionTrackingPictureLayerImplTest, | 3952 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 3994 OccludedTilesSkippedDuringRasterization) { | 3953 OccludedTilesSkippedDuringRasterization) { |
| 3995 base::TimeTicks time_ticks; | 3954 base::TimeTicks time_ticks; |
| 3996 time_ticks += base::TimeDelta::FromMilliseconds(1); | 3955 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 3997 host_impl_.SetCurrentBeginFrameArgs( | 3956 host_impl_.SetCurrentBeginFrameArgs( |
| 3998 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3957 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3999 | 3958 |
| 4000 gfx::Size tile_size(102, 102); | 3959 gfx::Size tile_size(102, 102); |
| 4001 gfx::Size layer_bounds(1000, 1000); | 3960 gfx::Size layer_bounds(1000, 1000); |
| 4002 gfx::Size viewport_size(500, 500); | 3961 gfx::Size viewport_size(500, 500); |
| 4003 gfx::Point occluding_layer_position(310, 0); | 3962 gfx::Point occluding_layer_position(310, 0); |
| 4004 | 3963 |
| 4005 host_impl_.SetViewportSize(viewport_size); | 3964 host_impl_.SetViewportSize(viewport_size); |
| 4006 | 3965 |
| 4007 scoped_refptr<FakePicturePileImpl> pending_pile = | 3966 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4008 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3967 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4009 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 3968 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 4010 | 3969 |
| 4011 // No occlusion. | 3970 // No occlusion. |
| 4012 int unoccluded_tile_count = 0; | 3971 int unoccluded_tile_count = 0; |
| 4013 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 3972 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 4014 pending_layer_->picture_layer_tiling_set(), false)); | 3973 pending_layer_->picture_layer_tiling_set(), false)); |
| 4015 while (!queue->IsEmpty()) { | 3974 while (!queue->IsEmpty()) { |
| 4016 Tile* tile = queue->Top(); | 3975 Tile* tile = queue->Top(); |
| 4017 | 3976 |
| 4018 // Occluded tiles should not be iterated over. | 3977 // Occluded tiles should not be iterated over. |
| 4019 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3978 EXPECT_FALSE(tile->is_occluded()); |
| 4020 | 3979 |
| 4021 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3980 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 4022 // visible and at least partially unoccluded, verified by the above expect. | 3981 // visible and at least partially unoccluded, verified by the above expect. |
| 4023 bool tile_is_visible = | 3982 bool tile_is_visible = |
| 4024 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3983 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 4025 if (tile_is_visible) | 3984 if (tile_is_visible) |
| 4026 unoccluded_tile_count++; | 3985 unoccluded_tile_count++; |
| 4027 queue->Pop(); | 3986 queue->Pop(); |
| 4028 } | 3987 } |
| 4029 EXPECT_EQ(unoccluded_tile_count, 25); | 3988 EXPECT_EQ(unoccluded_tile_count, 25); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4042 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4001 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4043 bool update_lcd_text = false; | 4002 bool update_lcd_text = false; |
| 4044 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4003 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4045 | 4004 |
| 4046 unoccluded_tile_count = 0; | 4005 unoccluded_tile_count = 0; |
| 4047 queue.reset(new TilingSetRasterQueueAll( | 4006 queue.reset(new TilingSetRasterQueueAll( |
| 4048 pending_layer_->picture_layer_tiling_set(), false)); | 4007 pending_layer_->picture_layer_tiling_set(), false)); |
| 4049 while (!queue->IsEmpty()) { | 4008 while (!queue->IsEmpty()) { |
| 4050 Tile* tile = queue->Top(); | 4009 Tile* tile = queue->Top(); |
| 4051 | 4010 |
| 4052 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4011 EXPECT_FALSE(tile->is_occluded()); |
| 4053 | 4012 |
| 4054 bool tile_is_visible = | 4013 bool tile_is_visible = |
| 4055 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4014 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 4056 if (tile_is_visible) | 4015 if (tile_is_visible) |
| 4057 unoccluded_tile_count++; | 4016 unoccluded_tile_count++; |
| 4058 queue->Pop(); | 4017 queue->Pop(); |
| 4059 } | 4018 } |
| 4060 EXPECT_EQ(20, unoccluded_tile_count); | 4019 EXPECT_EQ(20, unoccluded_tile_count); |
| 4061 | 4020 |
| 4062 // Full occlusion. | 4021 // Full occlusion. |
| 4063 layer1->SetPosition(gfx::Point(0, 0)); | 4022 layer1->SetPosition(gfx::Point(0, 0)); |
| 4064 | 4023 |
| 4065 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4024 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 4066 host_impl_.SetCurrentBeginFrameArgs( | 4025 host_impl_.SetCurrentBeginFrameArgs( |
| 4067 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4026 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4068 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4027 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4069 | 4028 |
| 4070 unoccluded_tile_count = 0; | 4029 unoccluded_tile_count = 0; |
| 4071 queue.reset(new TilingSetRasterQueueAll( | 4030 queue.reset(new TilingSetRasterQueueAll( |
| 4072 pending_layer_->picture_layer_tiling_set(), false)); | 4031 pending_layer_->picture_layer_tiling_set(), false)); |
| 4073 while (!queue->IsEmpty()) { | 4032 while (!queue->IsEmpty()) { |
| 4074 Tile* tile = queue->Top(); | 4033 Tile* tile = queue->Top(); |
| 4075 | 4034 |
| 4076 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4035 EXPECT_FALSE(tile->is_occluded()); |
| 4077 | 4036 |
| 4078 bool tile_is_visible = | 4037 bool tile_is_visible = |
| 4079 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4038 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 4080 if (tile_is_visible) | 4039 if (tile_is_visible) |
| 4081 unoccluded_tile_count++; | 4040 unoccluded_tile_count++; |
| 4082 queue->Pop(); | 4041 queue->Pop(); |
| 4083 } | 4042 } |
| 4084 EXPECT_EQ(unoccluded_tile_count, 0); | 4043 EXPECT_EQ(unoccluded_tile_count, 0); |
| 4085 } | 4044 } |
| 4086 | 4045 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4099 host_impl_.SetViewportSize(viewport_size); | 4058 host_impl_.SetViewportSize(viewport_size); |
| 4100 | 4059 |
| 4101 scoped_refptr<FakePicturePileImpl> pending_pile = | 4060 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4102 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4061 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4103 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 4062 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 4104 | 4063 |
| 4105 // No occlusion. | 4064 // No occlusion. |
| 4106 int occluded_tile_count = 0; | 4065 int occluded_tile_count = 0; |
| 4107 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4066 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4108 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4067 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4068 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4109 | 4069 |
| 4110 occluded_tile_count = 0; | 4070 occluded_tile_count = 0; |
| 4111 for (PictureLayerTiling::CoverageIterator iter( | 4071 for (PictureLayerTiling::CoverageIterator iter( |
| 4112 tiling, | 4072 tiling, |
| 4113 pending_layer_->contents_scale_x(), | 4073 pending_layer_->contents_scale_x(), |
| 4114 gfx::Rect(layer_bounds)); | 4074 gfx::Rect(layer_bounds)); |
| 4115 iter; | 4075 iter; |
| 4116 ++iter) { | 4076 ++iter) { |
| 4117 if (!*iter) | 4077 if (!*iter) |
| 4118 continue; | 4078 continue; |
| 4119 const Tile* tile = *iter; | 4079 const Tile* tile = *iter; |
| 4120 | 4080 |
| 4121 // Fully occluded tiles are not required for activation. | 4081 // Fully occluded tiles are not required for activation. |
| 4122 if (tile->is_occluded(PENDING_TREE)) { | 4082 if (tile->is_occluded()) { |
| 4123 EXPECT_FALSE(tile->required_for_activation()); | 4083 EXPECT_FALSE(tile->required_for_activation()); |
| 4124 occluded_tile_count++; | 4084 occluded_tile_count++; |
| 4125 } | 4085 } |
| 4126 } | 4086 } |
| 4127 EXPECT_EQ(occluded_tile_count, 0); | 4087 EXPECT_EQ(occluded_tile_count, 0); |
| 4128 } | 4088 } |
| 4129 | 4089 |
| 4130 // Partial occlusion. | 4090 // Partial occlusion. |
| 4131 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 4091 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
| 4132 LayerImpl* layer1 = pending_layer_->children()[0]; | 4092 LayerImpl* layer1 = pending_layer_->children()[0]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4150 for (PictureLayerTiling::CoverageIterator iter( | 4110 for (PictureLayerTiling::CoverageIterator iter( |
| 4151 tiling, | 4111 tiling, |
| 4152 pending_layer_->contents_scale_x(), | 4112 pending_layer_->contents_scale_x(), |
| 4153 gfx::Rect(layer_bounds)); | 4113 gfx::Rect(layer_bounds)); |
| 4154 iter; | 4114 iter; |
| 4155 ++iter) { | 4115 ++iter) { |
| 4156 if (!*iter) | 4116 if (!*iter) |
| 4157 continue; | 4117 continue; |
| 4158 const Tile* tile = *iter; | 4118 const Tile* tile = *iter; |
| 4159 | 4119 |
| 4160 if (tile->is_occluded(PENDING_TREE)) { | 4120 if (tile->is_occluded()) { |
| 4161 EXPECT_FALSE(tile->required_for_activation()); | 4121 EXPECT_FALSE(tile->required_for_activation()); |
| 4162 occluded_tile_count++; | 4122 occluded_tile_count++; |
| 4163 } | 4123 } |
| 4164 } | 4124 } |
| 4165 switch (i) { | 4125 switch (i) { |
| 4166 case 0: | 4126 case 0: |
| 4167 EXPECT_EQ(occluded_tile_count, 5); | 4127 EXPECT_EQ(occluded_tile_count, 5); |
| 4168 break; | 4128 break; |
| 4169 case 1: | 4129 case 1: |
| 4170 EXPECT_EQ(occluded_tile_count, 2); | 4130 EXPECT_EQ(occluded_tile_count, 2); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4190 for (PictureLayerTiling::CoverageIterator iter( | 4150 for (PictureLayerTiling::CoverageIterator iter( |
| 4191 tiling, | 4151 tiling, |
| 4192 pending_layer_->contents_scale_x(), | 4152 pending_layer_->contents_scale_x(), |
| 4193 gfx::Rect(layer_bounds)); | 4153 gfx::Rect(layer_bounds)); |
| 4194 iter; | 4154 iter; |
| 4195 ++iter) { | 4155 ++iter) { |
| 4196 if (!*iter) | 4156 if (!*iter) |
| 4197 continue; | 4157 continue; |
| 4198 const Tile* tile = *iter; | 4158 const Tile* tile = *iter; |
| 4199 | 4159 |
| 4200 if (tile->is_occluded(PENDING_TREE)) { | 4160 if (tile->is_occluded()) { |
| 4201 EXPECT_FALSE(tile->required_for_activation()); | 4161 EXPECT_FALSE(tile->required_for_activation()); |
| 4202 occluded_tile_count++; | 4162 occluded_tile_count++; |
| 4203 } | 4163 } |
| 4204 } | 4164 } |
| 4205 switch (i) { | 4165 switch (i) { |
| 4206 case 0: | 4166 case 0: |
| 4207 EXPECT_EQ(25, occluded_tile_count); | 4167 EXPECT_EQ(25, occluded_tile_count); |
| 4208 break; | 4168 break; |
| 4209 case 1: | 4169 case 1: |
| 4210 EXPECT_EQ(4, occluded_tile_count); | 4170 EXPECT_EQ(4, occluded_tile_count); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4260 EXPECT_EQ(5u, pending_layer_->num_tilings()); | 4220 EXPECT_EQ(5u, pending_layer_->num_tilings()); |
| 4261 | 4221 |
| 4262 int occluded_tile_count = 0; | 4222 int occluded_tile_count = 0; |
| 4263 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4223 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4264 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4224 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4265 tiling->UpdateAllTilePrioritiesForTesting(); | 4225 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4266 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4226 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4267 | 4227 |
| 4268 occluded_tile_count = 0; | 4228 occluded_tile_count = 0; |
| 4269 for (size_t j = 0; j < tiles.size(); ++j) { | 4229 for (size_t j = 0; j < tiles.size(); ++j) { |
| 4270 if (tiles[j]->is_occluded(PENDING_TREE)) { | 4230 if (tiles[j]->is_occluded()) { |
| 4271 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4231 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4272 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); | 4232 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); |
| 4273 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 4233 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
| 4274 occluded_tile_count++; | 4234 occluded_tile_count++; |
| 4275 } | 4235 } |
| 4276 } | 4236 } |
| 4277 | 4237 |
| 4278 switch (i) { | 4238 switch (i) { |
| 4279 case 0: | 4239 case 0: |
| 4280 EXPECT_EQ(occluded_tile_count, 30); | 4240 EXPECT_EQ(occluded_tile_count, 30); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4314 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4274 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4315 LayerImpl* layer1 = pending_layer_->children()[0]; | 4275 LayerImpl* layer1 = pending_layer_->children()[0]; |
| 4316 layer1->SetBounds(layer_bounds); | 4276 layer1->SetBounds(layer_bounds); |
| 4317 layer1->SetContentBounds(layer_bounds); | 4277 layer1->SetContentBounds(layer_bounds); |
| 4318 layer1->SetDrawsContent(true); | 4278 layer1->SetDrawsContent(true); |
| 4319 layer1->SetContentsOpaque(true); | 4279 layer1->SetContentsOpaque(true); |
| 4320 layer1->SetPosition(occluding_layer_position); | 4280 layer1->SetPosition(occluding_layer_position); |
| 4321 | 4281 |
| 4322 ActivateTree(); | 4282 ActivateTree(); |
| 4323 | 4283 |
| 4284 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4285 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4286 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4287 |
| 4288 for ( |
| 4289 PictureLayerTiling::CoverageIterator iter( |
| 4290 tiling, active_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
| 4291 iter; ++iter) { |
| 4292 if (!*iter) |
| 4293 continue; |
| 4294 const Tile* tile = *iter; |
| 4295 |
| 4296 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4297 tile->content_rect(), 1.0f / tile->contents_scale()); |
| 4298 // Tiles are occluded on the active tree iff they lie beneath the |
| 4299 // occluding layer. |
| 4300 EXPECT_EQ(tile->is_occluded(), |
| 4301 scaled_content_rect.x() >= occluding_layer_position.x()); |
| 4302 } |
| 4303 } |
| 4304 |
| 4324 // Partially invalidate the pending layer. | 4305 // Partially invalidate the pending layer. |
| 4325 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); | 4306 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); |
| 4326 | 4307 |
| 4327 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4308 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4328 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4309 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4329 tiling->UpdateAllTilePrioritiesForTesting(); | 4310 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4330 | 4311 |
| 4331 for (PictureLayerTiling::CoverageIterator iter( | 4312 for (PictureLayerTiling::CoverageIterator iter( |
| 4332 tiling, | 4313 tiling, |
| 4333 pending_layer_->contents_scale_x(), | |
| 4334 gfx::Rect(layer_bounds)); | |
| 4335 iter; | |
| 4336 ++iter) { | |
| 4337 if (!*iter) | |
| 4338 continue; | |
| 4339 const Tile* tile = *iter; | |
| 4340 | |
| 4341 // All tiles are unoccluded on the pending tree. | |
| 4342 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | |
| 4343 | |
| 4344 Tile* twin_tile = pending_layer_->GetPendingOrActiveTwinTiling(tiling) | |
| 4345 ->TileAt(iter.i(), iter.j()); | |
| 4346 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | |
| 4347 tile->content_rect(), 1.0f / tile->contents_scale()); | |
| 4348 | |
| 4349 if (scaled_content_rect.Intersects(invalidation_rect)) { | |
| 4350 // Tiles inside the invalidation rect are only on the pending tree. | |
| 4351 EXPECT_NE(tile, twin_tile); | |
| 4352 | |
| 4353 // Unshared tiles should be unoccluded on the active tree by default. | |
| 4354 EXPECT_FALSE(tile->is_occluded(ACTIVE_TREE)); | |
| 4355 } else { | |
| 4356 // Tiles outside the invalidation rect are shared between both trees. | |
| 4357 EXPECT_EQ(tile, twin_tile); | |
| 4358 // Shared tiles are occluded on the active tree iff they lie beneath the | |
| 4359 // occluding layer. | |
| 4360 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | |
| 4361 scaled_content_rect.x() >= occluding_layer_position.x()); | |
| 4362 } | |
| 4363 } | |
| 4364 } | |
| 4365 | |
| 4366 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | |
| 4367 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | |
| 4368 | |
| 4369 for (PictureLayerTiling::CoverageIterator iter( | |
| 4370 tiling, | |
| 4371 active_layer_->contents_scale_x(), | 4314 active_layer_->contents_scale_x(), |
| 4372 gfx::Rect(layer_bounds)); | 4315 gfx::Rect(layer_bounds)); |
| 4373 iter; | 4316 iter; |
| 4374 ++iter) { | 4317 ++iter) { |
| 4375 if (!*iter) | 4318 if (!*iter) |
| 4376 continue; | 4319 continue; |
| 4377 const Tile* tile = *iter; | 4320 const Tile* tile = *iter; |
| 4378 | 4321 |
| 4322 // All tiles are unoccluded, because the pending tree has no occlusion. |
| 4323 EXPECT_FALSE(tile->is_occluded()); |
| 4324 EXPECT_FALSE(tile->is_occluded()); |
| 4325 |
| 4379 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) | 4326 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) |
| 4380 ->TileAt(iter.i(), iter.j()); | 4327 ->TileAt(iter.i(), iter.j()); |
| 4381 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4328 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4382 tile->content_rect(), 1.0f / tile->contents_scale()); | 4329 tile->content_rect(), 1.0f / tile->contents_scale()); |
| 4383 | 4330 |
| 4384 // Since we've already checked the shared tiles, only consider tiles in | |
| 4385 // the invalidation rect. | |
| 4386 if (scaled_content_rect.Intersects(invalidation_rect)) { | 4331 if (scaled_content_rect.Intersects(invalidation_rect)) { |
| 4387 // Tiles inside the invalidation rect are only on the active tree. | 4332 // Tiles inside the invalidation rect exist on both trees. |
| 4333 EXPECT_TRUE(tile); |
| 4334 EXPECT_TRUE(twin_tile); |
| 4388 EXPECT_NE(tile, twin_tile); | 4335 EXPECT_NE(tile, twin_tile); |
| 4389 | 4336 } else { |
| 4390 // Unshared tiles should be unoccluded on the pending tree by default. | 4337 // Tiles outside the invalidation rect only exist on the active tree. |
| 4391 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4338 EXPECT_TRUE(tile); |
| 4392 | 4339 EXPECT_FALSE(twin_tile); |
| 4393 // Unshared tiles are occluded on the active tree iff they lie beneath | |
| 4394 // the occluding layer. | |
| 4395 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | |
| 4396 scaled_content_rect.x() >= occluding_layer_position.x()); | |
| 4397 } | 4340 } |
| 4398 } | 4341 } |
| 4399 } | 4342 } |
| 4400 } | 4343 } |
| 4401 | 4344 |
| 4402 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4345 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 4403 OccludedTilesConsideredDuringEviction) { | 4346 OccludedTilesConsideredDuringEviction) { |
| 4404 base::TimeTicks time_ticks; | 4347 base::TimeTicks time_ticks; |
| 4405 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4348 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4406 host_impl_.SetCurrentBeginFrameArgs( | 4349 host_impl_.SetCurrentBeginFrameArgs( |
| 4407 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4350 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4408 | 4351 |
| 4409 gfx::Size tile_size(102, 102); | 4352 gfx::Size tile_size(102, 102); |
| 4410 gfx::Size layer_bounds(1000, 1000); | 4353 gfx::Size layer_bounds(1000, 1000); |
| 4411 gfx::Size viewport_size(1000, 1000); | 4354 gfx::Size viewport_size(1000, 1000); |
| 4412 gfx::Point pending_occluding_layer_position(310, 0); | 4355 gfx::Point pending_occluding_layer_position(310, 0); |
| 4413 gfx::Point active_occluding_layer_position(0, 310); | 4356 gfx::Point active_occluding_layer_position(0, 310); |
| 4414 gfx::Rect invalidation_rect(230, 230, 102, 102); | 4357 gfx::Rect invalidation_rect(230, 230, 152, 152); |
| 4415 | 4358 |
| 4416 host_impl_.SetViewportSize(viewport_size); | 4359 host_impl_.SetViewportSize(viewport_size); |
| 4417 host_impl_.SetDeviceScaleFactor(2.f); | 4360 host_impl_.SetDeviceScaleFactor(2.f); |
| 4418 | 4361 |
| 4419 scoped_refptr<FakePicturePileImpl> pending_pile = | 4362 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4420 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4363 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4421 scoped_refptr<FakePicturePileImpl> active_pile = | 4364 scoped_refptr<FakePicturePileImpl> active_pile = |
| 4422 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4365 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4423 | 4366 |
| 4424 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); | 4367 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); |
| 4425 | 4368 |
| 4426 // Partially occlude the active layer. | 4369 // Partially occlude the active layer. |
| 4427 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4370 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4428 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; | 4371 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; |
| 4429 active_occluding_layer->SetBounds(layer_bounds); | 4372 active_occluding_layer->SetBounds(layer_bounds); |
| 4430 active_occluding_layer->SetContentBounds(layer_bounds); | 4373 active_occluding_layer->SetContentBounds(layer_bounds); |
| 4431 active_occluding_layer->SetDrawsContent(true); | 4374 active_occluding_layer->SetDrawsContent(true); |
| 4432 active_occluding_layer->SetContentsOpaque(true); | 4375 active_occluding_layer->SetContentsOpaque(true); |
| 4433 active_occluding_layer->SetPosition(active_occluding_layer_position); | 4376 active_occluding_layer->SetPosition(active_occluding_layer_position); |
| 4434 | 4377 |
| 4435 ActivateTree(); | 4378 ActivateTree(); |
| 4436 | 4379 |
| 4437 // Partially invalidate the pending layer. Tiles inside the invalidation rect | 4380 // Partially invalidate the pending layer. Tiles inside the invalidation rect |
| 4438 // are not shared between trees. | 4381 // are created. |
| 4439 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); | 4382 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); |
| 4440 | 4383 |
| 4441 // Partially occlude the pending layer in a different way. | 4384 // Partially occlude the pending layer in a different way. |
| 4442 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); | 4385 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); |
| 4443 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; | 4386 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; |
| 4444 pending_occluding_layer->SetBounds(layer_bounds); | 4387 pending_occluding_layer->SetBounds(layer_bounds); |
| 4445 pending_occluding_layer->SetContentBounds(layer_bounds); | 4388 pending_occluding_layer->SetContentBounds(layer_bounds); |
| 4446 pending_occluding_layer->SetDrawsContent(true); | 4389 pending_occluding_layer->SetDrawsContent(true); |
| 4447 pending_occluding_layer->SetContentsOpaque(true); | 4390 pending_occluding_layer->SetContentsOpaque(true); |
| 4448 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4391 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
| 4449 | 4392 |
| 4450 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 4393 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 4451 EXPECT_EQ(2u, active_layer_->num_tilings()); | 4394 EXPECT_EQ(2u, active_layer_->num_tilings()); |
| 4452 | 4395 |
| 4453 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4396 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4454 host_impl_.SetCurrentBeginFrameArgs( | 4397 host_impl_.SetCurrentBeginFrameArgs( |
| 4455 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4398 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4456 // UpdateDrawProperties with the occluding layer. | 4399 // UpdateDrawProperties with the occluding layer. |
| 4457 bool update_lcd_text = false; | 4400 bool update_lcd_text = false; |
| 4458 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4401 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4459 | 4402 |
| 4460 // The expected number of occluded tiles on each of the 2 tilings for each of | 4403 // The expected number of occluded tiles on each of the 2 tilings for each of |
| 4461 // the 3 tree priorities. | 4404 // the 3 tree priorities. |
| 4462 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; | 4405 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u}; |
| 4463 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; | 4406 size_t expected_occluded_tile_count_on_active[] = {12u, 1u}; |
| 4464 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; | 4407 size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u}; |
| 4465 | |
| 4466 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u}; | |
| 4467 | 4408 |
| 4468 // Verify number of occluded tiles on the pending layer for each tiling. | 4409 // Verify number of occluded tiles on the pending layer for each tiling. |
| 4469 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4410 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4470 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4411 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4471 tiling->UpdateAllTilePrioritiesForTesting(); | 4412 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4472 | 4413 |
| 4473 size_t occluded_tile_count_on_pending = 0u; | 4414 size_t occluded_tile_count_on_pending = 0u; |
| 4474 size_t occluded_tile_count_on_active = 0u; | |
| 4475 size_t occluded_tile_count_on_both = 0u; | |
| 4476 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, | 4415 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
| 4477 gfx::Rect(layer_bounds)); | 4416 gfx::Rect(layer_bounds)); |
| 4478 iter; ++iter) { | 4417 iter; ++iter) { |
| 4479 Tile* tile = *iter; | 4418 Tile* tile = *iter; |
| 4480 | 4419 |
| 4420 if (invalidation_rect.Intersects(iter.geometry_rect())) |
| 4421 EXPECT_TRUE(tile); |
| 4422 else |
| 4423 EXPECT_FALSE(tile); |
| 4424 |
| 4481 if (!tile) | 4425 if (!tile) |
| 4482 continue; | 4426 continue; |
| 4483 if (tile->is_occluded(PENDING_TREE)) | 4427 if (tile->is_occluded()) |
| 4484 occluded_tile_count_on_pending++; | 4428 occluded_tile_count_on_pending++; |
| 4485 if (tile->is_occluded(ACTIVE_TREE)) | |
| 4486 occluded_tile_count_on_active++; | |
| 4487 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | |
| 4488 occluded_tile_count_on_both++; | |
| 4489 } | 4429 } |
| 4490 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4430 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
| 4491 occluded_tile_count_on_pending) | 4431 occluded_tile_count_on_pending) |
| 4492 << tiling->contents_scale(); | 4432 << tiling->contents_scale(); |
| 4493 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | |
| 4494 occluded_tile_count_on_active) | |
| 4495 << tiling->contents_scale(); | |
| 4496 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | |
| 4497 occluded_tile_count_on_both) | |
| 4498 << tiling->contents_scale(); | |
| 4499 } | 4433 } |
| 4500 | 4434 |
| 4501 // Verify number of occluded tiles on the active layer for each tiling. | 4435 // Verify number of occluded tiles on the active layer for each tiling. |
| 4502 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4436 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4503 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4437 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4504 tiling->UpdateAllTilePrioritiesForTesting(); | 4438 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4505 | 4439 |
| 4506 size_t occluded_tile_count_on_pending = 0u; | |
| 4507 size_t occluded_tile_count_on_active = 0u; | 4440 size_t occluded_tile_count_on_active = 0u; |
| 4508 size_t occluded_tile_count_on_both = 0u; | |
| 4509 for (PictureLayerTiling::CoverageIterator iter( | 4441 for (PictureLayerTiling::CoverageIterator iter( |
| 4510 tiling, | 4442 tiling, |
| 4511 pending_layer_->contents_scale_x(), | 4443 pending_layer_->contents_scale_x(), |
| 4512 gfx::Rect(layer_bounds)); | 4444 gfx::Rect(layer_bounds)); |
| 4513 iter; | 4445 iter; |
| 4514 ++iter) { | 4446 ++iter) { |
| 4515 Tile* tile = *iter; | 4447 Tile* tile = *iter; |
| 4516 | 4448 |
| 4517 if (!tile) | 4449 if (!tile) |
| 4518 continue; | 4450 continue; |
| 4519 if (tile->is_occluded(PENDING_TREE)) | 4451 if (tile->is_occluded()) |
| 4520 occluded_tile_count_on_pending++; | |
| 4521 if (tile->is_occluded(ACTIVE_TREE)) | |
| 4522 occluded_tile_count_on_active++; | 4452 occluded_tile_count_on_active++; |
| 4523 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | |
| 4524 occluded_tile_count_on_both++; | |
| 4525 } | 4453 } |
| 4526 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | |
| 4527 occluded_tile_count_on_pending) | |
| 4528 << i; | |
| 4529 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | 4454 EXPECT_EQ(expected_occluded_tile_count_on_active[i], |
| 4530 occluded_tile_count_on_active) | 4455 occluded_tile_count_on_active) |
| 4531 << i; | 4456 << i; |
| 4532 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | |
| 4533 occluded_tile_count_on_both) | |
| 4534 << i; | |
| 4535 } | 4457 } |
| 4536 | 4458 |
| 4537 std::vector<Tile*> all_tiles; | 4459 std::vector<Tile*> all_tiles; |
| 4538 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4460 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4539 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4461 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4540 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4462 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4541 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); | 4463 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4542 } | 4464 } |
| 4465 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4466 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4467 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4468 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4469 } |
| 4543 | 4470 |
| 4544 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 4471 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 4545 | 4472 |
| 4546 VerifyEvictionConsidersOcclusion( | 4473 VerifyEvictionConsidersOcclusion( |
| 4547 pending_layer_, active_layer_, PENDING_TREE, | 4474 pending_layer_, active_layer_, PENDING_TREE, |
| 4548 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); | 4475 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4549 VerifyEvictionConsidersOcclusion( | 4476 VerifyEvictionConsidersOcclusion( |
| 4550 active_layer_, pending_layer_, ACTIVE_TREE, | 4477 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4551 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); | 4478 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4552 | 4479 |
| 4553 // Repeat the tests without valid active tree priorities. | 4480 // Repeat the tests without valid active tree priorities. |
| 4554 active_layer_->set_has_valid_tile_priorities(false); | 4481 active_layer_->set_has_valid_tile_priorities(false); |
| 4555 VerifyEvictionConsidersOcclusion( | 4482 VerifyEvictionConsidersOcclusion( |
| 4556 pending_layer_, active_layer_, PENDING_TREE, | 4483 pending_layer_, active_layer_, PENDING_TREE, |
| 4557 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); | 4484 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4558 VerifyEvictionConsidersOcclusion( | 4485 VerifyEvictionConsidersOcclusion( |
| 4559 active_layer_, pending_layer_, ACTIVE_TREE, 0u); | 4486 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4487 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4560 active_layer_->set_has_valid_tile_priorities(true); | 4488 active_layer_->set_has_valid_tile_priorities(true); |
| 4561 | 4489 |
| 4562 // Repeat the tests without valid pending tree priorities. | 4490 // Repeat the tests without valid pending tree priorities. |
| 4563 pending_layer_->set_has_valid_tile_priorities(false); | 4491 pending_layer_->set_has_valid_tile_priorities(false); |
| 4564 VerifyEvictionConsidersOcclusion( | 4492 VerifyEvictionConsidersOcclusion( |
| 4565 active_layer_, pending_layer_, ACTIVE_TREE, | 4493 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4566 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); | 4494 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4567 VerifyEvictionConsidersOcclusion( | 4495 VerifyEvictionConsidersOcclusion( |
| 4568 pending_layer_, active_layer_, PENDING_TREE, 0u); | 4496 pending_layer_, active_layer_, PENDING_TREE, |
| 4497 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4569 pending_layer_->set_has_valid_tile_priorities(true); | 4498 pending_layer_->set_has_valid_tile_priorities(true); |
| 4570 } | 4499 } |
| 4571 | 4500 |
| 4572 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { | 4501 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { |
| 4573 gfx::Size tile_size(102, 102); | 4502 gfx::Size tile_size(102, 102); |
| 4574 gfx::Size layer_bounds(1000, 1000); | 4503 gfx::Size layer_bounds(1000, 1000); |
| 4575 | 4504 |
| 4576 scoped_refptr<FakePicturePileImpl> pile = | 4505 scoped_refptr<FakePicturePileImpl> pile = |
| 4577 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4506 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4578 SetupPendingTree(pile); | 4507 SetupPendingTree(pile); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4787 std::vector<Tile*> tiles; | 4716 std::vector<Tile*> tiles; |
| 4788 for (PictureLayerTiling::CoverageIterator iter( | 4717 for (PictureLayerTiling::CoverageIterator iter( |
| 4789 pending_layer_->HighResTiling(), | 4718 pending_layer_->HighResTiling(), |
| 4790 1.f, | 4719 1.f, |
| 4791 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4720 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4792 iter; | 4721 iter; |
| 4793 ++iter) { | 4722 ++iter) { |
| 4794 if (*iter) | 4723 if (*iter) |
| 4795 tiles.push_back(*iter); | 4724 tiles.push_back(*iter); |
| 4796 } | 4725 } |
| 4726 for (PictureLayerTiling::CoverageIterator iter( |
| 4727 active_layer_->HighResTiling(), 1.f, |
| 4728 active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4729 iter; ++iter) { |
| 4730 if (*iter) |
| 4731 tiles.push_back(*iter); |
| 4732 } |
| 4797 | 4733 |
| 4798 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4734 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4799 | 4735 |
| 4800 // Ensure we can activate. | 4736 // Ensure we can activate. |
| 4801 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 4737 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 4802 } | 4738 } |
| 4803 | 4739 |
| 4804 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { | 4740 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { |
| 4805 gfx::Size tile_size(100, 100); | 4741 gfx::Size tile_size(100, 100); |
| 4806 gfx::Size layer_bounds(400, 400); | 4742 gfx::Size layer_bounds(400, 400); |
| 4807 | 4743 |
| 4808 scoped_refptr<FakePicturePileImpl> filled_pile = | 4744 scoped_refptr<FakePicturePileImpl> filled_pile = |
| 4809 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4745 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4810 | 4746 |
| 4811 scoped_ptr<FakePicturePile> partial_recording = | 4747 scoped_ptr<FakePicturePile> partial_recording = |
| 4812 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); | 4748 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); |
| 4813 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { | 4749 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { |
| 4814 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) | 4750 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) |
| 4815 partial_recording->AddRecordingAt(i, j); | 4751 partial_recording->AddRecordingAt(i, j); |
| 4816 } | 4752 } |
| 4817 scoped_refptr<FakePicturePileImpl> partial_pile = | 4753 scoped_refptr<FakePicturePileImpl> partial_pile = |
| 4818 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); | 4754 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); |
| 4819 | 4755 |
| 4820 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); | 4756 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); |
| 4821 ActivateTree(); | 4757 ActivateTree(); |
| 4822 | 4758 |
| 4823 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); | 4759 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); |
| 4824 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); | 4760 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); |
| 4825 | 4761 |
| 4826 // We should have all tiles in both tile sets. | 4762 // We should have all tiles on active, and none on pending. |
| 4827 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4763 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size()); |
| 4828 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4764 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4829 | 4765 |
| 4830 // Now put a partially-recorded pile on the pending tree (and invalidate | 4766 // Now put a partially-recorded pile on the pending tree (and invalidate |
| 4831 // everything, since the main thread PicturePile will invalidate dropped | 4767 // everything, since the main thread PicturePile will invalidate dropped |
| 4832 // recordings). This will cause us to be missing some tiles. | 4768 // recordings). This will cause us to be missing some tiles. |
| 4833 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, | 4769 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, |
| 4834 Region(gfx::Rect(layer_bounds))); | 4770 Region(gfx::Rect(layer_bounds))); |
| 4835 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); | 4771 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); |
| 4836 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); | 4772 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 4837 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); | 4773 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 4838 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); | 4774 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); |
| 4839 | 4775 |
| 4840 // Active is not affected yet. | 4776 // Active is not affected yet. |
| 4841 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4777 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4842 | 4778 |
| 4843 // Activate the tree. The same tiles go missing on the active tree. | 4779 // Activate the tree. The same tiles go missing on the active tree. |
| 4844 ActivateTree(); | 4780 ActivateTree(); |
| 4845 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); | 4781 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); |
| 4846 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 4782 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 4847 EXPECT_FALSE(active_tiling->TileAt(1, 1)); | 4783 EXPECT_FALSE(active_tiling->TileAt(1, 1)); |
| 4848 EXPECT_TRUE(active_tiling->TileAt(2, 2)); | 4784 EXPECT_TRUE(active_tiling->TileAt(2, 2)); |
| 4849 | 4785 |
| 4850 // Now put a full recording on the pending tree again. We'll get all our tiles | 4786 // Now put a full recording on the pending tree again. We'll get all our tiles |
| 4851 // back. | 4787 // back. |
| 4852 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, | 4788 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, |
| 4853 Region(gfx::Rect(layer_bounds))); | 4789 Region(gfx::Rect(layer_bounds))); |
| 4854 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4790 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); |
| 4791 Tile* tile00 = pending_tiling->TileAt(0, 0); |
| 4792 Tile* tile11 = pending_tiling->TileAt(1, 1); |
| 4793 Tile* tile22 = pending_tiling->TileAt(2, 2); |
| 4855 | 4794 |
| 4856 // Active is not affected yet. | 4795 // Active is not affected yet. |
| 4857 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); | 4796 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); |
| 4858 | 4797 |
| 4859 // Activate the tree. The tiles are created and shared on the active tree. | 4798 // Activate the tree. The tiles are moved to the active tree. |
| 4860 ActivateTree(); | 4799 ActivateTree(); |
| 4861 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4800 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4862 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | 4801 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0)); |
| 4863 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | 4802 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1)); |
| 4864 EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared()); | 4803 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2)); |
| 4865 } | 4804 } |
| 4866 | 4805 |
| 4867 class TileSizeSettings : public ImplSidePaintingSettings { | 4806 class TileSizeSettings : public ImplSidePaintingSettings { |
| 4868 public: | 4807 public: |
| 4869 TileSizeSettings() { | 4808 TileSizeSettings() { |
| 4870 default_tile_size = gfx::Size(100, 100); | 4809 default_tile_size = gfx::Size(100, 100); |
| 4871 max_untiled_layer_size = gfx::Size(200, 200); | 4810 max_untiled_layer_size = gfx::Size(200, 200); |
| 4872 } | 4811 } |
| 4873 }; | 4812 }; |
| 4874 | 4813 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4927 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4866 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4928 EXPECT_EQ(result.width(), 448); | 4867 EXPECT_EQ(result.width(), 448); |
| 4929 EXPECT_EQ(result.height(), 448); | 4868 EXPECT_EQ(result.height(), 448); |
| 4930 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4869 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4931 EXPECT_EQ(result.width(), 512); | 4870 EXPECT_EQ(result.width(), 512); |
| 4932 EXPECT_EQ(result.height(), 500 + 2); | 4871 EXPECT_EQ(result.height(), 500 + 2); |
| 4933 } | 4872 } |
| 4934 | 4873 |
| 4935 } // namespace | 4874 } // namespace |
| 4936 } // namespace cc | 4875 } // namespace cc |
| OLD | NEW |