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