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

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

Issue 605773004: CC: Tile-size cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 2 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
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 4349 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 PicturePileImpl::CreateFromOther(pile); 4360 PicturePileImpl::CreateFromOther(pile);
4361 4361
4362 SetupPendingTree(pending_pile2); 4362 SetupPendingTree(pending_pile2);
4363 ActivateTree(); 4363 ActivateTree();
4364 4364
4365 // We've switched to a solid color, so we should end up with no tilings. 4365 // We've switched to a solid color, so we should end up with no tilings.
4366 ASSERT_TRUE(active_layer_->tilings()); 4366 ASSERT_TRUE(active_layer_->tilings());
4367 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4367 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4368 } 4368 }
4369 4369
4370 class TileSizeSettings : public ImplSidePaintingSettings {
4371 public:
4372 TileSizeSettings() {
4373 default_tile_size = gfx::Size(100, 100);
4374 max_untiled_layer_size = gfx::Size(200, 200);
4375 }
4376 };
4377
4378 class TileSizeTest : public PictureLayerImplTest {
4379 public:
4380 TileSizeTest() : PictureLayerImplTest(TileSizeSettings()) {}
4381 };
4382
4383 TEST_F(TileSizeTest, TileSizes) {
4384 host_impl_.CreatePendingTree();
4385
4386 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
4387 scoped_ptr<FakePictureLayerImpl> layer =
4388 FakePictureLayerImpl::Create(pending_tree, id_);
4389
4390 gfx::Size viewport_size = gfx::Size(1000, 1000);
4391 gfx::Size gpu_tile_size = gfx::Size(1000, 250);
4392 gfx::Size small_layer_size(42, 42);
4393 gfx::Size medium_layer_size(260, 260);
4394 gfx::Size large_layer_size(10000, 10000);
4395 host_impl_.SetViewportSize(viewport_size);
4396 gfx::Size result;
4397
4398 host_impl_.SetUseGpuRasterization(false);
4399
4400 // Default tile-size for large layers.
4401 result = layer->CalculateTileSize(large_layer_size);
4402 EXPECT_EQ(result.width(), 100);
4403 EXPECT_EQ(result.height(), 100);
4404
4405 // Small layers don't tile if under max_untiled_layer_size.
4406 // Small layers also round up to multiples of 64.
4407 result = layer->CalculateTileSize(small_layer_size);
4408 EXPECT_EQ(result.width(), 64);
4409 EXPECT_EQ(result.height(), 64);
4410
4411 host_impl_.SetUseGpuRasterization(true);
4412
4413 // Gpu-rasterization uses 1/4 viewport-height tiles.
4414 result = layer->CalculateTileSize(large_layer_size);
4415 EXPECT_EQ(result.width(), gpu_tile_size.width());
4416 EXPECT_EQ(result.height(), gpu_tile_size.height());
4417
4418 // Same as non-gpu small layers.
4419 result = layer->CalculateTileSize(small_layer_size);
4420 EXPECT_EQ(result.width(), 64);
4421 EXPECT_EQ(result.height(), 64);
4422
4423 // The max untiled size for gpu-raster is 2x a normal tile.
4424 // These are also rounded up to multiples of 64.
4425 result = layer->CalculateTileSize(medium_layer_size);
4426 EXPECT_EQ(result.width(), 320);
4427 EXPECT_EQ(result.height(), 320);
4428 }
4429
4370 } // namespace 4430 } // namespace
4371 } // namespace cc 4431 } // namespace cc
OLDNEW
« cc/layers/picture_layer_impl.cc ('K') | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698