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 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 // ReleaseResources has set needs update draw properties so that the | 1720 // ReleaseResources has set needs update draw properties so that the |
1721 // new tiling gets the appropriate resolution set in ManageTilings. | 1721 // new tiling gets the appropriate resolution set in ManageTilings. |
1722 EXPECT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 1722 EXPECT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
1723 host_impl_.active_tree()->UpdateDrawProperties(); | 1723 host_impl_.active_tree()->UpdateDrawProperties(); |
1724 PictureLayerTiling* high_res = | 1724 PictureLayerTiling* high_res = |
1725 active_layer_->tilings()->TilingAtScale(new_scale); | 1725 active_layer_->tilings()->TilingAtScale(new_scale); |
1726 ASSERT_TRUE(!!high_res); | 1726 ASSERT_TRUE(!!high_res); |
1727 EXPECT_EQ(HIGH_RESOLUTION, high_res->resolution()); | 1727 EXPECT_EQ(HIGH_RESOLUTION, high_res->resolution()); |
1728 } | 1728 } |
1729 | 1729 |
| 1730 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { |
| 1731 SetupDefaultTrees(gfx::Size(10, 10)); |
| 1732 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1733 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
| 1734 |
| 1735 float result_scale_x; |
| 1736 float result_scale_y; |
| 1737 gfx::Size result_bounds; |
| 1738 active_layer_->CalculateContentsScale(0.5f, |
| 1739 0.5f, |
| 1740 0.5f, |
| 1741 0.5f, |
| 1742 false, |
| 1743 &result_scale_x, |
| 1744 &result_scale_y, |
| 1745 &result_bounds); |
| 1746 active_layer_->tilings()->RemoveAllTilings(); |
| 1747 PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f); |
| 1748 active_layer_->tilings()->AddTiling(1.5f); |
| 1749 active_layer_->tilings()->AddTiling(0.25f); |
| 1750 tiling->set_resolution(HIGH_RESOLUTION); |
| 1751 |
| 1752 // Sanity checks. |
| 1753 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1754 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); |
| 1755 |
| 1756 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes |
| 1757 // 1.0f). Note that we should also ensure that the pending layer needs post |
| 1758 // commit initialization, since this is what would happen during commit. In |
| 1759 // other words we want the pending layer to sync from the active layer. |
| 1760 pending_layer_->SetBounds(gfx::Size(1, 1)); |
| 1761 pending_layer_->SetNeedsPostCommitInitialization(); |
| 1762 pending_layer_->set_twin_layer(NULL); |
| 1763 active_layer_->set_twin_layer(NULL); |
| 1764 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); |
| 1765 |
| 1766 // Update the draw properties: sync from active tree should happen here. |
| 1767 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1768 |
| 1769 // Another sanity check. |
| 1770 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); |
| 1771 |
| 1772 // Now we should've synced 1.5f tiling, since that's the only one that doesn't |
| 1773 // violate minimum contents scale. At the same time, we should've created a |
| 1774 // new high res tiling at scale 1.0f. |
| 1775 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1776 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.0f)); |
| 1777 EXPECT_EQ(HIGH_RESOLUTION, |
| 1778 pending_layer_->tilings()->TilingAtScale(1.0f)->resolution()); |
| 1779 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f)); |
| 1780 EXPECT_EQ(NON_IDEAL_RESOLUTION, |
| 1781 pending_layer_->tilings()->TilingAtScale(1.5f)->resolution()); |
| 1782 } |
| 1783 |
1730 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { | 1784 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
1731 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1785 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
1732 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1786 gfx::Size layer_bounds(default_tile_size.width() * 4, |
1733 default_tile_size.height() * 4); | 1787 default_tile_size.height() * 4); |
1734 float result_scale_x, result_scale_y; | 1788 float result_scale_x, result_scale_y; |
1735 gfx::Size result_bounds; | 1789 gfx::Size result_bounds; |
1736 | 1790 |
1737 SetupDefaultTrees(layer_bounds); | 1791 SetupDefaultTrees(layer_bounds); |
1738 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); | 1792 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); |
1739 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1793 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 SetContentsScaleOnBothLayers(contents_scale, | 2356 SetContentsScaleOnBothLayers(contents_scale, |
2303 device_scale, | 2357 device_scale, |
2304 page_scale, | 2358 page_scale, |
2305 maximum_animation_scale, | 2359 maximum_animation_scale, |
2306 animating_transform); | 2360 animating_transform); |
2307 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2361 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2308 } | 2362 } |
2309 | 2363 |
2310 } // namespace | 2364 } // namespace |
2311 } // namespace cc | 2365 } // namespace cc |
OLD | NEW |