| Index: cc/base/tiling_data_unittest.cc
|
| diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc
|
| index 60e5a21e89f7311c69d4c79bbb1d4a2ced456009..dcb76ad14f9a0c2e7b601a35583222d8cb3e7500 100644
|
| --- a/cc/base/tiling_data_unittest.cc
|
| +++ b/cc/base/tiling_data_unittest.cc
|
| @@ -1086,24 +1086,23 @@ void TestIterate(const TilingData& data,
|
| }
|
|
|
| // Make sure this also works with a difference iterator and an empty ignore.
|
| - // The difference iterator always includes borders, so ignore it otherwise.
|
| - if (include_borders) {
|
| - std::vector<std::pair<int, int> > expected = original_expected;
|
| - for (TilingData::DifferenceIterator iter(&data, rect, gfx::Rect());
|
| - iter; ++iter) {
|
| - bool found = false;
|
| - for (size_t i = 0; i < expected.size(); ++i) {
|
| - if (expected[i] == iter.index()) {
|
| - expected[i] = expected.back();
|
| - expected.pop_back();
|
| - found = true;
|
| - break;
|
| - }
|
| + std::vector<std::pair<int, int> > expected = original_expected;
|
| + for (TilingData::DifferenceIterator iter(
|
| + &data, rect, gfx::Rect(), include_borders);
|
| + iter;
|
| + ++iter) {
|
| + bool found = false;
|
| + for (size_t i = 0; i < expected.size(); ++i) {
|
| + if (expected[i] == iter.index()) {
|
| + expected[i] = expected.back();
|
| + expected.pop_back();
|
| + found = true;
|
| + break;
|
| }
|
| - EXPECT_TRUE(found);
|
| }
|
| - EXPECT_EQ(0u, expected.size());
|
| + EXPECT_TRUE(found);
|
| }
|
| + EXPECT_EQ(0u, expected.size());
|
| }
|
|
|
| void TestIterateBorders(const TilingData& data,
|
| @@ -1250,16 +1249,16 @@ TEST(TilingDataTest, IteratorNoTiles) {
|
| TestIterateAll(data, gfx::Rect(100, 100), 0, 0, -1, -1);
|
| }
|
|
|
| -void TestDiff(
|
| - const TilingData& data,
|
| - gfx::Rect consider,
|
| - gfx::Rect ignore,
|
| - size_t num_tiles) {
|
| -
|
| +void TestDiff(const TilingData& data,
|
| + gfx::Rect consider,
|
| + gfx::Rect ignore,
|
| + size_t num_tiles,
|
| + bool include_borders) {
|
| std::vector<std::pair<int, int> > expected;
|
| for (int y = 0; y < data.num_tiles_y(); ++y) {
|
| for (int x = 0; x < data.num_tiles_x(); ++x) {
|
| - gfx::Rect bounds = data.TileBoundsWithBorder(x, y);
|
| + gfx::Rect bounds = include_borders ? data.TileBoundsWithBorder(x, y)
|
| + : data.TileBounds(x, y);
|
| if (bounds.Intersects(consider) && !bounds.Intersects(ignore))
|
| expected.push_back(std::make_pair(x, y));
|
| }
|
| @@ -1268,8 +1267,10 @@ void TestDiff(
|
| // Sanity check the test.
|
| EXPECT_EQ(num_tiles, expected.size());
|
|
|
| - for (TilingData::DifferenceIterator iter(&data, consider, ignore);
|
| - iter; ++iter) {
|
| + for (TilingData::DifferenceIterator iter(
|
| + &data, consider, ignore, include_borders);
|
| + iter;
|
| + ++iter) {
|
| bool found = false;
|
| for (size_t i = 0; i < expected.size(); ++i) {
|
| if (expected[i] == iter.index()) {
|
| @@ -1295,79 +1296,132 @@ TEST(TilingDataTest, DifferenceIteratorIgnoreGeometry) {
|
| TilingData data(gfx::Size(10, 10), gfx::Size(40, 25), false);
|
|
|
| // Fully ignored
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(40, 25), 0);
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-100, -100, 200, 200), 0);
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(9, 9, 30, 15), 0);
|
| - TestDiff(data, gfx::Rect(15, 15, 8, 8), gfx::Rect(15, 15, 8, 8), 0);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(40, 25), 0, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-100, -100, 200, 200), 0, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(9, 9, 30, 15), 0, true);
|
| + TestDiff(data, gfx::Rect(15, 15, 8, 8), gfx::Rect(15, 15, 8, 8), 0, true);
|
| +
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(40, 25), 0, false);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-100, -100, 200, 200), 0, false);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(9, 9, 30, 15), 0, false);
|
| + TestDiff(data, gfx::Rect(15, 15, 8, 8), gfx::Rect(15, 15, 8, 8), 0, false);
|
|
|
| // Fully un-ignored
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-30, -20, 8, 8), 12);
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(), 12);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-30, -20, 8, 8), 12, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(), 12, true);
|
| +
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-30, -20, 8, 8), 12, false);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(), 12, false);
|
|
|
| // Top left, remove 2x2 tiles
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 19), 8);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 19), 8, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 19), 8, false);
|
| // Bottom right, remove 2x2 tiles
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 15, 20, 6), 8);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 15, 20, 6), 8, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 15, 20, 6), 8, false);
|
| // Bottom left, remove 2x2 tiles
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 15, 20, 6), 8);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 15, 20, 6), 8, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 15, 20, 6), 8, false);
|
| // Top right, remove 2x2 tiles
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 0, 20, 19), 8);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 0, 20, 19), 8, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 0, 20, 19), 8, false);
|
| // Center, remove only one tile
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(10, 10, 5, 5), 11);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(10, 10, 5, 5), 11, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(10, 10, 5, 5), 11, false);
|
|
|
| // Left column, flush left, removing two columns
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 25), 6);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 25), 6, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 25), 6, false);
|
| // Middle column, removing two columns
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 0, 11, 25), 6);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 0, 11, 25), 6, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 0, 11, 25), 6, false);
|
| // Right column, flush right, removing one column
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(30, 0, 2, 25), 9);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(30, 0, 2, 25), 9, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(30, 0, 2, 25), 9, false);
|
|
|
| // Top row, flush top, removing one row
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 5, 40, 5), 8);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 5, 40, 5), 8, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 5, 40, 5), 8, false);
|
| // Middle row, removing one row
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 5), 8);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 5), 8, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 5), 8, false);
|
| // Bottom row, flush bottom, removing two rows
|
| - TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 12), 4);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 12), 4, true);
|
| + TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 12), 4, false);
|
|
|
| // Non-intersecting, but still touching two of the same tiles.
|
| - TestDiff(data, gfx::Rect(8, 0, 32, 25), gfx::Rect(0, 12, 5, 12), 10);
|
| + TestDiff(data, gfx::Rect(8, 0, 32, 25), gfx::Rect(0, 12, 5, 12), 10, true);
|
| + TestDiff(data, gfx::Rect(8, 0, 32, 25), gfx::Rect(0, 12, 5, 12), 10, false);
|
|
|
| // Intersecting, but neither contains the other. 2x3 with one overlap.
|
| - TestDiff(data, gfx::Rect(5, 2, 20, 10), gfx::Rect(25, 15, 5, 10), 5);
|
| + TestDiff(data, gfx::Rect(5, 2, 20, 10), gfx::Rect(25, 15, 5, 10), 5, true);
|
| + TestDiff(data, gfx::Rect(5, 2, 20, 10), gfx::Rect(25, 15, 5, 10), 5, false);
|
| }
|
|
|
| TEST(TilingDataTest, DifferenceIteratorManyBorderTexels) {
|
| // X border index by src coord: [0-50), [10-60), [20-65)
|
| // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
|
| + // X tile bounds by src coord: [0-30), [30-40), [40-65)
|
| + // Y tile bounds by src coord: [0-40), [40-60), [60-80), [80-110)
|
| TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
|
|
|
| - // Ignore one column, three rows
|
| - TestDiff(data, gfx::Rect(0, 30, 55, 80), gfx::Rect(5, 30, 5, 15), 9);
|
| + // Ignore one column, over three rows.
|
| + TestDiff(data, gfx::Rect(0, 30, 55, 80), gfx::Rect(5, 30, 5, 15), 9, true);
|
|
|
| - // Knock out three columns, leaving only one.
|
| - TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(30, 59, 20, 1), 3);
|
| + // Knock out three rows, leaving only one.
|
| + TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(30, 59, 20, 1), 3, true);
|
| +
|
| + // Knock out one row.
|
| + TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(29, 59, 20, 1), 9, false);
|
|
|
| // Overlap all tiles with ignore rect.
|
| - TestDiff(data, gfx::Rect(65, 110), gfx::Rect(30, 59, 1, 2), 0);
|
| + TestDiff(data, gfx::Rect(65, 110), gfx::Rect(30, 59, 1, 2), 0, true);
|
| +
|
| + TestDiff(data, gfx::Rect(65, 110), gfx::Rect(29, 39, 12, 42), 0, false);
|
| +
|
| + gfx::Rect tile = data.TileBounds(1, 1);
|
| +
|
| + // Ignore nine tiles.
|
| + TestDiff(data, gfx::Rect(20, 30, 45, 80), tile, 3, true);
|
| + // Ignore one tile.
|
| + TestDiff(data, gfx::Rect(20, 30, 45, 80), tile, 11, false);
|
| +
|
| + // Include nine tiles.
|
| + TestDiff(data, tile, gfx::Rect(), 9, true);
|
| + // Include one tile.
|
| + TestDiff(data, tile, gfx::Rect(), 1, false);
|
| }
|
|
|
| TEST(TilingDataTest, DifferenceIteratorOneTile) {
|
| TilingData no_border(gfx::Size(1000, 1000), gfx::Size(30, 40), false);
|
| - TestDiff(no_border, gfx::Rect(30, 40), gfx::Rect(), 1);
|
| - TestDiff(no_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
|
| + TestDiff(no_border, gfx::Rect(30, 40), gfx::Rect(), 1, true);
|
| + TestDiff(
|
| + no_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0, true);
|
| + TestDiff(no_border, gfx::Rect(30, 40), gfx::Rect(), 1, false);
|
| + TestDiff(
|
| + no_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0, false);
|
|
|
| TilingData one_border(gfx::Size(1000, 1000), gfx::Size(30, 40), true);
|
| - TestDiff(one_border, gfx::Rect(30, 40), gfx::Rect(), 1);
|
| - TestDiff(one_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
|
| + TestDiff(one_border, gfx::Rect(30, 40), gfx::Rect(), 1, true);
|
| + TestDiff(
|
| + one_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0, true);
|
| + TestDiff(one_border, gfx::Rect(30, 40), gfx::Rect(), 1, false);
|
| + TestDiff(
|
| + one_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0, false);
|
|
|
| TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50);
|
| - TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1);
|
| - TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
|
| + TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1, true);
|
| + TestDiff(
|
| + big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0, true);
|
| + TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1, false);
|
| + TestDiff(
|
| + big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0, false);
|
| }
|
|
|
| TEST(TilingDataTest, DifferenceIteratorNoTiles) {
|
| TilingData data(gfx::Size(100, 100), gfx::Size(), false);
|
| - TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0);
|
| + TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0, true);
|
| + TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0, false);
|
| }
|
|
|
| void TestSpiralIterate(int source_line_number,
|
|
|