Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 | 918 |
| 919 std::vector<PictureLayerTiling*> used_tilings; | 919 std::vector<PictureLayerTiling*> used_tilings; |
| 920 | 920 |
| 921 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 921 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 922 EXPECT_LT(low_res_factor, 1.f); | 922 EXPECT_LT(low_res_factor, 1.f); |
| 923 | 923 |
| 924 float scale = 1.f; | 924 float scale = 1.f; |
| 925 float page_scale = 1.f; | 925 float page_scale = 1.f; |
| 926 | 926 |
| 927 SetupDefaultTrees(layer_bounds); | 927 SetupDefaultTrees(layer_bounds); |
| 928 active_layer()->SetHasWillChangeTransformHint(true); | |
|
danakj
2016/06/16 18:15:29
What do you think of the test changes in https://c
| |
| 928 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); | 929 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 929 EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale()); | 930 EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale()); |
| 930 | 931 |
| 931 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to | 932 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
| 932 // |used_tilings| variable, and it's here only to ensure that active_layer() | 933 // |used_tilings| variable, and it's here only to ensure that active_layer() |
| 933 // won't remove tilings before the test has a chance to verify behavior. | 934 // won't remove tilings before the test has a chance to verify behavior. |
| 934 active_layer()->MarkAllTilingsUsed(); | 935 active_layer()->MarkAllTilingsUsed(); |
| 935 | 936 |
| 936 // We only have ideal tilings, so they aren't removed. | 937 // We only have ideal tilings, so they aren't removed. |
| 937 used_tilings.clear(); | 938 used_tilings.clear(); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1822 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1823 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1823 | 1824 |
| 1824 gfx::Size tile_size(100, 100); | 1825 gfx::Size tile_size(100, 100); |
| 1825 gfx::Size layer_bounds(200, 200); | 1826 gfx::Size layer_bounds(200, 200); |
| 1826 gfx::Size viewport_size(400, 400); | 1827 gfx::Size viewport_size(400, 400); |
| 1827 | 1828 |
| 1828 host_impl()->SetViewportSize(viewport_size); | 1829 host_impl()->SetViewportSize(viewport_size); |
| 1829 SetInitialDeviceScaleFactor(2.f); | 1830 SetInitialDeviceScaleFactor(2.f); |
| 1830 | 1831 |
| 1831 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1832 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 1833 active_layer()->SetHasWillChangeTransformHint(true); | |
| 1832 | 1834 |
| 1833 // One ideal tile exists, this will get used when drawing. | 1835 // One ideal tile exists, this will get used when drawing. |
| 1834 std::vector<Tile*> ideal_tiles; | 1836 std::vector<Tile*> ideal_tiles; |
| 1835 EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale()); | 1837 EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale()); |
| 1836 ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); | 1838 ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); |
| 1837 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1839 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1838 ideal_tiles); | 1840 ideal_tiles); |
| 1839 | 1841 |
| 1840 // Due to layer scale throttling, the raster contents scale is changed to 1, | 1842 // Due to layer scale throttling, the raster contents scale is changed to 1, |
| 1841 // while the ideal is still 2. | 1843 // while the ideal is still 2. |
| (...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3112 float maximum_animation_scale = 1.f; | 3114 float maximum_animation_scale = 1.f; |
| 3113 float starting_animation_scale = 0.f; | 3115 float starting_animation_scale = 0.f; |
| 3114 bool animating_transform = false; | 3116 bool animating_transform = false; |
| 3115 | 3117 |
| 3116 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3118 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3117 maximum_animation_scale, | 3119 maximum_animation_scale, |
| 3118 starting_animation_scale, animating_transform); | 3120 starting_animation_scale, animating_transform); |
| 3119 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 3121 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 3120 | 3122 |
| 3121 // Changing the source scale without being in an animation will cause | 3123 // Changing the source scale without being in an animation will cause |
| 3122 // the layer to reset its source scale to 1.f. | 3124 // the layer to change scale. |
| 3123 contents_scale = 3.f; | 3125 contents_scale = 3.f; |
| 3124 | 3126 |
| 3125 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3127 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3126 maximum_animation_scale, | 3128 maximum_animation_scale, |
| 3127 starting_animation_scale, animating_transform); | 3129 starting_animation_scale, animating_transform); |
| 3128 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3130 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
| 3129 | 3131 |
| 3130 // Further changes to the source scale will no longer be reflected in the | |
| 3131 // contents scale. | |
| 3132 contents_scale = 0.5f; | 3132 contents_scale = 0.5f; |
| 3133 | 3133 |
| 3134 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3134 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3135 maximum_animation_scale, | 3135 maximum_animation_scale, |
| 3136 starting_animation_scale, animating_transform); | 3136 starting_animation_scale, animating_transform); |
| 3137 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3137 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); |
| 3138 | |
| 3139 // However, if the layer has a will-change property, then the raster scale | |
| 3140 // will get fixed at the last value. | |
| 3141 active_layer()->SetHasWillChangeTransformHint(true); | |
| 3142 pending_layer()->SetHasWillChangeTransformHint(true); | |
| 3143 | |
| 3144 contents_scale = 3.f; | |
| 3145 | |
| 3146 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | |
| 3147 maximum_animation_scale, | |
| 3148 starting_animation_scale, animating_transform); | |
| 3149 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | |
| 3150 | |
| 3151 // Further changes to the source scale will no longer be reflected in the | |
| 3152 // contents scale. | |
| 3153 contents_scale = 1.f; | |
| 3154 | |
| 3155 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | |
| 3156 maximum_animation_scale, | |
| 3157 starting_animation_scale, animating_transform); | |
| 3158 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | |
| 3159 | |
| 3160 // Disabling the will-change hint will once again make the raster scale update | |
| 3161 // with the ideal scale. | |
| 3162 active_layer()->SetHasWillChangeTransformHint(false); | |
| 3163 pending_layer()->SetHasWillChangeTransformHint(false); | |
| 3164 | |
| 3165 contents_scale = 3.f; | |
| 3166 | |
| 3167 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | |
| 3168 maximum_animation_scale, | |
| 3169 starting_animation_scale, animating_transform); | |
| 3170 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | |
| 3138 } | 3171 } |
| 3139 | 3172 |
| 3140 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3173 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3141 gfx::Size tile_size(100, 100); | 3174 gfx::Size tile_size(100, 100); |
| 3142 gfx::Size layer_bounds(1000, 1000); | 3175 gfx::Size layer_bounds(1000, 1000); |
| 3143 | 3176 |
| 3144 // Make sure pending tree has tiles. | 3177 // Make sure pending tree has tiles. |
| 3145 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3178 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3146 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3179 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3147 | 3180 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3378 std::vector<PictureLayerTiling*> used_tilings; | 3411 std::vector<PictureLayerTiling*> used_tilings; |
| 3379 SetupDefaultTrees(layer_bounds); | 3412 SetupDefaultTrees(layer_bounds); |
| 3380 | 3413 |
| 3381 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 3414 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 3382 EXPECT_LT(low_res_factor, 1.f); | 3415 EXPECT_LT(low_res_factor, 1.f); |
| 3383 | 3416 |
| 3384 float device_scale = 1.7f; | 3417 float device_scale = 1.7f; |
| 3385 float page_scale = 3.2f; | 3418 float page_scale = 3.2f; |
| 3386 float scale = 1.f; | 3419 float scale = 1.f; |
| 3387 | 3420 |
| 3421 active_layer()->SetHasWillChangeTransformHint(true); | |
| 3388 ResetTilingsAndRasterScales(); | 3422 ResetTilingsAndRasterScales(); |
| 3389 | 3423 |
| 3390 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, 0.f, | 3424 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, 0.f, |
| 3391 false); | 3425 false); |
| 3392 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3426 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); |
| 3393 | 3427 |
| 3394 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to | 3428 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
| 3395 // |used_tilings| variable, and it's here only to ensure that active_layer() | 3429 // |used_tilings| variable, and it's here only to ensure that active_layer() |
| 3396 // won't remove tilings before the test has a chance to verify behavior. | 3430 // won't remove tilings before the test has a chance to verify behavior. |
| 3397 active_layer()->MarkAllTilingsUsed(); | 3431 active_layer()->MarkAllTilingsUsed(); |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4762 // New low res tiling. | 4796 // New low res tiling. |
| 4763 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 4797 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
| 4764 | 4798 |
| 4765 // This tiling will be high res now, it won't contain low res content since it | 4799 // This tiling will be high res now, it won't contain low res content since it |
| 4766 // was all destroyed. | 4800 // was all destroyed. |
| 4767 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 4801 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
| 4768 } | 4802 } |
| 4769 | 4803 |
| 4770 } // namespace | 4804 } // namespace |
| 4771 } // namespace cc | 4805 } // namespace cc |
| OLD | NEW |