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 // Ensure we need post commit initialization on the pending layer. | |
enne (OOO)
2014/05/19 22:27:36
This is a very informative comment. Maybe say you
vmpstr
2014/05/19 22:46:28
Done.
| |
1757 pending_layer_->SetNeedsPostCommitInitialization(); | |
1758 pending_layer_->set_twin_layer(NULL); | |
1759 active_layer_->set_twin_layer(NULL); | |
1760 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); | |
1761 | |
1762 pending_layer_->SetBounds(gfx::Size(1, 1)); | |
1763 host_impl_.pending_tree()->UpdateDrawProperties(); | |
1764 | |
1765 // Another sanity check. | |
1766 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); | |
1767 | |
1768 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | |
1769 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.0f)); | |
1770 EXPECT_EQ(HIGH_RESOLUTION, | |
1771 pending_layer_->tilings()->TilingAtScale(1.0f)->resolution()); | |
1772 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f)); | |
1773 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
1774 pending_layer_->tilings()->TilingAtScale(1.5f)->resolution()); | |
1775 } | |
1776 | |
1730 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { | 1777 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
1731 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1778 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
1732 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1779 gfx::Size layer_bounds(default_tile_size.width() * 4, |
1733 default_tile_size.height() * 4); | 1780 default_tile_size.height() * 4); |
1734 float result_scale_x, result_scale_y; | 1781 float result_scale_x, result_scale_y; |
1735 gfx::Size result_bounds; | 1782 gfx::Size result_bounds; |
1736 | 1783 |
1737 SetupDefaultTrees(layer_bounds); | 1784 SetupDefaultTrees(layer_bounds); |
1738 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); | 1785 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); |
1739 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1786 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, | 2349 SetContentsScaleOnBothLayers(contents_scale, |
2303 device_scale, | 2350 device_scale, |
2304 page_scale, | 2351 page_scale, |
2305 maximum_animation_scale, | 2352 maximum_animation_scale, |
2306 animating_transform); | 2353 animating_transform); |
2307 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2354 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2308 } | 2355 } |
2309 | 2356 |
2310 } // namespace | 2357 } // namespace |
2311 } // namespace cc | 2358 } // namespace cc |
OLD | NEW |