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 4369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4380 TileSizeTest() : PictureLayerImplTest(TileSizeSettings()) {} | 4380 TileSizeTest() : PictureLayerImplTest(TileSizeSettings()) {} |
4381 }; | 4381 }; |
4382 | 4382 |
4383 TEST_F(TileSizeTest, TileSizes) { | 4383 TEST_F(TileSizeTest, TileSizes) { |
4384 host_impl_.CreatePendingTree(); | 4384 host_impl_.CreatePendingTree(); |
4385 | 4385 |
4386 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 4386 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
4387 scoped_ptr<FakePictureLayerImpl> layer = | 4387 scoped_ptr<FakePictureLayerImpl> layer = |
4388 FakePictureLayerImpl::Create(pending_tree, id_); | 4388 FakePictureLayerImpl::Create(pending_tree, id_); |
4389 | 4389 |
4390 gfx::Size viewport_size = gfx::Size(1000, 1000); | 4390 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); |
4391 host_impl_.SetViewportSize(viewport_size); | |
4392 gfx::Size result; | 4391 gfx::Size result; |
4393 | 4392 |
4394 host_impl_.SetUseGpuRasterization(false); | 4393 host_impl_.SetUseGpuRasterization(false); |
4395 | 4394 |
4396 // Default tile-size for large layers. | 4395 // Default tile-size for large layers. |
4397 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4396 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
4398 EXPECT_EQ(result.width(), 100); | 4397 EXPECT_EQ(result.width(), 100); |
4399 EXPECT_EQ(result.height(), 100); | 4398 EXPECT_EQ(result.height(), 100); |
4400 // Don't tile and round-up, when under max_untiled_layer_size. | 4399 // Don't tile and round-up, when under max_untiled_layer_size. |
4401 result = layer->CalculateTileSize(gfx::Size(42, 42)); | 4400 result = layer->CalculateTileSize(gfx::Size(42, 42)); |
4402 EXPECT_EQ(result.width(), 64); | 4401 EXPECT_EQ(result.width(), 64); |
4403 EXPECT_EQ(result.height(), 64); | 4402 EXPECT_EQ(result.height(), 64); |
4404 result = layer->CalculateTileSize(gfx::Size(184, 184)); | 4403 result = layer->CalculateTileSize(gfx::Size(191, 191)); |
4405 EXPECT_EQ(result.width(), 192); | 4404 EXPECT_EQ(result.width(), 192); |
4406 EXPECT_EQ(result.height(), 192); | 4405 EXPECT_EQ(result.height(), 192); |
4407 result = layer->CalculateTileSize(gfx::Size(199, 199)); | 4406 result = layer->CalculateTileSize(gfx::Size(199, 199)); |
4408 EXPECT_EQ(result.width(), 200); | 4407 EXPECT_EQ(result.width(), 200); |
4409 EXPECT_EQ(result.height(), 200); | 4408 EXPECT_EQ(result.height(), 200); |
4410 | 4409 |
| 4410 // Gpu-rasterization uses 25% viewport-height tiles. |
| 4411 // The +2's below are for border texels. |
4411 host_impl_.SetUseGpuRasterization(true); | 4412 host_impl_.SetUseGpuRasterization(true); |
4412 | 4413 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); |
4413 // Gpu-rasterization uses 25% viewport-height tiles. | |
4414 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4414 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
4415 EXPECT_EQ(result.width(), 1000); | 4415 EXPECT_EQ(result.width(), 2000); |
4416 EXPECT_EQ(result.height(), 250); | 4416 EXPECT_EQ(result.height(), 500 + 2); |
4417 | 4417 |
4418 // Clamp and round-up, when smaller than viewport. | 4418 // Clamp and round-up, when smaller than viewport. |
4419 result = layer->CalculateTileSize(gfx::Size(831, 10000)); | |
4420 EXPECT_EQ(result.width(), 832); | |
4421 EXPECT_EQ(result.height(), 250); | |
4422 | |
4423 // Tile-height doubles to 50% when width shrinks to <= 50%. | 4419 // Tile-height doubles to 50% when width shrinks to <= 50%. |
| 4420 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); |
4424 result = layer->CalculateTileSize(gfx::Size(447, 10000)); | 4421 result = layer->CalculateTileSize(gfx::Size(447, 10000)); |
4425 EXPECT_EQ(result.width(), 448); | 4422 EXPECT_EQ(result.width(), 448); |
4426 EXPECT_EQ(result.height(), 500); | 4423 EXPECT_EQ(result.height(), 500 + 2); |
4427 | 4424 |
4428 // Largest layer is 50% of viewport width (rounded up), and | 4425 // Largest layer is 50% of viewport width (rounded up), and |
4429 // 50% of viewport in height. | 4426 // 50% of viewport in height. |
4430 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4427 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4431 EXPECT_EQ(result.width(), 448); | 4428 EXPECT_EQ(result.width(), 448); |
4432 EXPECT_EQ(result.height(), 448); | 4429 EXPECT_EQ(result.height(), 448); |
4433 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4430 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4434 EXPECT_EQ(result.width(), 512); | 4431 EXPECT_EQ(result.width(), 512); |
4435 EXPECT_EQ(result.height(), 500); | 4432 EXPECT_EQ(result.height(), 500 + 2); |
4436 } | 4433 } |
4437 | 4434 |
4438 } // namespace | 4435 } // namespace |
4439 } // namespace cc | 4436 } // namespace cc |
OLD | NEW |