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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "cc/resources/managed_tile_state.h" | 8 #include "cc/resources/managed_tile_state.h" |
9 #include "cc/resources/prioritized_tile_set.h" | 9 #include "cc/resources/prioritized_tile_set.h" |
10 #include "cc/resources/tile.h" | 10 #include "cc/resources/tile.h" |
11 #include "cc/test/fake_output_surface.h" | 11 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_output_surface_client.h" | 12 #include "cc/test/fake_output_surface_client.h" |
13 #include "cc/test/fake_picture_pile_impl.h" | 13 #include "cc/test/fake_picture_pile_impl.h" |
14 #include "cc/test/fake_tile_manager.h" | 14 #include "cc/test/fake_tile_manager.h" |
15 #include "cc/test/fake_tile_manager_client.h" | 15 #include "cc/test/fake_tile_manager_client.h" |
16 #include "cc/test/test_tile_priorities.h" | 16 #include "cc/test/test_tile_priorities.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class BinComparator { | 21 class BinComparator { |
22 public: | 22 public: |
23 bool operator()(const scoped_refptr<Tile>& a, | 23 bool operator()(const scoped_refptr<Tile>& a, |
24 const scoped_refptr<Tile>& b) const { | 24 const scoped_refptr<Tile>& b) const { |
25 const ManagedTileState& ams = a->managed_state(); | 25 const ManagedTileState& ams = a->managed_state(); |
26 const ManagedTileState& bms = b->managed_state(); | 26 const ManagedTileState& bms = b->managed_state(); |
27 | 27 |
28 if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) | |
29 return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; | |
30 | |
31 if (ams.required_for_activation != bms.required_for_activation) | 28 if (ams.required_for_activation != bms.required_for_activation) |
32 return ams.required_for_activation; | 29 return ams.required_for_activation; |
33 | 30 |
34 if (ams.resolution != bms.resolution) | 31 if (ams.resolution != bms.resolution) |
35 return ams.resolution < bms.resolution; | 32 return ams.resolution < bms.resolution; |
36 | 33 |
37 if (ams.time_to_needed_in_seconds != bms.time_to_needed_in_seconds) | 34 if (ams.time_to_needed_in_seconds != bms.time_to_needed_in_seconds) |
38 return ams.time_to_needed_in_seconds < bms.time_to_needed_in_seconds; | 35 return ams.time_to_needed_in_seconds < bms.time_to_needed_in_seconds; |
39 | 36 |
40 if (ams.distance_to_visible_in_pixels != | 37 if (ams.distance_to_visible_in_pixels != |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 int i = 0; | 300 int i = 0; |
304 for (PrioritizedTileSet::Iterator it(&set, true); | 301 for (PrioritizedTileSet::Iterator it(&set, true); |
305 it; | 302 it; |
306 ++it) { | 303 ++it) { |
307 EXPECT_TRUE(*it == tiles[i].get()); | 304 EXPECT_TRUE(*it == tiles[i].get()); |
308 ++i; | 305 ++i; |
309 } | 306 } |
310 EXPECT_EQ(20, i); | 307 EXPECT_EQ(20, i); |
311 } | 308 } |
312 | 309 |
313 TEST_F(PrioritizedTileSetTest, NeverAndActiveBin) { | 310 TEST_F(PrioritizedTileSetTest, AtLastAndActiveBin) { |
314 // Ensure that NEVER_AND_ACTIVE_BIN tiles are sorted. | 311 // Ensure that AT_LAST_AND_ACTIVE_BIN tiles are sorted. |
315 | 312 |
316 PrioritizedTileSet set; | 313 PrioritizedTileSet set; |
317 TilePriority priorities[4] = { | 314 TilePriority priorities[4] = { |
318 TilePriorityForEventualBin(), | 315 TilePriorityForEventualBin(), |
319 TilePriorityForNowBin(), | 316 TilePriorityForNowBin(), |
320 TilePriority(), | 317 TilePriority(), |
321 TilePriorityForSoonBin()}; | 318 TilePriorityForSoonBin()}; |
322 | 319 |
323 std::vector<scoped_refptr<Tile> > tiles; | 320 std::vector<scoped_refptr<Tile> > tiles; |
324 for (int priority = 0; priority < 4; ++priority) { | 321 for (int priority = 0; priority < 4; ++priority) { |
325 for (int i = 0; i < 5; ++i) { | 322 for (int i = 0; i < 5; ++i) { |
326 scoped_refptr<Tile> tile = CreateTile(); | 323 scoped_refptr<Tile> tile = CreateTile(); |
327 tile->SetPriority(ACTIVE_TREE, priorities[priority]); | 324 tile->SetPriority(ACTIVE_TREE, priorities[priority]); |
328 tile->SetPriority(PENDING_TREE, priorities[priority]); | 325 tile->SetPriority(PENDING_TREE, priorities[priority]); |
329 tiles.push_back(tile); | 326 tiles.push_back(tile); |
330 set.InsertTile(tile, NEVER_AND_ACTIVE_BIN); | 327 set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); |
331 } | 328 } |
332 } | 329 } |
333 | 330 |
334 // Tiles should appear in BinComparator order. | 331 // Tiles should appear in BinComparator order. |
335 std::sort(tiles.begin(), tiles.end(), BinComparator()); | 332 std::sort(tiles.begin(), tiles.end(), BinComparator()); |
336 | 333 |
337 int i = 0; | 334 int i = 0; |
338 for (PrioritizedTileSet::Iterator it(&set, true); | 335 for (PrioritizedTileSet::Iterator it(&set, true); |
339 it; | 336 it; |
340 ++it) { | 337 ++it) { |
341 EXPECT_TRUE(*it == tiles[i].get()); | 338 EXPECT_TRUE(*it == tiles[i].get()); |
342 ++i; | 339 ++i; |
343 } | 340 } |
344 EXPECT_EQ(20, i); | 341 EXPECT_EQ(20, i); |
345 } | 342 } |
346 | 343 |
347 TEST_F(PrioritizedTileSetTest, NeverBin) { | 344 TEST_F(PrioritizedTileSetTest, AtLastBin) { |
348 // Ensure that NEVER_BIN tiles are sorted, since they might not | 345 // Ensure that AT_LAST_BIN tiles are sorted. |
349 // be NEVER_BIN on a LOW_PRIORITY tree. | |
350 | 346 |
351 PrioritizedTileSet set; | 347 PrioritizedTileSet set; |
352 TilePriority priorities[4] = { | 348 TilePriority priorities[4] = { |
353 TilePriorityForEventualBin(), | 349 TilePriorityForEventualBin(), |
354 TilePriorityForNowBin(), | 350 TilePriorityForNowBin(), |
355 TilePriority(), | 351 TilePriority(), |
356 TilePriorityForSoonBin()}; | 352 TilePriorityForSoonBin()}; |
357 | 353 |
358 std::vector<scoped_refptr<Tile> > tiles; | 354 std::vector<scoped_refptr<Tile> > tiles; |
359 for (int priority = 0; priority < 4; ++priority) { | 355 for (int priority = 0; priority < 4; ++priority) { |
360 for (int i = 0; i < 5; ++i) { | 356 for (int i = 0; i < 5; ++i) { |
361 scoped_refptr<Tile> tile = CreateTile(); | 357 scoped_refptr<Tile> tile = CreateTile(); |
362 tile->SetPriority(ACTIVE_TREE, priorities[priority]); | 358 tile->SetPriority(ACTIVE_TREE, priorities[priority]); |
363 tile->SetPriority(PENDING_TREE, priorities[priority]); | 359 tile->SetPriority(PENDING_TREE, priorities[priority]); |
364 tiles.push_back(tile); | 360 tiles.push_back(tile); |
365 set.InsertTile(tile, NEVER_BIN); | 361 set.InsertTile(tile, AT_LAST_BIN); |
366 } | 362 } |
367 } | 363 } |
368 | 364 |
369 // Tiles should appear in BinComparator order. | 365 // Tiles should appear in BinComparator order. |
370 std::sort(tiles.begin(), tiles.end(), BinComparator()); | 366 std::sort(tiles.begin(), tiles.end(), BinComparator()); |
371 | 367 |
372 int i = 0; | 368 int i = 0; |
373 for (PrioritizedTileSet::Iterator it(&set, true); | 369 for (PrioritizedTileSet::Iterator it(&set, true); |
374 it; | 370 it; |
375 ++it) { | 371 ++it) { |
376 EXPECT_TRUE(*it == tiles[i].get()); | 372 EXPECT_TRUE(*it == tiles[i].get()); |
377 ++i; | 373 ++i; |
378 } | 374 } |
379 EXPECT_EQ(20, i); | 375 EXPECT_EQ(20, i); |
380 } | 376 } |
381 | 377 |
382 TEST_F(PrioritizedTileSetTest, TilesForEachBin) { | 378 TEST_F(PrioritizedTileSetTest, TilesForEachBin) { |
383 // Aggregate test with one tile for each of the bins, which | 379 // Aggregate test with one tile for each of the bins, which |
384 // should appear in order of the bins. | 380 // should appear in order of the bins. |
385 | 381 |
386 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); | 382 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); |
387 scoped_refptr<Tile> now_bin = CreateTile(); | 383 scoped_refptr<Tile> now_bin = CreateTile(); |
388 scoped_refptr<Tile> soon_bin = CreateTile(); | 384 scoped_refptr<Tile> soon_bin = CreateTile(); |
389 scoped_refptr<Tile> eventually_and_active_bin = CreateTile(); | 385 scoped_refptr<Tile> eventually_and_active_bin = CreateTile(); |
390 scoped_refptr<Tile> eventually_bin = CreateTile(); | 386 scoped_refptr<Tile> eventually_bin = CreateTile(); |
391 scoped_refptr<Tile> never_bin = CreateTile(); | 387 scoped_refptr<Tile> at_last_bin = CreateTile(); |
392 scoped_refptr<Tile> never_and_active_bin = CreateTile(); | 388 scoped_refptr<Tile> at_last_and_active_bin = CreateTile(); |
393 | 389 |
394 PrioritizedTileSet set; | 390 PrioritizedTileSet set; |
395 set.InsertTile(soon_bin, SOON_BIN); | 391 set.InsertTile(soon_bin, SOON_BIN); |
396 set.InsertTile(never_and_active_bin, NEVER_AND_ACTIVE_BIN); | 392 set.InsertTile(at_last_and_active_bin, AT_LAST_AND_ACTIVE_BIN); |
397 set.InsertTile(eventually_bin, EVENTUALLY_BIN); | 393 set.InsertTile(eventually_bin, EVENTUALLY_BIN); |
398 set.InsertTile(now_bin, NOW_BIN); | 394 set.InsertTile(now_bin, NOW_BIN); |
399 set.InsertTile(eventually_and_active_bin, EVENTUALLY_AND_ACTIVE_BIN); | 395 set.InsertTile(eventually_and_active_bin, EVENTUALLY_AND_ACTIVE_BIN); |
400 set.InsertTile(never_bin, NEVER_BIN); | 396 set.InsertTile(at_last_bin, AT_LAST_BIN); |
401 set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); | 397 set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); |
402 | 398 |
403 // Tiles should appear in order. | 399 // Tiles should appear in order. |
404 PrioritizedTileSet::Iterator it(&set, true); | 400 PrioritizedTileSet::Iterator it(&set, true); |
405 EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); | 401 EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); |
406 ++it; | 402 ++it; |
407 EXPECT_TRUE(*it == now_bin.get()); | 403 EXPECT_TRUE(*it == now_bin.get()); |
408 ++it; | 404 ++it; |
409 EXPECT_TRUE(*it == soon_bin.get()); | 405 EXPECT_TRUE(*it == soon_bin.get()); |
410 ++it; | 406 ++it; |
411 EXPECT_TRUE(*it == eventually_and_active_bin.get()); | 407 EXPECT_TRUE(*it == eventually_and_active_bin.get()); |
412 ++it; | 408 ++it; |
413 EXPECT_TRUE(*it == eventually_bin.get()); | 409 EXPECT_TRUE(*it == eventually_bin.get()); |
414 ++it; | 410 ++it; |
415 EXPECT_TRUE(*it == never_and_active_bin.get()); | 411 EXPECT_TRUE(*it == at_last_and_active_bin.get()); |
416 ++it; | 412 ++it; |
417 EXPECT_TRUE(*it == never_bin.get()); | 413 EXPECT_TRUE(*it == at_last_bin.get()); |
418 ++it; | 414 ++it; |
419 EXPECT_FALSE(it); | 415 EXPECT_FALSE(it); |
420 } | 416 } |
421 | 417 |
422 TEST_F(PrioritizedTileSetTest, ManyTilesForEachBin) { | 418 TEST_F(PrioritizedTileSetTest, ManyTilesForEachBin) { |
423 // Aggregate test with many tiles in each of the bins of various | 419 // Aggregate test with many tiles in each of the bins of various |
424 // priorities. Ensure that they are all returned in a sorted order. | 420 // priorities. Ensure that they are all returned in a sorted order. |
425 | 421 |
426 std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; | 422 std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; |
427 std::vector<scoped_refptr<Tile> > now_bins; | 423 std::vector<scoped_refptr<Tile> > now_bins; |
428 std::vector<scoped_refptr<Tile> > soon_bins; | 424 std::vector<scoped_refptr<Tile> > soon_bins; |
429 std::vector<scoped_refptr<Tile> > eventually_and_active_bins; | 425 std::vector<scoped_refptr<Tile> > eventually_and_active_bins; |
430 std::vector<scoped_refptr<Tile> > eventually_bins; | 426 std::vector<scoped_refptr<Tile> > eventually_bins; |
431 std::vector<scoped_refptr<Tile> > never_bins; | 427 std::vector<scoped_refptr<Tile> > at_last_bins; |
432 std::vector<scoped_refptr<Tile> > never_and_active_bins; | 428 std::vector<scoped_refptr<Tile> > at_last_and_active_bins; |
433 | 429 |
434 TilePriority priorities[4] = { | 430 TilePriority priorities[4] = { |
435 TilePriorityForEventualBin(), | 431 TilePriorityForEventualBin(), |
436 TilePriorityForNowBin(), | 432 TilePriorityForNowBin(), |
437 TilePriority(), | 433 TilePriority(), |
438 TilePriorityForSoonBin()}; | 434 TilePriorityForSoonBin()}; |
439 | 435 |
440 PrioritizedTileSet set; | 436 PrioritizedTileSet set; |
441 for (int priority = 0; priority < 4; ++priority) { | 437 for (int priority = 0; priority < 4; ++priority) { |
442 for (int i = 0; i < 5; ++i) { | 438 for (int i = 0; i < 5; ++i) { |
443 scoped_refptr<Tile> tile = CreateTile(); | 439 scoped_refptr<Tile> tile = CreateTile(); |
444 tile->SetPriority(ACTIVE_TREE, priorities[priority]); | 440 tile->SetPriority(ACTIVE_TREE, priorities[priority]); |
445 tile->SetPriority(PENDING_TREE, priorities[priority]); | 441 tile->SetPriority(PENDING_TREE, priorities[priority]); |
446 | 442 |
447 now_and_ready_to_draw_bins.push_back(tile); | 443 now_and_ready_to_draw_bins.push_back(tile); |
448 now_bins.push_back(tile); | 444 now_bins.push_back(tile); |
449 soon_bins.push_back(tile); | 445 soon_bins.push_back(tile); |
450 eventually_and_active_bins.push_back(tile); | 446 eventually_and_active_bins.push_back(tile); |
451 eventually_bins.push_back(tile); | 447 eventually_bins.push_back(tile); |
452 never_bins.push_back(tile); | 448 at_last_bins.push_back(tile); |
453 never_and_active_bins.push_back(tile); | 449 at_last_and_active_bins.push_back(tile); |
454 | 450 |
455 set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); | 451 set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); |
456 set.InsertTile(tile, NOW_BIN); | 452 set.InsertTile(tile, NOW_BIN); |
457 set.InsertTile(tile, SOON_BIN); | 453 set.InsertTile(tile, SOON_BIN); |
458 set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); | 454 set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); |
459 set.InsertTile(tile, EVENTUALLY_BIN); | 455 set.InsertTile(tile, EVENTUALLY_BIN); |
460 set.InsertTile(tile, NEVER_BIN); | 456 set.InsertTile(tile, AT_LAST_BIN); |
461 set.InsertTile(tile, NEVER_AND_ACTIVE_BIN); | 457 set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); |
462 } | 458 } |
463 } | 459 } |
464 | 460 |
465 PrioritizedTileSet::Iterator it(&set, true); | 461 PrioritizedTileSet::Iterator it(&set, true); |
466 std::vector<scoped_refptr<Tile> >::iterator vector_it; | 462 std::vector<scoped_refptr<Tile> >::iterator vector_it; |
467 | 463 |
468 // Now and ready are not sorted. | 464 // Now and ready are not sorted. |
469 for (vector_it = now_and_ready_to_draw_bins.begin(); | 465 for (vector_it = now_and_ready_to_draw_bins.begin(); |
470 vector_it != now_and_ready_to_draw_bins.end(); | 466 vector_it != now_and_ready_to_draw_bins.end(); |
471 ++vector_it) { | 467 ++vector_it) { |
(...skipping 28 matching lines...) Expand all Loading... |
500 } | 496 } |
501 | 497 |
502 // Eventually bins are sorted. | 498 // Eventually bins are sorted. |
503 std::sort(eventually_bins.begin(), eventually_bins.end(), BinComparator()); | 499 std::sort(eventually_bins.begin(), eventually_bins.end(), BinComparator()); |
504 for (vector_it = eventually_bins.begin(); vector_it != eventually_bins.end(); | 500 for (vector_it = eventually_bins.begin(); vector_it != eventually_bins.end(); |
505 ++vector_it) { | 501 ++vector_it) { |
506 EXPECT_TRUE(*vector_it == *it); | 502 EXPECT_TRUE(*vector_it == *it); |
507 ++it; | 503 ++it; |
508 } | 504 } |
509 | 505 |
510 // Never and active bins are sorted. | 506 // At last and active bins are sorted. |
511 std::sort(never_and_active_bins.begin(), | 507 std::sort(at_last_and_active_bins.begin(), |
512 never_and_active_bins.end(), | 508 at_last_and_active_bins.end(), |
513 BinComparator()); | 509 BinComparator()); |
514 for (vector_it = never_and_active_bins.begin(); | 510 for (vector_it = at_last_and_active_bins.begin(); |
515 vector_it != never_and_active_bins.end(); | 511 vector_it != at_last_and_active_bins.end(); |
516 ++vector_it) { | 512 ++vector_it) { |
517 EXPECT_TRUE(*vector_it == *it); | 513 EXPECT_TRUE(*vector_it == *it); |
518 ++it; | 514 ++it; |
519 } | 515 } |
520 | 516 |
521 // Never bins are sorted. | 517 // At last bins are sorted. |
522 std::sort(never_bins.begin(), never_bins.end(), BinComparator()); | 518 std::sort(at_last_bins.begin(), at_last_bins.end(), BinComparator()); |
523 for (vector_it = never_bins.begin(); vector_it != never_bins.end(); | 519 for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); |
524 ++vector_it) { | 520 ++vector_it) { |
525 EXPECT_TRUE(*vector_it == *it); | 521 EXPECT_TRUE(*vector_it == *it); |
526 ++it; | 522 ++it; |
527 } | 523 } |
528 | 524 |
529 EXPECT_FALSE(it); | 525 EXPECT_FALSE(it); |
530 } | 526 } |
531 | 527 |
532 TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { | 528 TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { |
533 // Aggregate test with many tiles for each of the bins. Tiles should | 529 // Aggregate test with many tiles for each of the bins. Tiles should |
534 // appear in order, until DisablePriorityOrdering is called. After that | 530 // appear in order, until DisablePriorityOrdering is called. After that |
535 // tiles should appear in the order they were inserted. | 531 // tiles should appear in the order they were inserted. |
536 | 532 |
537 std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; | 533 std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; |
538 std::vector<scoped_refptr<Tile> > now_bins; | 534 std::vector<scoped_refptr<Tile> > now_bins; |
539 std::vector<scoped_refptr<Tile> > soon_bins; | 535 std::vector<scoped_refptr<Tile> > soon_bins; |
540 std::vector<scoped_refptr<Tile> > eventually_and_active_bins; | 536 std::vector<scoped_refptr<Tile> > eventually_and_active_bins; |
541 std::vector<scoped_refptr<Tile> > eventually_bins; | 537 std::vector<scoped_refptr<Tile> > eventually_bins; |
542 std::vector<scoped_refptr<Tile> > never_bins; | 538 std::vector<scoped_refptr<Tile> > at_last_bins; |
543 std::vector<scoped_refptr<Tile> > never_and_active_bins; | 539 std::vector<scoped_refptr<Tile> > at_last_and_active_bins; |
544 | 540 |
545 TilePriority priorities[4] = { | 541 TilePriority priorities[4] = { |
546 TilePriorityForEventualBin(), | 542 TilePriorityForEventualBin(), |
547 TilePriorityForNowBin(), | 543 TilePriorityForNowBin(), |
548 TilePriority(), | 544 TilePriority(), |
549 TilePriorityForSoonBin()}; | 545 TilePriorityForSoonBin()}; |
550 | 546 |
551 PrioritizedTileSet set; | 547 PrioritizedTileSet set; |
552 for (int priority = 0; priority < 4; ++priority) { | 548 for (int priority = 0; priority < 4; ++priority) { |
553 for (int i = 0; i < 5; ++i) { | 549 for (int i = 0; i < 5; ++i) { |
554 scoped_refptr<Tile> tile = CreateTile(); | 550 scoped_refptr<Tile> tile = CreateTile(); |
555 tile->SetPriority(ACTIVE_TREE, priorities[priority]); | 551 tile->SetPriority(ACTIVE_TREE, priorities[priority]); |
556 tile->SetPriority(PENDING_TREE, priorities[priority]); | 552 tile->SetPriority(PENDING_TREE, priorities[priority]); |
557 | 553 |
558 now_and_ready_to_draw_bins.push_back(tile); | 554 now_and_ready_to_draw_bins.push_back(tile); |
559 now_bins.push_back(tile); | 555 now_bins.push_back(tile); |
560 soon_bins.push_back(tile); | 556 soon_bins.push_back(tile); |
561 eventually_and_active_bins.push_back(tile); | 557 eventually_and_active_bins.push_back(tile); |
562 eventually_bins.push_back(tile); | 558 eventually_bins.push_back(tile); |
563 never_bins.push_back(tile); | 559 at_last_bins.push_back(tile); |
564 never_and_active_bins.push_back(tile); | 560 at_last_and_active_bins.push_back(tile); |
565 | 561 |
566 set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); | 562 set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); |
567 set.InsertTile(tile, NOW_BIN); | 563 set.InsertTile(tile, NOW_BIN); |
568 set.InsertTile(tile, SOON_BIN); | 564 set.InsertTile(tile, SOON_BIN); |
569 set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); | 565 set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); |
570 set.InsertTile(tile, EVENTUALLY_BIN); | 566 set.InsertTile(tile, EVENTUALLY_BIN); |
571 set.InsertTile(tile, NEVER_BIN); | 567 set.InsertTile(tile, AT_LAST_BIN); |
572 set.InsertTile(tile, NEVER_AND_ACTIVE_BIN); | 568 set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); |
573 } | 569 } |
574 } | 570 } |
575 | 571 |
576 PrioritizedTileSet::Iterator it(&set, true); | 572 PrioritizedTileSet::Iterator it(&set, true); |
577 std::vector<scoped_refptr<Tile> >::iterator vector_it; | 573 std::vector<scoped_refptr<Tile> >::iterator vector_it; |
578 | 574 |
579 // Now and ready are not sorted. | 575 // Now and ready are not sorted. |
580 for (vector_it = now_and_ready_to_draw_bins.begin(); | 576 for (vector_it = now_and_ready_to_draw_bins.begin(); |
581 vector_it != now_and_ready_to_draw_bins.end(); | 577 vector_it != now_and_ready_to_draw_bins.end(); |
582 ++vector_it) { | 578 ++vector_it) { |
(...skipping 30 matching lines...) Expand all Loading... |
613 ++it; | 609 ++it; |
614 } | 610 } |
615 | 611 |
616 // Eventually bins are not sorted. | 612 // Eventually bins are not sorted. |
617 for (vector_it = eventually_bins.begin(); vector_it != eventually_bins.end(); | 613 for (vector_it = eventually_bins.begin(); vector_it != eventually_bins.end(); |
618 ++vector_it) { | 614 ++vector_it) { |
619 EXPECT_TRUE(*vector_it == *it); | 615 EXPECT_TRUE(*vector_it == *it); |
620 ++it; | 616 ++it; |
621 } | 617 } |
622 | 618 |
623 // Never and active bins are not sorted. | 619 // At last and active bins are not sorted. |
624 for (vector_it = never_and_active_bins.begin(); | 620 for (vector_it = at_last_and_active_bins.begin(); |
625 vector_it != never_and_active_bins.end(); | 621 vector_it != at_last_and_active_bins.end(); |
626 ++vector_it) { | 622 ++vector_it) { |
627 EXPECT_TRUE(*vector_it == *it); | 623 EXPECT_TRUE(*vector_it == *it); |
628 ++it; | 624 ++it; |
629 } | 625 } |
630 | 626 |
631 // Never bins are not sorted. | 627 // At last bins are not sorted. |
632 for (vector_it = never_bins.begin(); vector_it != never_bins.end(); | 628 for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); |
633 ++vector_it) { | 629 ++vector_it) { |
634 EXPECT_TRUE(*vector_it == *it); | 630 EXPECT_TRUE(*vector_it == *it); |
635 ++it; | 631 ++it; |
636 } | 632 } |
637 | 633 |
638 EXPECT_FALSE(it); | 634 EXPECT_FALSE(it); |
639 } | 635 } |
640 | 636 |
641 TEST_F(PrioritizedTileSetTest, TilesForFirstAndLastBins) { | 637 TEST_F(PrioritizedTileSetTest, TilesForFirstAndLastBins) { |
642 // Make sure that if we have empty lists between two non-empty lists, | 638 // Make sure that if we have empty lists between two non-empty lists, |
643 // we just get two tiles from the iterator. | 639 // we just get two tiles from the iterator. |
644 | 640 |
645 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); | 641 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); |
646 scoped_refptr<Tile> never_bin = CreateTile(); | 642 scoped_refptr<Tile> at_last_bin = CreateTile(); |
647 | 643 |
648 PrioritizedTileSet set; | 644 PrioritizedTileSet set; |
649 set.InsertTile(never_bin, NEVER_BIN); | 645 set.InsertTile(at_last_bin, AT_LAST_BIN); |
650 set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); | 646 set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); |
651 | 647 |
652 // Only two tiles should appear and they should appear in order. | 648 // Only two tiles should appear and they should appear in order. |
653 PrioritizedTileSet::Iterator it(&set, true); | 649 PrioritizedTileSet::Iterator it(&set, true); |
654 EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); | 650 EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); |
655 ++it; | 651 ++it; |
656 EXPECT_TRUE(*it == never_bin.get()); | 652 EXPECT_TRUE(*it == at_last_bin.get()); |
657 ++it; | 653 ++it; |
658 EXPECT_FALSE(it); | 654 EXPECT_FALSE(it); |
659 } | 655 } |
660 | 656 |
661 TEST_F(PrioritizedTileSetTest, MultipleIterators) { | 657 TEST_F(PrioritizedTileSetTest, MultipleIterators) { |
662 // Ensure that multiple iterators don't interfere with each other. | 658 // Ensure that multiple iterators don't interfere with each other. |
663 | 659 |
664 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); | 660 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); |
665 scoped_refptr<Tile> now_bin = CreateTile(); | 661 scoped_refptr<Tile> now_bin = CreateTile(); |
666 scoped_refptr<Tile> soon_bin = CreateTile(); | 662 scoped_refptr<Tile> soon_bin = CreateTile(); |
667 scoped_refptr<Tile> eventually_bin = CreateTile(); | 663 scoped_refptr<Tile> eventually_bin = CreateTile(); |
668 scoped_refptr<Tile> never_bin = CreateTile(); | 664 scoped_refptr<Tile> at_last_bin = CreateTile(); |
669 | 665 |
670 PrioritizedTileSet set; | 666 PrioritizedTileSet set; |
671 set.InsertTile(soon_bin, SOON_BIN); | 667 set.InsertTile(soon_bin, SOON_BIN); |
672 set.InsertTile(eventually_bin, EVENTUALLY_BIN); | 668 set.InsertTile(eventually_bin, EVENTUALLY_BIN); |
673 set.InsertTile(now_bin, NOW_BIN); | 669 set.InsertTile(now_bin, NOW_BIN); |
674 set.InsertTile(never_bin, NEVER_BIN); | 670 set.InsertTile(at_last_bin, AT_LAST_BIN); |
675 set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); | 671 set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); |
676 | 672 |
677 // Tiles should appear in order. | 673 // Tiles should appear in order. |
678 PrioritizedTileSet::Iterator it(&set, true); | 674 PrioritizedTileSet::Iterator it(&set, true); |
679 EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); | 675 EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); |
680 ++it; | 676 ++it; |
681 EXPECT_TRUE(*it == now_bin.get()); | 677 EXPECT_TRUE(*it == now_bin.get()); |
682 ++it; | 678 ++it; |
683 EXPECT_TRUE(*it == soon_bin.get()); | 679 EXPECT_TRUE(*it == soon_bin.get()); |
684 ++it; | 680 ++it; |
685 EXPECT_TRUE(*it == eventually_bin.get()); | 681 EXPECT_TRUE(*it == eventually_bin.get()); |
686 ++it; | 682 ++it; |
687 EXPECT_TRUE(*it == never_bin.get()); | 683 EXPECT_TRUE(*it == at_last_bin.get()); |
688 ++it; | 684 ++it; |
689 EXPECT_FALSE(it); | 685 EXPECT_FALSE(it); |
690 | 686 |
691 // Creating multiple iterators shouldn't affect old iterators. | 687 // Creating multiple iterators shouldn't affect old iterators. |
692 PrioritizedTileSet::Iterator second_it(&set, true); | 688 PrioritizedTileSet::Iterator second_it(&set, true); |
693 EXPECT_TRUE(second_it); | 689 EXPECT_TRUE(second_it); |
694 EXPECT_FALSE(it); | 690 EXPECT_FALSE(it); |
695 | 691 |
696 ++second_it; | 692 ++second_it; |
697 EXPECT_TRUE(second_it); | 693 EXPECT_TRUE(second_it); |
698 ++second_it; | 694 ++second_it; |
699 EXPECT_TRUE(second_it); | 695 EXPECT_TRUE(second_it); |
700 EXPECT_FALSE(it); | 696 EXPECT_FALSE(it); |
701 | 697 |
702 PrioritizedTileSet::Iterator third_it(&set, true); | 698 PrioritizedTileSet::Iterator third_it(&set, true); |
703 EXPECT_TRUE(third_it); | 699 EXPECT_TRUE(third_it); |
704 ++second_it; | 700 ++second_it; |
705 ++second_it; | 701 ++second_it; |
706 EXPECT_TRUE(second_it); | 702 EXPECT_TRUE(second_it); |
707 EXPECT_TRUE(third_it); | 703 EXPECT_TRUE(third_it); |
708 EXPECT_FALSE(it); | 704 EXPECT_FALSE(it); |
709 | 705 |
710 ++third_it; | 706 ++third_it; |
711 ++third_it; | 707 ++third_it; |
712 EXPECT_TRUE(third_it); | 708 EXPECT_TRUE(third_it); |
713 EXPECT_TRUE(*third_it == soon_bin.get()); | 709 EXPECT_TRUE(*third_it == soon_bin.get()); |
714 EXPECT_TRUE(second_it); | 710 EXPECT_TRUE(second_it); |
715 EXPECT_TRUE(*second_it == never_bin.get()); | 711 EXPECT_TRUE(*second_it == at_last_bin.get()); |
716 EXPECT_FALSE(it); | 712 EXPECT_FALSE(it); |
717 | 713 |
718 ++second_it; | 714 ++second_it; |
719 EXPECT_TRUE(third_it); | 715 EXPECT_TRUE(third_it); |
720 EXPECT_FALSE(second_it); | 716 EXPECT_FALSE(second_it); |
721 EXPECT_FALSE(it); | 717 EXPECT_FALSE(it); |
722 | 718 |
723 set.Clear(); | 719 set.Clear(); |
724 | 720 |
725 PrioritizedTileSet::Iterator empty_it(&set, true); | 721 PrioritizedTileSet::Iterator empty_it(&set, true); |
726 EXPECT_FALSE(empty_it); | 722 EXPECT_FALSE(empty_it); |
727 } | 723 } |
728 | 724 |
729 } // namespace | 725 } // namespace |
730 } // namespace cc | 726 } // namespace cc |
731 | 727 |
OLD | NEW |