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

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

Issue 2612413003: Clean up tile deletion (Closed)
Patch Set: "Fix Tile* comparison in tests" Created 3 years, 11 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') | cc/test/fake_picture_layer_tiling_client.h » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 4460 matching lines...) Expand 10 before | Expand all | Expand 10 after
4471 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4471 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4472 EXPECT_FALSE(active_tiling->TileAt(0, 0)); 4472 EXPECT_FALSE(active_tiling->TileAt(0, 0));
4473 EXPECT_FALSE(active_tiling->TileAt(1, 1)); 4473 EXPECT_FALSE(active_tiling->TileAt(1, 1));
4474 EXPECT_TRUE(active_tiling->TileAt(2, 2)); 4474 EXPECT_TRUE(active_tiling->TileAt(2, 2));
4475 4475
4476 // Now put a full recording on the pending tree again. We'll get all our tiles 4476 // Now put a full recording on the pending tree again. We'll get all our tiles
4477 // back. 4477 // back.
4478 SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size, 4478 SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size,
4479 Region(gfx::Rect(layer_bounds))); 4479 Region(gfx::Rect(layer_bounds)));
4480 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); 4480 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
4481 Tile* tile00 = pending_tiling->TileAt(0, 0); 4481 Tile::Id tile00 = pending_tiling->TileAt(0, 0)->id();
4482 Tile* tile11 = pending_tiling->TileAt(1, 1); 4482 Tile::Id tile11 = pending_tiling->TileAt(1, 1)->id();
4483 Tile* tile22 = pending_tiling->TileAt(2, 2); 4483 Tile::Id tile22 = pending_tiling->TileAt(2, 2)->id();
4484 4484
4485 // Active is not affected yet. 4485 // Active is not affected yet.
4486 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4486 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4487 4487
4488 // Activate the tree. The tiles are moved to the active tree. 4488 // Activate the tree. The tiles are moved to the active tree.
4489 ActivateTree(); 4489 ActivateTree();
4490 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4490 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4491 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0)); 4491 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0)->id());
4492 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1)); 4492 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1)->id());
4493 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2)); 4493 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2)->id());
4494 } 4494 }
4495 4495
4496 TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) { 4496 TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) {
4497 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4497 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4498 4498
4499 gfx::Size tile_size(102, 102); 4499 gfx::Size tile_size(102, 102);
4500 gfx::Size layer_bounds(100, 100); 4500 gfx::Size layer_bounds(100, 100);
4501 gfx::Size viewport_size(100, 100); 4501 gfx::Size viewport_size(100, 100);
4502 4502
4503 host_impl()->SetViewportSize(viewport_size); 4503 host_impl()->SetViewportSize(viewport_size);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4764 page_scale, 1.0f, 0.f, false); 4764 page_scale, 1.0f, 0.f, false);
4765 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); 4765 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings());
4766 EXPECT_EQ(page_scale, 4766 EXPECT_EQ(page_scale,
4767 active_layer()->tilings()->tiling_at(0)->contents_scale_key()); 4767 active_layer()->tilings()->tiling_at(0)->contents_scale_key());
4768 EXPECT_EQ(low_res, 4768 EXPECT_EQ(low_res,
4769 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); 4769 active_layer()->tilings()->tiling_at(1)->contents_scale_key());
4770 4770
4771 // Grab a current low res tile. 4771 // Grab a current low res tile.
4772 PictureLayerTiling* old_low_res_tiling = 4772 PictureLayerTiling* old_low_res_tiling =
4773 active_layer()->tilings()->tiling_at(1); 4773 active_layer()->tilings()->tiling_at(1);
4774 Tile* old_low_res_tile = 4774 Tile::Id old_low_res_tile_id =
4775 active_layer()->tilings()->tiling_at(1)->TileAt(0, 0); 4775 active_layer()->tilings()->tiling_at(1)->TileAt(0, 0)->id();
4776 4776
4777 // The tiling knows it has low res content. 4777 // The tiling knows it has low res content.
4778 EXPECT_TRUE(active_layer() 4778 EXPECT_TRUE(active_layer()
4779 ->tilings() 4779 ->tilings()
4780 ->tiling_at(1) 4780 ->tiling_at(1)
4781 ->may_contain_low_resolution_tiles()); 4781 ->may_contain_low_resolution_tiles());
4782 4782
4783 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4783 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4784 4784
4785 // Zoom in to exactly the low res factor so that the previous low res 4785 // Zoom in to exactly the low res factor so that the previous low res
4786 // would be equal to the current high res. 4786 // would be equal to the current high res.
4787 SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res, 4787 SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res,
4788 1.0f, 0.f, false); 4788 1.0f, 0.f, false);
4789 // 3 tilings. The old high res, the new high res (old low res) and the new low 4789 // 3 tilings. The old high res, the new high res (old low res) and the new low
4790 // res. 4790 // res.
4791 EXPECT_EQ(3u, active_layer()->num_tilings()); 4791 EXPECT_EQ(3u, active_layer()->num_tilings());
4792 4792
4793 PictureLayerTilingSet* tilings = active_layer()->tilings(); 4793 PictureLayerTilingSet* tilings = active_layer()->tilings();
4794 EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale_key()); 4794 EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale_key());
4795 EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale_key()); 4795 EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale_key());
4796 EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale_key()); 4796 EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale_key());
4797 4797
4798 EXPECT_EQ(NON_IDEAL_RESOLUTION, tilings->tiling_at(0)->resolution()); 4798 EXPECT_EQ(NON_IDEAL_RESOLUTION, tilings->tiling_at(0)->resolution());
4799 EXPECT_EQ(HIGH_RESOLUTION, tilings->tiling_at(1)->resolution()); 4799 EXPECT_EQ(HIGH_RESOLUTION, tilings->tiling_at(1)->resolution());
4800 EXPECT_EQ(LOW_RESOLUTION, tilings->tiling_at(2)->resolution()); 4800 EXPECT_EQ(LOW_RESOLUTION, tilings->tiling_at(2)->resolution());
4801 4801
4802 // The old low res tile was destroyed and replaced. 4802 // The old low res tile was destroyed and replaced.
4803 EXPECT_EQ(old_low_res_tiling, tilings->tiling_at(1)); 4803 EXPECT_EQ(old_low_res_tiling, tilings->tiling_at(1));
4804 EXPECT_NE(old_low_res_tile, tilings->tiling_at(1)->TileAt(0, 0)); 4804 EXPECT_NE(old_low_res_tile_id, tilings->tiling_at(1)->TileAt(0, 0)->id());
4805 EXPECT_TRUE(tilings->tiling_at(1)->TileAt(0, 0)); 4805 EXPECT_TRUE(tilings->tiling_at(1)->TileAt(0, 0));
4806 4806
4807 // New high res tiling. 4807 // New high res tiling.
4808 EXPECT_FALSE(tilings->tiling_at(0)->may_contain_low_resolution_tiles()); 4808 EXPECT_FALSE(tilings->tiling_at(0)->may_contain_low_resolution_tiles());
4809 // New low res tiling. 4809 // New low res tiling.
4810 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); 4810 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles());
4811 4811
4812 // This tiling will be high res now, it won't contain low res content since it 4812 // This tiling will be high res now, it won't contain low res content since it
4813 // was all destroyed. 4813 // was all destroyed.
4814 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); 4814 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4954 EXPECT_FLOAT_EQ(expected_contents_scale, 4954 EXPECT_FLOAT_EQ(expected_contents_scale,
4955 pending_layer_ptr->picture_layer_tiling_set() 4955 pending_layer_ptr->picture_layer_tiling_set()
4956 ->FindTilingWithResolution(HIGH_RESOLUTION) 4956 ->FindTilingWithResolution(HIGH_RESOLUTION)
4957 ->contents_scale_key()) 4957 ->contents_scale_key())
4958 << "ideal_contents_scale: " << ideal_contents_scale; 4958 << "ideal_contents_scale: " << ideal_contents_scale;
4959 } 4959 }
4960 } 4960 }
4961 4961
4962 } // namespace 4962 } // namespace
4963 } // namespace cc 4963 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/test/fake_picture_layer_tiling_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698