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