| 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/resources/tile.h" | 5 #include "cc/resources/tile.h" |
| 6 #include "cc/resources/tile_priority.h" | 6 #include "cc/resources/tile_priority.h" |
| 7 #include "cc/test/fake_output_surface.h" | 7 #include "cc/test/fake_output_surface.h" |
| 8 #include "cc/test/fake_output_surface_client.h" | 8 #include "cc/test/fake_output_surface_client.h" |
| 9 #include "cc/test/fake_picture_pile_impl.h" | 9 #include "cc/test/fake_picture_pile_impl.h" |
| 10 #include "cc/test/fake_tile_manager.h" | 10 #include "cc/test/fake_tile_manager.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 state.memory_limit_in_bytes = | 60 state.memory_limit_in_bytes = |
| 61 max_memory_tiles_ * 4 * tile_size.width() * tile_size.height(); | 61 max_memory_tiles_ * 4 * tile_size.width() * tile_size.height(); |
| 62 state.unused_memory_limit_in_bytes = state.memory_limit_in_bytes; | 62 state.unused_memory_limit_in_bytes = state.memory_limit_in_bytes; |
| 63 state.memory_limit_policy = memory_limit_policy_; | 63 state.memory_limit_policy = memory_limit_policy_; |
| 64 state.num_resources_limit = 100; | 64 state.num_resources_limit = 100; |
| 65 state.tree_priority = tree_priority; | 65 state.tree_priority = tree_priority; |
| 66 global_state_ = state; | 66 global_state_ = state; |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void TearDown() OVERRIDE { | 69 virtual void TearDown() OVERRIDE { |
| 70 bundles_.clear(); | |
| 71 tile_manager_.reset(NULL); | 70 tile_manager_.reset(NULL); |
| 72 picture_pile_ = NULL; | 71 picture_pile_ = NULL; |
| 73 | 72 |
| 74 testing::Test::TearDown(); | 73 testing::Test::TearDown(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 TileVector CreateTilesWithSize(int count, | 76 TileVector CreateTilesWithSize(int count, |
| 78 TilePriority active_priority, | 77 TilePriority active_priority, |
| 79 TilePriority pending_priority, | 78 TilePriority pending_priority, |
| 80 gfx::Size tile_size) { | 79 gfx::Size tile_size) { |
| 81 TileVector tiles; | 80 TileVector tiles; |
| 82 for (int i = 0; i < count; ++i) { | 81 for (int i = 0; i < count; ++i) { |
| 83 scoped_refptr<Tile> tile = tile_manager_->CreateTile(picture_pile_.get(), | 82 scoped_refptr<Tile> tile = tile_manager_->CreateTile(picture_pile_.get(), |
| 84 tile_size, | 83 tile_size, |
| 85 gfx::Rect(), | 84 gfx::Rect(), |
| 86 gfx::Rect(), | 85 gfx::Rect(), |
| 87 1.0, | 86 1.0, |
| 88 0, | 87 0, |
| 89 0, | 88 0, |
| 90 Tile::USE_LCD_TEXT); | 89 Tile::USE_LCD_TEXT); |
| 91 scoped_refptr<TileBundle> bundle = | 90 tile->SetPriority(ACTIVE_TREE, active_priority); |
| 92 tile_manager_->CreateTileBundle(0, 0, 1, 1); | 91 tile->SetPriority(PENDING_TREE, pending_priority); |
| 93 bundle->SetPriority(ACTIVE_TREE, active_priority); | |
| 94 bundle->SetPriority(PENDING_TREE, pending_priority); | |
| 95 bundle->AddTileAt(ACTIVE_TREE, 0, 0, tile); | |
| 96 bundle->AddTileAt(PENDING_TREE, 0, 0, tile); | |
| 97 tiles.push_back(tile); | 92 tiles.push_back(tile); |
| 98 bundles_.push_back(bundle); | |
| 99 } | 93 } |
| 100 return tiles; | 94 return tiles; |
| 101 } | 95 } |
| 102 | 96 |
| 103 TileVector CreateTiles(int count, | 97 TileVector CreateTiles(int count, |
| 104 TilePriority active_priority, | 98 TilePriority active_priority, |
| 105 TilePriority pending_priority) { | 99 TilePriority pending_priority) { |
| 106 return CreateTilesWithSize(count, | 100 return CreateTilesWithSize(count, |
| 107 active_priority, | 101 active_priority, |
| 108 pending_priority, | 102 pending_priority, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 private: | 135 private: |
| 142 FakeTileManagerClient tile_manager_client_; | 136 FakeTileManagerClient tile_manager_client_; |
| 143 LayerTreeSettings settings_; | 137 LayerTreeSettings settings_; |
| 144 scoped_ptr<FakeTileManager> tile_manager_; | 138 scoped_ptr<FakeTileManager> tile_manager_; |
| 145 scoped_refptr<FakePicturePileImpl> picture_pile_; | 139 scoped_refptr<FakePicturePileImpl> picture_pile_; |
| 146 FakeOutputSurfaceClient output_surface_client_; | 140 FakeOutputSurfaceClient output_surface_client_; |
| 147 scoped_ptr<FakeOutputSurface> output_surface_; | 141 scoped_ptr<FakeOutputSurface> output_surface_; |
| 148 scoped_ptr<ResourceProvider> resource_provider_; | 142 scoped_ptr<ResourceProvider> resource_provider_; |
| 149 TileMemoryLimitPolicy memory_limit_policy_; | 143 TileMemoryLimitPolicy memory_limit_policy_; |
| 150 int max_memory_tiles_; | 144 int max_memory_tiles_; |
| 151 std::vector<scoped_refptr<TileBundle> > bundles_; | |
| 152 }; | 145 }; |
| 153 | 146 |
| 154 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { | 147 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { |
| 155 // A few tiles of each type of priority, with enough memory for all tiles. | 148 // A few tiles of each type of priority, with enough memory for all tiles. |
| 156 | 149 |
| 157 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 150 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 158 TileVector active_now = | 151 TileVector active_now = |
| 159 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 152 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 160 TileVector pending_now = | 153 TileVector pending_now = |
| 161 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 154 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 } | 521 } |
| 529 | 522 |
| 530 // If true, the max tile limit should be applied as bytes; if false, | 523 // If true, the max tile limit should be applied as bytes; if false, |
| 531 // as num_resources_limit. | 524 // as num_resources_limit. |
| 532 INSTANTIATE_TEST_CASE_P(TileManagerTests, | 525 INSTANTIATE_TEST_CASE_P(TileManagerTests, |
| 533 TileManagerTest, | 526 TileManagerTest, |
| 534 ::testing::Values(true, false)); | 527 ::testing::Values(true, false)); |
| 535 | 528 |
| 536 } // namespace | 529 } // namespace |
| 537 } // namespace cc | 530 } // namespace cc |
| 538 | |
| OLD | NEW |