Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 290573007: cc: Move gpu rasterization flag from tree-impl to tree-host-impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, SyncTilingAfterGpuRasterizationToggles) {
1731 SetupDefaultTrees(gfx::Size(10, 10));
1732
1733 const float kScale = 1.f;
1734 pending_layer_->AddTiling(kScale);
1735 EXPECT_TRUE(pending_layer_->tilings()->TilingAtScale(kScale));
1736 EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(kScale));
1737
1738 // Gpu rasterization is disabled by default.
1739 EXPECT_FALSE(host_impl_.use_gpu_rasterization());
1740 // Toggling the gpu rasterization clears all tilings on both trees.
1741 host_impl_.SetUseGpuRasterization(true);
1742 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1743 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
1744
1745 // Make sure that we can still add tiling to the pending layer,
1746 // that gets synced to the active layer.
1747 pending_layer_->AddTiling(kScale);
1748 EXPECT_TRUE(pending_layer_->tilings()->TilingAtScale(kScale));
1749 EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(kScale));
1750
1751 // Toggling the gpu rasterization clears all tilings on both trees.
1752 EXPECT_TRUE(host_impl_.use_gpu_rasterization());
1753 host_impl_.SetUseGpuRasterization(false);
1754 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1755 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
1756 }
1757
1730 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { 1758 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) {
1731 SetupDefaultTrees(gfx::Size(10, 10)); 1759 SetupDefaultTrees(gfx::Size(10, 10));
1732 host_impl_.active_tree()->UpdateDrawProperties(); 1760 host_impl_.active_tree()->UpdateDrawProperties();
1733 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); 1761 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties());
1734 1762
1735 float result_scale_x; 1763 float result_scale_x;
1736 float result_scale_y; 1764 float result_scale_y;
1737 gfx::Size result_bounds; 1765 gfx::Size result_bounds;
1738 active_layer_->CalculateContentsScale(0.5f, 1766 active_layer_->CalculateContentsScale(0.5f,
1739 0.5f, 1767 0.5f,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 } 1810 }
1783 1811
1784 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { 1812 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) {
1785 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); 1813 gfx::Size default_tile_size(host_impl_.settings().default_tile_size);
1786 gfx::Size layer_bounds(default_tile_size.width() * 4, 1814 gfx::Size layer_bounds(default_tile_size.width() * 4,
1787 default_tile_size.height() * 4); 1815 default_tile_size.height() * 4);
1788 float result_scale_x, result_scale_y; 1816 float result_scale_x, result_scale_y;
1789 gfx::Size result_bounds; 1817 gfx::Size result_bounds;
1790 1818
1791 SetupDefaultTrees(layer_bounds); 1819 SetupDefaultTrees(layer_bounds);
1792 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); 1820 EXPECT_FALSE(host_impl_.use_gpu_rasterization());
1793 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 1821 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1794 pending_layer_->CalculateContentsScale(1.f, 1822 pending_layer_->CalculateContentsScale(1.f,
1795 1.f, 1823 1.f,
1796 1.f, 1824 1.f,
1797 1.f, 1825 1.f,
1798 false, 1826 false,
1799 &result_scale_x, 1827 &result_scale_x,
1800 &result_scale_y, 1828 &result_scale_y,
1801 &result_bounds); 1829 &result_bounds);
1802 // Should have a low-res and a high-res tiling. 1830 // Should have a low-res and a high-res tiling.
1803 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); 1831 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
1804 1832
1805 ResetTilingsAndRasterScales(); 1833 ResetTilingsAndRasterScales();
1806 1834
1807 host_impl_.pending_tree()->SetUseGpuRasterization(true); 1835 host_impl_.SetUseGpuRasterization(true);
1808 EXPECT_TRUE(pending_layer_->use_gpu_rasterization()); 1836 EXPECT_TRUE(host_impl_.use_gpu_rasterization());
1809 pending_layer_->CalculateContentsScale(1.f, 1837 pending_layer_->CalculateContentsScale(1.f,
1810 1.f, 1838 1.f,
1811 1.f, 1839 1.f,
1812 1.f, 1840 1.f,
1813 false, 1841 false,
1814 &result_scale_x, 1842 &result_scale_x,
1815 &result_scale_y, 1843 &result_scale_y,
1816 &result_bounds); 1844 &result_bounds);
1817 // Should only have the high-res tiling. 1845 // Should only have the high-res tiling.
1818 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 1846 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 SetContentsScaleOnBothLayers(contents_scale, 2384 SetContentsScaleOnBothLayers(contents_scale,
2357 device_scale, 2385 device_scale,
2358 page_scale, 2386 page_scale,
2359 maximum_animation_scale, 2387 maximum_animation_scale,
2360 animating_transform); 2388 animating_transform);
2361 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); 2389 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f);
2362 } 2390 }
2363 2391
2364 } // namespace 2392 } // namespace
2365 } // namespace cc 2393 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698