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