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 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(kScale)); | 2215 EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(kScale)); |
2216 | 2216 |
2217 // Toggling the gpu rasterization clears all tilings on both trees. | 2217 // Toggling the gpu rasterization clears all tilings on both trees. |
2218 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 2218 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
2219 host_impl_.SetUseGpuRasterization(false); | 2219 host_impl_.SetUseGpuRasterization(false); |
2220 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2220 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
2221 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 2221 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
2222 } | 2222 } |
2223 | 2223 |
2224 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { | 2224 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { |
2225 SetupDefaultTrees(gfx::Size(10, 10)); | 2225 gfx::Size tile_size(100, 100); |
| 2226 |
| 2227 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2228 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(10, 10)); |
| 2229 SetupPendingTree(active_pile); |
| 2230 ActivateTree(); |
2226 host_impl_.active_tree()->UpdateDrawProperties(); | 2231 host_impl_.active_tree()->UpdateDrawProperties(); |
2227 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | 2232 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
2228 | 2233 |
2229 SetupDrawPropertiesAndUpdateTiles( | 2234 SetupDrawPropertiesAndUpdateTiles( |
2230 active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); | 2235 active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); |
2231 pending_layer_->tilings()->RemoveAllTilings(); | |
2232 active_layer_->tilings()->RemoveAllTilings(); | 2236 active_layer_->tilings()->RemoveAllTilings(); |
2233 PictureLayerTiling* tiling = active_layer_->AddTiling(0.5f); | 2237 PictureLayerTiling* tiling = active_layer_->AddTiling(0.5f); |
2234 active_layer_->AddTiling(1.5f); | 2238 active_layer_->AddTiling(1.5f); |
2235 active_layer_->AddTiling(0.25f); | 2239 active_layer_->AddTiling(0.25f); |
2236 tiling->set_resolution(HIGH_RESOLUTION); | 2240 tiling->set_resolution(HIGH_RESOLUTION); |
2237 | 2241 |
2238 // Sanity checks. | 2242 // Sanity checks. |
2239 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 2243 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
2240 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); | 2244 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); |
2241 | 2245 |
2242 pending_layer_->tilings()->RemoveAllTilings(); | |
2243 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
2244 | |
2245 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes | 2246 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes |
2246 // 1.0f). Note that we should also ensure that the pending layer needs post | 2247 // 1.0f). Note that we should also ensure that the pending layer needs post |
2247 // commit initialization, since this is what would happen during commit. In | 2248 // commit initialization, since this is what would happen during commit. In |
2248 // other words we want the pending layer to sync from the active layer. | 2249 // other words we want the pending layer to sync from the active layer. |
2249 pending_layer_->SetBounds(gfx::Size(1, 1)); | 2250 scoped_refptr<FakePicturePileImpl> pending_pile = |
2250 pending_layer_->SetNeedsPostCommitInitialization(); | 2251 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1, 1)); |
2251 pending_layer_->set_twin_layer(nullptr); | 2252 SetupPendingTree(pending_pile); |
2252 active_layer_->set_twin_layer(nullptr); | |
2253 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); | |
2254 | 2253 |
2255 // Update the draw properties: sync from active tree should happen here. | 2254 // Update the draw properties: sync from active tree should happen here. |
2256 host_impl_.pending_tree()->UpdateDrawProperties(); | 2255 host_impl_.pending_tree()->UpdateDrawProperties(); |
2257 | 2256 |
2258 // Another sanity check. | 2257 // Another sanity check. |
2259 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); | 2258 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); |
2260 | 2259 |
2261 // Now we should've synced 1.5f tiling, since that's the only one that doesn't | 2260 // Now we should've synced 1.5f tiling, since that's the only one that doesn't |
2262 // violate minimum contents scale. At the same time, we should've created a | 2261 // violate minimum contents scale. At the same time, we should've created a |
2263 // new high res tiling at scale 1.0f. | 2262 // new high res tiling at scale 1.0f. |
(...skipping 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4647 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4646 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4648 EXPECT_EQ(result.width(), 448); | 4647 EXPECT_EQ(result.width(), 448); |
4649 EXPECT_EQ(result.height(), 448); | 4648 EXPECT_EQ(result.height(), 448); |
4650 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4649 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4651 EXPECT_EQ(result.width(), 512); | 4650 EXPECT_EQ(result.width(), 512); |
4652 EXPECT_EQ(result.height(), 500 + 2); | 4651 EXPECT_EQ(result.height(), 500 + 2); |
4653 } | 4652 } |
4654 | 4653 |
4655 } // namespace | 4654 } // namespace |
4656 } // namespace cc | 4655 } // namespace cc |
OLD | NEW |