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

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: Cleanup. 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
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | 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 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 host_impl_.SetViewportSize(viewport_size);
4392 gfx::Size result;
4393
4394 host_impl_.SetUseGpuRasterization(false);
4395
4396 // Default tile-size for large layers.
4397 result = layer->CalculateTileSize(gfx::Size(10000, 10000));
4398 EXPECT_EQ(result.width(), 100);
4399 EXPECT_EQ(result.height(), 100);
4400 // Don't tile and round-up, when under max_untiled_layer_size.
4401 result = layer->CalculateTileSize(gfx::Size(42, 42));
4402 EXPECT_EQ(result.width(), 64);
4403 EXPECT_EQ(result.height(), 64);
4404 result = layer->CalculateTileSize(gfx::Size(184, 184));
4405 EXPECT_EQ(result.width(), 192);
4406 EXPECT_EQ(result.height(), 192);
4407 result = layer->CalculateTileSize(gfx::Size(199, 199));
4408 EXPECT_EQ(result.width(), 200);
4409 EXPECT_EQ(result.height(), 200);
4410
4411 host_impl_.SetUseGpuRasterization(true);
4412
4413 // Gpu-rasterization uses 25% viewport-height tiles.
4414 result = layer->CalculateTileSize(gfx::Size(10000, 10000));
4415 EXPECT_EQ(result.width(), 1000);
4416 EXPECT_EQ(result.height(), 250);
4417
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%.
4424 result = layer->CalculateTileSize(gfx::Size(447, 10000));
4425 EXPECT_EQ(result.width(), 448);
4426 EXPECT_EQ(result.height(), 500);
4427
4428 // Largest layer is 50% of viewport width (rounded up), and
4429 // 50% of viewport in height.
4430 result = layer->CalculateTileSize(gfx::Size(447, 400));
4431 EXPECT_EQ(result.width(), 448);
4432 EXPECT_EQ(result.height(), 448);
4433 result = layer->CalculateTileSize(gfx::Size(500, 499));
4434 EXPECT_EQ(result.width(), 512);
4435 EXPECT_EQ(result.height(), 500);
4436 }
4437
4370 } // namespace 4438 } // namespace
4371 } // namespace cc 4439 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698