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

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

Issue 799463005: cc: Mirror LiveTilesRect and tiles between active and recycled trees. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: noswap-ltr: withcheck Created 6 years 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 4530 matching lines...) Expand 10 before | Expand all | Expand 10 after
4541 if (*iter) 4541 if (*iter)
4542 tiles.push_back(*iter); 4542 tiles.push_back(*iter);
4543 } 4543 }
4544 4544
4545 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4545 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4546 4546
4547 // Ensure we can activate. 4547 // Ensure we can activate.
4548 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 4548 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
4549 } 4549 }
4550 4550
4551 TEST_F(PictureLayerImplTest, CloneMissingRecordings) {
4552 gfx::Size tile_size(100, 100);
4553 gfx::Size layer_bounds(400, 400);
4554
4555 scoped_refptr<FakePicturePileImpl> filled_pile =
4556 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4557 scoped_refptr<FakePicturePileImpl> partial_pile =
4558 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
4559 for (int i = 1; i < partial_pile->tiling().num_tiles_x(); ++i) {
4560 for (int j = 1; j < partial_pile->tiling().num_tiles_y(); ++j)
4561 partial_pile->AddRecordingAt(i, j);
4562 }
4563
4564 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region());
4565 ActivateTree();
4566
4567 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling();
4568 PictureLayerTiling* active_tiling = active_layer_->HighResTiling();
4569
4570 // We should have all tiles in both tile sets.
4571 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
4572 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4573
4574 // Now put a partially-recorded pile on the pending tree (and invalidate
4575 // everything, since the main thread PicturePile will invalidate dropped
4576 // recordings). This will cause us to be missing some tiles.
4577 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size,
4578 Region(gfx::Rect(layer_bounds)));
4579 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size());
4580 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
4581 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
4582 EXPECT_TRUE(pending_tiling->TileAt(2, 2));
4583
4584 // Active is not affected yet.
4585 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4586
4587 // Activate the tree. The same tiles go missing on the active tree.
4588 ActivateTree();
4589 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4590 EXPECT_FALSE(active_tiling->TileAt(0, 0));
4591 EXPECT_FALSE(active_tiling->TileAt(1, 1));
4592 EXPECT_TRUE(active_tiling->TileAt(2, 2));
4593
4594 // Now put a full recording on the pending tree again. We'll get all our tiles
4595 // back.
4596 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size,
4597 Region(gfx::Rect(layer_bounds)));
4598 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
4599
4600 // Active is not affected yet.
4601 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4602
4603 // Activate the tree. The tiles are created and shared on the active tree.
4604 ActivateTree();
4605 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4606 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared());
4607 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared());
4608 EXPECT_TRUE(active_tiling->TileAt(2, 2)->is_shared());
4609 }
4610
4551 class TileSizeSettings : public ImplSidePaintingSettings { 4611 class TileSizeSettings : public ImplSidePaintingSettings {
4552 public: 4612 public:
4553 TileSizeSettings() { 4613 TileSizeSettings() {
4554 default_tile_size = gfx::Size(100, 100); 4614 default_tile_size = gfx::Size(100, 100);
4555 max_untiled_layer_size = gfx::Size(200, 200); 4615 max_untiled_layer_size = gfx::Size(200, 200);
4556 } 4616 }
4557 }; 4617 };
4558 4618
4559 class TileSizeTest : public PictureLayerImplTest { 4619 class TileSizeTest : public PictureLayerImplTest {
4560 public: 4620 public:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4608 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4668 result = layer->CalculateTileSize(gfx::Size(447, 400));
4609 EXPECT_EQ(result.width(), 448); 4669 EXPECT_EQ(result.width(), 448);
4610 EXPECT_EQ(result.height(), 448); 4670 EXPECT_EQ(result.height(), 448);
4611 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4671 result = layer->CalculateTileSize(gfx::Size(500, 499));
4612 EXPECT_EQ(result.width(), 512); 4672 EXPECT_EQ(result.width(), 512);
4613 EXPECT_EQ(result.height(), 500 + 2); 4673 EXPECT_EQ(result.height(), 500 + 2);
4614 } 4674 }
4615 4675
4616 } // namespace 4676 } // namespace
4617 } // namespace cc 4677 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698