| 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 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 306 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
| 303 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 307 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 304 for (size_t i = 0; i < tiles.size(); ++i) | 308 for (size_t i = 0; i < tiles.size(); ++i) |
| 305 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; | 309 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; |
| 306 EXPECT_GT(tiles.size(), 0u); | 310 EXPECT_GT(tiles.size(), 0u); |
| 307 } | 311 } |
| 308 | 312 |
| 309 void AssertNoTilesRequired(PictureLayerTiling* tiling) { | 313 void AssertNoTilesRequired(PictureLayerTiling* tiling) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 403 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 400 | 404 |
| 401 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); | 405 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
| 402 | 406 |
| 403 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | 407 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
| 404 active_layer_->tilings()->num_tilings()); | 408 active_layer_->tilings()->num_tilings()); |
| 405 | 409 |
| 406 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 410 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 407 EXPECT_GT(tilings->num_tilings(), 0u); | 411 EXPECT_GT(tilings->num_tilings(), 0u); |
| 408 for (size_t i = 0; i < tilings->num_tilings(); ++i) | 412 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
| 409 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); | 413 EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty()); |
| 410 } | 414 } |
| 411 | 415 |
| 412 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { | 416 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { |
| 413 base::TimeTicks time_ticks; | 417 base::TimeTicks time_ticks; |
| 414 time_ticks += base::TimeDelta::FromMilliseconds(1); | 418 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 415 host_impl_.SetCurrentBeginFrameArgs( | 419 host_impl_.SetCurrentBeginFrameArgs( |
| 416 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 420 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 417 gfx::Size tile_size(100, 100); | 421 gfx::Size tile_size(100, 100); |
| 418 gfx::Size layer_bounds(400, 400); | 422 gfx::Size layer_bounds(400, 400); |
| 419 | 423 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 654 |
| 651 scoped_refptr<FakePicturePileImpl> pending_pile = | 655 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 652 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 656 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 653 scoped_refptr<FakePicturePileImpl> active_pile = | 657 scoped_refptr<FakePicturePileImpl> active_pile = |
| 654 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 658 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 655 scoped_refptr<FakePicturePileImpl> lost_pile = | 659 scoped_refptr<FakePicturePileImpl> lost_pile = |
| 656 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 660 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 657 | 661 |
| 658 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); | 662 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); |
| 659 ActivateTree(); | 663 ActivateTree(); |
| 660 // Add a non-shared tiling on the active tree. | 664 // Add a unique tiling on the active tree. |
| 661 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); | 665 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); |
| 662 tiling->CreateAllTilesForTesting(); | 666 tiling->CreateAllTilesForTesting(); |
| 663 | 667 |
| 664 // Ensure UpdateTiles won't remove any tilings. | 668 // Ensure UpdateTiles won't remove any tilings. |
| 665 active_layer_->MarkAllTilingsUsed(); | 669 active_layer_->MarkAllTilingsUsed(); |
| 666 | 670 |
| 667 // Then setup a new pending tree and activate it. | 671 // Then setup a new pending tree and activate it. |
| 668 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), | 672 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), |
| 669 layer_invalidation); | 673 layer_invalidation); |
| 670 | 674 |
| 671 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 675 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 672 EXPECT_EQ(3u, active_layer_->num_tilings()); | 676 EXPECT_EQ(3u, active_layer_->num_tilings()); |
| 673 | 677 |
| 674 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 678 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 675 EXPECT_GT(tilings->num_tilings(), 0u); | 679 EXPECT_GT(tilings->num_tilings(), 0u); |
| 676 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 680 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 677 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 681 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 678 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( | 682 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( |
| 679 layer_invalidation, | 683 layer_invalidation, |
| 680 tiling->contents_scale()); | 684 tiling->contents_scale()); |
| 681 for (PictureLayerTiling::CoverageIterator iter( | 685 for (PictureLayerTiling::CoverageIterator iter( |
| 682 tiling, | 686 tiling, |
| 683 tiling->contents_scale(), | 687 tiling->contents_scale(), |
| 684 gfx::Rect(tiling->tiling_size())); | 688 gfx::Rect(tiling->tiling_size())); |
| 685 iter; | 689 iter; |
| 686 ++iter) { | 690 ++iter) { |
| 687 EXPECT_TRUE(*iter); | 691 // We don't always have a tile, but when we do it's because it was |
| 688 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 692 // invalidated and it has the latest raster source. |
| 689 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | 693 if (*iter) { |
| 694 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 695 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
| 696 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); |
| 697 } else { |
| 698 // We don't create tiles in non-invalidated regions. |
| 699 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); |
| 700 } |
| 690 } | 701 } |
| 691 } | 702 } |
| 692 | 703 |
| 693 tilings = active_layer_->tilings(); | 704 tilings = active_layer_->tilings(); |
| 694 EXPECT_GT(tilings->num_tilings(), 0u); | 705 EXPECT_GT(tilings->num_tilings(), 0u); |
| 695 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 706 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 696 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 707 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 697 gfx::Rect content_invalidation = | 708 gfx::Rect content_invalidation = |
| 698 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); | 709 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); |
| 699 for (PictureLayerTiling::CoverageIterator iter( | 710 for (PictureLayerTiling::CoverageIterator iter( |
| 700 tiling, | 711 tiling, |
| 701 tiling->contents_scale(), | 712 tiling->contents_scale(), |
| 702 gfx::Rect(tiling->tiling_size())); | 713 gfx::Rect(tiling->tiling_size())); |
| 703 iter; | 714 iter; |
| 704 ++iter) { | 715 ++iter) { |
| 705 EXPECT_TRUE(*iter); | 716 EXPECT_TRUE(*iter); |
| 706 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 717 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 707 if (iter.geometry_rect().Intersects(content_invalidation)) | 718 // Pile will be updated upon activation. |
| 708 EXPECT_EQ(active_pile.get(), iter->raster_source()); | 719 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
| 709 else if (!active_layer_->GetPendingOrActiveTwinTiling(tiling)) | |
| 710 EXPECT_EQ(active_pile.get(), iter->raster_source()); | |
| 711 else | |
| 712 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | |
| 713 } | 720 } |
| 714 } | 721 } |
| 715 } | 722 } |
| 716 | 723 |
| 717 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { | 724 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { |
| 718 gfx::Size tile_size(90, 80); | 725 gfx::Size tile_size(90, 80); |
| 719 gfx::Size layer_bounds(300, 500); | 726 gfx::Size layer_bounds(300, 500); |
| 720 | 727 |
| 721 scoped_refptr<FakePicturePileImpl> pending_pile = | 728 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 722 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 729 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 // This should create new tilings. | 1527 // This should create new tilings. |
| 1521 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 1528 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 1522 1.f, // ideal contents scale | 1529 1.f, // ideal contents scale |
| 1523 1.f, // device scale | 1530 1.f, // device scale |
| 1524 1.f, // page scale | 1531 1.f, // page scale |
| 1525 1.f, // maximum animation scale | 1532 1.f, // maximum animation scale |
| 1526 false); | 1533 false); |
| 1527 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1534 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1528 } | 1535 } |
| 1529 | 1536 |
| 1530 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1537 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { |
| 1531 // The default max tile size is larger than 400x400. | 1538 // The default max tile size is larger than 400x400. |
| 1532 gfx::Size tile_size(400, 400); | 1539 gfx::Size tile_size(400, 400); |
| 1533 gfx::Size layer_bounds(5000, 5000); | 1540 gfx::Size layer_bounds(5000, 5000); |
| 1534 | 1541 |
| 1535 scoped_refptr<FakePicturePileImpl> pending_pile = | 1542 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1536 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1543 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1537 scoped_refptr<FakePicturePileImpl> active_pile = | |
| 1538 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 1539 | 1544 |
| 1540 SetupTrees(pending_pile, active_pile); | 1545 SetupPendingTree(pending_pile); |
| 1541 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); | 1546 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); |
| 1542 | 1547 |
| 1543 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1548 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1544 | 1549 |
| 1545 // The default value. | 1550 // The default value. |
| 1546 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1551 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1547 host_impl_.settings().default_tile_size.ToString()); | 1552 host_impl_.settings().default_tile_size.ToString()); |
| 1548 | 1553 |
| 1549 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1554 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1550 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1555 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1575 // The default max tile size is larger than 400x400. | 1580 // The default max tile size is larger than 400x400. |
| 1576 gfx::Size tile_size(400, 400); | 1581 gfx::Size tile_size(400, 400); |
| 1577 gfx::Size layer_bounds(500, 500); | 1582 gfx::Size layer_bounds(500, 500); |
| 1578 | 1583 |
| 1579 scoped_refptr<FakePicturePileImpl> pending_pile = | 1584 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1580 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1585 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1581 scoped_refptr<FakePicturePileImpl> active_pile = | 1586 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1582 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1587 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1583 | 1588 |
| 1584 SetupTrees(pending_pile, active_pile); | 1589 SetupTrees(pending_pile, active_pile); |
| 1585 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); | 1590 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u); |
| 1586 | 1591 |
| 1587 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1592 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1588 | 1593 |
| 1589 // The default value. The layer is smaller than this. | 1594 // The default value. The layer is smaller than this. |
| 1590 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1595 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
| 1591 host_impl_.settings().max_untiled_layer_size.ToString()); | 1596 host_impl_.settings().max_untiled_layer_size.ToString()); |
| 1592 | 1597 |
| 1593 // There should be a single tile since the layer is small. | 1598 // There should be a single tile since the layer is small. |
| 1594 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1599 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1595 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1600 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1596 | 1601 |
| 1597 ResetTilingsAndRasterScales(); | 1602 ResetTilingsAndRasterScales(); |
| 1598 | 1603 |
| 1599 // Change the max texture size on the output surface context. | 1604 // Change the max texture size on the output surface context. |
| 1600 scoped_ptr<TestWebGraphicsContext3D> context = | 1605 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1601 TestWebGraphicsContext3D::Create(); | 1606 TestWebGraphicsContext3D::Create(); |
| 1602 context->set_max_texture_size(140); | 1607 context->set_max_texture_size(140); |
| 1603 host_impl_.DidLoseOutputSurface(); | 1608 host_impl_.DidLoseOutputSurface(); |
| 1604 host_impl_.InitializeRenderer( | 1609 host_impl_.InitializeRenderer( |
| 1605 FakeOutputSurface::Create3d(context.Pass()).Pass()); | 1610 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
| 1606 | 1611 |
| 1607 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1612 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1608 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1613 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); |
| 1609 | 1614 |
| 1610 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1615 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1611 | 1616 |
| 1612 // There should be more than one tile since the max texture size won't cover | 1617 // There should be more than one tile since the max texture size won't cover |
| 1613 // the layer. | 1618 // the layer. |
| 1614 high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1619 high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1615 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1620 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1616 | 1621 |
| 1617 // Verify the tiles are not larger than the context's max texture size. | 1622 // Verify the tiles are not larger than the context's max texture size. |
| 1618 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1623 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1619 EXPECT_GE(140, tile->content_rect().width()); | 1624 EXPECT_GE(140, tile->content_rect().width()); |
| 1620 EXPECT_GE(140, tile->content_rect().height()); | 1625 EXPECT_GE(140, tile->content_rect().height()); |
| 1621 } | 1626 } |
| 1622 | 1627 |
| 1623 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { | 1628 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
| 1624 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1629 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1625 | 1630 |
| 1626 gfx::Size tile_size(400, 400); | 1631 gfx::Size tile_size(400, 400); |
| 1627 gfx::Size layer_bounds(1300, 1900); | 1632 gfx::Size layer_bounds(1300, 1900); |
| 1628 | 1633 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 pending_layer_->UpdateTiles(resourceless_software_draw); | 1737 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 1733 | 1738 |
| 1734 int num_visible = 0; | 1739 int num_visible = 0; |
| 1735 int num_offscreen = 0; | 1740 int num_offscreen = 0; |
| 1736 | 1741 |
| 1737 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 1742 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 1738 pending_layer_->picture_layer_tiling_set(), false)); | 1743 pending_layer_->picture_layer_tiling_set(), false)); |
| 1739 for (; !queue->IsEmpty(); queue->Pop()) { | 1744 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1740 const Tile* tile = queue->Top(); | 1745 const Tile* tile = queue->Top(); |
| 1741 DCHECK(tile); | 1746 DCHECK(tile); |
| 1742 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1747 if (tile->priority().distance_to_visible == 0.f) { |
| 1743 EXPECT_TRUE(tile->required_for_activation()); | 1748 EXPECT_TRUE(tile->required_for_activation()); |
| 1744 num_visible++; | 1749 num_visible++; |
| 1745 } else { | 1750 } else { |
| 1746 EXPECT_FALSE(tile->required_for_activation()); | 1751 EXPECT_FALSE(tile->required_for_activation()); |
| 1747 num_offscreen++; | 1752 num_offscreen++; |
| 1748 } | 1753 } |
| 1749 } | 1754 } |
| 1750 | 1755 |
| 1751 EXPECT_GT(num_visible, 0); | 1756 EXPECT_GT(num_visible, 0); |
| 1752 EXPECT_GT(num_offscreen, 0); | 1757 EXPECT_GT(num_offscreen, 0); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 host_impl_.SetCurrentBeginFrameArgs( | 1802 host_impl_.SetCurrentBeginFrameArgs( |
| 1798 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1803 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1799 pending_layer_->UpdateTiles(resourceless_software_draw); | 1804 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 1800 | 1805 |
| 1801 // Intersect the two rects. Any tile outside should not be required for | 1806 // Intersect the two rects. Any tile outside should not be required for |
| 1802 // activation. | 1807 // activation. |
| 1803 gfx::Rect viewport_for_tile_priority = | 1808 gfx::Rect viewport_for_tile_priority = |
| 1804 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); | 1809 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); |
| 1805 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); | 1810 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); |
| 1806 | 1811 |
| 1812 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 1813 |
| 1807 int num_inside = 0; | 1814 int num_inside = 0; |
| 1808 int num_outside = 0; | 1815 int num_outside = 0; |
| 1809 for (PictureLayerTiling::CoverageIterator iter( | 1816 for (PictureLayerTiling::CoverageIterator iter(active_layer_->HighResTiling(), |
| 1810 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); | 1817 1.f, gfx::Rect(layer_bounds)); |
| 1811 iter; ++iter) { | 1818 iter; ++iter) { |
| 1812 if (!*iter) | 1819 if (!*iter) |
| 1813 continue; | 1820 continue; |
| 1814 Tile* tile = *iter; | 1821 Tile* tile = *iter; |
| 1815 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { | 1822 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { |
| 1816 num_inside++; | 1823 num_inside++; |
| 1817 // Mark everything in viewport for tile priority as ready to draw. | 1824 // Mark everything in viewport for tile priority as ready to draw. |
| 1818 TileDrawInfo& draw_info = tile->draw_info(); | 1825 TileDrawInfo& draw_info = tile->draw_info(); |
| 1819 draw_info.SetSolidColorForTesting(SK_ColorRED); | 1826 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 1820 } else { | 1827 } else { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), | 2036 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), |
| 2030 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) | 2037 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) |
| 2031 ->tex_coord_rect.size()); | 2038 ->tex_coord_rect.size()); |
| 2032 | 2039 |
| 2033 // Neither the high res nor the ideal tiles were considered as incomplete. | 2040 // Neither the high res nor the ideal tiles were considered as incomplete. |
| 2034 EXPECT_EQ(0u, data.num_missing_tiles); | 2041 EXPECT_EQ(0u, data.num_missing_tiles); |
| 2035 EXPECT_EQ(0u, data.num_incomplete_tiles); | 2042 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 2036 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 2043 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 2037 } | 2044 } |
| 2038 | 2045 |
| 2039 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 2046 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveAllReady) { |
| 2040 gfx::Size layer_bounds(400, 400); | 2047 gfx::Size layer_bounds(400, 400); |
| 2041 gfx::Size tile_size(100, 100); | 2048 gfx::Size tile_size(100, 100); |
| 2042 | 2049 |
| 2043 // No tiles shared. | |
| 2044 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, | 2050 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, |
| 2045 gfx::Rect(layer_bounds)); | 2051 gfx::Rect(layer_bounds)); |
| 2046 | 2052 |
| 2047 active_layer_->SetAllTilesReady(); | 2053 active_layer_->SetAllTilesReady(); |
| 2048 | 2054 |
| 2049 // No shared tiles and all active tiles ready, so pending can only | 2055 // All active tiles ready, so pending can only activate with all high res |
| 2050 // activate with all high res tiles. | 2056 // tiles. |
| 2051 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2057 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2052 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2058 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2053 | 2059 |
| 2054 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2060 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 2055 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2061 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| 2056 } | 2062 } |
| 2057 | 2063 |
| 2058 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 2064 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
| 2059 gfx::Size layer_bounds(400, 400); | 2065 gfx::Size layer_bounds(400, 400); |
| 2060 gfx::Size tile_size(100, 100); | 2066 gfx::Size tile_size(100, 100); |
| 2061 | 2067 |
| 2062 // All tiles shared (no invalidation). | 2068 // No invalidation. |
| 2063 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2069 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2064 | 2070 |
| 2065 // Verify active tree not ready. | 2071 // Verify active tree not ready. |
| 2066 Tile* some_active_tile = | 2072 Tile* some_active_tile = |
| 2067 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2073 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2068 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2074 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2069 | 2075 |
| 2070 // When high res are required, even if the active tree is not ready, | 2076 // When high res are required, all tiles in active high res tiling should be |
| 2071 // the high res tiles must be ready. | 2077 // required for activation. |
| 2072 host_impl_.SetRequiresHighResToDraw(); | 2078 host_impl_.SetRequiresHighResToDraw(); |
| 2073 | 2079 |
| 2074 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2080 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2075 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2081 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2082 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2083 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2076 | 2084 |
| 2077 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2085 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2078 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2086 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2087 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2088 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2079 } | 2089 } |
| 2080 | 2090 |
| 2081 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 2091 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 2082 gfx::Size layer_bounds(400, 400); | 2092 gfx::Size layer_bounds(400, 400); |
| 2083 gfx::Size tile_size(100, 100); | 2093 gfx::Size tile_size(100, 100); |
| 2084 | 2094 |
| 2085 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2095 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2086 | 2096 |
| 2087 Tile* some_active_tile = | 2097 Tile* some_active_tile = |
| 2088 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2098 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2089 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2099 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2090 | 2100 |
| 2091 // All tiles shared (no invalidation), so even though the active tree's | 2101 // Since there are no invalidations, pending tree should have no tiles. |
| 2092 // tiles aren't ready, the high res tiles are required for activation. | 2102 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2093 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2103 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2094 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 2095 | 2104 |
| 2096 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2105 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2097 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2106 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2107 |
| 2108 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2109 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2098 } | 2110 } |
| 2099 | 2111 |
| 2100 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { | 2112 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { |
| 2101 gfx::Size layer_bounds(400, 400); | 2113 gfx::Size layer_bounds(400, 400); |
| 2102 gfx::Size tile_size(100, 100); | 2114 gfx::Size tile_size(100, 100); |
| 2103 | 2115 |
| 2104 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2116 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 2105 | 2117 |
| 2106 Tile* some_active_tile = | 2118 Tile* some_active_tile = |
| 2107 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2119 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 2108 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2120 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 2109 | 2121 |
| 2122 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 2123 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2124 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
| 2125 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
| 2110 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); | 2126 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
| 2111 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); | 2127 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
| 2112 | 2128 |
| 2113 // If we disallow required for activation, no tiles can be required. | 2129 // If we disallow required for activation, no tiles can be required. |
| 2114 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2130 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2115 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2131 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2116 | 2132 |
| 2117 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2133 AssertNoTilesRequired(active_layer_->HighResTiling()); |
| 2118 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2134 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2119 } | 2135 } |
| 2120 | 2136 |
| 2121 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2137 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 2122 gfx::Size layer_bounds(400, 400); | 2138 gfx::Size layer_bounds(400, 400); |
| 2123 gfx::Size tile_size(100, 100); | 2139 gfx::Size tile_size(100, 100); |
| 2124 | 2140 |
| 2125 scoped_refptr<FakePicturePileImpl> pending_pile = | 2141 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2126 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2142 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2127 // This pile will create tilings, but has no recordings so will not create any | 2143 // This pile will create tilings, but has no recordings so will not create any |
| 2128 // tiles. This is attempting to simulate scrolling past the end of recorded | 2144 // 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... |
| 2182 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); | 2198 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); |
| 2183 scoped_refptr<FakePicturePileImpl> active_pile = | 2199 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2184 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); | 2200 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); |
| 2185 | 2201 |
| 2186 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2202 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
| 2187 | 2203 |
| 2188 // Since the active layer has different bounds, the pending layer needs all | 2204 // Since the active layer has different bounds, the pending layer needs all |
| 2189 // high res tiles in order to activate. | 2205 // high res tiles in order to activate. |
| 2190 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2206 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2191 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2207 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2208 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2209 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 2192 | 2210 |
| 2193 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2211 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 2194 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2212 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 2213 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 2214 // Since the test doesn't invalidate the resized region, we expect that the |
| 2215 // same low res tile would exist (which means we don't create a new one of the |
| 2216 // pending tree). |
| 2217 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 2195 } | 2218 } |
| 2196 | 2219 |
| 2197 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 2220 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
| 2198 gfx::Size tile_size(100, 100); | 2221 gfx::Size tile_size(100, 100); |
| 2199 gfx::Size layer_bounds(400, 400); | 2222 gfx::Size layer_bounds(400, 400); |
| 2200 scoped_refptr<FakePicturePileImpl> pending_pile = | 2223 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2201 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2224 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2202 | 2225 |
| 2203 host_impl_.CreatePendingTree(); | 2226 host_impl_.CreatePendingTree(); |
| 2204 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 2227 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 // Activate and make a pending tree with an invalidated raster tile 1,1. | 2276 // Activate and make a pending tree with an invalidated raster tile 1,1. |
| 2254 ActivateTree(); | 2277 ActivateTree(); |
| 2255 | 2278 |
| 2256 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); | 2279 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); |
| 2257 | 2280 |
| 2258 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2281 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2259 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2282 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2260 | 2283 |
| 2261 // pending_tiling->CreateAllTilesForTesting(); | 2284 // pending_tiling->CreateAllTilesForTesting(); |
| 2262 | 2285 |
| 2263 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2286 // Tile 0,0 not exist on pending, but tile 1,1 should. |
| 2264 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2287 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2265 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2288 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2266 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2289 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2290 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2291 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2292 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2267 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2293 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2268 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2294 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2269 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2295 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
| 2270 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | |
| 2271 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | |
| 2272 | 2296 |
| 2273 // Drop the tiles on the active tree and recreate them. The same tiles | 2297 // Drop the tiles on the active tree and recreate them. |
| 2274 // should be shared or not. | |
| 2275 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); | 2298 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); |
| 2276 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); | 2299 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); |
| 2277 active_tiling->CreateAllTilesForTesting(); | 2300 active_tiling->CreateAllTilesForTesting(); |
| 2278 | 2301 |
| 2279 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2302 // Tile 0,0 not exist on pending, but tile 1,1 should. |
| 2280 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2303 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2281 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2304 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2282 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2305 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2306 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2307 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2308 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2283 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2309 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
| 2284 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2310 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2285 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2311 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
| 2286 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | |
| 2287 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | |
| 2288 } | 2312 } |
| 2289 | 2313 |
| 2290 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) { | 2314 TEST_F(PictureLayerImplTest, PendingHasNoTilesWithNoInvalidation) { |
| 2291 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2315 SetupDefaultTrees(gfx::Size(1500, 1500)); |
| 2292 | 2316 |
| 2293 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2317 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2294 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2318 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2295 | 2319 |
| 2296 // No invalidation, so all tiles are shared. | 2320 // No invalidation. |
| 2297 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2321 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2298 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2322 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2299 ASSERT_TRUE(active_tiling); | 2323 ASSERT_TRUE(active_tiling); |
| 2300 ASSERT_TRUE(pending_tiling); | 2324 ASSERT_TRUE(pending_tiling); |
| 2301 | 2325 |
| 2302 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2326 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2303 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2327 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2304 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2328 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2305 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2329 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2306 | 2330 |
| 2307 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2331 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2308 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2332 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2309 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2333 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2310 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2334 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2311 | |
| 2312 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | |
| 2313 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | |
| 2314 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
| 2315 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
| 2316 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
| 2317 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); | |
| 2318 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
| 2319 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2320 } | 2335 } |
| 2321 | 2336 |
| 2322 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { | 2337 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { |
| 2323 gfx::Size tile_size(100, 100); | 2338 gfx::Size tile_size(100, 100); |
| 2324 gfx::Size layer_bounds(1500, 1500); | 2339 gfx::Size layer_bounds(1500, 1500); |
| 2325 | 2340 |
| 2326 scoped_refptr<FakePicturePileImpl> pending_pile = | 2341 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2327 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2342 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2328 scoped_refptr<FakePicturePileImpl> active_pile = | 2343 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2329 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2344 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2330 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); | 2345 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); |
| 2331 // Activate the invalidation. | 2346 // Activate the invalidation. |
| 2332 ActivateTree(); | 2347 ActivateTree(); |
| 2333 // Make another pending tree without any invalidation in it. | 2348 // Make another pending tree without any invalidation in it. |
| 2334 scoped_refptr<FakePicturePileImpl> pending_pile2 = | 2349 scoped_refptr<FakePicturePileImpl> pending_pile2 = |
| 2335 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2350 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2336 SetupPendingTree(pending_pile2); | 2351 SetupPendingTree(pending_pile2); |
| 2337 | 2352 |
| 2338 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2353 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2339 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2354 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2340 | 2355 |
| 2341 // The active tree invalidation was handled by the active tiles, so they | 2356 // The active tree invalidation was handled by the active tiles. |
| 2342 // can be shared with the pending tree. | |
| 2343 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2357 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2344 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2358 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2345 ASSERT_TRUE(active_tiling); | 2359 ASSERT_TRUE(active_tiling); |
| 2346 ASSERT_TRUE(pending_tiling); | 2360 ASSERT_TRUE(pending_tiling); |
| 2347 | 2361 |
| 2348 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2362 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2349 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2363 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2350 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2364 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2351 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2365 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2352 | 2366 |
| 2353 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2367 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 2354 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2368 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2355 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2369 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2356 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2370 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2357 | |
| 2358 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | |
| 2359 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | |
| 2360 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
| 2361 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
| 2362 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
| 2363 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); | |
| 2364 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
| 2365 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2366 } | 2371 } |
| 2367 | 2372 |
| 2368 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { | 2373 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { |
| 2369 // Set some invalidation on the pending tree. We should replace raster tiles | 2374 // Set some invalidation on the pending tree. We should replace raster tiles |
| 2370 // that touch this. | 2375 // that touch this. |
| 2371 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); | 2376 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); |
| 2372 | 2377 |
| 2373 EXPECT_GE(active_layer_->num_tilings(), 1u); | 2378 EXPECT_GE(active_layer_->num_tilings(), 1u); |
| 2374 EXPECT_GE(pending_layer_->num_tilings(), 1u); | 2379 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
| 2375 | 2380 |
| 2376 // The pending tree invalidation means tiles can not be shared with the | 2381 // The pending tree invalidation creates tiles on the pending tree. |
| 2377 // active tree. | |
| 2378 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2382 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2379 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2383 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2380 ASSERT_TRUE(active_tiling); | 2384 ASSERT_TRUE(active_tiling); |
| 2381 ASSERT_TRUE(pending_tiling); | 2385 ASSERT_TRUE(pending_tiling); |
| 2382 | 2386 |
| 2383 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2387 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2384 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2388 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2385 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2389 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2386 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2390 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
| 2387 | 2391 |
| 2388 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2392 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
| 2389 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2393 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); |
| 2390 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2394 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); |
| 2391 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2395 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 2392 | 2396 |
| 2393 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2397 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
| 2394 EXPECT_FALSE(active_tiling->TileAt(0, 0)->is_shared()); | |
| 2395 EXPECT_FALSE(pending_tiling->TileAt(0, 0)->is_shared()); | |
| 2396 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
| 2397 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
| 2398 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
| 2399 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2400 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
| 2401 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
| 2402 } | 2398 } |
| 2403 | 2399 |
| 2404 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { | 2400 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { |
| 2405 base::TimeTicks time_ticks; | 2401 base::TimeTicks time_ticks; |
| 2406 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2402 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 2407 host_impl_.SetCurrentBeginFrameArgs( | 2403 host_impl_.SetCurrentBeginFrameArgs( |
| 2408 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2404 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2409 | 2405 |
| 2410 gfx::Size tile_size(100, 100); | 2406 gfx::Size tile_size(100, 100); |
| 2411 gfx::Size layer_bounds(10, 10); | 2407 gfx::Size layer_bounds(10, 10); |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2834 std::set<Tile*> unique_tiles; | 2830 std::set<Tile*> unique_tiles; |
| 2835 bool reached_prepaint = false; | 2831 bool reached_prepaint = false; |
| 2836 int non_ideal_tile_count = 0u; | 2832 int non_ideal_tile_count = 0u; |
| 2837 int low_res_tile_count = 0u; | 2833 int low_res_tile_count = 0u; |
| 2838 int high_res_tile_count = 0u; | 2834 int high_res_tile_count = 0u; |
| 2839 int high_res_now_tiles = 0u; | 2835 int high_res_now_tiles = 0u; |
| 2840 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 2836 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 2841 pending_layer_->picture_layer_tiling_set(), false)); | 2837 pending_layer_->picture_layer_tiling_set(), false)); |
| 2842 while (!queue->IsEmpty()) { | 2838 while (!queue->IsEmpty()) { |
| 2843 Tile* tile = queue->Top(); | 2839 Tile* tile = queue->Top(); |
| 2844 TilePriority priority = tile->priority(PENDING_TREE); | 2840 TilePriority priority = tile->priority(); |
| 2845 | 2841 |
| 2846 EXPECT_TRUE(tile); | 2842 EXPECT_TRUE(tile); |
| 2847 | 2843 |
| 2848 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2844 // Non-high res tiles only get visible tiles. Also, prepaint should only |
| 2849 // come at the end of the iteration. | 2845 // come at the end of the iteration. |
| 2850 if (priority.resolution != HIGH_RESOLUTION) { | 2846 if (priority.resolution != HIGH_RESOLUTION) { |
| 2851 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2847 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 2852 } else if (reached_prepaint) { | 2848 } else if (reached_prepaint) { |
| 2853 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2849 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 2854 } else { | 2850 } else { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2908 gfx::Rect(1100, 1100, 500, 500); | 2904 gfx::Rect(1100, 1100, 500, 500); |
| 2909 bool resourceless_software_draw = false; | 2905 bool resourceless_software_draw = false; |
| 2910 pending_layer_->UpdateTiles(resourceless_software_draw); | 2906 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 2911 | 2907 |
| 2912 unique_tiles.clear(); | 2908 unique_tiles.clear(); |
| 2913 high_res_tile_count = 0u; | 2909 high_res_tile_count = 0u; |
| 2914 queue.reset(new TilingSetRasterQueueAll( | 2910 queue.reset(new TilingSetRasterQueueAll( |
| 2915 pending_layer_->picture_layer_tiling_set(), false)); | 2911 pending_layer_->picture_layer_tiling_set(), false)); |
| 2916 while (!queue->IsEmpty()) { | 2912 while (!queue->IsEmpty()) { |
| 2917 Tile* tile = queue->Top(); | 2913 Tile* tile = queue->Top(); |
| 2918 TilePriority priority = tile->priority(PENDING_TREE); | 2914 TilePriority priority = tile->priority(); |
| 2919 | 2915 |
| 2920 EXPECT_TRUE(tile); | 2916 EXPECT_TRUE(tile); |
| 2921 | 2917 |
| 2922 // Non-high res tiles only get visible tiles. | 2918 // Non-high res tiles only get visible tiles. |
| 2923 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); | 2919 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); |
| 2924 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2920 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 2925 | 2921 |
| 2926 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2922 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 2927 | 2923 |
| 2928 unique_tiles.insert(tile); | 2924 unique_tiles.insert(tile); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2950 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2946 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 2951 } | 2947 } |
| 2952 | 2948 |
| 2953 non_ideal_tile_count = 0; | 2949 non_ideal_tile_count = 0; |
| 2954 low_res_tile_count = 0; | 2950 low_res_tile_count = 0; |
| 2955 high_res_tile_count = 0; | 2951 high_res_tile_count = 0; |
| 2956 queue.reset(new TilingSetRasterQueueAll( | 2952 queue.reset(new TilingSetRasterQueueAll( |
| 2957 pending_layer_->picture_layer_tiling_set(), true)); | 2953 pending_layer_->picture_layer_tiling_set(), true)); |
| 2958 while (!queue->IsEmpty()) { | 2954 while (!queue->IsEmpty()) { |
| 2959 Tile* tile = queue->Top(); | 2955 Tile* tile = queue->Top(); |
| 2960 TilePriority priority = tile->priority(PENDING_TREE); | 2956 TilePriority priority = tile->priority(); |
| 2961 | 2957 |
| 2962 EXPECT_TRUE(tile); | 2958 EXPECT_TRUE(tile); |
| 2963 | 2959 |
| 2964 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 2960 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
| 2965 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 2961 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
| 2966 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2962 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
| 2967 queue->Pop(); | 2963 queue->Pop(); |
| 2968 } | 2964 } |
| 2969 | 2965 |
| 2970 EXPECT_EQ(0, non_ideal_tile_count); | 2966 EXPECT_EQ(0, non_ideal_tile_count); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 size_t distance_increasing = 0; | 3092 size_t distance_increasing = 0; |
| 3097 queue.reset(new TilingSetEvictionQueue( | 3093 queue.reset(new TilingSetEvictionQueue( |
| 3098 pending_layer_->picture_layer_tiling_set(), false)); | 3094 pending_layer_->picture_layer_tiling_set(), false)); |
| 3099 while (!queue->IsEmpty()) { | 3095 while (!queue->IsEmpty()) { |
| 3100 Tile* tile = queue->Top(); | 3096 Tile* tile = queue->Top(); |
| 3101 if (!last_tile) | 3097 if (!last_tile) |
| 3102 last_tile = tile; | 3098 last_tile = tile; |
| 3103 | 3099 |
| 3104 EXPECT_TRUE(tile); | 3100 EXPECT_TRUE(tile); |
| 3105 | 3101 |
| 3106 TilePriority priority = tile->priority(PENDING_TREE); | 3102 TilePriority priority = tile->priority(); |
| 3107 | 3103 |
| 3108 if (priority.priority_bin == TilePriority::NOW) { | 3104 if (priority.priority_bin == TilePriority::NOW) { |
| 3109 reached_visible = true; | 3105 reached_visible = true; |
| 3110 last_tile = tile; | 3106 last_tile = tile; |
| 3111 break; | 3107 break; |
| 3112 } | 3108 } |
| 3113 | 3109 |
| 3114 EXPECT_FALSE(tile->required_for_activation()); | 3110 EXPECT_FALSE(tile->required_for_activation()); |
| 3115 | 3111 |
| 3116 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3112 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
| 3117 std::numeric_limits<float>::epsilon()) { | 3113 std::numeric_limits<float>::epsilon()) { |
| 3118 ++scale_index; | 3114 ++scale_index; |
| 3119 ASSERT_LT(scale_index, arraysize(expected_scales)); | 3115 ASSERT_LT(scale_index, arraysize(expected_scales)); |
| 3120 } | 3116 } |
| 3121 | 3117 |
| 3122 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 3118 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
| 3123 unique_tiles.insert(tile); | 3119 unique_tiles.insert(tile); |
| 3124 | 3120 |
| 3125 if (tile->required_for_activation() == | 3121 if (tile->required_for_activation() == |
| 3126 last_tile->required_for_activation() && | 3122 last_tile->required_for_activation() && |
| 3127 std::abs(tile->contents_scale() - last_tile->contents_scale()) < | 3123 std::abs(tile->contents_scale() - last_tile->contents_scale()) < |
| 3128 std::numeric_limits<float>::epsilon()) { | 3124 std::numeric_limits<float>::epsilon()) { |
| 3129 if (priority.distance_to_visible <= | 3125 if (priority.distance_to_visible <= |
| 3130 last_tile->priority(PENDING_TREE).distance_to_visible) | 3126 last_tile->priority().distance_to_visible) |
| 3131 ++distance_decreasing; | 3127 ++distance_decreasing; |
| 3132 else | 3128 else |
| 3133 ++distance_increasing; | 3129 ++distance_increasing; |
| 3134 } | 3130 } |
| 3135 | 3131 |
| 3136 last_tile = tile; | 3132 last_tile = tile; |
| 3137 queue->Pop(); | 3133 queue->Pop(); |
| 3138 } | 3134 } |
| 3139 | 3135 |
| 3140 // 4 high res tiles are inside the viewport, the rest are evicted. | 3136 // 4 high res tiles are inside the viewport, the rest are evicted. |
| 3141 EXPECT_TRUE(reached_visible); | 3137 EXPECT_TRUE(reached_visible); |
| 3142 EXPECT_EQ(12u, unique_tiles.size()); | 3138 EXPECT_EQ(12u, unique_tiles.size()); |
| 3143 EXPECT_EQ(1u, distance_increasing); | 3139 EXPECT_EQ(1u, distance_increasing); |
| 3144 EXPECT_EQ(11u, distance_decreasing); | 3140 EXPECT_EQ(11u, distance_decreasing); |
| 3145 | 3141 |
| 3146 scale_index = 0; | 3142 scale_index = 0; |
| 3147 bool reached_required = false; | 3143 bool reached_required = false; |
| 3148 while (!queue->IsEmpty()) { | 3144 while (!queue->IsEmpty()) { |
| 3149 Tile* tile = queue->Top(); | 3145 Tile* tile = queue->Top(); |
| 3150 EXPECT_TRUE(tile); | 3146 EXPECT_TRUE(tile); |
| 3151 | 3147 |
| 3152 TilePriority priority = tile->priority(PENDING_TREE); | 3148 TilePriority priority = tile->priority(); |
| 3153 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 3149 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 3154 | 3150 |
| 3155 if (reached_required) { | 3151 if (reached_required) { |
| 3156 EXPECT_TRUE(tile->required_for_activation()); | 3152 EXPECT_TRUE(tile->required_for_activation()); |
| 3157 } else if (tile->required_for_activation()) { | 3153 } else if (tile->required_for_activation()) { |
| 3158 reached_required = true; | 3154 reached_required = true; |
| 3159 scale_index = 0; | 3155 scale_index = 0; |
| 3160 } | 3156 } |
| 3161 | 3157 |
| 3162 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3158 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3263 page_scale, | 3259 page_scale, |
| 3264 maximum_animation_scale, | 3260 maximum_animation_scale, |
| 3265 animating_transform); | 3261 animating_transform); |
| 3266 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3262 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 3267 } | 3263 } |
| 3268 | 3264 |
| 3269 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3265 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3270 gfx::Size tile_size(100, 100); | 3266 gfx::Size tile_size(100, 100); |
| 3271 gfx::Size layer_bounds(1000, 1000); | 3267 gfx::Size layer_bounds(1000, 1000); |
| 3272 | 3268 |
| 3273 // Make sure some tiles are not shared. | 3269 // Make sure pending tree has tiles. |
| 3274 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3270 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3275 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3271 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3276 | 3272 |
| 3277 // All pending layer tiles required are not ready. | 3273 // All pending layer tiles required are not ready. |
| 3278 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3274 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3279 | 3275 |
| 3280 // Initialize all low-res tiles. | 3276 // Initialize all low-res tiles. |
| 3281 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3277 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3278 pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling()); |
| 3282 | 3279 |
| 3283 // Low-res tiles should not be enough. | 3280 // Low-res tiles should not be enough. |
| 3284 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3281 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3285 | 3282 |
| 3286 // Initialize remaining tiles. | 3283 // Initialize remaining tiles. |
| 3287 pending_layer_->SetAllTilesReady(); | 3284 pending_layer_->SetAllTilesReady(); |
| 3285 active_layer_->SetAllTilesReady(); |
| 3288 | 3286 |
| 3289 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3287 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3290 } | 3288 } |
| 3291 | 3289 |
| 3292 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { | 3290 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
| 3293 gfx::Size tile_size(100, 100); | 3291 gfx::Size tile_size(100, 100); |
| 3294 gfx::Size layer_bounds(1000, 1000); | 3292 gfx::Size layer_bounds(1000, 1000); |
| 3295 | 3293 |
| 3296 // Make sure some tiles are not shared. | 3294 // Make sure pending tree has tiles. |
| 3297 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3295 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3298 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3296 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3299 | 3297 |
| 3300 // All pending layer tiles required are not ready. | 3298 // All pending layer tiles required are not ready. |
| 3301 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3299 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3302 | 3300 |
| 3303 // Initialize all high-res tiles. | 3301 // Initialize all high-res tiles. |
| 3304 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3302 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3303 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3305 | 3304 |
| 3306 // High-res tiles should be enough, since they cover everything visible. | 3305 // High-res tiles should be enough, since they cover everything visible. |
| 3307 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3306 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3308 } | 3307 } |
| 3309 | 3308 |
| 3310 TEST_F(PictureLayerImplTest, | 3309 TEST_F(PictureLayerImplTest, |
| 3311 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { | 3310 ActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
| 3312 gfx::Size tile_size(100, 100); | 3311 gfx::Size tile_size(100, 100); |
| 3313 gfx::Size layer_bounds(1000, 1000); | 3312 gfx::Size layer_bounds(1000, 1000); |
| 3314 | 3313 |
| 3315 // Make sure some tiles are not shared. | 3314 // Make sure pending tree has tiles. |
| 3316 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3315 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3317 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3316 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3318 | 3317 |
| 3319 // Initialize all high-res tiles in the active layer. | 3318 // Initialize all high-res tiles in the active layer. |
| 3320 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3319 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3321 // And all the low-res tiles in the pending layer. | 3320 // And all the low-res tiles in the pending layer. |
| 3322 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3321 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 3323 | 3322 |
| 3324 // The unshared high-res tiles are not ready, so we cannot activate. | 3323 // The pending high-res tiles are not ready, so we cannot activate. |
| 3325 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3324 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3326 | 3325 |
| 3327 // When the unshared pending high-res tiles are ready, we can activate. | 3326 // When the pending high-res tiles are ready, we can activate. |
| 3328 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3327 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3329 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3328 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3330 } | 3329 } |
| 3331 | 3330 |
| 3332 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { | 3331 TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) { |
| 3333 gfx::Size tile_size(100, 100); | 3332 gfx::Size tile_size(100, 100); |
| 3334 gfx::Size layer_bounds(1000, 1000); | 3333 gfx::Size layer_bounds(1000, 1000); |
| 3335 | 3334 |
| 3336 // Make sure some tiles are not shared. | 3335 // Make sure pending tree has tiles. |
| 3337 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3336 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3338 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3337 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3339 | 3338 |
| 3340 // Initialize all high-res tiles in the active layer. | 3339 // Initialize all high-res tiles in the active layer. |
| 3341 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3340 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 3342 | 3341 |
| 3343 // The unshared high-res tiles are not ready, so we cannot activate. | 3342 // The pending high-res tiles are not ready, so we cannot activate. |
| 3344 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 3343 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3345 | 3344 |
| 3346 // When the unshared pending high-res tiles are ready, we can activate. | 3345 // When the pending pending high-res tiles are ready, we can activate. |
| 3347 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3346 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 3348 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 3347 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 3349 } | 3348 } |
| 3350 | 3349 |
| 3351 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { | 3350 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 3352 gfx::Size tile_size(400, 400); | 3351 gfx::Size tile_size(400, 400); |
| 3353 gfx::Size layer_bounds(1300, 1900); | 3352 gfx::Size layer_bounds(1300, 1900); |
| 3354 | 3353 |
| 3355 scoped_refptr<FakePicturePileImpl> pending_pile = | 3354 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3356 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3355 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3463 7.26f, // ideal contents scale | 3462 7.26f, // ideal contents scale |
| 3464 2.2f, // device scale | 3463 2.2f, // device scale |
| 3465 3.3f, // page scale | 3464 3.3f, // page scale |
| 3466 1.f, // maximum animation scale | 3465 1.f, // maximum animation scale |
| 3467 false); | 3466 false); |
| 3468 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3467 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3469 EXPECT_FLOAT_EQ(7.26f, | 3468 EXPECT_FLOAT_EQ(7.26f, |
| 3470 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3469 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3471 } | 3470 } |
| 3472 | 3471 |
| 3473 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 3472 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 3474 gfx::Size layer_bounds(400, 400); | 3473 gfx::Size layer_bounds(400, 400); |
| 3475 gfx::Size tile_size(100, 100); | 3474 gfx::Size tile_size(100, 100); |
| 3476 | 3475 |
| 3477 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 3476 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 3478 | 3477 |
| 3479 Tile* some_active_tile = | 3478 Tile* some_active_tile = |
| 3480 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 3479 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 3481 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 3480 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 3482 | 3481 |
| 3483 // All tiles shared (no invalidation), so even though the active tree's | 3482 // Since there is no invalidaiton, pending tree should have no tiles. |
| 3484 // tiles aren't ready, there is nothing required. | 3483 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
| 3485 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
| 3486 if (host_impl_.settings().create_low_res_tiling) | 3484 if (host_impl_.settings().create_low_res_tiling) |
| 3487 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 3485 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
| 3488 | 3486 |
| 3489 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 3487 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 3490 if (host_impl_.settings().create_low_res_tiling) | 3488 if (host_impl_.settings().create_low_res_tiling) |
| 3491 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 3489 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
| 3490 |
| 3491 AssertAllTilesRequired(active_layer_->HighResTiling()); |
| 3492 if (host_impl_.settings().create_low_res_tiling) |
| 3493 AssertNoTilesRequired(active_layer_->LowResTiling()); |
| 3492 } | 3494 } |
| 3493 | 3495 |
| 3494 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 3496 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 3495 gfx::Size layer_bounds(400, 400); | 3497 gfx::Size layer_bounds(400, 400); |
| 3496 gfx::Size tile_size(100, 100); | 3498 gfx::Size tile_size(100, 100); |
| 3497 | 3499 |
| 3498 scoped_refptr<FakePicturePileImpl> pending_pile = | 3500 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3499 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3501 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3500 // This pile will create tilings, but has no recordings so will not create any | 3502 // This pile will create tilings, but has no recordings so will not create any |
| 3501 // tiles. This is attempting to simulate scrolling past the end of recorded | 3503 // 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... |
| 3867 }; | 3869 }; |
| 3868 | 3870 |
| 3869 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3871 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
| 3870 public: | 3872 public: |
| 3871 OcclusionTrackingPictureLayerImplTest() | 3873 OcclusionTrackingPictureLayerImplTest() |
| 3872 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3874 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
| 3873 | 3875 |
| 3874 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3876 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
| 3875 FakePictureLayerImpl* twin_layer, | 3877 FakePictureLayerImpl* twin_layer, |
| 3876 WhichTree tree, | 3878 WhichTree tree, |
| 3877 size_t expected_occluded_tile_count) { | 3879 size_t expected_occluded_tile_count, |
| 3878 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 3880 int source_line) { |
| 3879 size_t occluded_tile_count = 0u; | 3881 size_t occluded_tile_count = 0u; |
| 3880 Tile* last_tile = nullptr; | 3882 Tile* last_tile = nullptr; |
| 3881 std::set<Tile*> shared_tiles; | |
| 3882 | 3883 |
| 3883 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 3884 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
| 3884 layer->picture_layer_tiling_set(), layer && twin_layer)); | 3885 layer->picture_layer_tiling_set(), layer && twin_layer)); |
| 3885 while (!queue->IsEmpty()) { | 3886 while (!queue->IsEmpty()) { |
| 3886 Tile* tile = queue->Top(); | 3887 Tile* tile = queue->Top(); |
| 3887 if (!last_tile) | 3888 if (!last_tile) |
| 3888 last_tile = tile; | 3889 last_tile = tile; |
| 3889 if (tile->is_shared()) | |
| 3890 EXPECT_TRUE(shared_tiles.insert(tile).second); | |
| 3891 | 3890 |
| 3892 // The only way we will encounter an occluded tile after an unoccluded | 3891 // The only way we will encounter an occluded tile after an unoccluded |
| 3893 // tile is if the priorty bin decreased, the tile is required for | 3892 // tile is if the priorty bin decreased, the tile is required for |
| 3894 // activation, or the scale changed. | 3893 // activation, or the scale changed. |
| 3895 bool tile_is_occluded = tile->is_occluded(tree); | 3894 bool tile_is_occluded = tile->is_occluded(); |
| 3896 if (tile_is_occluded) { | 3895 if (tile_is_occluded) { |
| 3897 occluded_tile_count++; | 3896 occluded_tile_count++; |
| 3898 | 3897 |
| 3899 bool last_tile_is_occluded = last_tile->is_occluded(tree); | 3898 bool last_tile_is_occluded = last_tile->is_occluded(); |
| 3900 if (!last_tile_is_occluded) { | 3899 if (!last_tile_is_occluded) { |
| 3901 TilePriority::PriorityBin tile_priority_bin = | 3900 TilePriority::PriorityBin tile_priority_bin = |
| 3902 tile->priority(tree).priority_bin; | 3901 tile->priority().priority_bin; |
| 3903 TilePriority::PriorityBin last_tile_priority_bin = | 3902 TilePriority::PriorityBin last_tile_priority_bin = |
| 3904 last_tile->priority(tree).priority_bin; | 3903 last_tile->priority().priority_bin; |
| 3905 | 3904 |
| 3906 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || | 3905 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
| 3907 tile->required_for_activation() || | 3906 tile->required_for_activation() || |
| 3908 tile->contents_scale() != last_tile->contents_scale()); | 3907 tile->contents_scale() != last_tile->contents_scale()) |
| 3908 << "line: " << source_line; |
| 3909 } | 3909 } |
| 3910 } | 3910 } |
| 3911 last_tile = tile; | 3911 last_tile = tile; |
| 3912 queue->Pop(); | 3912 queue->Pop(); |
| 3913 } | 3913 } |
| 3914 // Count also shared tiles which are occluded in the tree but which were | 3914 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) |
| 3915 // not returned by the tiling set eviction queue. Those shared tiles | 3915 << "line: " << source_line; |
| 3916 // shall be returned by the twin tiling set eviction queue. | |
| 3917 queue.reset(new TilingSetEvictionQueue( | |
| 3918 twin_layer->picture_layer_tiling_set(), layer && twin_layer)); | |
| 3919 while (!queue->IsEmpty()) { | |
| 3920 Tile* tile = queue->Top(); | |
| 3921 if (tile->is_shared()) { | |
| 3922 EXPECT_TRUE(shared_tiles.insert(tile).second); | |
| 3923 if (tile->is_occluded(tree)) | |
| 3924 ++occluded_tile_count; | |
| 3925 // Check the reasons why the shared tile was not returned by | |
| 3926 // the first tiling set eviction queue. | |
| 3927 const TilePriority& combined_priority = tile->combined_priority(); | |
| 3928 const TilePriority& priority = tile->priority(tree); | |
| 3929 const TilePriority& twin_priority = tile->priority(twin_tree); | |
| 3930 // Check if the shared tile was not returned by the first tiling | |
| 3931 // set eviction queue because it was out of order for the first | |
| 3932 // tiling set eviction queue but not for the twin tiling set | |
| 3933 // eviction queue. | |
| 3934 if (priority.priority_bin != twin_priority.priority_bin) { | |
| 3935 EXPECT_LT(combined_priority.priority_bin, priority.priority_bin); | |
| 3936 EXPECT_EQ(combined_priority.priority_bin, twin_priority.priority_bin); | |
| 3937 } else if (tile->is_occluded(tree) != tile->is_occluded(twin_tree)) { | |
| 3938 EXPECT_TRUE(tile->is_occluded(tree)); | |
| 3939 EXPECT_FALSE(tile->is_occluded(twin_tree)); | |
| 3940 EXPECT_FALSE(tile->is_occluded_combined()); | |
| 3941 } else if (priority.distance_to_visible != | |
| 3942 twin_priority.distance_to_visible) { | |
| 3943 EXPECT_LT(combined_priority.distance_to_visible, | |
| 3944 priority.distance_to_visible); | |
| 3945 EXPECT_EQ(combined_priority.distance_to_visible, | |
| 3946 twin_priority.distance_to_visible); | |
| 3947 } else { | |
| 3948 // Shared tiles having the same active and pending priorities | |
| 3949 // should be returned only by a pending tree eviction queue. | |
| 3950 EXPECT_EQ(ACTIVE_TREE, tree); | |
| 3951 } | |
| 3952 } | |
| 3953 queue->Pop(); | |
| 3954 } | |
| 3955 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count); | |
| 3956 } | 3916 } |
| 3957 }; | 3917 }; |
| 3958 | 3918 |
| 3959 TEST_F(OcclusionTrackingPictureLayerImplTest, | 3919 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 3960 OccludedTilesSkippedDuringRasterization) { | 3920 OccludedTilesSkippedDuringRasterization) { |
| 3961 base::TimeTicks time_ticks; | 3921 base::TimeTicks time_ticks; |
| 3962 time_ticks += base::TimeDelta::FromMilliseconds(1); | 3922 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 3963 host_impl_.SetCurrentBeginFrameArgs( | 3923 host_impl_.SetCurrentBeginFrameArgs( |
| 3964 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3924 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3965 | 3925 |
| 3966 gfx::Size tile_size(102, 102); | 3926 gfx::Size tile_size(102, 102); |
| 3967 gfx::Size layer_bounds(1000, 1000); | 3927 gfx::Size layer_bounds(1000, 1000); |
| 3968 gfx::Size viewport_size(500, 500); | 3928 gfx::Size viewport_size(500, 500); |
| 3969 gfx::Point occluding_layer_position(310, 0); | 3929 gfx::Point occluding_layer_position(310, 0); |
| 3970 | 3930 |
| 3971 host_impl_.SetViewportSize(viewport_size); | 3931 host_impl_.SetViewportSize(viewport_size); |
| 3972 | 3932 |
| 3973 scoped_refptr<FakePicturePileImpl> pending_pile = | 3933 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3974 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3934 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3975 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 3935 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 3976 | 3936 |
| 3977 // No occlusion. | 3937 // No occlusion. |
| 3978 int unoccluded_tile_count = 0; | 3938 int unoccluded_tile_count = 0; |
| 3979 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 3939 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 3980 pending_layer_->picture_layer_tiling_set(), false)); | 3940 pending_layer_->picture_layer_tiling_set(), false)); |
| 3981 while (!queue->IsEmpty()) { | 3941 while (!queue->IsEmpty()) { |
| 3982 Tile* tile = queue->Top(); | 3942 Tile* tile = queue->Top(); |
| 3983 | 3943 |
| 3984 // Occluded tiles should not be iterated over. | 3944 // Occluded tiles should not be iterated over. |
| 3985 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3945 EXPECT_FALSE(tile->is_occluded()); |
| 3986 | 3946 |
| 3987 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3947 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 3988 // visible and at least partially unoccluded, verified by the above expect. | 3948 // visible and at least partially unoccluded, verified by the above expect. |
| 3989 bool tile_is_visible = | 3949 bool tile_is_visible = |
| 3990 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3950 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 3991 if (tile_is_visible) | 3951 if (tile_is_visible) |
| 3992 unoccluded_tile_count++; | 3952 unoccluded_tile_count++; |
| 3993 queue->Pop(); | 3953 queue->Pop(); |
| 3994 } | 3954 } |
| 3995 EXPECT_EQ(unoccluded_tile_count, 25); | 3955 EXPECT_EQ(unoccluded_tile_count, 25); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4008 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3968 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4009 bool update_lcd_text = false; | 3969 bool update_lcd_text = false; |
| 4010 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 3970 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4011 | 3971 |
| 4012 unoccluded_tile_count = 0; | 3972 unoccluded_tile_count = 0; |
| 4013 queue.reset(new TilingSetRasterQueueAll( | 3973 queue.reset(new TilingSetRasterQueueAll( |
| 4014 pending_layer_->picture_layer_tiling_set(), false)); | 3974 pending_layer_->picture_layer_tiling_set(), false)); |
| 4015 while (!queue->IsEmpty()) { | 3975 while (!queue->IsEmpty()) { |
| 4016 Tile* tile = queue->Top(); | 3976 Tile* tile = queue->Top(); |
| 4017 | 3977 |
| 4018 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3978 EXPECT_FALSE(tile->is_occluded()); |
| 4019 | 3979 |
| 4020 bool tile_is_visible = | 3980 bool tile_is_visible = |
| 4021 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3981 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 4022 if (tile_is_visible) | 3982 if (tile_is_visible) |
| 4023 unoccluded_tile_count++; | 3983 unoccluded_tile_count++; |
| 4024 queue->Pop(); | 3984 queue->Pop(); |
| 4025 } | 3985 } |
| 4026 EXPECT_EQ(20, unoccluded_tile_count); | 3986 EXPECT_EQ(20, unoccluded_tile_count); |
| 4027 | 3987 |
| 4028 // Full occlusion. | 3988 // Full occlusion. |
| 4029 layer1->SetPosition(gfx::Point(0, 0)); | 3989 layer1->SetPosition(gfx::Point(0, 0)); |
| 4030 | 3990 |
| 4031 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3991 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 4032 host_impl_.SetCurrentBeginFrameArgs( | 3992 host_impl_.SetCurrentBeginFrameArgs( |
| 4033 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3993 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4034 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 3994 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4035 | 3995 |
| 4036 unoccluded_tile_count = 0; | 3996 unoccluded_tile_count = 0; |
| 4037 queue.reset(new TilingSetRasterQueueAll( | 3997 queue.reset(new TilingSetRasterQueueAll( |
| 4038 pending_layer_->picture_layer_tiling_set(), false)); | 3998 pending_layer_->picture_layer_tiling_set(), false)); |
| 4039 while (!queue->IsEmpty()) { | 3999 while (!queue->IsEmpty()) { |
| 4040 Tile* tile = queue->Top(); | 4000 Tile* tile = queue->Top(); |
| 4041 | 4001 |
| 4042 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4002 EXPECT_FALSE(tile->is_occluded()); |
| 4043 | 4003 |
| 4044 bool tile_is_visible = | 4004 bool tile_is_visible = |
| 4045 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4005 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
| 4046 if (tile_is_visible) | 4006 if (tile_is_visible) |
| 4047 unoccluded_tile_count++; | 4007 unoccluded_tile_count++; |
| 4048 queue->Pop(); | 4008 queue->Pop(); |
| 4049 } | 4009 } |
| 4050 EXPECT_EQ(unoccluded_tile_count, 0); | 4010 EXPECT_EQ(unoccluded_tile_count, 0); |
| 4051 } | 4011 } |
| 4052 | 4012 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4065 host_impl_.SetViewportSize(viewport_size); | 4025 host_impl_.SetViewportSize(viewport_size); |
| 4066 | 4026 |
| 4067 scoped_refptr<FakePicturePileImpl> pending_pile = | 4027 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4068 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4028 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4069 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 4029 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 4070 | 4030 |
| 4071 // No occlusion. | 4031 // No occlusion. |
| 4072 int occluded_tile_count = 0; | 4032 int occluded_tile_count = 0; |
| 4073 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4033 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4074 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4034 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4035 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4075 | 4036 |
| 4076 occluded_tile_count = 0; | 4037 occluded_tile_count = 0; |
| 4077 for (PictureLayerTiling::CoverageIterator iter( | 4038 for (PictureLayerTiling::CoverageIterator iter( |
| 4078 tiling, | 4039 tiling, |
| 4079 pending_layer_->contents_scale_x(), | 4040 pending_layer_->contents_scale_x(), |
| 4080 gfx::Rect(layer_bounds)); | 4041 gfx::Rect(layer_bounds)); |
| 4081 iter; | 4042 iter; |
| 4082 ++iter) { | 4043 ++iter) { |
| 4083 if (!*iter) | 4044 if (!*iter) |
| 4084 continue; | 4045 continue; |
| 4085 const Tile* tile = *iter; | 4046 const Tile* tile = *iter; |
| 4086 | 4047 |
| 4087 // Fully occluded tiles are not required for activation. | 4048 // Fully occluded tiles are not required for activation. |
| 4088 if (tile->is_occluded(PENDING_TREE)) { | 4049 if (tile->is_occluded()) { |
| 4089 EXPECT_FALSE(tile->required_for_activation()); | 4050 EXPECT_FALSE(tile->required_for_activation()); |
| 4090 occluded_tile_count++; | 4051 occluded_tile_count++; |
| 4091 } | 4052 } |
| 4092 } | 4053 } |
| 4093 EXPECT_EQ(occluded_tile_count, 0); | 4054 EXPECT_EQ(occluded_tile_count, 0); |
| 4094 } | 4055 } |
| 4095 | 4056 |
| 4096 // Partial occlusion. | 4057 // Partial occlusion. |
| 4097 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 4058 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
| 4098 LayerImpl* layer1 = pending_layer_->children()[0]; | 4059 LayerImpl* layer1 = pending_layer_->children()[0]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4116 for (PictureLayerTiling::CoverageIterator iter( | 4077 for (PictureLayerTiling::CoverageIterator iter( |
| 4117 tiling, | 4078 tiling, |
| 4118 pending_layer_->contents_scale_x(), | 4079 pending_layer_->contents_scale_x(), |
| 4119 gfx::Rect(layer_bounds)); | 4080 gfx::Rect(layer_bounds)); |
| 4120 iter; | 4081 iter; |
| 4121 ++iter) { | 4082 ++iter) { |
| 4122 if (!*iter) | 4083 if (!*iter) |
| 4123 continue; | 4084 continue; |
| 4124 const Tile* tile = *iter; | 4085 const Tile* tile = *iter; |
| 4125 | 4086 |
| 4126 if (tile->is_occluded(PENDING_TREE)) { | 4087 if (tile->is_occluded()) { |
| 4127 EXPECT_FALSE(tile->required_for_activation()); | 4088 EXPECT_FALSE(tile->required_for_activation()); |
| 4128 occluded_tile_count++; | 4089 occluded_tile_count++; |
| 4129 } | 4090 } |
| 4130 } | 4091 } |
| 4131 switch (i) { | 4092 switch (i) { |
| 4132 case 0: | 4093 case 0: |
| 4133 EXPECT_EQ(occluded_tile_count, 5); | 4094 EXPECT_EQ(occluded_tile_count, 5); |
| 4134 break; | 4095 break; |
| 4135 case 1: | 4096 case 1: |
| 4136 EXPECT_EQ(occluded_tile_count, 2); | 4097 EXPECT_EQ(occluded_tile_count, 2); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4156 for (PictureLayerTiling::CoverageIterator iter( | 4117 for (PictureLayerTiling::CoverageIterator iter( |
| 4157 tiling, | 4118 tiling, |
| 4158 pending_layer_->contents_scale_x(), | 4119 pending_layer_->contents_scale_x(), |
| 4159 gfx::Rect(layer_bounds)); | 4120 gfx::Rect(layer_bounds)); |
| 4160 iter; | 4121 iter; |
| 4161 ++iter) { | 4122 ++iter) { |
| 4162 if (!*iter) | 4123 if (!*iter) |
| 4163 continue; | 4124 continue; |
| 4164 const Tile* tile = *iter; | 4125 const Tile* tile = *iter; |
| 4165 | 4126 |
| 4166 if (tile->is_occluded(PENDING_TREE)) { | 4127 if (tile->is_occluded()) { |
| 4167 EXPECT_FALSE(tile->required_for_activation()); | 4128 EXPECT_FALSE(tile->required_for_activation()); |
| 4168 occluded_tile_count++; | 4129 occluded_tile_count++; |
| 4169 } | 4130 } |
| 4170 } | 4131 } |
| 4171 switch (i) { | 4132 switch (i) { |
| 4172 case 0: | 4133 case 0: |
| 4173 EXPECT_EQ(25, occluded_tile_count); | 4134 EXPECT_EQ(25, occluded_tile_count); |
| 4174 break; | 4135 break; |
| 4175 case 1: | 4136 case 1: |
| 4176 EXPECT_EQ(4, occluded_tile_count); | 4137 EXPECT_EQ(4, occluded_tile_count); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4226 EXPECT_EQ(5u, pending_layer_->num_tilings()); | 4187 EXPECT_EQ(5u, pending_layer_->num_tilings()); |
| 4227 | 4188 |
| 4228 int occluded_tile_count = 0; | 4189 int occluded_tile_count = 0; |
| 4229 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4190 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4230 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4191 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4231 tiling->UpdateAllTilePrioritiesForTesting(); | 4192 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4232 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4193 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4233 | 4194 |
| 4234 occluded_tile_count = 0; | 4195 occluded_tile_count = 0; |
| 4235 for (size_t j = 0; j < tiles.size(); ++j) { | 4196 for (size_t j = 0; j < tiles.size(); ++j) { |
| 4236 if (tiles[j]->is_occluded(PENDING_TREE)) { | 4197 if (tiles[j]->is_occluded()) { |
| 4237 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4198 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4238 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); | 4199 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); |
| 4239 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 4200 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
| 4240 occluded_tile_count++; | 4201 occluded_tile_count++; |
| 4241 } | 4202 } |
| 4242 } | 4203 } |
| 4243 | 4204 |
| 4244 switch (i) { | 4205 switch (i) { |
| 4245 case 0: | 4206 case 0: |
| 4246 EXPECT_EQ(occluded_tile_count, 30); | 4207 EXPECT_EQ(occluded_tile_count, 30); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4280 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4241 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4281 LayerImpl* layer1 = pending_layer_->children()[0]; | 4242 LayerImpl* layer1 = pending_layer_->children()[0]; |
| 4282 layer1->SetBounds(layer_bounds); | 4243 layer1->SetBounds(layer_bounds); |
| 4283 layer1->SetContentBounds(layer_bounds); | 4244 layer1->SetContentBounds(layer_bounds); |
| 4284 layer1->SetDrawsContent(true); | 4245 layer1->SetDrawsContent(true); |
| 4285 layer1->SetContentsOpaque(true); | 4246 layer1->SetContentsOpaque(true); |
| 4286 layer1->SetPosition(occluding_layer_position); | 4247 layer1->SetPosition(occluding_layer_position); |
| 4287 | 4248 |
| 4288 ActivateTree(); | 4249 ActivateTree(); |
| 4289 | 4250 |
| 4251 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4252 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4253 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4254 |
| 4255 for ( |
| 4256 PictureLayerTiling::CoverageIterator iter( |
| 4257 tiling, active_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
| 4258 iter; ++iter) { |
| 4259 if (!*iter) |
| 4260 continue; |
| 4261 const Tile* tile = *iter; |
| 4262 |
| 4263 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4264 tile->content_rect(), 1.0f / tile->contents_scale()); |
| 4265 // Tiles are occluded on the active tree iff they lie beneath the |
| 4266 // occluding layer. |
| 4267 EXPECT_EQ(tile->is_occluded(), |
| 4268 scaled_content_rect.x() >= occluding_layer_position.x()); |
| 4269 } |
| 4270 } |
| 4271 |
| 4290 // Partially invalidate the pending layer. | 4272 // Partially invalidate the pending layer. |
| 4291 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); | 4273 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); |
| 4292 | 4274 |
| 4293 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4275 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4294 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4276 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4295 tiling->UpdateAllTilePrioritiesForTesting(); | 4277 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4296 | 4278 |
| 4297 for (PictureLayerTiling::CoverageIterator iter( | 4279 for (PictureLayerTiling::CoverageIterator iter( |
| 4298 tiling, | 4280 tiling, |
| 4299 pending_layer_->contents_scale_x(), | |
| 4300 gfx::Rect(layer_bounds)); | |
| 4301 iter; | |
| 4302 ++iter) { | |
| 4303 if (!*iter) | |
| 4304 continue; | |
| 4305 const Tile* tile = *iter; | |
| 4306 | |
| 4307 // All tiles are unoccluded on the pending tree. | |
| 4308 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | |
| 4309 | |
| 4310 Tile* twin_tile = pending_layer_->GetPendingOrActiveTwinTiling(tiling) | |
| 4311 ->TileAt(iter.i(), iter.j()); | |
| 4312 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | |
| 4313 tile->content_rect(), 1.0f / tile->contents_scale()); | |
| 4314 | |
| 4315 if (scaled_content_rect.Intersects(invalidation_rect)) { | |
| 4316 // Tiles inside the invalidation rect are only on the pending tree. | |
| 4317 EXPECT_NE(tile, twin_tile); | |
| 4318 | |
| 4319 // Unshared tiles should be unoccluded on the active tree by default. | |
| 4320 EXPECT_FALSE(tile->is_occluded(ACTIVE_TREE)); | |
| 4321 } else { | |
| 4322 // Tiles outside the invalidation rect are shared between both trees. | |
| 4323 EXPECT_EQ(tile, twin_tile); | |
| 4324 // Shared tiles are occluded on the active tree iff they lie beneath the | |
| 4325 // occluding layer. | |
| 4326 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | |
| 4327 scaled_content_rect.x() >= occluding_layer_position.x()); | |
| 4328 } | |
| 4329 } | |
| 4330 } | |
| 4331 | |
| 4332 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | |
| 4333 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | |
| 4334 | |
| 4335 for (PictureLayerTiling::CoverageIterator iter( | |
| 4336 tiling, | |
| 4337 active_layer_->contents_scale_x(), | 4281 active_layer_->contents_scale_x(), |
| 4338 gfx::Rect(layer_bounds)); | 4282 gfx::Rect(layer_bounds)); |
| 4339 iter; | 4283 iter; |
| 4340 ++iter) { | 4284 ++iter) { |
| 4341 if (!*iter) | 4285 if (!*iter) |
| 4342 continue; | 4286 continue; |
| 4343 const Tile* tile = *iter; | 4287 const Tile* tile = *iter; |
| 4344 | 4288 |
| 4289 // All tiles are unoccluded, because the pending tree has no occlusion. |
| 4290 EXPECT_FALSE(tile->is_occluded()); |
| 4291 EXPECT_FALSE(tile->is_occluded()); |
| 4292 |
| 4345 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) | 4293 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) |
| 4346 ->TileAt(iter.i(), iter.j()); | 4294 ->TileAt(iter.i(), iter.j()); |
| 4347 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4295 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4348 tile->content_rect(), 1.0f / tile->contents_scale()); | 4296 tile->content_rect(), 1.0f / tile->contents_scale()); |
| 4349 | 4297 |
| 4350 // Since we've already checked the shared tiles, only consider tiles in | |
| 4351 // the invalidation rect. | |
| 4352 if (scaled_content_rect.Intersects(invalidation_rect)) { | 4298 if (scaled_content_rect.Intersects(invalidation_rect)) { |
| 4353 // Tiles inside the invalidation rect are only on the active tree. | 4299 // Tiles inside the invalidation rect exist on both trees. |
| 4300 EXPECT_TRUE(tile); |
| 4301 EXPECT_TRUE(twin_tile); |
| 4354 EXPECT_NE(tile, twin_tile); | 4302 EXPECT_NE(tile, twin_tile); |
| 4355 | 4303 } else { |
| 4356 // Unshared tiles should be unoccluded on the pending tree by default. | 4304 // Tiles outside the invalidation rect only exist on the active tree. |
| 4357 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 4305 EXPECT_TRUE(tile); |
| 4358 | 4306 EXPECT_FALSE(twin_tile); |
| 4359 // Unshared tiles are occluded on the active tree iff they lie beneath | |
| 4360 // the occluding layer. | |
| 4361 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | |
| 4362 scaled_content_rect.x() >= occluding_layer_position.x()); | |
| 4363 } | 4307 } |
| 4364 } | 4308 } |
| 4365 } | 4309 } |
| 4366 } | 4310 } |
| 4367 | 4311 |
| 4368 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4312 TEST_F(OcclusionTrackingPictureLayerImplTest, |
| 4369 OccludedTilesConsideredDuringEviction) { | 4313 OccludedTilesConsideredDuringEviction) { |
| 4370 base::TimeTicks time_ticks; | 4314 base::TimeTicks time_ticks; |
| 4371 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4315 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4372 host_impl_.SetCurrentBeginFrameArgs( | 4316 host_impl_.SetCurrentBeginFrameArgs( |
| 4373 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4317 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4374 | 4318 |
| 4375 gfx::Size tile_size(102, 102); | 4319 gfx::Size tile_size(102, 102); |
| 4376 gfx::Size layer_bounds(1000, 1000); | 4320 gfx::Size layer_bounds(1000, 1000); |
| 4377 gfx::Size viewport_size(1000, 1000); | 4321 gfx::Size viewport_size(1000, 1000); |
| 4378 gfx::Point pending_occluding_layer_position(310, 0); | 4322 gfx::Point pending_occluding_layer_position(310, 0); |
| 4379 gfx::Point active_occluding_layer_position(0, 310); | 4323 gfx::Point active_occluding_layer_position(0, 310); |
| 4380 gfx::Rect invalidation_rect(230, 230, 102, 102); | 4324 gfx::Rect invalidation_rect(230, 230, 152, 152); |
| 4381 | 4325 |
| 4382 host_impl_.SetViewportSize(viewport_size); | 4326 host_impl_.SetViewportSize(viewport_size); |
| 4383 host_impl_.SetDeviceScaleFactor(2.f); | 4327 host_impl_.SetDeviceScaleFactor(2.f); |
| 4384 | 4328 |
| 4385 scoped_refptr<FakePicturePileImpl> pending_pile = | 4329 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4386 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4330 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4387 scoped_refptr<FakePicturePileImpl> active_pile = | 4331 scoped_refptr<FakePicturePileImpl> active_pile = |
| 4388 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4332 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4389 | 4333 |
| 4390 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); | 4334 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); |
| 4391 | 4335 |
| 4392 // Partially occlude the active layer. | 4336 // Partially occlude the active layer. |
| 4393 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); | 4337 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4394 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; | 4338 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; |
| 4395 active_occluding_layer->SetBounds(layer_bounds); | 4339 active_occluding_layer->SetBounds(layer_bounds); |
| 4396 active_occluding_layer->SetContentBounds(layer_bounds); | 4340 active_occluding_layer->SetContentBounds(layer_bounds); |
| 4397 active_occluding_layer->SetDrawsContent(true); | 4341 active_occluding_layer->SetDrawsContent(true); |
| 4398 active_occluding_layer->SetContentsOpaque(true); | 4342 active_occluding_layer->SetContentsOpaque(true); |
| 4399 active_occluding_layer->SetPosition(active_occluding_layer_position); | 4343 active_occluding_layer->SetPosition(active_occluding_layer_position); |
| 4400 | 4344 |
| 4401 ActivateTree(); | 4345 ActivateTree(); |
| 4402 | 4346 |
| 4403 // Partially invalidate the pending layer. Tiles inside the invalidation rect | 4347 // Partially invalidate the pending layer. Tiles inside the invalidation rect |
| 4404 // are not shared between trees. | 4348 // are created. |
| 4405 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); | 4349 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); |
| 4406 | 4350 |
| 4407 // Partially occlude the pending layer in a different way. | 4351 // Partially occlude the pending layer in a different way. |
| 4408 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); | 4352 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); |
| 4409 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; | 4353 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; |
| 4410 pending_occluding_layer->SetBounds(layer_bounds); | 4354 pending_occluding_layer->SetBounds(layer_bounds); |
| 4411 pending_occluding_layer->SetContentBounds(layer_bounds); | 4355 pending_occluding_layer->SetContentBounds(layer_bounds); |
| 4412 pending_occluding_layer->SetDrawsContent(true); | 4356 pending_occluding_layer->SetDrawsContent(true); |
| 4413 pending_occluding_layer->SetContentsOpaque(true); | 4357 pending_occluding_layer->SetContentsOpaque(true); |
| 4414 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4358 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
| 4415 | 4359 |
| 4416 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 4360 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 4417 EXPECT_EQ(2u, active_layer_->num_tilings()); | 4361 EXPECT_EQ(2u, active_layer_->num_tilings()); |
| 4418 | 4362 |
| 4419 time_ticks += base::TimeDelta::FromMilliseconds(1); | 4363 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4420 host_impl_.SetCurrentBeginFrameArgs( | 4364 host_impl_.SetCurrentBeginFrameArgs( |
| 4421 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4365 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4422 // UpdateDrawProperties with the occluding layer. | 4366 // UpdateDrawProperties with the occluding layer. |
| 4423 bool update_lcd_text = false; | 4367 bool update_lcd_text = false; |
| 4424 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4368 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 4425 | 4369 |
| 4426 // The expected number of occluded tiles on each of the 2 tilings for each of | 4370 // The expected number of occluded tiles on each of the 2 tilings for each of |
| 4427 // the 3 tree priorities. | 4371 // the 3 tree priorities. |
| 4428 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; | 4372 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u}; |
| 4429 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; | 4373 size_t expected_occluded_tile_count_on_active[] = {12u, 1u}; |
| 4430 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; | 4374 size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u}; |
| 4431 | |
| 4432 size_t total_expected_occluded_tile_count_on_trees[] = {33u, 33u}; | |
| 4433 | 4375 |
| 4434 // Verify number of occluded tiles on the pending layer for each tiling. | 4376 // Verify number of occluded tiles on the pending layer for each tiling. |
| 4435 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4377 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4436 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4378 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4437 tiling->UpdateAllTilePrioritiesForTesting(); | 4379 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4438 | 4380 |
| 4439 size_t occluded_tile_count_on_pending = 0u; | 4381 size_t occluded_tile_count_on_pending = 0u; |
| 4440 size_t occluded_tile_count_on_active = 0u; | |
| 4441 size_t occluded_tile_count_on_both = 0u; | |
| 4442 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, | 4382 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
| 4443 gfx::Rect(layer_bounds)); | 4383 gfx::Rect(layer_bounds)); |
| 4444 iter; ++iter) { | 4384 iter; ++iter) { |
| 4445 Tile* tile = *iter; | 4385 Tile* tile = *iter; |
| 4446 | 4386 |
| 4387 if (invalidation_rect.Intersects(iter.geometry_rect())) |
| 4388 EXPECT_TRUE(tile); |
| 4389 else |
| 4390 EXPECT_FALSE(tile); |
| 4391 |
| 4447 if (!tile) | 4392 if (!tile) |
| 4448 continue; | 4393 continue; |
| 4449 if (tile->is_occluded(PENDING_TREE)) | 4394 if (tile->is_occluded()) |
| 4450 occluded_tile_count_on_pending++; | 4395 occluded_tile_count_on_pending++; |
| 4451 if (tile->is_occluded(ACTIVE_TREE)) | |
| 4452 occluded_tile_count_on_active++; | |
| 4453 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | |
| 4454 occluded_tile_count_on_both++; | |
| 4455 } | 4396 } |
| 4456 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4397 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
| 4457 occluded_tile_count_on_pending) | 4398 occluded_tile_count_on_pending) |
| 4458 << tiling->contents_scale(); | 4399 << tiling->contents_scale(); |
| 4459 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | |
| 4460 occluded_tile_count_on_active) | |
| 4461 << tiling->contents_scale(); | |
| 4462 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | |
| 4463 occluded_tile_count_on_both) | |
| 4464 << tiling->contents_scale(); | |
| 4465 } | 4400 } |
| 4466 | 4401 |
| 4467 // Verify number of occluded tiles on the active layer for each tiling. | 4402 // Verify number of occluded tiles on the active layer for each tiling. |
| 4468 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4403 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4469 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4404 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4470 tiling->UpdateAllTilePrioritiesForTesting(); | 4405 tiling->UpdateAllTilePrioritiesForTesting(); |
| 4471 | 4406 |
| 4472 size_t occluded_tile_count_on_pending = 0u; | |
| 4473 size_t occluded_tile_count_on_active = 0u; | 4407 size_t occluded_tile_count_on_active = 0u; |
| 4474 size_t occluded_tile_count_on_both = 0u; | |
| 4475 for (PictureLayerTiling::CoverageIterator iter( | 4408 for (PictureLayerTiling::CoverageIterator iter( |
| 4476 tiling, | 4409 tiling, |
| 4477 pending_layer_->contents_scale_x(), | 4410 pending_layer_->contents_scale_x(), |
| 4478 gfx::Rect(layer_bounds)); | 4411 gfx::Rect(layer_bounds)); |
| 4479 iter; | 4412 iter; |
| 4480 ++iter) { | 4413 ++iter) { |
| 4481 Tile* tile = *iter; | 4414 Tile* tile = *iter; |
| 4482 | 4415 |
| 4483 if (!tile) | 4416 if (!tile) |
| 4484 continue; | 4417 continue; |
| 4485 if (tile->is_occluded(PENDING_TREE)) | 4418 if (tile->is_occluded()) |
| 4486 occluded_tile_count_on_pending++; | |
| 4487 if (tile->is_occluded(ACTIVE_TREE)) | |
| 4488 occluded_tile_count_on_active++; | 4419 occluded_tile_count_on_active++; |
| 4489 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | |
| 4490 occluded_tile_count_on_both++; | |
| 4491 } | 4420 } |
| 4492 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | |
| 4493 occluded_tile_count_on_pending) | |
| 4494 << i; | |
| 4495 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | 4421 EXPECT_EQ(expected_occluded_tile_count_on_active[i], |
| 4496 occluded_tile_count_on_active) | 4422 occluded_tile_count_on_active) |
| 4497 << i; | 4423 << i; |
| 4498 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | |
| 4499 occluded_tile_count_on_both) | |
| 4500 << i; | |
| 4501 } | 4424 } |
| 4502 | 4425 |
| 4503 std::vector<Tile*> all_tiles; | 4426 std::vector<Tile*> all_tiles; |
| 4504 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4427 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 4505 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4428 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 4506 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4429 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4507 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); | 4430 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4508 } | 4431 } |
| 4432 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 4433 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 4434 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 4435 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
| 4436 } |
| 4509 | 4437 |
| 4510 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 4438 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 4511 | 4439 |
| 4512 VerifyEvictionConsidersOcclusion( | 4440 VerifyEvictionConsidersOcclusion( |
| 4513 pending_layer_, active_layer_, PENDING_TREE, | 4441 pending_layer_, active_layer_, PENDING_TREE, |
| 4514 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); | 4442 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4515 VerifyEvictionConsidersOcclusion( | 4443 VerifyEvictionConsidersOcclusion( |
| 4516 active_layer_, pending_layer_, ACTIVE_TREE, | 4444 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4517 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); | 4445 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4518 | 4446 |
| 4519 // Repeat the tests without valid active tree priorities. | 4447 // Repeat the tests without valid active tree priorities. |
| 4520 active_layer_->set_has_valid_tile_priorities(false); | 4448 active_layer_->set_has_valid_tile_priorities(false); |
| 4521 VerifyEvictionConsidersOcclusion( | 4449 VerifyEvictionConsidersOcclusion( |
| 4522 pending_layer_, active_layer_, PENDING_TREE, | 4450 pending_layer_, active_layer_, PENDING_TREE, |
| 4523 total_expected_occluded_tile_count_on_trees[PENDING_TREE]); | 4451 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4524 VerifyEvictionConsidersOcclusion( | 4452 VerifyEvictionConsidersOcclusion( |
| 4525 active_layer_, pending_layer_, ACTIVE_TREE, 0u); | 4453 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4454 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4526 active_layer_->set_has_valid_tile_priorities(true); | 4455 active_layer_->set_has_valid_tile_priorities(true); |
| 4527 | 4456 |
| 4528 // Repeat the tests without valid pending tree priorities. | 4457 // Repeat the tests without valid pending tree priorities. |
| 4529 pending_layer_->set_has_valid_tile_priorities(false); | 4458 pending_layer_->set_has_valid_tile_priorities(false); |
| 4530 VerifyEvictionConsidersOcclusion( | 4459 VerifyEvictionConsidersOcclusion( |
| 4531 active_layer_, pending_layer_, ACTIVE_TREE, | 4460 active_layer_, pending_layer_, ACTIVE_TREE, |
| 4532 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE]); | 4461 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); |
| 4533 VerifyEvictionConsidersOcclusion( | 4462 VerifyEvictionConsidersOcclusion( |
| 4534 pending_layer_, active_layer_, PENDING_TREE, 0u); | 4463 pending_layer_, active_layer_, PENDING_TREE, |
| 4464 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); |
| 4535 pending_layer_->set_has_valid_tile_priorities(true); | 4465 pending_layer_->set_has_valid_tile_priorities(true); |
| 4536 } | 4466 } |
| 4537 | 4467 |
| 4538 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { | 4468 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { |
| 4539 gfx::Size tile_size(102, 102); | 4469 gfx::Size tile_size(102, 102); |
| 4540 gfx::Size layer_bounds(1000, 1000); | 4470 gfx::Size layer_bounds(1000, 1000); |
| 4541 | 4471 |
| 4542 scoped_refptr<FakePicturePileImpl> pile = | 4472 scoped_refptr<FakePicturePileImpl> pile = |
| 4543 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4473 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4544 SetupPendingTree(pile); | 4474 SetupPendingTree(pile); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4753 std::vector<Tile*> tiles; | 4683 std::vector<Tile*> tiles; |
| 4754 for (PictureLayerTiling::CoverageIterator iter( | 4684 for (PictureLayerTiling::CoverageIterator iter( |
| 4755 pending_layer_->HighResTiling(), | 4685 pending_layer_->HighResTiling(), |
| 4756 1.f, | 4686 1.f, |
| 4757 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4687 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4758 iter; | 4688 iter; |
| 4759 ++iter) { | 4689 ++iter) { |
| 4760 if (*iter) | 4690 if (*iter) |
| 4761 tiles.push_back(*iter); | 4691 tiles.push_back(*iter); |
| 4762 } | 4692 } |
| 4693 for (PictureLayerTiling::CoverageIterator iter( |
| 4694 active_layer_->HighResTiling(), 1.f, |
| 4695 active_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
| 4696 iter; ++iter) { |
| 4697 if (*iter) |
| 4698 tiles.push_back(*iter); |
| 4699 } |
| 4763 | 4700 |
| 4764 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4701 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4765 | 4702 |
| 4766 // Ensure we can activate. | 4703 // Ensure we can activate. |
| 4767 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 4704 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 4768 } | 4705 } |
| 4769 | 4706 |
| 4770 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { | 4707 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { |
| 4771 gfx::Size tile_size(100, 100); | 4708 gfx::Size tile_size(100, 100); |
| 4772 gfx::Size layer_bounds(400, 400); | 4709 gfx::Size layer_bounds(400, 400); |
| 4773 | 4710 |
| 4774 scoped_refptr<FakePicturePileImpl> filled_pile = | 4711 scoped_refptr<FakePicturePileImpl> filled_pile = |
| 4775 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4712 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4776 | 4713 |
| 4777 scoped_ptr<FakePicturePile> partial_recording = | 4714 scoped_ptr<FakePicturePile> partial_recording = |
| 4778 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); | 4715 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); |
| 4779 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { | 4716 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { |
| 4780 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) | 4717 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) |
| 4781 partial_recording->AddRecordingAt(i, j); | 4718 partial_recording->AddRecordingAt(i, j); |
| 4782 } | 4719 } |
| 4783 scoped_refptr<FakePicturePileImpl> partial_pile = | 4720 scoped_refptr<FakePicturePileImpl> partial_pile = |
| 4784 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); | 4721 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); |
| 4785 | 4722 |
| 4786 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); | 4723 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); |
| 4787 ActivateTree(); | 4724 ActivateTree(); |
| 4788 | 4725 |
| 4789 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); | 4726 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); |
| 4790 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); | 4727 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); |
| 4791 | 4728 |
| 4792 // We should have all tiles in both tile sets. | 4729 // We should have all tiles on active, and none on pending. |
| 4793 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4730 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size()); |
| 4794 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4731 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4795 | 4732 |
| 4796 // Now put a partially-recorded pile on the pending tree (and invalidate | 4733 // Now put a partially-recorded pile on the pending tree (and invalidate |
| 4797 // everything, since the main thread PicturePile will invalidate dropped | 4734 // everything, since the main thread PicturePile will invalidate dropped |
| 4798 // recordings). This will cause us to be missing some tiles. | 4735 // recordings). This will cause us to be missing some tiles. |
| 4799 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, | 4736 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, |
| 4800 Region(gfx::Rect(layer_bounds))); | 4737 Region(gfx::Rect(layer_bounds))); |
| 4801 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); | 4738 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); |
| 4802 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); | 4739 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); |
| 4803 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); | 4740 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); |
| 4804 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); | 4741 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); |
| 4805 | 4742 |
| 4806 // Active is not affected yet. | 4743 // Active is not affected yet. |
| 4807 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4744 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4808 | 4745 |
| 4809 // Activate the tree. The same tiles go missing on the active tree. | 4746 // Activate the tree. The same tiles go missing on the active tree. |
| 4810 ActivateTree(); | 4747 ActivateTree(); |
| 4811 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); | 4748 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); |
| 4812 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 4749 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 4813 EXPECT_FALSE(active_tiling->TileAt(1, 1)); | 4750 EXPECT_FALSE(active_tiling->TileAt(1, 1)); |
| 4814 EXPECT_TRUE(active_tiling->TileAt(2, 2)); | 4751 EXPECT_TRUE(active_tiling->TileAt(2, 2)); |
| 4815 | 4752 |
| 4816 // Now put a full recording on the pending tree again. We'll get all our tiles | 4753 // Now put a full recording on the pending tree again. We'll get all our tiles |
| 4817 // back. | 4754 // back. |
| 4818 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, | 4755 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, |
| 4819 Region(gfx::Rect(layer_bounds))); | 4756 Region(gfx::Rect(layer_bounds))); |
| 4820 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4757 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); |
| 4758 Tile* tile00 = pending_tiling->TileAt(0, 0); |
| 4759 Tile* tile11 = pending_tiling->TileAt(1, 1); |
| 4760 Tile* tile22 = pending_tiling->TileAt(2, 2); |
| 4821 | 4761 |
| 4822 // Active is not affected yet. | 4762 // Active is not affected yet. |
| 4823 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); | 4763 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); |
| 4824 | 4764 |
| 4825 // Activate the tree. The tiles are created and shared on the active tree. | 4765 // Activate the tree. The tiles are moved to the active tree. |
| 4826 ActivateTree(); | 4766 ActivateTree(); |
| 4827 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4767 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| 4828 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | 4768 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0)); |
| 4829 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | 4769 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1)); |
| 4830 EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared()); | 4770 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2)); |
| 4831 } | 4771 } |
| 4832 | 4772 |
| 4833 class TileSizeSettings : public ImplSidePaintingSettings { | 4773 class TileSizeSettings : public ImplSidePaintingSettings { |
| 4834 public: | 4774 public: |
| 4835 TileSizeSettings() { | 4775 TileSizeSettings() { |
| 4836 default_tile_size = gfx::Size(100, 100); | 4776 default_tile_size = gfx::Size(100, 100); |
| 4837 max_untiled_layer_size = gfx::Size(200, 200); | 4777 max_untiled_layer_size = gfx::Size(200, 200); |
| 4838 } | 4778 } |
| 4839 }; | 4779 }; |
| 4840 | 4780 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4893 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4833 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4894 EXPECT_EQ(result.width(), 448); | 4834 EXPECT_EQ(result.width(), 448); |
| 4895 EXPECT_EQ(result.height(), 448); | 4835 EXPECT_EQ(result.height(), 448); |
| 4896 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4836 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4897 EXPECT_EQ(result.width(), 512); | 4837 EXPECT_EQ(result.width(), 512); |
| 4898 EXPECT_EQ(result.height(), 500 + 2); | 4838 EXPECT_EQ(result.height(), 500 + 2); |
| 4899 } | 4839 } |
| 4900 | 4840 |
| 4901 } // namespace | 4841 } // namespace |
| 4902 } // namespace cc | 4842 } // namespace cc |
| OLD | NEW |