Chromium Code Reviews| 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_impl_proxy.h" | 7 #include "cc/test/fake_impl_proxy.h" |
| 8 #include "cc/test/fake_layer_tree_host_impl.h" | 8 #include "cc/test/fake_layer_tree_host_impl.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 return tiles; | 110 return tiles; |
| 111 } | 111 } |
| 112 | 112 |
| 113 TileVector CreateTiles(int count, | 113 TileVector CreateTiles(int count, |
| 114 TilePriority active_priority, | 114 TilePriority active_priority, |
| 115 TilePriority pending_priority) { | 115 TilePriority pending_priority) { |
| 116 return CreateTilesWithSize( | 116 return CreateTilesWithSize( |
| 117 count, active_priority, pending_priority, settings_.default_tile_size); | 117 count, active_priority, pending_priority, settings_.default_tile_size); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ReleaseTileOnBothTree(TileVector tiles) { | |
|
reveman
2014/07/30 18:41:39
ReleaseTiles(TileVector* tiles)
sohanjg
2014/07/31 13:42:56
Done.
| |
| 121 for (TileVector::iterator it = tiles.begin(); it != tiles.end(); it++) { | |
| 122 Tile* tile = *it; | |
| 123 tile->SetPriority(ACTIVE_TREE, TilePriority()); | |
| 124 tile->SetPriority(PENDING_TREE, TilePriority()); | |
| 125 } | |
| 126 } | |
| 127 | |
| 120 FakeTileManager* tile_manager() { return tile_manager_.get(); } | 128 FakeTileManager* tile_manager() { return tile_manager_.get(); } |
| 121 | 129 |
| 122 int AssignedMemoryCount(const TileVector& tiles) { | 130 int AssignedMemoryCount(const TileVector& tiles) { |
| 123 int has_memory_count = 0; | 131 int has_memory_count = 0; |
| 124 for (TileVector::const_iterator it = tiles.begin(); it != tiles.end(); | 132 for (TileVector::const_iterator it = tiles.begin(); it != tiles.end(); |
| 125 ++it) { | 133 ++it) { |
| 126 if (tile_manager_->HasBeenAssignedMemory(*it)) | 134 if (tile_manager_->HasBeenAssignedMemory(*it)) |
| 127 ++has_memory_count; | 135 ++has_memory_count; |
| 128 } | 136 } |
| 129 return has_memory_count; | 137 return has_memory_count; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 TileVector active_pending_soon = | 173 TileVector active_pending_soon = |
| 166 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 174 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 167 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 175 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 168 | 176 |
| 169 tile_manager()->AssignMemoryToTiles(global_state_); | 177 tile_manager()->AssignMemoryToTiles(global_state_); |
| 170 | 178 |
| 171 EXPECT_EQ(3, AssignedMemoryCount(active_now)); | 179 EXPECT_EQ(3, AssignedMemoryCount(active_now)); |
| 172 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); | 180 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); |
| 173 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); | 181 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); |
| 174 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 182 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
| 183 | |
| 184 ReleaseTileOnBothTree(active_now); | |
| 185 ReleaseTileOnBothTree(pending_now); | |
| 186 ReleaseTileOnBothTree(active_pending_soon); | |
| 187 ReleaseTileOnBothTree(never_bin); | |
| 175 } | 188 } |
| 176 | 189 |
| 177 TEST_P(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { | 190 TEST_P(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { |
| 178 // A few tiles of each type of priority, with enough memory for all tiles, | 191 // A few tiles of each type of priority, with enough memory for all tiles, |
| 179 // with the exception of never bin. | 192 // with the exception of never bin. |
| 180 | 193 |
| 181 Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); | 194 Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); |
| 182 TileVector active_now = | 195 TileVector active_now = |
| 183 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 196 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 184 TileVector pending_now = | 197 TileVector pending_now = |
| 185 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 198 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 186 TileVector active_pending_soon = | 199 TileVector active_pending_soon = |
| 187 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 200 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 188 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 201 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 189 | 202 |
| 190 tile_manager()->AssignMemoryToTiles(global_state_); | 203 tile_manager()->AssignMemoryToTiles(global_state_); |
| 191 | 204 |
| 192 EXPECT_EQ(3, AssignedMemoryCount(active_now)); | 205 EXPECT_EQ(3, AssignedMemoryCount(active_now)); |
| 193 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); | 206 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); |
| 194 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); | 207 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); |
| 195 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 208 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
| 209 | |
| 210 ReleaseTileOnBothTree(active_now); | |
| 211 ReleaseTileOnBothTree(pending_now); | |
| 212 ReleaseTileOnBothTree(active_pending_soon); | |
| 213 ReleaseTileOnBothTree(never_bin); | |
| 196 } | 214 } |
| 197 | 215 |
| 198 TEST_P(TileManagerTest, EnoughMemoryPendingLowResAllowAbsoluteMinimum) { | 216 TEST_P(TileManagerTest, EnoughMemoryPendingLowResAllowAbsoluteMinimum) { |
| 199 // A few low-res tiles required for activation, with enough memory for all | 217 // A few low-res tiles required for activation, with enough memory for all |
| 200 // tiles. | 218 // tiles. |
| 201 | 219 |
| 202 Initialize(5, ALLOW_ABSOLUTE_MINIMUM, SAME_PRIORITY_FOR_BOTH_TREES); | 220 Initialize(5, ALLOW_ABSOLUTE_MINIMUM, SAME_PRIORITY_FOR_BOTH_TREES); |
| 203 TileVector pending_low_res = | 221 TileVector pending_low_res = |
| 204 CreateTiles(5, TilePriority(), TilePriorityLowRes()); | 222 CreateTiles(5, TilePriority(), TilePriorityLowRes()); |
| 205 | 223 |
| 206 tile_manager()->AssignMemoryToTiles(global_state_); | 224 tile_manager()->AssignMemoryToTiles(global_state_); |
| 207 | 225 |
| 208 EXPECT_EQ(5, AssignedMemoryCount(pending_low_res)); | 226 EXPECT_EQ(5, AssignedMemoryCount(pending_low_res)); |
| 227 ReleaseTileOnBothTree(pending_low_res); | |
| 209 } | 228 } |
| 210 | 229 |
| 211 TEST_P(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { | 230 TEST_P(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { |
| 212 // A few tiles of each type of priority, with enough memory for all tiles, | 231 // A few tiles of each type of priority, with enough memory for all tiles, |
| 213 // with the exception of never and soon bins. | 232 // with the exception of never and soon bins. |
| 214 | 233 |
| 215 Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); | 234 Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); |
| 216 TileVector active_now = | 235 TileVector active_now = |
| 217 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 236 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 218 TileVector pending_now = | 237 TileVector pending_now = |
| 219 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 238 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 220 TileVector active_pending_soon = | 239 TileVector active_pending_soon = |
| 221 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 240 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 222 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 241 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 223 | 242 |
| 224 tile_manager()->AssignMemoryToTiles(global_state_); | 243 tile_manager()->AssignMemoryToTiles(global_state_); |
| 225 | 244 |
| 226 EXPECT_EQ(3, AssignedMemoryCount(active_now)); | 245 EXPECT_EQ(3, AssignedMemoryCount(active_now)); |
| 227 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); | 246 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); |
| 228 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); | 247 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); |
| 229 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 248 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
| 249 | |
| 250 ReleaseTileOnBothTree(active_now); | |
| 251 ReleaseTileOnBothTree(pending_now); | |
| 252 ReleaseTileOnBothTree(active_pending_soon); | |
| 253 ReleaseTileOnBothTree(never_bin); | |
| 230 } | 254 } |
| 231 | 255 |
| 232 TEST_P(TileManagerTest, EnoughMemoryAllowNothing) { | 256 TEST_P(TileManagerTest, EnoughMemoryAllowNothing) { |
| 233 // A few tiles of each type of priority, with enough memory for all tiles, | 257 // A few tiles of each type of priority, with enough memory for all tiles, |
| 234 // but allow nothing should not assign any memory. | 258 // but allow nothing should not assign any memory. |
| 235 | 259 |
| 236 Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); | 260 Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 237 TileVector active_now = | 261 TileVector active_now = |
| 238 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 262 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 239 TileVector pending_now = | 263 TileVector pending_now = |
| 240 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 264 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 241 TileVector active_pending_soon = | 265 TileVector active_pending_soon = |
| 242 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 266 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 243 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 267 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 244 | 268 |
| 245 tile_manager()->AssignMemoryToTiles(global_state_); | 269 tile_manager()->AssignMemoryToTiles(global_state_); |
| 246 | 270 |
| 247 EXPECT_EQ(0, AssignedMemoryCount(active_now)); | 271 EXPECT_EQ(0, AssignedMemoryCount(active_now)); |
| 248 EXPECT_EQ(0, AssignedMemoryCount(pending_now)); | 272 EXPECT_EQ(0, AssignedMemoryCount(pending_now)); |
| 249 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); | 273 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); |
| 250 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 274 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
| 275 | |
| 276 ReleaseTileOnBothTree(active_now); | |
| 277 ReleaseTileOnBothTree(pending_now); | |
| 278 ReleaseTileOnBothTree(active_pending_soon); | |
| 279 ReleaseTileOnBothTree(never_bin); | |
| 251 } | 280 } |
| 252 | 281 |
| 253 TEST_P(TileManagerTest, PartialOOMMemoryToPending) { | 282 TEST_P(TileManagerTest, PartialOOMMemoryToPending) { |
| 254 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are | 283 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are |
| 255 // required for activation, but only enough memory for 8 tiles. The result | 284 // required for activation, but only enough memory for 8 tiles. The result |
| 256 // is all pending tree tiles get memory, and 3 of the active tree tiles | 285 // is all pending tree tiles get memory, and 3 of the active tree tiles |
| 257 // get memory. None of these tiles is needed to avoid calimity (flickering or | 286 // get memory. None of these tiles is needed to avoid calimity (flickering or |
| 258 // raster-on-demand) so the soft memory limit is used. | 287 // raster-on-demand) so the soft memory limit is used. |
| 259 | 288 |
| 260 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 289 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 261 TileVector active_tree_tiles = | 290 TileVector active_tree_tiles = |
| 262 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); | 291 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); |
| 263 TileVector pending_tree_tiles = | 292 TileVector pending_tree_tiles = |
| 264 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); | 293 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
| 265 tile_manager()->AssignMemoryToTiles(global_state_); | 294 tile_manager()->AssignMemoryToTiles(global_state_); |
| 266 | 295 |
| 267 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); | 296 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); |
| 268 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); | 297 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); |
| 269 | 298 |
| 270 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 299 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 271 tile_manager()->AssignMemoryToTiles(global_state_); | 300 tile_manager()->AssignMemoryToTiles(global_state_); |
| 272 | 301 |
| 273 EXPECT_EQ(3, AssignedMemoryCount(active_tree_tiles)); | 302 EXPECT_EQ(3, AssignedMemoryCount(active_tree_tiles)); |
| 274 EXPECT_EQ(5, AssignedMemoryCount(pending_tree_tiles)); | 303 EXPECT_EQ(5, AssignedMemoryCount(pending_tree_tiles)); |
| 304 | |
| 305 ReleaseTileOnBothTree(active_tree_tiles); | |
| 306 ReleaseTileOnBothTree(pending_tree_tiles); | |
| 275 } | 307 } |
| 276 | 308 |
| 277 TEST_P(TileManagerTest, PartialOOMMemoryToActive) { | 309 TEST_P(TileManagerTest, PartialOOMMemoryToActive) { |
| 278 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, | 310 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
| 279 // but only enough memory for 8 tiles. The result is all active tree tiles | 311 // but only enough memory for 8 tiles. The result is all active tree tiles |
| 280 // get memory, and 3 of the pending tree tiles get memory. | 312 // get memory, and 3 of the pending tree tiles get memory. |
| 281 // The pending tiles are not needed to avoid calimity (flickering or | 313 // The pending tiles are not needed to avoid calimity (flickering or |
| 282 // raster-on-demand) and the active tiles fit, so the soft limit is used. | 314 // raster-on-demand) and the active tiles fit, so the soft limit is used. |
| 283 | 315 |
| 284 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 316 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 285 TileVector active_tree_tiles = | 317 TileVector active_tree_tiles = |
| 286 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); | 318 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); |
| 287 TileVector pending_tree_tiles = | 319 TileVector pending_tree_tiles = |
| 288 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); | 320 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
| 289 | 321 |
| 290 tile_manager()->AssignMemoryToTiles(global_state_); | 322 tile_manager()->AssignMemoryToTiles(global_state_); |
| 291 | 323 |
| 292 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); | 324 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); |
| 293 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); | 325 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); |
| 326 | |
| 327 ReleaseTileOnBothTree(active_tree_tiles); | |
| 328 ReleaseTileOnBothTree(pending_tree_tiles); | |
| 294 } | 329 } |
| 295 | 330 |
| 296 TEST_P(TileManagerTest, TotalOOMMemoryToPending) { | 331 TEST_P(TileManagerTest, TotalOOMMemoryToPending) { |
| 297 // 10 tiles on active tree eventually bin, 10 tiles on pending tree that are | 332 // 10 tiles on active tree eventually bin, 10 tiles on pending tree that are |
| 298 // required for activation, but only enough tiles for 4 tiles. The result | 333 // required for activation, but only enough tiles for 4 tiles. The result |
| 299 // is 4 pending tree tiles get memory, and none of the active tree tiles | 334 // is 4 pending tree tiles get memory, and none of the active tree tiles |
| 300 // get memory. | 335 // get memory. |
| 301 | 336 |
| 302 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 337 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 303 TileVector active_tree_tiles = | 338 TileVector active_tree_tiles = |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 315 | 350 |
| 316 if (UsingResourceLimit()) { | 351 if (UsingResourceLimit()) { |
| 317 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 352 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
| 318 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); | 353 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); |
| 319 } else { | 354 } else { |
| 320 // Pending tiles are now required to avoid calimity (flickering or | 355 // Pending tiles are now required to avoid calimity (flickering or |
| 321 // raster-on-demand). Hard-limit is used and double the tiles fit. | 356 // raster-on-demand). Hard-limit is used and double the tiles fit. |
| 322 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 357 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
| 323 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); | 358 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); |
| 324 } | 359 } |
| 360 | |
| 361 ReleaseTileOnBothTree(active_tree_tiles); | |
| 362 ReleaseTileOnBothTree(pending_tree_tiles); | |
| 325 } | 363 } |
| 326 | 364 |
| 327 TEST_P(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { | 365 TEST_P(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { |
| 328 // 10 tiles on active tree soon bin, 10 tiles on pending tree that are | 366 // 10 tiles on active tree soon bin, 10 tiles on pending tree that are |
| 329 // required for activation, but only enough tiles for 4 tiles. The result | 367 // required for activation, but only enough tiles for 4 tiles. The result |
| 330 // is 4 pending tree tiles get memory, and none of the active tree tiles | 368 // is 4 pending tree tiles get memory, and none of the active tree tiles |
| 331 // get memory. | 369 // get memory. |
| 332 | 370 |
| 333 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 371 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 334 TileVector active_tree_tiles = | 372 TileVector active_tree_tiles = |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 346 | 384 |
| 347 if (UsingResourceLimit()) { | 385 if (UsingResourceLimit()) { |
| 348 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 386 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
| 349 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); | 387 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); |
| 350 } else { | 388 } else { |
| 351 // Pending tiles are now required to avoid calimity (flickering or | 389 // Pending tiles are now required to avoid calimity (flickering or |
| 352 // raster-on-demand). Hard-limit is used and double the tiles fit. | 390 // raster-on-demand). Hard-limit is used and double the tiles fit. |
| 353 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 391 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
| 354 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); | 392 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); |
| 355 } | 393 } |
| 394 | |
| 395 ReleaseTileOnBothTree(active_tree_tiles); | |
| 396 ReleaseTileOnBothTree(pending_tree_tiles); | |
| 356 } | 397 } |
| 357 | 398 |
| 358 TEST_P(TileManagerTest, TotalOOMMemoryToActive) { | 399 TEST_P(TileManagerTest, TotalOOMMemoryToActive) { |
| 359 // 10 tiles on active tree eventually bin, 10 tiles on pending tree now bin, | 400 // 10 tiles on active tree eventually bin, 10 tiles on pending tree now bin, |
| 360 // but only enough memory for 4 tiles. The result is 4 active tree tiles | 401 // but only enough memory for 4 tiles. The result is 4 active tree tiles |
| 361 // get memory, and none of the pending tree tiles get memory. | 402 // get memory, and none of the pending tree tiles get memory. |
| 362 | 403 |
| 363 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 404 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 364 TileVector active_tree_tiles = | 405 TileVector active_tree_tiles = |
| 365 CreateTiles(10, TilePriorityForNowBin(), TilePriority()); | 406 CreateTiles(10, TilePriorityForNowBin(), TilePriority()); |
| 366 TileVector pending_tree_tiles = | 407 TileVector pending_tree_tiles = |
| 367 CreateTiles(10, TilePriority(), TilePriorityForNowBin()); | 408 CreateTiles(10, TilePriority(), TilePriorityForNowBin()); |
| 368 | 409 |
| 369 tile_manager()->AssignMemoryToTiles(global_state_); | 410 tile_manager()->AssignMemoryToTiles(global_state_); |
| 370 | 411 |
| 371 if (UsingResourceLimit()) { | 412 if (UsingResourceLimit()) { |
| 372 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); | 413 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); |
| 373 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 414 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
| 374 } else { | 415 } else { |
| 375 // Active tiles are required to avoid calimity (flickering or | 416 // Active tiles are required to avoid calimity (flickering or |
| 376 // raster-on-demand). Hard-limit is used and double the tiles fit. | 417 // raster-on-demand). Hard-limit is used and double the tiles fit. |
| 377 EXPECT_EQ(8, AssignedMemoryCount(active_tree_tiles)); | 418 EXPECT_EQ(8, AssignedMemoryCount(active_tree_tiles)); |
| 378 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 419 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
| 379 } | 420 } |
| 421 | |
| 422 ReleaseTileOnBothTree(active_tree_tiles); | |
| 423 ReleaseTileOnBothTree(pending_tree_tiles); | |
| 380 } | 424 } |
| 381 | 425 |
| 382 TEST_P(TileManagerTest, TotalOOMMemoryToNewContent) { | 426 TEST_P(TileManagerTest, TotalOOMMemoryToNewContent) { |
| 383 // 10 tiles on active tree now bin, 10 tiles on pending tree now bin, | 427 // 10 tiles on active tree now bin, 10 tiles on pending tree now bin, |
| 384 // but only enough memory for 8 tiles. Any tile missing would cause | 428 // but only enough memory for 8 tiles. Any tile missing would cause |
| 385 // a calamity (flickering or raster-on-demand). Depending on mode, | 429 // a calamity (flickering or raster-on-demand). Depending on mode, |
| 386 // we should use varying amounts of the higher hard memory limit. | 430 // we should use varying amounts of the higher hard memory limit. |
| 387 if (UsingResourceLimit()) | 431 if (UsingResourceLimit()) |
| 388 return; | 432 return; |
| 389 | 433 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 409 AssignedMemoryCount(active_tree_tiles) + | 453 AssignedMemoryCount(active_tree_tiles) + |
| 410 AssignedMemoryCount(pending_tree_tiles)); | 454 AssignedMemoryCount(pending_tree_tiles)); |
| 411 | 455 |
| 412 // The pending tree is now more important. Active tiles will take higher | 456 // The pending tree is now more important. Active tiles will take higher |
| 413 // priority if they are ready-to-draw in practice. Importantly though, | 457 // priority if they are ready-to-draw in practice. Importantly though, |
| 414 // pending tiles also utilize the hard-limit. | 458 // pending tiles also utilize the hard-limit. |
| 415 SetTreePriority(NEW_CONTENT_TAKES_PRIORITY); | 459 SetTreePriority(NEW_CONTENT_TAKES_PRIORITY); |
| 416 tile_manager()->AssignMemoryToTiles(global_state_); | 460 tile_manager()->AssignMemoryToTiles(global_state_); |
| 417 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 461 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
| 418 EXPECT_EQ(10, AssignedMemoryCount(pending_tree_tiles)); | 462 EXPECT_EQ(10, AssignedMemoryCount(pending_tree_tiles)); |
| 463 | |
| 464 ReleaseTileOnBothTree(active_tree_tiles); | |
| 465 ReleaseTileOnBothTree(pending_tree_tiles); | |
| 419 } | 466 } |
| 420 | 467 |
| 421 // If true, the max tile limit should be applied as bytes; if false, | 468 // If true, the max tile limit should be applied as bytes; if false, |
| 422 // as num_resources_limit. | 469 // as num_resources_limit. |
| 423 INSTANTIATE_TEST_CASE_P(TileManagerTests, | 470 INSTANTIATE_TEST_CASE_P(TileManagerTests, |
| 424 TileManagerTest, | 471 TileManagerTest, |
| 425 ::testing::Values(true, false)); | 472 ::testing::Values(true, false)); |
| 426 | 473 |
| 427 class TileManagerTileIteratorTest : public testing::Test { | 474 class TileManagerTileIteratorTest : public testing::Test { |
| 428 public: | 475 public: |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1099 } | 1146 } |
| 1100 } | 1147 } |
| 1101 last_tile = tile; | 1148 last_tile = tile; |
| 1102 } | 1149 } |
| 1103 size_t expected_occluded_count = | 1150 size_t expected_occluded_count = |
| 1104 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size(); | 1151 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size(); |
| 1105 EXPECT_EQ(expected_occluded_count, occluded_count); | 1152 EXPECT_EQ(expected_occluded_count, occluded_count); |
| 1106 } | 1153 } |
| 1107 } // namespace | 1154 } // namespace |
| 1108 } // namespace cc | 1155 } // namespace cc |
| OLD | NEW |