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 <map> | 5 #include <map> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
10 #include "cc/test/fake_rendering_stats_instrumentation.h" | 10 #include "cc/test/fake_rendering_stats_instrumentation.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 EXPECT_EQ(8, pile_->tiling().num_tiles_y()); | 465 EXPECT_EQ(8, pile_->tiling().num_tiles_y()); |
466 for (int i = 0; i < 6; ++i) { | 466 for (int i = 0; i < 6; ++i) { |
467 for (int j = 0; j < 6; ++j) { | 467 for (int j = 0; j < 6; ++j) { |
468 TestPicturePile::PictureMapKey key(i, j); | 468 TestPicturePile::PictureMapKey key(i, j); |
469 TestPicturePile::PictureMap& map = pile_->picture_map(); | 469 TestPicturePile::PictureMap& map = pile_->picture_map(); |
470 TestPicturePile::PictureMap::iterator it = map.find(key); | 470 TestPicturePile::PictureMap::iterator it = map.find(key); |
471 EXPECT_EQ(j < 5, it != map.end() && it->second.GetPicture()); | 471 EXPECT_EQ(j < 5, it != map.end() && it->second.GetPicture()); |
472 } | 472 } |
473 } | 473 } |
474 | 474 |
475 // We invalidated the old bottom row. | 475 // We invalidated any new pixels. |
vmpstr
2014/09/09 22:43:00
nit: That comment doesn't make sense to me, can yo
danakj
2014/09/10 16:52:49
Done. s/any new pixels/all new pixels in the recor
| |
476 expected_invalidation = gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | 476 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
477 pile_->tiling().TileBounds(5, 5)); | 477 gfx::Rect(base_tiling_size)); |
478 // But the new pixels don't cover the whole bottom row. | |
479 gfx::Rect bottom_row = gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | |
480 pile_->tiling().TileBounds(5, 5)); | |
481 EXPECT_FALSE(expected_invalidation.Contains(bottom_row)); | |
482 // We invalidated the entire old bottom row. | |
483 expected_invalidation.Union(bottom_row); | |
478 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 484 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
479 invalidation.Clear(); | 485 invalidation.Clear(); |
480 | 486 |
481 UpdateWholePile(); | 487 UpdateWholePile(); |
482 UpdateAndExpandInvalidation(&invalidation, | 488 UpdateAndExpandInvalidation(&invalidation, |
483 base_tiling_size, | 489 base_tiling_size, |
484 CornerSinglePixelRect(corner, base_tiling_size)); | 490 CornerSinglePixelRect(corner, base_tiling_size)); |
485 | 491 |
486 // We should have lost the recordings that are now outside the tiling only. | 492 // We should have lost the recordings that are now outside the tiling only. |
487 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); | 493 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); |
(...skipping 23 matching lines...) Expand all Loading... | |
511 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); | 517 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); |
512 for (int i = 0; i < 6; ++i) { | 518 for (int i = 0; i < 6; ++i) { |
513 for (int j = 0; j < 6; ++j) { | 519 for (int j = 0; j < 6; ++j) { |
514 TestPicturePile::PictureMapKey key(i, j); | 520 TestPicturePile::PictureMapKey key(i, j); |
515 TestPicturePile::PictureMap& map = pile_->picture_map(); | 521 TestPicturePile::PictureMap& map = pile_->picture_map(); |
516 TestPicturePile::PictureMap::iterator it = map.find(key); | 522 TestPicturePile::PictureMap::iterator it = map.find(key); |
517 EXPECT_EQ(i < 5, it != map.end() && it->second.GetPicture()); | 523 EXPECT_EQ(i < 5, it != map.end() && it->second.GetPicture()); |
518 } | 524 } |
519 } | 525 } |
520 | 526 |
521 // We invalidated the old right column. | 527 // We invalidated any new pixels. |
522 expected_invalidation = gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | 528 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
523 pile_->tiling().TileBounds(5, 5)); | 529 gfx::Rect(base_tiling_size)); |
530 // But the new pixels don't cover the whole right_column. | |
531 gfx::Rect right_column = gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | |
532 pile_->tiling().TileBounds(5, 5)); | |
533 EXPECT_FALSE(expected_invalidation.Contains(right_column)); | |
534 // We invalidated the entire old right column. | |
535 expected_invalidation.Union(right_column); | |
524 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 536 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
525 invalidation.Clear(); | 537 invalidation.Clear(); |
526 | 538 |
527 UpdateWholePile(); | 539 UpdateWholePile(); |
528 UpdateAndExpandInvalidation(&invalidation, | 540 UpdateAndExpandInvalidation(&invalidation, |
529 base_tiling_size, | 541 base_tiling_size, |
530 CornerSinglePixelRect(corner, base_tiling_size)); | 542 CornerSinglePixelRect(corner, base_tiling_size)); |
531 | 543 |
532 // We should have lost the recordings that are now outside the tiling only. | 544 // We should have lost the recordings that are now outside the tiling only. |
533 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); | 545 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); |
(...skipping 23 matching lines...) Expand all Loading... | |
557 EXPECT_EQ(8, pile_->tiling().num_tiles_y()); | 569 EXPECT_EQ(8, pile_->tiling().num_tiles_y()); |
558 for (int i = 0; i < 6; ++i) { | 570 for (int i = 0; i < 6; ++i) { |
559 for (int j = 0; j < 6; ++j) { | 571 for (int j = 0; j < 6; ++j) { |
560 TestPicturePile::PictureMapKey key(i, j); | 572 TestPicturePile::PictureMapKey key(i, j); |
561 TestPicturePile::PictureMap& map = pile_->picture_map(); | 573 TestPicturePile::PictureMap& map = pile_->picture_map(); |
562 TestPicturePile::PictureMap::iterator it = map.find(key); | 574 TestPicturePile::PictureMap::iterator it = map.find(key); |
563 EXPECT_EQ(i < 5 && j < 5, it != map.end() && it->second.GetPicture()); | 575 EXPECT_EQ(i < 5 && j < 5, it != map.end() && it->second.GetPicture()); |
564 } | 576 } |
565 } | 577 } |
566 | 578 |
567 // We invalidated the old right column and the old bottom row. | 579 // We invalidated any new pixels. |
568 expected_invalidation = gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | 580 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
569 pile_->tiling().TileBounds(5, 5)); | 581 gfx::Rect(base_tiling_size)); |
570 expected_invalidation.Union(gfx::UnionRects( | 582 // But the new pixels don't cover the whole right_column. |
571 pile_->tiling().TileBounds(0, 5), pile_->tiling().TileBounds(5, 5))); | 583 Region right_column_and_bottom_row = |
584 UnionRegions(gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | |
585 pile_->tiling().TileBounds(5, 5)), | |
586 gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | |
587 pile_->tiling().TileBounds(5, 5))); | |
588 EXPECT_FALSE(expected_invalidation.Contains(right_column_and_bottom_row)); | |
589 // We invalidated the entire old right column and the old bottom row. | |
590 expected_invalidation.Union(right_column_and_bottom_row); | |
572 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 591 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
573 invalidation.Clear(); | 592 invalidation.Clear(); |
574 | 593 |
575 UpdateWholePile(); | 594 UpdateWholePile(); |
576 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); | 595 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); |
577 | 596 |
578 // We should have lost the recordings that are now outside the tiling only. | 597 // We should have lost the recordings that are now outside the tiling only. |
579 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); | 598 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); |
580 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); | 599 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); |
581 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { | 600 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { | 946 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
928 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { | 947 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
929 TestPicturePile::PictureMapKey key(i, j); | 948 TestPicturePile::PictureMapKey key(i, j); |
930 TestPicturePile::PictureMap& map = pile_->picture_map(); | 949 TestPicturePile::PictureMap& map = pile_->picture_map(); |
931 TestPicturePile::PictureMap::iterator it = map.find(key); | 950 TestPicturePile::PictureMap::iterator it = map.find(key); |
932 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 951 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
933 } | 952 } |
934 } | 953 } |
935 | 954 |
936 // We invalidated the newly exposed pixels on the bottom row of tiles. | 955 // We invalidated the newly exposed pixels on the bottom row of tiles. |
937 expected_invalidation = gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | 956 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
938 pile_->tiling().TileBounds(5, 5)); | 957 gfx::Rect(base_tiling_size)); |
939 expected_invalidation.Subtract(gfx::Rect(base_tiling_size)); | 958 Region bottom_row_new_pixels = |
959 SubtractRegions(gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | |
960 pile_->tiling().TileBounds(5, 5)), | |
961 gfx::Rect(base_tiling_size)); | |
962 EXPECT_TRUE(expected_invalidation.Contains(bottom_row_new_pixels)); | |
940 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 963 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
941 invalidation.Clear(); | 964 invalidation.Clear(); |
942 | 965 |
943 UpdateWholePile(); | 966 UpdateWholePile(); |
944 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); | 967 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); |
945 | 968 |
946 // We should have a recording for every tile. | 969 // We should have a recording for every tile. |
947 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); | 970 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); |
948 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); | 971 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); |
949 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { | 972 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
(...skipping 19 matching lines...) Expand all Loading... | |
969 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { | 992 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
970 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { | 993 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
971 TestPicturePile::PictureMapKey key(i, j); | 994 TestPicturePile::PictureMapKey key(i, j); |
972 TestPicturePile::PictureMap& map = pile_->picture_map(); | 995 TestPicturePile::PictureMap& map = pile_->picture_map(); |
973 TestPicturePile::PictureMap::iterator it = map.find(key); | 996 TestPicturePile::PictureMap::iterator it = map.find(key); |
974 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 997 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
975 } | 998 } |
976 } | 999 } |
977 | 1000 |
978 // We invalidated the newly exposed pixels on the right column of tiles. | 1001 // We invalidated the newly exposed pixels on the right column of tiles. |
979 expected_invalidation = gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | 1002 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
980 pile_->tiling().TileBounds(5, 5)); | 1003 gfx::Rect(base_tiling_size)); |
981 expected_invalidation.Subtract(gfx::Rect(base_tiling_size)); | 1004 Region right_column_new_pixels = |
1005 SubtractRegions(gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | |
1006 pile_->tiling().TileBounds(5, 5)), | |
1007 gfx::Rect(base_tiling_size)); | |
1008 EXPECT_TRUE(expected_invalidation.Contains(right_column_new_pixels)); | |
982 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1009 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
983 invalidation.Clear(); | 1010 invalidation.Clear(); |
984 | 1011 |
985 UpdateWholePile(); | 1012 UpdateWholePile(); |
986 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); | 1013 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); |
987 | 1014 |
988 // We should have lost the recordings that are now outside the tiling only. | 1015 // We should have lost the recordings that are now outside the tiling only. |
989 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); | 1016 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); |
990 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); | 1017 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); |
991 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { | 1018 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
(...skipping 20 matching lines...) Expand all Loading... | |
1012 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { | 1039 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
1013 TestPicturePile::PictureMapKey key(i, j); | 1040 TestPicturePile::PictureMapKey key(i, j); |
1014 TestPicturePile::PictureMap& map = pile_->picture_map(); | 1041 TestPicturePile::PictureMap& map = pile_->picture_map(); |
1015 TestPicturePile::PictureMap::iterator it = map.find(key); | 1042 TestPicturePile::PictureMap::iterator it = map.find(key); |
1016 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1043 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
1017 } | 1044 } |
1018 } | 1045 } |
1019 | 1046 |
1020 // We invalidated the newly exposed pixels on the bottom row and right column | 1047 // We invalidated the newly exposed pixels on the bottom row and right column |
1021 // of tiles. | 1048 // of tiles. |
1022 expected_invalidation = | 1049 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
1023 UnionRegions(gfx::UnionRects(pile_->tiling().TileBounds(5, 0), | 1050 gfx::Rect(base_tiling_size)); |
1051 Region bottom_row_and_right_column_new_pixels = SubtractRegions( | |
1052 UnionRegions(gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | |
1024 pile_->tiling().TileBounds(5, 5)), | 1053 pile_->tiling().TileBounds(5, 5)), |
1025 gfx::UnionRects(pile_->tiling().TileBounds(0, 5), | 1054 gfx::UnionRects(pile_->tiling().TileBounds(5, 0), |
1026 pile_->tiling().TileBounds(5, 5))); | 1055 pile_->tiling().TileBounds(5, 5))), |
1027 expected_invalidation.Subtract(gfx::Rect(base_tiling_size)); | 1056 gfx::Rect(base_tiling_size)); |
1057 EXPECT_TRUE( | |
1058 expected_invalidation.Contains(bottom_row_and_right_column_new_pixels)); | |
1028 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1059 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
1029 invalidation.Clear(); | 1060 invalidation.Clear(); |
1030 | 1061 |
1031 UpdateWholePile(); | 1062 UpdateWholePile(); |
1032 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); | 1063 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); |
1033 | 1064 |
1034 // We should have lost the recordings that are now outside the tiling only. | 1065 // We should have lost the recordings that are now outside the tiling only. |
1035 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); | 1066 EXPECT_EQ(6, pile_->tiling().num_tiles_x()); |
1036 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); | 1067 EXPECT_EQ(6, pile_->tiling().num_tiles_y()); |
1037 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { | 1068 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1240 client_.add_draw_rect(tiling_rect(), paint); | 1271 client_.add_draw_rect(tiling_rect(), paint); |
1241 client_.add_draw_rect(tiling_rect(), paint); | 1272 client_.add_draw_rect(tiling_rect(), paint); |
1242 client_.add_draw_rect(tiling_rect(), paint); | 1273 client_.add_draw_rect(tiling_rect(), paint); |
1243 Region invalidation5(tiling_rect()); | 1274 Region invalidation5(tiling_rect()); |
1244 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); | 1275 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); |
1245 EXPECT_FALSE(pile_->IsSolidColor()); | 1276 EXPECT_FALSE(pile_->IsSolidColor()); |
1246 } | 1277 } |
1247 | 1278 |
1248 } // namespace | 1279 } // namespace |
1249 } // namespace cc | 1280 } // namespace cc |
OLD | NEW |