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
3 // found in the LICENSE file.
5 #include "cc/base/tiling_data.h"
10 #include "cc/test/geometry_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h"
16 int NumTiles(const gfx::Size
& max_texture_size
,
17 const gfx::Rect
& tiling_rect
,
18 bool has_border_texels
) {
19 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
20 int num_tiles
= tiling
.num_tiles_x() * tiling
.num_tiles_y();
22 // Assert no overflow.
23 EXPECT_GE(num_tiles
, 0);
25 EXPECT_EQ(num_tiles
/ tiling
.num_tiles_x(), tiling
.num_tiles_y());
30 int XIndex(const gfx::Size
& max_texture_size
,
31 const gfx::Rect
& tiling_rect
,
32 bool has_border_texels
,
34 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
35 return tiling
.TileXIndexFromSrcCoord(x_coord
);
38 int YIndex(const gfx::Size
& max_texture_size
,
39 const gfx::Rect
& tiling_rect
,
40 bool has_border_texels
,
42 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
43 return tiling
.TileYIndexFromSrcCoord(y_coord
);
46 int MinBorderXIndex(const gfx::Size
& max_texture_size
,
47 const gfx::Rect
& tiling_rect
,
48 bool has_border_texels
,
50 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
51 return tiling
.FirstBorderTileXIndexFromSrcCoord(x_coord
);
54 int MinBorderYIndex(const gfx::Size
& max_texture_size
,
55 const gfx::Rect
& tiling_rect
,
56 bool has_border_texels
,
58 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
59 return tiling
.FirstBorderTileYIndexFromSrcCoord(y_coord
);
62 int MaxBorderXIndex(const gfx::Size
& max_texture_size
,
63 const gfx::Rect
& tiling_rect
,
64 bool has_border_texels
,
66 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
67 return tiling
.LastBorderTileXIndexFromSrcCoord(x_coord
);
70 int MaxBorderYIndex(const gfx::Size
& max_texture_size
,
71 const gfx::Rect
& tiling_rect
,
72 bool has_border_texels
,
74 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
75 return tiling
.LastBorderTileYIndexFromSrcCoord(y_coord
);
78 int PosX(const gfx::Size
& max_texture_size
,
79 const gfx::Rect
& tiling_rect
,
80 bool has_border_texels
,
82 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
83 return tiling
.TilePositionX(x_index
);
86 int PosY(const gfx::Size
& max_texture_size
,
87 const gfx::Rect
& tiling_rect
,
88 bool has_border_texels
,
90 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
91 return tiling
.TilePositionY(y_index
);
94 int SizeX(const gfx::Size
& max_texture_size
,
95 const gfx::Rect
& tiling_rect
,
96 bool has_border_texels
,
98 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
99 return tiling
.TileSizeX(x_index
);
102 int SizeY(const gfx::Size
& max_texture_size
,
103 const gfx::Rect
& tiling_rect
,
104 bool has_border_texels
,
106 TilingData
tiling(max_texture_size
, tiling_rect
, has_border_texels
);
107 return tiling
.TileSizeY(y_index
);
110 class TilingDataTest
: public ::testing::TestWithParam
<gfx::Point
> {};
112 TEST_P(TilingDataTest
, NumTiles_NoTiling
) {
113 gfx::Point origin
= GetParam();
117 NumTiles(gfx::Size(16, 16), gfx::Rect(origin
, gfx::Size(16, 16)), false));
120 NumTiles(gfx::Size(16, 16), gfx::Rect(origin
, gfx::Size(15, 15)), true));
123 NumTiles(gfx::Size(16, 16), gfx::Rect(origin
, gfx::Size(16, 16)), true));
126 NumTiles(gfx::Size(16, 16), gfx::Rect(origin
, gfx::Size(1, 16)), false));
129 NumTiles(gfx::Size(15, 15), gfx::Rect(origin
, gfx::Size(15, 15)), true));
132 NumTiles(gfx::Size(32, 16), gfx::Rect(origin
, gfx::Size(32, 16)), false));
135 NumTiles(gfx::Size(32, 16), gfx::Rect(origin
, gfx::Size(32, 16)), true));
138 TEST_P(TilingDataTest
, NumTiles_TilingNoBorders
) {
139 gfx::Point origin
= GetParam();
142 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(0, 0)), false));
144 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(4, 0)), false));
146 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(0, 4)), false));
148 0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(4, 0)), false));
150 0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(0, 4)), false));
152 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(1, 1)), false));
155 1, NumTiles(gfx::Size(1, 1), gfx::Rect(origin
, gfx::Size(1, 1)), false));
157 2, NumTiles(gfx::Size(1, 1), gfx::Rect(origin
, gfx::Size(1, 2)), false));
159 2, NumTiles(gfx::Size(1, 1), gfx::Rect(origin
, gfx::Size(2, 1)), false));
161 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(1, 1)), false));
163 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(1, 2)), false));
165 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(2, 1)), false));
167 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(2, 2)), false));
169 1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 3)), false));
172 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(1, 4)), false));
174 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(2, 4)), false));
176 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(3, 4)), false));
178 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(4, 4)), false));
180 2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(5, 4)), false));
182 2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(6, 4)), false));
184 2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(7, 4)), false));
186 2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(8, 4)), false));
188 3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(9, 4)), false));
190 3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(10, 4)), false));
192 3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(11, 4)), false));
195 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(1, 5)), false));
197 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(2, 5)), false));
199 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(3, 5)), false));
201 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(4, 5)), false));
203 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), false));
205 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 5)), false));
207 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(7, 5)), false));
209 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 5)), false));
211 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(9, 5)), false));
213 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 5)), false));
215 3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(11, 5)), false));
219 NumTiles(gfx::Size(16, 16), gfx::Rect(origin
, gfx::Size(16, 16)), false));
222 NumTiles(gfx::Size(17, 17), gfx::Rect(origin
, gfx::Size(16, 16)), false));
225 NumTiles(gfx::Size(15, 15), gfx::Rect(origin
, gfx::Size(16, 16)), false));
228 NumTiles(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(16, 16)), false));
231 NumTiles(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(17, 16)), false));
235 NumTiles(gfx::Size(5, 8), gfx::Rect(origin
, gfx::Size(17, 16)), false));
238 TEST_P(TilingDataTest
, NumTiles_TilingWithBorders
) {
239 gfx::Point origin
= GetParam();
242 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(0, 0)), true));
244 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(4, 0)), true));
246 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(0, 4)), true));
248 0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(4, 0)), true));
250 0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(0, 4)), true));
252 0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(1, 1)), true));
255 1, NumTiles(gfx::Size(1, 1), gfx::Rect(origin
, gfx::Size(1, 1)), true));
257 0, NumTiles(gfx::Size(1, 1), gfx::Rect(origin
, gfx::Size(1, 2)), true));
259 0, NumTiles(gfx::Size(1, 1), gfx::Rect(origin
, gfx::Size(2, 1)), true));
261 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(1, 1)), true));
263 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(1, 2)), true));
265 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(2, 1)), true));
267 1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin
, gfx::Size(2, 2)), true));
270 1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 3)), true));
272 1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(2, 3)), true));
274 1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 3)), true));
276 2, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(4, 3)), true));
278 3, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(5, 3)), true));
280 4, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 3)), true));
282 5, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(7, 3)), true));
285 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(1, 4)), true));
287 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(2, 4)), true));
289 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(3, 4)), true));
291 1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(4, 4)), true));
293 2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(5, 4)), true));
295 2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(6, 4)), true));
297 3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(7, 4)), true));
299 3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(8, 4)), true));
301 4, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(9, 4)), true));
303 4, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(10, 4)), true));
305 5, NumTiles(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(11, 4)), true));
308 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(1, 5)), true));
310 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(2, 5)), true));
312 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(3, 5)), true));
314 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(4, 5)), true));
316 1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), true));
318 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 5)), true));
320 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(7, 5)), true));
322 2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 5)), true));
324 3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(9, 5)), true));
326 3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 5)), true));
328 3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(11, 5)), true));
332 NumTiles(gfx::Size(8, 5), gfx::Rect(origin
, gfx::Size(16, 32)), true));
335 TEST_P(TilingDataTest
, TileXIndexFromSrcCoord
) {
336 gfx::Point origin
= GetParam();
339 XIndex(gfx::Size(3, 3),
340 gfx::Rect(origin
, gfx::Size(10, 10)),
344 XIndex(gfx::Size(3, 3),
345 gfx::Rect(origin
, gfx::Size(10, 10)),
349 XIndex(gfx::Size(3, 3),
350 gfx::Rect(origin
, gfx::Size(10, 10)),
354 XIndex(gfx::Size(3, 3),
355 gfx::Rect(origin
, gfx::Size(10, 10)),
359 XIndex(gfx::Size(3, 3),
360 gfx::Rect(origin
, gfx::Size(10, 10)),
364 XIndex(gfx::Size(3, 3),
365 gfx::Rect(origin
, gfx::Size(10, 10)),
369 XIndex(gfx::Size(3, 3),
370 gfx::Rect(origin
, gfx::Size(10, 10)),
374 XIndex(gfx::Size(3, 3),
375 gfx::Rect(origin
, gfx::Size(10, 10)),
379 XIndex(gfx::Size(3, 3),
380 gfx::Rect(origin
, gfx::Size(10, 10)),
384 XIndex(gfx::Size(3, 3),
385 gfx::Rect(origin
, gfx::Size(10, 10)),
389 XIndex(gfx::Size(3, 3),
390 gfx::Rect(origin
, gfx::Size(10, 10)),
394 XIndex(gfx::Size(3, 3),
395 gfx::Rect(origin
, gfx::Size(10, 10)),
400 XIndex(gfx::Size(3, 3),
401 gfx::Rect(origin
, gfx::Size(10, 10)),
405 XIndex(gfx::Size(3, 3),
406 gfx::Rect(origin
, gfx::Size(10, 10)),
410 XIndex(gfx::Size(3, 3),
411 gfx::Rect(origin
, gfx::Size(10, 10)),
415 XIndex(gfx::Size(3, 3),
416 gfx::Rect(origin
, gfx::Size(10, 10)),
420 XIndex(gfx::Size(3, 3),
421 gfx::Rect(origin
, gfx::Size(10, 10)),
425 XIndex(gfx::Size(3, 3),
426 gfx::Rect(origin
, gfx::Size(10, 10)),
430 XIndex(gfx::Size(3, 3),
431 gfx::Rect(origin
, gfx::Size(10, 10)),
435 XIndex(gfx::Size(3, 3),
436 gfx::Rect(origin
, gfx::Size(10, 10)),
440 XIndex(gfx::Size(3, 3),
441 gfx::Rect(origin
, gfx::Size(10, 10)),
445 XIndex(gfx::Size(3, 3),
446 gfx::Rect(origin
, gfx::Size(10, 10)),
450 XIndex(gfx::Size(3, 3),
451 gfx::Rect(origin
, gfx::Size(10, 10)),
455 XIndex(gfx::Size(3, 3),
456 gfx::Rect(origin
, gfx::Size(10, 10)),
461 XIndex(gfx::Size(1, 1),
462 gfx::Rect(origin
, gfx::Size(1, 1)),
466 XIndex(gfx::Size(2, 2),
467 gfx::Rect(origin
, gfx::Size(2, 2)),
471 XIndex(gfx::Size(2, 2),
472 gfx::Rect(origin
, gfx::Size(2, 2)),
476 XIndex(gfx::Size(3, 3),
477 gfx::Rect(origin
, gfx::Size(3, 3)),
481 XIndex(gfx::Size(3, 3),
482 gfx::Rect(origin
, gfx::Size(3, 3)),
486 XIndex(gfx::Size(3, 3),
487 gfx::Rect(origin
, gfx::Size(3, 3)),
492 XIndex(gfx::Size(3, 3),
493 gfx::Rect(origin
, gfx::Size(4, 3)),
497 XIndex(gfx::Size(3, 3),
498 gfx::Rect(origin
, gfx::Size(4, 3)),
502 XIndex(gfx::Size(3, 3),
503 gfx::Rect(origin
, gfx::Size(4, 3)),
507 XIndex(gfx::Size(3, 3),
508 gfx::Rect(origin
, gfx::Size(4, 3)),
513 XIndex(gfx::Size(1, 1),
514 gfx::Rect(origin
, gfx::Size(1, 1)),
518 XIndex(gfx::Size(2, 2),
519 gfx::Rect(origin
, gfx::Size(2, 2)),
523 XIndex(gfx::Size(2, 2),
524 gfx::Rect(origin
, gfx::Size(2, 2)),
528 XIndex(gfx::Size(3, 3),
529 gfx::Rect(origin
, gfx::Size(3, 3)),
533 XIndex(gfx::Size(3, 3),
534 gfx::Rect(origin
, gfx::Size(3, 3)),
538 XIndex(gfx::Size(3, 3),
539 gfx::Rect(origin
, gfx::Size(3, 3)),
544 XIndex(gfx::Size(3, 3),
545 gfx::Rect(origin
, gfx::Size(4, 3)),
549 XIndex(gfx::Size(3, 3),
550 gfx::Rect(origin
, gfx::Size(4, 3)),
554 XIndex(gfx::Size(3, 3),
555 gfx::Rect(origin
, gfx::Size(4, 3)),
559 XIndex(gfx::Size(3, 3),
560 gfx::Rect(origin
, gfx::Size(4, 3)),
565 TEST_P(TilingDataTest
, FirstBorderTileXIndexFromSrcCoord
) {
566 gfx::Point origin
= GetParam();
569 MinBorderXIndex(gfx::Size(3, 3),
570 gfx::Rect(origin
, gfx::Size(10, 10)),
574 MinBorderXIndex(gfx::Size(3, 3),
575 gfx::Rect(origin
, gfx::Size(10, 10)),
579 MinBorderXIndex(gfx::Size(3, 3),
580 gfx::Rect(origin
, gfx::Size(10, 10)),
584 MinBorderXIndex(gfx::Size(3, 3),
585 gfx::Rect(origin
, gfx::Size(10, 10)),
589 MinBorderXIndex(gfx::Size(3, 3),
590 gfx::Rect(origin
, gfx::Size(10, 10)),
594 MinBorderXIndex(gfx::Size(3, 3),
595 gfx::Rect(origin
, gfx::Size(10, 10)),
599 MinBorderXIndex(gfx::Size(3, 3),
600 gfx::Rect(origin
, gfx::Size(10, 10)),
604 MinBorderXIndex(gfx::Size(3, 3),
605 gfx::Rect(origin
, gfx::Size(10, 10)),
609 MinBorderXIndex(gfx::Size(3, 3),
610 gfx::Rect(origin
, gfx::Size(10, 10)),
614 MinBorderXIndex(gfx::Size(3, 3),
615 gfx::Rect(origin
, gfx::Size(10, 10)),
619 MinBorderXIndex(gfx::Size(3, 3),
620 gfx::Rect(origin
, gfx::Size(10, 10)),
624 MinBorderXIndex(gfx::Size(3, 3),
625 gfx::Rect(origin
, gfx::Size(10, 10)),
630 MinBorderXIndex(gfx::Size(3, 3),
631 gfx::Rect(origin
, gfx::Size(10, 10)),
635 MinBorderXIndex(gfx::Size(3, 3),
636 gfx::Rect(origin
, gfx::Size(10, 10)),
640 MinBorderXIndex(gfx::Size(3, 3),
641 gfx::Rect(origin
, gfx::Size(10, 10)),
645 MinBorderXIndex(gfx::Size(3, 3),
646 gfx::Rect(origin
, gfx::Size(10, 10)),
650 MinBorderXIndex(gfx::Size(3, 3),
651 gfx::Rect(origin
, gfx::Size(10, 10)),
655 MinBorderXIndex(gfx::Size(3, 3),
656 gfx::Rect(origin
, gfx::Size(10, 10)),
660 MinBorderXIndex(gfx::Size(3, 3),
661 gfx::Rect(origin
, gfx::Size(10, 10)),
665 MinBorderXIndex(gfx::Size(3, 3),
666 gfx::Rect(origin
, gfx::Size(10, 10)),
670 MinBorderXIndex(gfx::Size(3, 3),
671 gfx::Rect(origin
, gfx::Size(10, 10)),
675 MinBorderXIndex(gfx::Size(3, 3),
676 gfx::Rect(origin
, gfx::Size(10, 10)),
680 MinBorderXIndex(gfx::Size(3, 3),
681 gfx::Rect(origin
, gfx::Size(10, 10)),
685 MinBorderXIndex(gfx::Size(3, 3),
686 gfx::Rect(origin
, gfx::Size(10, 10)),
691 MinBorderXIndex(gfx::Size(1, 1),
692 gfx::Rect(origin
, gfx::Size(1, 1)),
696 MinBorderXIndex(gfx::Size(2, 2),
697 gfx::Rect(origin
, gfx::Size(2, 2)),
701 MinBorderXIndex(gfx::Size(2, 2),
702 gfx::Rect(origin
, gfx::Size(2, 2)),
706 MinBorderXIndex(gfx::Size(3, 3),
707 gfx::Rect(origin
, gfx::Size(3, 3)),
711 MinBorderXIndex(gfx::Size(3, 3),
712 gfx::Rect(origin
, gfx::Size(3, 3)),
716 MinBorderXIndex(gfx::Size(3, 3),
717 gfx::Rect(origin
, gfx::Size(3, 3)),
722 MinBorderXIndex(gfx::Size(3, 3),
723 gfx::Rect(origin
, gfx::Size(4, 3)),
727 MinBorderXIndex(gfx::Size(3, 3),
728 gfx::Rect(origin
, gfx::Size(4, 3)),
732 MinBorderXIndex(gfx::Size(3, 3),
733 gfx::Rect(origin
, gfx::Size(4, 3)),
737 MinBorderXIndex(gfx::Size(3, 3),
738 gfx::Rect(origin
, gfx::Size(4, 3)),
743 MinBorderXIndex(gfx::Size(1, 1),
744 gfx::Rect(origin
, gfx::Size(1, 1)),
748 MinBorderXIndex(gfx::Size(2, 2),
749 gfx::Rect(origin
, gfx::Size(2, 2)),
753 MinBorderXIndex(gfx::Size(2, 2),
754 gfx::Rect(origin
, gfx::Size(2, 2)),
758 MinBorderXIndex(gfx::Size(3, 3),
759 gfx::Rect(origin
, gfx::Size(3, 3)),
763 MinBorderXIndex(gfx::Size(3, 3),
764 gfx::Rect(origin
, gfx::Size(3, 3)),
768 MinBorderXIndex(gfx::Size(3, 3),
769 gfx::Rect(origin
, gfx::Size(3, 3)),
774 MinBorderXIndex(gfx::Size(3, 3),
775 gfx::Rect(origin
, gfx::Size(4, 3)),
779 MinBorderXIndex(gfx::Size(3, 3),
780 gfx::Rect(origin
, gfx::Size(4, 3)),
784 MinBorderXIndex(gfx::Size(3, 3),
785 gfx::Rect(origin
, gfx::Size(4, 3)),
789 MinBorderXIndex(gfx::Size(3, 3),
790 gfx::Rect(origin
, gfx::Size(4, 3)),
795 TEST_P(TilingDataTest
, LastBorderTileXIndexFromSrcCoord
) {
796 gfx::Point origin
= GetParam();
799 MaxBorderXIndex(gfx::Size(3, 3),
800 gfx::Rect(origin
, gfx::Size(10, 10)),
804 MaxBorderXIndex(gfx::Size(3, 3),
805 gfx::Rect(origin
, gfx::Size(10, 10)),
809 MaxBorderXIndex(gfx::Size(3, 3),
810 gfx::Rect(origin
, gfx::Size(10, 10)),
814 MaxBorderXIndex(gfx::Size(3, 3),
815 gfx::Rect(origin
, gfx::Size(10, 10)),
819 MaxBorderXIndex(gfx::Size(3, 3),
820 gfx::Rect(origin
, gfx::Size(10, 10)),
824 MaxBorderXIndex(gfx::Size(3, 3),
825 gfx::Rect(origin
, gfx::Size(10, 10)),
829 MaxBorderXIndex(gfx::Size(3, 3),
830 gfx::Rect(origin
, gfx::Size(10, 10)),
834 MaxBorderXIndex(gfx::Size(3, 3),
835 gfx::Rect(origin
, gfx::Size(10, 10)),
839 MaxBorderXIndex(gfx::Size(3, 3),
840 gfx::Rect(origin
, gfx::Size(10, 10)),
844 MaxBorderXIndex(gfx::Size(3, 3),
845 gfx::Rect(origin
, gfx::Size(10, 10)),
849 MaxBorderXIndex(gfx::Size(3, 3),
850 gfx::Rect(origin
, gfx::Size(10, 10)),
854 MaxBorderXIndex(gfx::Size(3, 3),
855 gfx::Rect(origin
, gfx::Size(10, 10)),
860 MaxBorderXIndex(gfx::Size(3, 3),
861 gfx::Rect(origin
, gfx::Size(10, 10)),
865 MaxBorderXIndex(gfx::Size(3, 3),
866 gfx::Rect(origin
, gfx::Size(10, 10)),
870 MaxBorderXIndex(gfx::Size(3, 3),
871 gfx::Rect(origin
, gfx::Size(10, 10)),
875 MaxBorderXIndex(gfx::Size(3, 3),
876 gfx::Rect(origin
, gfx::Size(10, 10)),
880 MaxBorderXIndex(gfx::Size(3, 3),
881 gfx::Rect(origin
, gfx::Size(10, 10)),
885 MaxBorderXIndex(gfx::Size(3, 3),
886 gfx::Rect(origin
, gfx::Size(10, 10)),
890 MaxBorderXIndex(gfx::Size(3, 3),
891 gfx::Rect(origin
, gfx::Size(10, 10)),
895 MaxBorderXIndex(gfx::Size(3, 3),
896 gfx::Rect(origin
, gfx::Size(10, 10)),
900 MaxBorderXIndex(gfx::Size(3, 3),
901 gfx::Rect(origin
, gfx::Size(10, 10)),
905 MaxBorderXIndex(gfx::Size(3, 3),
906 gfx::Rect(origin
, gfx::Size(10, 10)),
910 MaxBorderXIndex(gfx::Size(3, 3),
911 gfx::Rect(origin
, gfx::Size(10, 10)),
915 MaxBorderXIndex(gfx::Size(3, 3),
916 gfx::Rect(origin
, gfx::Size(10, 10)),
921 MaxBorderXIndex(gfx::Size(1, 1),
922 gfx::Rect(origin
, gfx::Size(1, 1)),
926 MaxBorderXIndex(gfx::Size(2, 2),
927 gfx::Rect(origin
, gfx::Size(2, 2)),
931 MaxBorderXIndex(gfx::Size(2, 2),
932 gfx::Rect(origin
, gfx::Size(2, 2)),
936 MaxBorderXIndex(gfx::Size(3, 3),
937 gfx::Rect(origin
, gfx::Size(3, 3)),
941 MaxBorderXIndex(gfx::Size(3, 3),
942 gfx::Rect(origin
, gfx::Size(3, 3)),
946 MaxBorderXIndex(gfx::Size(3, 3),
947 gfx::Rect(origin
, gfx::Size(3, 3)),
952 MaxBorderXIndex(gfx::Size(3, 3),
953 gfx::Rect(origin
, gfx::Size(4, 3)),
957 MaxBorderXIndex(gfx::Size(3, 3),
958 gfx::Rect(origin
, gfx::Size(4, 3)),
962 MaxBorderXIndex(gfx::Size(3, 3),
963 gfx::Rect(origin
, gfx::Size(4, 3)),
967 MaxBorderXIndex(gfx::Size(3, 3),
968 gfx::Rect(origin
, gfx::Size(4, 3)),
973 MaxBorderXIndex(gfx::Size(1, 1),
974 gfx::Rect(origin
, gfx::Size(1, 1)),
978 MaxBorderXIndex(gfx::Size(2, 2),
979 gfx::Rect(origin
, gfx::Size(2, 2)),
983 MaxBorderXIndex(gfx::Size(2, 2),
984 gfx::Rect(origin
, gfx::Size(2, 2)),
988 MaxBorderXIndex(gfx::Size(3, 3),
989 gfx::Rect(origin
, gfx::Size(3, 3)),
993 MaxBorderXIndex(gfx::Size(3, 3),
994 gfx::Rect(origin
, gfx::Size(3, 3)),
998 MaxBorderXIndex(gfx::Size(3, 3),
999 gfx::Rect(origin
, gfx::Size(3, 3)),
1004 MaxBorderXIndex(gfx::Size(3, 3),
1005 gfx::Rect(origin
, gfx::Size(4, 3)),
1009 MaxBorderXIndex(gfx::Size(3, 3),
1010 gfx::Rect(origin
, gfx::Size(4, 3)),
1014 MaxBorderXIndex(gfx::Size(3, 3),
1015 gfx::Rect(origin
, gfx::Size(4, 3)),
1019 MaxBorderXIndex(gfx::Size(3, 3),
1020 gfx::Rect(origin
, gfx::Size(4, 3)),
1025 TEST_P(TilingDataTest
, TileYIndexFromSrcCoord
) {
1026 gfx::Point origin
= GetParam();
1029 YIndex(gfx::Size(3, 3),
1030 gfx::Rect(origin
, gfx::Size(10, 10)),
1034 YIndex(gfx::Size(3, 3),
1035 gfx::Rect(origin
, gfx::Size(10, 10)),
1039 YIndex(gfx::Size(3, 3),
1040 gfx::Rect(origin
, gfx::Size(10, 10)),
1044 YIndex(gfx::Size(3, 3),
1045 gfx::Rect(origin
, gfx::Size(10, 10)),
1049 YIndex(gfx::Size(3, 3),
1050 gfx::Rect(origin
, gfx::Size(10, 10)),
1054 YIndex(gfx::Size(3, 3),
1055 gfx::Rect(origin
, gfx::Size(10, 10)),
1059 YIndex(gfx::Size(3, 3),
1060 gfx::Rect(origin
, gfx::Size(10, 10)),
1064 YIndex(gfx::Size(3, 3),
1065 gfx::Rect(origin
, gfx::Size(10, 10)),
1069 YIndex(gfx::Size(3, 3),
1070 gfx::Rect(origin
, gfx::Size(10, 10)),
1074 YIndex(gfx::Size(3, 3),
1075 gfx::Rect(origin
, gfx::Size(10, 10)),
1079 YIndex(gfx::Size(3, 3),
1080 gfx::Rect(origin
, gfx::Size(10, 10)),
1084 YIndex(gfx::Size(3, 3),
1085 gfx::Rect(origin
, gfx::Size(10, 10)),
1090 YIndex(gfx::Size(3, 3),
1091 gfx::Rect(origin
, gfx::Size(10, 10)),
1095 YIndex(gfx::Size(3, 3),
1096 gfx::Rect(origin
, gfx::Size(10, 10)),
1100 YIndex(gfx::Size(3, 3),
1101 gfx::Rect(origin
, gfx::Size(10, 10)),
1105 YIndex(gfx::Size(3, 3),
1106 gfx::Rect(origin
, gfx::Size(10, 10)),
1110 YIndex(gfx::Size(3, 3),
1111 gfx::Rect(origin
, gfx::Size(10, 10)),
1115 YIndex(gfx::Size(3, 3),
1116 gfx::Rect(origin
, gfx::Size(10, 10)),
1120 YIndex(gfx::Size(3, 3),
1121 gfx::Rect(origin
, gfx::Size(10, 10)),
1125 YIndex(gfx::Size(3, 3),
1126 gfx::Rect(origin
, gfx::Size(10, 10)),
1130 YIndex(gfx::Size(3, 3),
1131 gfx::Rect(origin
, gfx::Size(10, 10)),
1135 YIndex(gfx::Size(3, 3),
1136 gfx::Rect(origin
, gfx::Size(10, 10)),
1140 YIndex(gfx::Size(3, 3),
1141 gfx::Rect(origin
, gfx::Size(10, 10)),
1145 YIndex(gfx::Size(3, 3),
1146 gfx::Rect(origin
, gfx::Size(10, 10)),
1151 YIndex(gfx::Size(1, 1),
1152 gfx::Rect(origin
, gfx::Size(1, 1)),
1156 YIndex(gfx::Size(2, 2),
1157 gfx::Rect(origin
, gfx::Size(2, 2)),
1161 YIndex(gfx::Size(2, 2),
1162 gfx::Rect(origin
, gfx::Size(2, 2)),
1166 YIndex(gfx::Size(3, 3),
1167 gfx::Rect(origin
, gfx::Size(3, 3)),
1171 YIndex(gfx::Size(3, 3),
1172 gfx::Rect(origin
, gfx::Size(3, 3)),
1176 YIndex(gfx::Size(3, 3),
1177 gfx::Rect(origin
, gfx::Size(3, 3)),
1182 YIndex(gfx::Size(3, 3),
1183 gfx::Rect(origin
, gfx::Size(3, 4)),
1187 YIndex(gfx::Size(3, 3),
1188 gfx::Rect(origin
, gfx::Size(3, 4)),
1192 YIndex(gfx::Size(3, 3),
1193 gfx::Rect(origin
, gfx::Size(3, 4)),
1197 YIndex(gfx::Size(3, 3),
1198 gfx::Rect(origin
, gfx::Size(3, 4)),
1203 YIndex(gfx::Size(1, 1),
1204 gfx::Rect(origin
, gfx::Size(1, 1)),
1208 YIndex(gfx::Size(2, 2),
1209 gfx::Rect(origin
, gfx::Size(2, 2)),
1213 YIndex(gfx::Size(2, 2),
1214 gfx::Rect(origin
, gfx::Size(2, 2)),
1218 YIndex(gfx::Size(3, 3),
1219 gfx::Rect(origin
, gfx::Size(3, 3)),
1223 YIndex(gfx::Size(3, 3),
1224 gfx::Rect(origin
, gfx::Size(3, 3)),
1228 YIndex(gfx::Size(3, 3),
1229 gfx::Rect(origin
, gfx::Size(3, 3)),
1234 YIndex(gfx::Size(3, 3),
1235 gfx::Rect(origin
, gfx::Size(3, 4)),
1239 YIndex(gfx::Size(3, 3),
1240 gfx::Rect(origin
, gfx::Size(3, 4)),
1244 YIndex(gfx::Size(3, 3),
1245 gfx::Rect(origin
, gfx::Size(3, 4)),
1249 YIndex(gfx::Size(3, 3),
1250 gfx::Rect(origin
, gfx::Size(3, 4)),
1255 TEST_P(TilingDataTest
, FirstBorderTileYIndexFromSrcCoord
) {
1256 gfx::Point origin
= GetParam();
1259 MinBorderYIndex(gfx::Size(3, 3),
1260 gfx::Rect(origin
, gfx::Size(10, 10)),
1264 MinBorderYIndex(gfx::Size(3, 3),
1265 gfx::Rect(origin
, gfx::Size(10, 10)),
1269 MinBorderYIndex(gfx::Size(3, 3),
1270 gfx::Rect(origin
, gfx::Size(10, 10)),
1274 MinBorderYIndex(gfx::Size(3, 3),
1275 gfx::Rect(origin
, gfx::Size(10, 10)),
1279 MinBorderYIndex(gfx::Size(3, 3),
1280 gfx::Rect(origin
, gfx::Size(10, 10)),
1284 MinBorderYIndex(gfx::Size(3, 3),
1285 gfx::Rect(origin
, gfx::Size(10, 10)),
1289 MinBorderYIndex(gfx::Size(3, 3),
1290 gfx::Rect(origin
, gfx::Size(10, 10)),
1294 MinBorderYIndex(gfx::Size(3, 3),
1295 gfx::Rect(origin
, gfx::Size(10, 10)),
1299 MinBorderYIndex(gfx::Size(3, 3),
1300 gfx::Rect(origin
, gfx::Size(10, 10)),
1304 MinBorderYIndex(gfx::Size(3, 3),
1305 gfx::Rect(origin
, gfx::Size(10, 10)),
1309 MinBorderYIndex(gfx::Size(3, 3),
1310 gfx::Rect(origin
, gfx::Size(10, 10)),
1314 MinBorderYIndex(gfx::Size(3, 3),
1315 gfx::Rect(origin
, gfx::Size(10, 10)),
1320 MinBorderYIndex(gfx::Size(3, 3),
1321 gfx::Rect(origin
, gfx::Size(10, 10)),
1325 MinBorderYIndex(gfx::Size(3, 3),
1326 gfx::Rect(origin
, gfx::Size(10, 10)),
1330 MinBorderYIndex(gfx::Size(3, 3),
1331 gfx::Rect(origin
, gfx::Size(10, 10)),
1335 MinBorderYIndex(gfx::Size(3, 3),
1336 gfx::Rect(origin
, gfx::Size(10, 10)),
1340 MinBorderYIndex(gfx::Size(3, 3),
1341 gfx::Rect(origin
, gfx::Size(10, 10)),
1345 MinBorderYIndex(gfx::Size(3, 3),
1346 gfx::Rect(origin
, gfx::Size(10, 10)),
1350 MinBorderYIndex(gfx::Size(3, 3),
1351 gfx::Rect(origin
, gfx::Size(10, 10)),
1355 MinBorderYIndex(gfx::Size(3, 3),
1356 gfx::Rect(origin
, gfx::Size(10, 10)),
1360 MinBorderYIndex(gfx::Size(3, 3),
1361 gfx::Rect(origin
, gfx::Size(10, 10)),
1365 MinBorderYIndex(gfx::Size(3, 3),
1366 gfx::Rect(origin
, gfx::Size(10, 10)),
1370 MinBorderYIndex(gfx::Size(3, 3),
1371 gfx::Rect(origin
, gfx::Size(10, 10)),
1375 MinBorderYIndex(gfx::Size(3, 3),
1376 gfx::Rect(origin
, gfx::Size(10, 10)),
1381 MinBorderYIndex(gfx::Size(1, 1),
1382 gfx::Rect(origin
, gfx::Size(1, 1)),
1386 MinBorderYIndex(gfx::Size(2, 2),
1387 gfx::Rect(origin
, gfx::Size(2, 2)),
1391 MinBorderYIndex(gfx::Size(2, 2),
1392 gfx::Rect(origin
, gfx::Size(2, 2)),
1396 MinBorderYIndex(gfx::Size(3, 3),
1397 gfx::Rect(origin
, gfx::Size(3, 3)),
1401 MinBorderYIndex(gfx::Size(3, 3),
1402 gfx::Rect(origin
, gfx::Size(3, 3)),
1406 MinBorderYIndex(gfx::Size(3, 3),
1407 gfx::Rect(origin
, gfx::Size(3, 3)),
1412 MinBorderYIndex(gfx::Size(3, 3),
1413 gfx::Rect(origin
, gfx::Size(3, 4)),
1417 MinBorderYIndex(gfx::Size(3, 3),
1418 gfx::Rect(origin
, gfx::Size(3, 4)),
1422 MinBorderYIndex(gfx::Size(3, 3),
1423 gfx::Rect(origin
, gfx::Size(3, 4)),
1427 MinBorderYIndex(gfx::Size(3, 3),
1428 gfx::Rect(origin
, gfx::Size(3, 4)),
1433 MinBorderYIndex(gfx::Size(1, 1),
1434 gfx::Rect(origin
, gfx::Size(1, 1)),
1438 MinBorderYIndex(gfx::Size(2, 2),
1439 gfx::Rect(origin
, gfx::Size(2, 2)),
1443 MinBorderYIndex(gfx::Size(2, 2),
1444 gfx::Rect(origin
, gfx::Size(2, 2)),
1448 MinBorderYIndex(gfx::Size(3, 3),
1449 gfx::Rect(origin
, gfx::Size(3, 3)),
1453 MinBorderYIndex(gfx::Size(3, 3),
1454 gfx::Rect(origin
, gfx::Size(3, 3)),
1458 MinBorderYIndex(gfx::Size(3, 3),
1459 gfx::Rect(origin
, gfx::Size(3, 3)),
1464 MinBorderYIndex(gfx::Size(3, 3),
1465 gfx::Rect(origin
, gfx::Size(3, 4)),
1469 MinBorderYIndex(gfx::Size(3, 3),
1470 gfx::Rect(origin
, gfx::Size(3, 4)),
1474 MinBorderYIndex(gfx::Size(3, 3),
1475 gfx::Rect(origin
, gfx::Size(3, 4)),
1479 MinBorderYIndex(gfx::Size(3, 3),
1480 gfx::Rect(origin
, gfx::Size(3, 4)),
1485 TEST_P(TilingDataTest
, LastBorderTileYIndexFromSrcCoord
) {
1486 gfx::Point origin
= GetParam();
1489 MaxBorderYIndex(gfx::Size(3, 3),
1490 gfx::Rect(origin
, gfx::Size(10, 10)),
1494 MaxBorderYIndex(gfx::Size(3, 3),
1495 gfx::Rect(origin
, gfx::Size(10, 10)),
1499 MaxBorderYIndex(gfx::Size(3, 3),
1500 gfx::Rect(origin
, gfx::Size(10, 10)),
1504 MaxBorderYIndex(gfx::Size(3, 3),
1505 gfx::Rect(origin
, gfx::Size(10, 10)),
1509 MaxBorderYIndex(gfx::Size(3, 3),
1510 gfx::Rect(origin
, gfx::Size(10, 10)),
1514 MaxBorderYIndex(gfx::Size(3, 3),
1515 gfx::Rect(origin
, gfx::Size(10, 10)),
1519 MaxBorderYIndex(gfx::Size(3, 3),
1520 gfx::Rect(origin
, gfx::Size(10, 10)),
1524 MaxBorderYIndex(gfx::Size(3, 3),
1525 gfx::Rect(origin
, gfx::Size(10, 10)),
1529 MaxBorderYIndex(gfx::Size(3, 3),
1530 gfx::Rect(origin
, gfx::Size(10, 10)),
1534 MaxBorderYIndex(gfx::Size(3, 3),
1535 gfx::Rect(origin
, gfx::Size(10, 10)),
1539 MaxBorderYIndex(gfx::Size(3, 3),
1540 gfx::Rect(origin
, gfx::Size(10, 10)),
1544 MaxBorderYIndex(gfx::Size(3, 3),
1545 gfx::Rect(origin
, gfx::Size(10, 10)),
1550 MaxBorderYIndex(gfx::Size(3, 3),
1551 gfx::Rect(origin
, gfx::Size(10, 10)),
1555 MaxBorderYIndex(gfx::Size(3, 3),
1556 gfx::Rect(origin
, gfx::Size(10, 10)),
1560 MaxBorderYIndex(gfx::Size(3, 3),
1561 gfx::Rect(origin
, gfx::Size(10, 10)),
1565 MaxBorderYIndex(gfx::Size(3, 3),
1566 gfx::Rect(origin
, gfx::Size(10, 10)),
1570 MaxBorderYIndex(gfx::Size(3, 3),
1571 gfx::Rect(origin
, gfx::Size(10, 10)),
1575 MaxBorderYIndex(gfx::Size(3, 3),
1576 gfx::Rect(origin
, gfx::Size(10, 10)),
1580 MaxBorderYIndex(gfx::Size(3, 3),
1581 gfx::Rect(origin
, gfx::Size(10, 10)),
1585 MaxBorderYIndex(gfx::Size(3, 3),
1586 gfx::Rect(origin
, gfx::Size(10, 10)),
1590 MaxBorderYIndex(gfx::Size(3, 3),
1591 gfx::Rect(origin
, gfx::Size(10, 10)),
1595 MaxBorderYIndex(gfx::Size(3, 3),
1596 gfx::Rect(origin
, gfx::Size(10, 10)),
1600 MaxBorderYIndex(gfx::Size(3, 3),
1601 gfx::Rect(origin
, gfx::Size(10, 10)),
1605 MaxBorderYIndex(gfx::Size(3, 3),
1606 gfx::Rect(origin
, gfx::Size(10, 10)),
1611 MaxBorderYIndex(gfx::Size(1, 1),
1612 gfx::Rect(origin
, gfx::Size(1, 1)),
1616 MaxBorderYIndex(gfx::Size(2, 2),
1617 gfx::Rect(origin
, gfx::Size(2, 2)),
1621 MaxBorderYIndex(gfx::Size(2, 2),
1622 gfx::Rect(origin
, gfx::Size(2, 2)),
1626 MaxBorderYIndex(gfx::Size(3, 3),
1627 gfx::Rect(origin
, gfx::Size(3, 3)),
1631 MaxBorderYIndex(gfx::Size(3, 3),
1632 gfx::Rect(origin
, gfx::Size(3, 3)),
1636 MaxBorderYIndex(gfx::Size(3, 3),
1637 gfx::Rect(origin
, gfx::Size(3, 3)),
1642 MaxBorderYIndex(gfx::Size(3, 3),
1643 gfx::Rect(origin
, gfx::Size(3, 4)),
1647 MaxBorderYIndex(gfx::Size(3, 3),
1648 gfx::Rect(origin
, gfx::Size(3, 4)),
1652 MaxBorderYIndex(gfx::Size(3, 3),
1653 gfx::Rect(origin
, gfx::Size(3, 4)),
1657 MaxBorderYIndex(gfx::Size(3, 3),
1658 gfx::Rect(origin
, gfx::Size(3, 4)),
1663 MaxBorderYIndex(gfx::Size(1, 1),
1664 gfx::Rect(origin
, gfx::Size(1, 1)),
1668 MaxBorderYIndex(gfx::Size(2, 2),
1669 gfx::Rect(origin
, gfx::Size(2, 2)),
1673 MaxBorderYIndex(gfx::Size(2, 2),
1674 gfx::Rect(origin
, gfx::Size(2, 2)),
1678 MaxBorderYIndex(gfx::Size(3, 3),
1679 gfx::Rect(origin
, gfx::Size(3, 3)),
1683 MaxBorderYIndex(gfx::Size(3, 3),
1684 gfx::Rect(origin
, gfx::Size(3, 3)),
1688 MaxBorderYIndex(gfx::Size(3, 3),
1689 gfx::Rect(origin
, gfx::Size(3, 3)),
1694 MaxBorderYIndex(gfx::Size(3, 3),
1695 gfx::Rect(origin
, gfx::Size(3, 4)),
1699 MaxBorderYIndex(gfx::Size(3, 3),
1700 gfx::Rect(origin
, gfx::Size(3, 4)),
1704 MaxBorderYIndex(gfx::Size(3, 3),
1705 gfx::Rect(origin
, gfx::Size(3, 4)),
1709 MaxBorderYIndex(gfx::Size(3, 3),
1710 gfx::Rect(origin
, gfx::Size(3, 4)),
1715 TEST_P(TilingDataTest
, TileSizeX
) {
1716 gfx::Point origin
= GetParam();
1719 5, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), false, 0));
1721 5, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), true, 0));
1724 5, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), false, 0));
1726 1, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), false, 1));
1728 4, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), true, 0));
1730 2, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), true, 1));
1733 5, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), false, 0));
1735 3, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), false, 1));
1737 4, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), true, 0));
1739 4, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), true, 1));
1743 SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), false, 0));
1746 SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), false, 1));
1748 4, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), true, 0));
1750 3, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), true, 1));
1752 3, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), true, 2));
1755 4, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(11, 11)), true, 2));
1757 3, SizeX(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(12, 12)), true, 2));
1760 3, SizeX(gfx::Size(5, 9), gfx::Rect(origin
, gfx::Size(12, 17)), true, 2));
1763 TEST_P(TilingDataTest
, TileSizeY
) {
1764 gfx::Point origin
= GetParam();
1767 5, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), false, 0));
1769 5, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), true, 0));
1772 5, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), false, 0));
1774 1, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), false, 1));
1776 4, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), true, 0));
1778 2, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(6, 6)), true, 1));
1781 5, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), false, 0));
1783 3, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), false, 1));
1785 4, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), true, 0));
1787 4, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(8, 8)), true, 1));
1791 SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), false, 0));
1794 SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), false, 1));
1796 4, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), true, 0));
1798 3, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), true, 1));
1800 3, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(10, 10)), true, 2));
1803 4, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(11, 11)), true, 2));
1805 3, SizeY(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(12, 12)), true, 2));
1808 3, SizeY(gfx::Size(9, 5), gfx::Rect(origin
, gfx::Size(17, 12)), true, 2));
1811 TEST_P(TilingDataTest
, TileSizeX_and_TilePositionX
) {
1812 gfx::Point origin
= GetParam();
1814 // Single tile cases:
1816 1, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), false, 0));
1819 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), false, 0));
1822 SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 100)), false, 0));
1825 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 100)), false, 0));
1827 3, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 1)), false, 0));
1830 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 1)), false, 0));
1833 SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 100)), false, 0));
1836 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 100)), false, 0));
1838 1, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), true, 0));
1839 EXPECT_EQ(origin
.x(),
1840 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), true, 0));
1842 1, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 100)), true, 0));
1845 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 100)), true, 0));
1847 3, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 1)), true, 0));
1848 EXPECT_EQ(origin
.x(),
1849 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 1)), true, 0));
1851 3, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 100)), true, 0));
1854 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(3, 100)), true, 0));
1860 2, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), false));
1862 3, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), false, 0));
1864 3, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), false, 1));
1867 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), false, 0));
1870 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), false, 1));
1873 SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 100)), false, 0));
1876 SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 100)), false, 1));
1879 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 100)), false, 0));
1882 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 100)), false, 1));
1886 // positions 0, 2, 3, 4
1888 4, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true));
1890 2, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 0));
1892 1, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 1));
1894 1, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 2));
1896 2, SizeX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 3));
1897 EXPECT_EQ(origin
.x() + 0,
1898 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 0));
1899 EXPECT_EQ(origin
.x() + 2,
1900 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 1));
1901 EXPECT_EQ(origin
.x() + 3,
1902 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 2));
1903 EXPECT_EQ(origin
.x() + 4,
1904 PosX(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(6, 1)), true, 3));
1906 2, SizeX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 0));
1908 1, SizeX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 1));
1910 1, SizeX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 2));
1912 2, SizeX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 3));
1915 PosX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 0));
1918 PosX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 1));
1921 PosX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 2));
1924 PosX(gfx::Size(3, 7), gfx::Rect(origin
, gfx::Size(6, 100)), true, 3));
1927 TEST_P(TilingDataTest
, TileSizeY_and_TilePositionY
) {
1928 gfx::Point origin
= GetParam();
1930 // Single tile cases:
1932 1, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), false, 0));
1935 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), false, 0));
1938 SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 1)), false, 0));
1941 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 1)), false, 0));
1943 3, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 3)), false, 0));
1946 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 3)), false, 0));
1949 SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 3)), false, 0));
1952 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 3)), false, 0));
1954 1, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), true, 0));
1955 EXPECT_EQ(origin
.y(),
1956 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 1)), true, 0));
1958 1, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 1)), true, 0));
1961 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 1)), true, 0));
1963 3, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 3)), true, 0));
1964 EXPECT_EQ(origin
.y(),
1965 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 3)), true, 0));
1967 3, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 3)), true, 0));
1970 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 3)), true, 0));
1976 2, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), false));
1978 3, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), false, 0));
1980 3, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), false, 1));
1983 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), false, 0));
1986 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), false, 1));
1989 SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 6)), false, 0));
1992 SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 6)), false, 1));
1995 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 6)), false, 0));
1998 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(100, 6)), false, 1));
2002 // positions 0, 2, 3, 4
2004 4, NumTiles(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true));
2006 2, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 0));
2008 1, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 1));
2010 1, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 2));
2012 2, SizeY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 3));
2013 EXPECT_EQ(origin
.y() + 0,
2014 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 0));
2015 EXPECT_EQ(origin
.y() + 2,
2016 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 1));
2017 EXPECT_EQ(origin
.y() + 3,
2018 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 2));
2019 EXPECT_EQ(origin
.y() + 4,
2020 PosY(gfx::Size(3, 3), gfx::Rect(origin
, gfx::Size(1, 6)), true, 3));
2022 2, SizeY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 0));
2024 1, SizeY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 1));
2026 1, SizeY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 2));
2028 2, SizeY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 3));
2031 PosY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 0));
2034 PosY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 1));
2037 PosY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 2));
2040 PosY(gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(100, 6)), true, 3));
2043 TEST_P(TilingDataTest
, SetTotalSize
) {
2044 gfx::Point origin
= GetParam();
2046 TilingData
data(gfx::Size(5, 5), gfx::Rect(origin
, gfx::Size(5, 5)), false);
2047 EXPECT_EQ(origin
.x(), data
.tiling_rect().x());
2048 EXPECT_EQ(origin
.y(), data
.tiling_rect().y());
2049 EXPECT_EQ(5, data
.tiling_rect().width());
2050 EXPECT_EQ(5, data
.tiling_rect().height());
2051 EXPECT_EQ(1, data
.num_tiles_x());
2052 EXPECT_EQ(5, data
.TileSizeX(0));
2053 EXPECT_EQ(1, data
.num_tiles_y());
2054 EXPECT_EQ(5, data
.TileSizeY(0));
2056 data
.SetTilingRect(gfx::Rect(36, 82, 6, 5));
2057 EXPECT_EQ(36, data
.tiling_rect().x());
2058 EXPECT_EQ(82, data
.tiling_rect().y());
2059 EXPECT_EQ(6, data
.tiling_rect().width());
2060 EXPECT_EQ(5, data
.tiling_rect().height());
2061 EXPECT_EQ(2, data
.num_tiles_x());
2062 EXPECT_EQ(5, data
.TileSizeX(0));
2063 EXPECT_EQ(1, data
.TileSizeX(1));
2064 EXPECT_EQ(1, data
.num_tiles_y());
2065 EXPECT_EQ(5, data
.TileSizeY(0));
2067 data
.SetTilingRect(gfx::Rect(4, 22, 5, 12));
2068 EXPECT_EQ(4, data
.tiling_rect().x());
2069 EXPECT_EQ(22, data
.tiling_rect().y());
2070 EXPECT_EQ(5, data
.tiling_rect().width());
2071 EXPECT_EQ(12, data
.tiling_rect().height());
2072 EXPECT_EQ(1, data
.num_tiles_x());
2073 EXPECT_EQ(5, data
.TileSizeX(0));
2074 EXPECT_EQ(3, data
.num_tiles_y());
2075 EXPECT_EQ(5, data
.TileSizeY(0));
2076 EXPECT_EQ(5, data
.TileSizeY(1));
2077 EXPECT_EQ(2, data
.TileSizeY(2));
2080 TEST_P(TilingDataTest
, SetMaxTextureSizeNoBorders
) {
2081 gfx::Point origin
= GetParam();
2083 TilingData
data(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(16, 32)), false);
2084 EXPECT_EQ(2, data
.num_tiles_x());
2085 EXPECT_EQ(4, data
.num_tiles_y());
2087 data
.SetMaxTextureSize(gfx::Size(32, 32));
2088 EXPECT_EQ(gfx::Size(32, 32), data
.max_texture_size());
2089 EXPECT_EQ(1, data
.num_tiles_x());
2090 EXPECT_EQ(1, data
.num_tiles_y());
2092 data
.SetMaxTextureSize(gfx::Size(2, 2));
2093 EXPECT_EQ(gfx::Size(2, 2), data
.max_texture_size());
2094 EXPECT_EQ(8, data
.num_tiles_x());
2095 EXPECT_EQ(16, data
.num_tiles_y());
2097 data
.SetMaxTextureSize(gfx::Size(5, 5));
2098 EXPECT_EQ(gfx::Size(5, 5), data
.max_texture_size());
2099 EXPECT_EQ(4, data
.num_tiles_x());
2100 EXPECT_EQ(7, data
.num_tiles_y());
2102 data
.SetMaxTextureSize(gfx::Size(8, 5));
2103 EXPECT_EQ(gfx::Size(8, 5), data
.max_texture_size());
2104 EXPECT_EQ(2, data
.num_tiles_x());
2105 EXPECT_EQ(7, data
.num_tiles_y());
2108 TEST_P(TilingDataTest
, SetMaxTextureSizeBorders
) {
2109 gfx::Point origin
= GetParam();
2111 TilingData
data(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(16, 32)), true);
2112 EXPECT_EQ(3, data
.num_tiles_x());
2113 EXPECT_EQ(5, data
.num_tiles_y());
2115 data
.SetMaxTextureSize(gfx::Size(32, 32));
2116 EXPECT_EQ(gfx::Size(32, 32), data
.max_texture_size());
2117 EXPECT_EQ(1, data
.num_tiles_x());
2118 EXPECT_EQ(1, data
.num_tiles_y());
2120 data
.SetMaxTextureSize(gfx::Size(2, 2));
2121 EXPECT_EQ(gfx::Size(2, 2), data
.max_texture_size());
2122 EXPECT_EQ(0, data
.num_tiles_x());
2123 EXPECT_EQ(0, data
.num_tiles_y());
2125 data
.SetMaxTextureSize(gfx::Size(5, 5));
2126 EXPECT_EQ(gfx::Size(5, 5), data
.max_texture_size());
2127 EXPECT_EQ(5, data
.num_tiles_x());
2128 EXPECT_EQ(10, data
.num_tiles_y());
2130 data
.SetMaxTextureSize(gfx::Size(8, 5));
2131 EXPECT_EQ(gfx::Size(8, 5), data
.max_texture_size());
2132 EXPECT_EQ(3, data
.num_tiles_x());
2133 EXPECT_EQ(10, data
.num_tiles_y());
2136 TEST_P(TilingDataTest
, ExpandRectToTileBoundsWithBordersEmpty
) {
2137 gfx::Point origin
= GetParam();
2138 TilingData
empty_total_size(
2139 gfx::Size(0, 0), gfx::Rect(origin
, gfx::Size(8, 8)), true);
2142 empty_total_size
.ExpandRectToTileBoundsWithBorders(gfx::Rect()));
2143 EXPECT_RECT_EQ(gfx::Rect(),
2144 empty_total_size
.ExpandRectToTileBoundsWithBorders(
2145 gfx::Rect(100, 100, 100, 100)));
2146 EXPECT_RECT_EQ(gfx::Rect(),
2147 empty_total_size
.ExpandRectToTileBoundsWithBorders(
2148 gfx::Rect(0, 0, 100, 100)));
2150 TilingData
empty_max_texture_size(
2151 gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(0, 0)), true);
2154 empty_max_texture_size
.ExpandRectToTileBoundsWithBorders(gfx::Rect()));
2155 EXPECT_RECT_EQ(gfx::Rect(),
2156 empty_max_texture_size
.ExpandRectToTileBoundsWithBorders(
2157 gfx::Rect(100, 100, 100, 100)));
2158 EXPECT_RECT_EQ(gfx::Rect(),
2159 empty_max_texture_size
.ExpandRectToTileBoundsWithBorders(
2160 gfx::Rect(0, 0, 100, 100)));
2163 TEST_P(TilingDataTest
, ExpandRectToTileBoundsWithBorders
) {
2164 gfx::Point origin
= GetParam();
2165 TilingData
data(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(16, 32)), true);
2167 // Small rect at origin rounds up to tile 0, 0.
2168 gfx::Rect
at_origin_src(origin
, gfx::Size(1, 1));
2169 gfx::Rect
at_origin_result(data
.TileBoundsWithBorder(0, 0));
2170 EXPECT_NE(at_origin_src
, at_origin_result
);
2171 EXPECT_RECT_EQ(at_origin_result
,
2172 data
.ExpandRectToTileBoundsWithBorders(at_origin_src
));
2174 // Arbitrary internal rect.
2175 gfx::Rect
rect_src(origin
.x() + 6, origin
.y() + 6, 1, 3);
2176 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
2177 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
2178 gfx::Rect
rect_result(gfx::UnionRects(data
.TileBoundsWithBorder(2, 2),
2179 data
.TileBoundsWithBorder(3, 4)));
2180 EXPECT_NE(rect_src
, rect_result
);
2181 EXPECT_RECT_EQ(rect_result
, data
.ExpandRectToTileBoundsWithBorders(rect_src
));
2183 // On tile bounds rounds up to next tile (since border overlaps).
2184 gfx::Rect
border_rect_src(
2185 gfx::UnionRects(data
.TileBounds(1, 2), data
.TileBounds(3, 4)));
2186 gfx::Rect
border_rect_result(gfx::UnionRects(
2187 data
.TileBoundsWithBorder(0, 1), data
.TileBoundsWithBorder(4, 5)));
2188 EXPECT_RECT_EQ(border_rect_result
,
2189 data
.ExpandRectToTileBoundsWithBorders(border_rect_src
));
2191 // Equal to tiling rect.
2192 EXPECT_RECT_EQ(data
.tiling_rect(),
2193 data
.ExpandRectToTileBoundsWithBorders(data
.tiling_rect()));
2195 // Containing, but larger than tiling rect.
2196 EXPECT_RECT_EQ(data
.tiling_rect(),
2197 data
.ExpandRectToTileBoundsWithBorders(
2198 gfx::Rect(origin
, gfx::Size(100, 100))));
2200 // Non-intersecting with tiling rect.
2201 gfx::Rect
non_intersect(origin
.x() + 200, origin
.y() + 200, 100, 100);
2202 EXPECT_FALSE(non_intersect
.Intersects(data
.tiling_rect()));
2203 EXPECT_RECT_EQ(gfx::Rect(),
2204 data
.ExpandRectToTileBoundsWithBorders(non_intersect
));
2206 TilingData
data2(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(32, 64)), true);
2208 // Inside other tile border texels doesn't include other tiles.
2209 gfx::Rect
inner_rect_src(data2
.TileBounds(1, 1));
2210 inner_rect_src
.Inset(data2
.border_texels(), data
.border_texels());
2211 gfx::Rect
inner_rect_result(data2
.TileBoundsWithBorder(1, 1));
2212 gfx::Rect expanded
= data2
.ExpandRectToTileBoundsWithBorders(inner_rect_src
);
2213 EXPECT_EQ(inner_rect_result
.ToString(), expanded
.ToString());
2216 TEST_P(TilingDataTest
, ExpandRectToTileBounds
) {
2217 gfx::Point origin
= GetParam();
2218 TilingData
data(gfx::Size(4, 4), gfx::Rect(origin
, gfx::Size(16, 32)), true);
2220 // Small rect at origin rounds up to tile 0, 0.
2221 gfx::Rect
at_origin_src(origin
, gfx::Size(1, 1));
2222 gfx::Rect
at_origin_result(data
.TileBounds(0, 0));
2223 EXPECT_NE(at_origin_src
, at_origin_result
);
2224 EXPECT_RECT_EQ(at_origin_result
, data
.ExpandRectToTileBounds(at_origin_src
));
2226 // Arbitrary internal rect.
2227 gfx::Rect
rect_src(origin
.x() + 6, origin
.y() + 6, 1, 3);
2228 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
2229 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
2230 gfx::Rect
rect_result(
2231 gfx::UnionRects(data
.TileBounds(2, 2), data
.TileBounds(3, 4)));
2232 EXPECT_NE(rect_src
, rect_result
);
2233 EXPECT_RECT_EQ(rect_result
, data
.ExpandRectToTileBounds(rect_src
));
2235 // On tile bounds rounds up to next tile (since border overlaps).
2236 gfx::Rect
border_rect_src(
2237 gfx::UnionRects(data
.TileBounds(1, 2), data
.TileBounds(3, 4)));
2238 gfx::Rect
border_rect_result(
2239 gfx::UnionRects(data
.TileBounds(0, 1), data
.TileBounds(4, 5)));
2240 EXPECT_RECT_EQ(border_rect_result
,
2241 data
.ExpandRectToTileBounds(border_rect_src
));
2243 // Equal to tiling rect.
2244 EXPECT_RECT_EQ(data
.tiling_rect(),
2245 data
.ExpandRectToTileBounds(data
.tiling_rect()));
2247 // Containing, but larger than tiling rect.
2250 data
.ExpandRectToTileBounds(gfx::Rect(origin
, gfx::Size(100, 100))));
2252 // Non-intersecting with tiling rect.
2253 gfx::Rect
non_intersect(origin
.x() + 200, origin
.y() + 200, 100, 100);
2254 EXPECT_FALSE(non_intersect
.Intersects(data
.tiling_rect()));
2255 EXPECT_RECT_EQ(gfx::Rect(), data
.ExpandRectToTileBounds(non_intersect
));
2257 TilingData
data2(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(32, 64)), true);
2259 // Inside other tile border texels doesn't include other tiles.
2260 gfx::Rect
inner_rect_src(data2
.TileBounds(1, 1));
2261 inner_rect_src
.Inset(data2
.border_texels(), data
.border_texels());
2262 gfx::Rect
inner_rect_result(data2
.TileBounds(1, 1));
2263 gfx::Rect expanded
= data2
.ExpandRectToTileBounds(inner_rect_src
);
2264 EXPECT_EQ(inner_rect_result
.ToString(), expanded
.ToString());
2267 TEST_P(TilingDataTest
, Assignment
) {
2268 gfx::Point origin
= GetParam();
2272 gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(16, 32)), true);
2273 TilingData dest
= source
;
2274 EXPECT_EQ(source
.border_texels(), dest
.border_texels());
2275 EXPECT_EQ(source
.max_texture_size(), dest
.max_texture_size());
2276 EXPECT_EQ(source
.num_tiles_x(), dest
.num_tiles_x());
2277 EXPECT_EQ(source
.num_tiles_y(), dest
.num_tiles_y());
2278 EXPECT_EQ(source
.tiling_rect().x(), dest
.tiling_rect().x());
2279 EXPECT_EQ(source
.tiling_rect().y(), dest
.tiling_rect().y());
2280 EXPECT_EQ(source
.tiling_rect().width(), dest
.tiling_rect().width());
2281 EXPECT_EQ(source
.tiling_rect().height(), dest
.tiling_rect().height());
2285 gfx::Size(7, 3), gfx::Rect(origin
, gfx::Size(6, 100)), false);
2286 TilingData
dest(source
);
2287 EXPECT_EQ(source
.border_texels(), dest
.border_texels());
2288 EXPECT_EQ(source
.max_texture_size(), dest
.max_texture_size());
2289 EXPECT_EQ(source
.num_tiles_x(), dest
.num_tiles_x());
2290 EXPECT_EQ(source
.num_tiles_y(), dest
.num_tiles_y());
2291 EXPECT_EQ(source
.tiling_rect().x(), dest
.tiling_rect().x());
2292 EXPECT_EQ(source
.tiling_rect().y(), dest
.tiling_rect().y());
2293 EXPECT_EQ(source
.tiling_rect().width(), dest
.tiling_rect().width());
2294 EXPECT_EQ(source
.tiling_rect().height(), dest
.tiling_rect().height());
2298 TEST_P(TilingDataTest
, SetBorderTexels
) {
2299 gfx::Point origin
= GetParam();
2301 TilingData
data(gfx::Size(8, 8), gfx::Rect(origin
, gfx::Size(16, 32)), false);
2302 EXPECT_EQ(2, data
.num_tiles_x());
2303 EXPECT_EQ(4, data
.num_tiles_y());
2305 data
.SetHasBorderTexels(true);
2306 EXPECT_EQ(3, data
.num_tiles_x());
2307 EXPECT_EQ(5, data
.num_tiles_y());
2309 data
.SetHasBorderTexels(false);
2310 EXPECT_EQ(2, data
.num_tiles_x());
2311 EXPECT_EQ(4, data
.num_tiles_y());
2314 TEST_P(TilingDataTest
, LargeBorders
) {
2315 gfx::Point origin
= GetParam();
2318 gfx::Size(100, 80), gfx::Rect(origin
, gfx::Size(200, 145)), 30);
2319 EXPECT_EQ(30, data
.border_texels());
2321 EXPECT_EQ(70, data
.TileSizeX(0));
2322 EXPECT_EQ(40, data
.TileSizeX(1));
2323 EXPECT_EQ(40, data
.TileSizeX(2));
2324 EXPECT_EQ(50, data
.TileSizeX(3));
2325 EXPECT_EQ(4, data
.num_tiles_x());
2327 EXPECT_EQ(50, data
.TileSizeY(0));
2328 EXPECT_EQ(20, data
.TileSizeY(1));
2329 EXPECT_EQ(20, data
.TileSizeY(2));
2330 EXPECT_EQ(20, data
.TileSizeY(3));
2331 EXPECT_EQ(35, data
.TileSizeY(4));
2332 EXPECT_EQ(5, data
.num_tiles_y());
2334 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 0, origin
.y() + 0, 70, 50),
2335 data
.TileBounds(0, 0));
2336 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 70, origin
.y() + 50, 40, 20),
2337 data
.TileBounds(1, 1));
2338 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 110, origin
.y() + 110, 40, 35),
2339 data
.TileBounds(2, 4));
2340 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 150, origin
.y() + 70, 50, 20),
2341 data
.TileBounds(3, 2));
2342 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 150, origin
.y() + 110, 50, 35),
2343 data
.TileBounds(3, 4));
2345 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 0, origin
.y() + 0, 100, 80),
2346 data
.TileBoundsWithBorder(0, 0));
2347 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 40, origin
.y() + 20, 100, 80),
2348 data
.TileBoundsWithBorder(1, 1));
2349 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 80, origin
.y() + 80, 100, 65),
2350 data
.TileBoundsWithBorder(2, 4));
2351 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 120, origin
.y() + 40, 80, 80),
2352 data
.TileBoundsWithBorder(3, 2));
2353 EXPECT_RECT_EQ(gfx::Rect(origin
.x() + 120, origin
.y() + 80, 80, 65),
2354 data
.TileBoundsWithBorder(3, 4));
2356 EXPECT_EQ(0, data
.TileXIndexFromSrcCoord(origin
.x() + 0));
2357 EXPECT_EQ(0, data
.TileXIndexFromSrcCoord(origin
.x() + 69));
2358 EXPECT_EQ(1, data
.TileXIndexFromSrcCoord(origin
.x() + 70));
2359 EXPECT_EQ(1, data
.TileXIndexFromSrcCoord(origin
.x() + 109));
2360 EXPECT_EQ(2, data
.TileXIndexFromSrcCoord(origin
.x() + 110));
2361 EXPECT_EQ(2, data
.TileXIndexFromSrcCoord(origin
.x() + 149));
2362 EXPECT_EQ(3, data
.TileXIndexFromSrcCoord(origin
.x() + 150));
2363 EXPECT_EQ(3, data
.TileXIndexFromSrcCoord(origin
.x() + 199));
2365 EXPECT_EQ(0, data
.TileYIndexFromSrcCoord(origin
.y() + 0));
2366 EXPECT_EQ(0, data
.TileYIndexFromSrcCoord(origin
.y() + 49));
2367 EXPECT_EQ(1, data
.TileYIndexFromSrcCoord(origin
.y() + 50));
2368 EXPECT_EQ(1, data
.TileYIndexFromSrcCoord(origin
.y() + 69));
2369 EXPECT_EQ(2, data
.TileYIndexFromSrcCoord(origin
.y() + 70));
2370 EXPECT_EQ(2, data
.TileYIndexFromSrcCoord(origin
.y() + 89));
2371 EXPECT_EQ(3, data
.TileYIndexFromSrcCoord(origin
.y() + 90));
2372 EXPECT_EQ(3, data
.TileYIndexFromSrcCoord(origin
.y() + 109));
2373 EXPECT_EQ(4, data
.TileYIndexFromSrcCoord(origin
.y() + 110));
2374 EXPECT_EQ(4, data
.TileYIndexFromSrcCoord(origin
.y() + 144));
2376 EXPECT_EQ(0, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 0));
2377 EXPECT_EQ(0, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 99));
2378 EXPECT_EQ(1, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 100));
2379 EXPECT_EQ(1, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 139));
2380 EXPECT_EQ(2, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 140));
2381 EXPECT_EQ(2, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 179));
2382 EXPECT_EQ(3, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 180));
2383 EXPECT_EQ(3, data
.FirstBorderTileXIndexFromSrcCoord(origin
.x() + 199));
2385 EXPECT_EQ(0, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 0));
2386 EXPECT_EQ(0, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 79));
2387 EXPECT_EQ(1, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 80));
2388 EXPECT_EQ(1, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 99));
2389 EXPECT_EQ(2, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 100));
2390 EXPECT_EQ(2, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 119));
2391 EXPECT_EQ(3, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 120));
2392 EXPECT_EQ(3, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 139));
2393 EXPECT_EQ(4, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 140));
2394 EXPECT_EQ(4, data
.FirstBorderTileYIndexFromSrcCoord(origin
.y() + 144));
2396 EXPECT_EQ(0, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 0));
2397 EXPECT_EQ(0, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 39));
2398 EXPECT_EQ(1, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 40));
2399 EXPECT_EQ(1, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 79));
2400 EXPECT_EQ(2, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 80));
2401 EXPECT_EQ(2, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 119));
2402 EXPECT_EQ(3, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 120));
2403 EXPECT_EQ(3, data
.LastBorderTileXIndexFromSrcCoord(origin
.x() + 199));
2405 EXPECT_EQ(0, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 0));
2406 EXPECT_EQ(0, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 19));
2407 EXPECT_EQ(1, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 20));
2408 EXPECT_EQ(1, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 39));
2409 EXPECT_EQ(2, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 40));
2410 EXPECT_EQ(2, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 59));
2411 EXPECT_EQ(3, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 60));
2412 EXPECT_EQ(3, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 79));
2413 EXPECT_EQ(4, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 80));
2414 EXPECT_EQ(4, data
.LastBorderTileYIndexFromSrcCoord(origin
.y() + 144));
2417 void TestIterate(const TilingData
& data
,
2423 bool include_borders
) {
2424 EXPECT_GE(expect_left
, 0);
2425 EXPECT_GE(expect_top
, 0);
2426 EXPECT_LT(expect_right
, data
.num_tiles_x());
2427 EXPECT_LT(expect_bottom
, data
.num_tiles_y());
2429 std::vector
<std::pair
<int, int> > original_expected
;
2430 for (int x
= 0; x
< data
.num_tiles_x(); ++x
) {
2431 for (int y
= 0; y
< data
.num_tiles_y(); ++y
) {
2433 if (include_borders
)
2434 bounds
= data
.TileBoundsWithBorder(x
, y
);
2436 bounds
= data
.TileBounds(x
, y
);
2437 if (x
>= expect_left
&& x
<= expect_right
&&
2438 y
>= expect_top
&& y
<= expect_bottom
) {
2439 EXPECT_TRUE(bounds
.Intersects(rect
));
2440 original_expected
.push_back(std::make_pair(x
, y
));
2442 EXPECT_FALSE(bounds
.Intersects(rect
));
2447 // Verify with vanilla iterator.
2449 std::vector
<std::pair
<int, int> > expected
= original_expected
;
2450 for (TilingData::Iterator
iter(&data
, rect
, include_borders
); iter
;
2453 for (size_t i
= 0; i
< expected
.size(); ++i
) {
2454 if (expected
[i
] == iter
.index()) {
2455 expected
[i
] = expected
.back();
2456 expected
.pop_back();
2463 EXPECT_EQ(0u, expected
.size());
2466 // Make sure this also works with a difference iterator and an empty ignore.
2467 // The difference iterator always includes borders, so ignore it otherwise.
2468 if (include_borders
) {
2469 std::vector
<std::pair
<int, int> > expected
= original_expected
;
2470 for (TilingData::DifferenceIterator
iter(&data
, rect
, gfx::Rect());
2473 for (size_t i
= 0; i
< expected
.size(); ++i
) {
2474 if (expected
[i
] == iter
.index()) {
2475 expected
[i
] = expected
.back();
2476 expected
.pop_back();
2483 EXPECT_EQ(0u, expected
.size());
2487 void TestIterateBorders(const TilingData
& data
,
2492 int expect_bottom
) {
2493 bool include_borders
= true;
2503 void TestIterateNoBorders(const TilingData
& data
,
2508 int expect_bottom
) {
2509 bool include_borders
= false;
2519 void TestIterateAll(const TilingData
& data
,
2524 int expect_bottom
) {
2526 data
, rect
, expect_left
, expect_top
, expect_right
, expect_bottom
);
2527 TestIterateNoBorders(
2528 data
, rect
, expect_left
, expect_top
, expect_right
, expect_bottom
);
2531 TEST_P(TilingDataTest
, IteratorNoBorderTexels
) {
2532 gfx::Point origin
= GetParam();
2535 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(40, 25)), false);
2536 // The following Coordinates are relative to the origin.
2537 // X border index by src coord: [0-10), [10-20), [20, 30), [30, 40)
2538 // Y border index by src coord: [0-10), [10-20), [20, 25)
2539 TestIterateAll(data
, gfx::Rect(origin
.x(), origin
.y(), 40, 25), 0, 0, 3, 2);
2541 data
, gfx::Rect(origin
.x() + 15, origin
.y() + 15, 8, 8), 1, 1, 2, 2);
2544 TestIterateAll(data
,
2545 gfx::Rect(origin
.x() - 100, origin
.y() - 100, 1000, 1000),
2551 data
, gfx::Rect(origin
.x() - 100, origin
.y() + 20, 1000, 1), 0, 2, 3, 2);
2553 data
, gfx::Rect(origin
.x() + 29, origin
.y() - 100, 31, 1000), 2, 0, 3, 2);
2555 TestIterateAll(data
,
2556 gfx::Rect(origin
.x() + 60, origin
.y() + 80, 100, 100),
2563 TEST_P(TilingDataTest
, BordersIteratorOneBorderTexel
) {
2564 gfx::Point origin
= GetParam();
2567 gfx::Size(10, 20), gfx::Rect(origin
, gfx::Size(25, 45)), true);
2568 // The following Coordinates are relative to the origin.
2569 // X border index by src coord: [0-10), [8-18), [16-25)
2570 // Y border index by src coord: [0-20), [18-38), [36-45)
2572 data
, gfx::Rect(origin
.x(), origin
.y(), 25, 45), 0, 0, 2, 2);
2574 data
, gfx::Rect(origin
.x() + 18, origin
.y() + 19, 3, 17), 2, 0, 2, 1);
2576 data
, gfx::Rect(origin
.x() + 10, origin
.y() + 20, 6, 16), 1, 1, 1, 1);
2578 data
, gfx::Rect(origin
.x() + 9, origin
.y() + 19, 8, 18), 0, 0, 2, 2);
2580 TestIterateBorders(data
,
2581 gfx::Rect(origin
.x() - 100, origin
.y() - 100, 1000, 1000),
2587 data
, gfx::Rect(origin
.x() - 100, origin
.y() + 20, 1000, 1), 0, 1, 2, 1);
2589 data
, gfx::Rect(origin
.x() + 18, origin
.y() - 100, 6, 1000), 2, 0, 2, 2);
2591 TestIterateBorders(data
,
2592 gfx::Rect(origin
.x() + 60, origin
.y() + 80, 100, 100),
2599 TEST_P(TilingDataTest
, NoBordersIteratorOneBorderTexel
) {
2600 gfx::Point origin
= GetParam();
2603 gfx::Size(10, 20), gfx::Rect(origin
, gfx::Size(25, 45)), true);
2604 // The following Coordinates are relative to the origin.
2605 // X index by src coord: [0-9), [9-17), [17-25)
2606 // Y index by src coord: [0-19), [19-37), [37-45)
2607 TestIterateNoBorders(
2608 data
, gfx::Rect(origin
.x(), origin
.y(), 25, 45), 0, 0, 2, 2);
2609 TestIterateNoBorders(
2610 data
, gfx::Rect(origin
.x() + 17, origin
.y() + 19, 3, 18), 2, 1, 2, 1);
2611 TestIterateNoBorders(
2612 data
, gfx::Rect(origin
.x() + 17, origin
.y() + 19, 3, 19), 2, 1, 2, 2);
2613 TestIterateNoBorders(
2614 data
, gfx::Rect(origin
.x() + 8, origin
.y() + 18, 9, 19), 0, 0, 1, 1);
2615 TestIterateNoBorders(
2616 data
, gfx::Rect(origin
.x() + 9, origin
.y() + 19, 9, 19), 1, 1, 2, 2);
2618 TestIterateNoBorders(
2620 gfx::Rect(origin
.x() - 100, origin
.y() - 100, 1000, 1000),
2625 TestIterateNoBorders(
2626 data
, gfx::Rect(origin
.x() - 100, origin
.y() + 20, 1000, 1), 0, 1, 2, 1);
2627 TestIterateNoBorders(
2628 data
, gfx::Rect(origin
.x() + 18, origin
.y() - 100, 6, 1000), 2, 0, 2, 2);
2630 TestIterateNoBorders(data
,
2631 gfx::Rect(origin
.x() + 60, origin
.y() + 80, 100, 100),
2638 TEST_P(TilingDataTest
, BordersIteratorManyBorderTexels
) {
2639 gfx::Point origin
= GetParam();
2641 TilingData
data(gfx::Size(50, 60), gfx::Rect(origin
, gfx::Size(65, 110)), 20);
2642 // The following Coordinates are relative to the origin.
2643 // X border index by src coord: [0-50), [10-60), [20-65)
2644 // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
2646 data
, gfx::Rect(origin
.x(), origin
.y(), 65, 110), 0, 0, 2, 3);
2648 data
, gfx::Rect(origin
.x() + 50, origin
.y() + 60, 15, 65), 1, 1, 2, 3);
2650 data
, gfx::Rect(origin
.x() + 60, origin
.y() + 30, 2, 10), 2, 0, 2, 1);
2652 TestIterateBorders(data
,
2653 gfx::Rect(origin
.x() - 100, origin
.y() - 100, 1000, 1000),
2659 data
, gfx::Rect(origin
.x() - 100, origin
.y() + 10, 1000, 10), 0, 0, 2, 0);
2661 data
, gfx::Rect(origin
.x() + 10, origin
.y() - 100, 10, 1000), 0, 0, 1, 3);
2663 TestIterateBorders(data
,
2664 gfx::Rect(origin
.x() + 65, origin
.y() + 110, 100, 100),
2671 TEST_P(TilingDataTest
, NoBordersIteratorManyBorderTexels
) {
2672 gfx::Point origin
= GetParam();
2674 TilingData
data(gfx::Size(50, 60), gfx::Rect(origin
, gfx::Size(65, 110)), 20);
2675 // The following Coordinates are relative to the origin.
2676 // X index by src coord: [0-30), [30-40), [40, 65)
2677 // Y index by src coord: [0-40), [40-60), [60, 80), [80-110)
2678 TestIterateNoBorders(
2679 data
, gfx::Rect(origin
.x(), origin
.y(), 65, 110), 0, 0, 2, 3);
2680 TestIterateNoBorders(
2681 data
, gfx::Rect(origin
.x() + 30, origin
.y() + 40, 15, 65), 1, 1, 2, 3);
2682 TestIterateNoBorders(
2683 data
, gfx::Rect(origin
.x() + 60, origin
.y() + 20, 2, 21), 2, 0, 2, 1);
2685 TestIterateNoBorders(
2687 gfx::Rect(origin
.x() - 100, origin
.y() - 100, 1000, 1000),
2692 TestIterateNoBorders(
2693 data
, gfx::Rect(origin
.x() - 100, origin
.y() + 10, 1000, 10), 0, 0, 2, 0);
2694 TestIterateNoBorders(
2695 data
, gfx::Rect(origin
.x() + 10, origin
.y() - 100, 10, 1000), 0, 0, 0, 3);
2697 TestIterateNoBorders(data
,
2698 gfx::Rect(origin
.x() + 65, origin
.y() + 110, 100, 100),
2705 TEST_P(TilingDataTest
, IteratorOneTile
) {
2706 gfx::Point origin
= GetParam();
2708 TilingData
no_border(
2709 gfx::Size(1000, 1000), gfx::Rect(origin
, gfx::Size(30, 40)), false);
2711 no_border
, gfx::Rect(origin
.x(), origin
.y(), 30, 40), 0, 0, 0, 0);
2712 TestIterateAll(no_border
,
2713 gfx::Rect(origin
.x() + 10, origin
.y() + 10, 20, 20),
2718 TestIterateAll(no_border
,
2719 gfx::Rect(origin
.x() + 30, origin
.y() + 40, 100, 100),
2725 TilingData
one_border(
2726 gfx::Size(1000, 1000), gfx::Rect(origin
, gfx::Size(30, 40)), true);
2728 one_border
, gfx::Rect(origin
.x(), origin
.y(), 30, 40), 0, 0, 0, 0);
2729 TestIterateAll(one_border
,
2730 gfx::Rect(origin
.x() + 10, origin
.y() + 10, 20, 20),
2735 TestIterateAll(one_border
,
2736 gfx::Rect(origin
.x() + 30, origin
.y() + 40, 100, 100),
2742 TilingData
big_border(
2743 gfx::Size(1000, 1000), gfx::Rect(origin
, gfx::Size(30, 40)), 50);
2745 big_border
, gfx::Rect(origin
.x(), origin
.y(), 30, 40), 0, 0, 0, 0);
2746 TestIterateAll(big_border
,
2747 gfx::Rect(origin
.x() + 10, origin
.y() + 10, 20, 20),
2752 TestIterateAll(big_border
,
2753 gfx::Rect(origin
.x() + 30, origin
.y() + 40, 100, 100),
2760 TEST(TilingDataTest
, IteratorNoTiles
) {
2761 TilingData
data(gfx::Size(100, 100), gfx::Rect(), false);
2762 TestIterateAll(data
, gfx::Rect(0, 0, 100, 100), 0, 0, -1, -1);
2766 const TilingData
& data
,
2771 std::vector
<std::pair
<int, int> > expected
;
2772 for (int y
= 0; y
< data
.num_tiles_y(); ++y
) {
2773 for (int x
= 0; x
< data
.num_tiles_x(); ++x
) {
2774 gfx::Rect bounds
= data
.TileBoundsWithBorder(x
, y
);
2775 if (bounds
.Intersects(consider
) && !bounds
.Intersects(ignore
))
2776 expected
.push_back(std::make_pair(x
, y
));
2780 // Sanity check the test.
2781 EXPECT_EQ(num_tiles
, expected
.size());
2783 for (TilingData::DifferenceIterator
iter(&data
, consider
, ignore
);
2786 for (size_t i
= 0; i
< expected
.size(); ++i
) {
2787 if (expected
[i
] == iter
.index()) {
2788 expected
[i
] = expected
.back();
2789 expected
.pop_back();
2796 EXPECT_EQ(0u, expected
.size());
2799 TEST_P(TilingDataTest
, DifferenceIteratorIgnoreGeometry
) {
2800 // This test is checking that the iterator can handle different geometries of
2801 // ignore rects relative to the consider rect. The consider rect indices
2802 // themselves are mostly tested by the non-difference iterator tests, so the
2803 // full rect is mostly used here for simplicity.
2805 gfx::Point origin
= GetParam();
2807 // The following Coordinates are relative to the origin.
2808 // X border index by src coord: [0-10), [10-20), [20, 30), [30, 40)
2809 // Y border index by src coord: [0-10), [10-20), [20, 25)
2811 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(40, 25)), false);
2815 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2816 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2819 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2820 gfx::Rect(origin
.x() - 100, origin
.y() - 100, 200, 200),
2823 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2824 gfx::Rect(origin
.x() + 9, origin
.y() + 9, 30, 15),
2827 gfx::Rect(origin
.x() + 15, origin
.y() + 15, 8, 8),
2828 gfx::Rect(origin
.x() + 15, origin
.y() + 15, 8, 8),
2833 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2834 gfx::Rect(origin
.x() - 30, origin
.y() - 20, 8, 8),
2836 TestDiff(data
, gfx::Rect(origin
.x(), origin
.y(), 40, 25), gfx::Rect(), 12);
2838 // Top left, remove 2x2 tiles
2840 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2841 gfx::Rect(origin
.x(), origin
.y(), 20, 19),
2843 // Bottom right, remove 2x2 tiles
2845 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2846 gfx::Rect(origin
.x() + 20, origin
.y() + 15, 20, 6),
2848 // Bottom left, remove 2x2 tiles
2850 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2851 gfx::Rect(origin
.x(), origin
.y() + 15, 20, 6),
2853 // Top right, remove 2x2 tiles
2855 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2856 gfx::Rect(origin
.x() + 20, origin
.y(), 20, 19),
2858 // Center, remove only one tile
2860 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2861 gfx::Rect(origin
.x() + 10, origin
.y() + 10, 5, 5),
2864 // Left column, flush left, removing two columns
2866 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2867 gfx::Rect(origin
.x(), origin
.y(), 11, 25),
2869 // Middle column, removing two columns
2871 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2872 gfx::Rect(origin
.x() + 11, origin
.y(), 11, 25),
2874 // Right column, flush right, removing one column
2876 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2877 gfx::Rect(origin
.x() + 30, origin
.y(), 2, 25),
2880 // Top row, flush top, removing one row
2882 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2883 gfx::Rect(origin
.x(), origin
.y() + 5, 40, 5),
2885 // Middle row, removing one row
2887 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2888 gfx::Rect(origin
.x(), origin
.y() + 13, 40, 5),
2890 // Bottom row, flush bottom, removing two rows
2892 gfx::Rect(origin
.x(), origin
.y(), 40, 25),
2893 gfx::Rect(origin
.x(), origin
.y() + 13, 40, 12),
2896 // Non-intersecting, but still touching two of the same tiles.
2898 gfx::Rect(origin
.x() + 8, origin
.y(), 32, 25),
2899 gfx::Rect(origin
.x(), origin
.y() + 12, 5, 12),
2902 // Intersecting, but neither contains the other. 2x3 with one overlap.
2904 gfx::Rect(origin
.x() + 5, origin
.y() + 2, 20, 10),
2905 gfx::Rect(origin
.x() + 25, origin
.y() + 15, 5, 10),
2909 TEST_P(TilingDataTest
, DifferenceIteratorManyBorderTexels
) {
2910 gfx::Point origin
= GetParam();
2912 // The following Coordinates are relative to the origin.
2913 // X border index by src coord: [0-50), [10-60), [20-65)
2914 // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
2915 TilingData
data(gfx::Size(50, 60), gfx::Rect(origin
, gfx::Size(65, 110)), 20);
2917 // Ignore one column, three rows
2919 gfx::Rect(origin
.x(), origin
.y() + 30, 55, 80),
2920 gfx::Rect(origin
.x() + 5, origin
.y() + 30, 5, 15),
2923 // Knock out three columns, leaving only one.
2925 gfx::Rect(origin
.x() + 10, origin
.y() + 30, 55, 80),
2926 gfx::Rect(origin
.x() + 30, origin
.y() + 59, 20, 1),
2929 // Overlap all tiles with ignore rect.
2931 gfx::Rect(origin
.x(), origin
.y(), 65, 110),
2932 gfx::Rect(origin
.x() + 30, origin
.y() + 59, 1, 2),
2936 TEST_P(TilingDataTest
, DifferenceIteratorOneTile
) {
2937 gfx::Point origin
= GetParam();
2939 TilingData
no_border(
2940 gfx::Size(1000, 1000), gfx::Rect(origin
, gfx::Size(30, 40)), false);
2942 no_border
, gfx::Rect(origin
.x(), origin
.y(), 30, 40), gfx::Rect(), 1);
2944 gfx::Rect(origin
.x() + 5, origin
.y() + 5, 100, 100),
2945 gfx::Rect(origin
.x() + 5, origin
.y() + 5, 1, 1),
2948 TilingData
one_border(
2949 gfx::Size(1000, 1000), gfx::Rect(origin
, gfx::Size(30, 40)), true);
2951 one_border
, gfx::Rect(origin
.x(), origin
.y(), 30, 40), gfx::Rect(), 1);
2952 TestDiff(one_border
,
2953 gfx::Rect(origin
.x() + 5, origin
.y() + 5, 100, 100),
2954 gfx::Rect(origin
.x() + 5, origin
.y() + 5, 1, 1),
2957 TilingData
big_border(
2958 gfx::Size(1000, 1000), gfx::Rect(origin
, gfx::Size(30, 40)), 50);
2960 big_border
, gfx::Rect(origin
.x(), origin
.y(), 30, 40), gfx::Rect(), 1);
2961 TestDiff(big_border
,
2962 gfx::Rect(origin
.x() + 5, origin
.y() + 5, 100, 100),
2963 gfx::Rect(origin
.x() + 5, origin
.y() + 5, 1, 1),
2967 TEST(TilingDataTest
, DifferenceIteratorNoTiles
) {
2968 TilingData
data(gfx::Size(100, 100), gfx::Rect(), false);
2969 TestDiff(data
, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 5, 5), 0);
2972 void TestSpiralIterate(int source_line_number
,
2973 const TilingData
& tiling_data
,
2974 const gfx::Rect
& consider
,
2975 const gfx::Rect
& ignore
,
2976 const gfx::Rect
& center
,
2977 const std::vector
<std::pair
<int, int> >& expected
) {
2978 std::vector
<std::pair
<int, int> > actual
;
2979 for (TilingData::SpiralDifferenceIterator
it(
2980 &tiling_data
, consider
, ignore
, center
);
2983 actual
.push_back(it
.index());
2986 EXPECT_EQ(expected
.size(), actual
.size()) << "error from line "
2987 << source_line_number
;
2988 for (size_t i
= 0; i
< std::min(expected
.size(), actual
.size()); ++i
) {
2989 EXPECT_EQ(expected
[i
].first
, actual
[i
].first
)
2990 << "i: " << i
<< " error from line: " << source_line_number
;
2991 EXPECT_EQ(expected
[i
].second
, actual
[i
].second
)
2992 << "i: " << i
<< " error from line: " << source_line_number
;
2996 TEST_P(TilingDataTest
, SpiralDifferenceIteratorNoIgnoreFullConsider
) {
2997 gfx::Point origin
= GetParam();
2998 TilingData
tiling_data(
2999 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(30, 30)), false);
3000 gfx::Rect
consider(origin
.x(), origin
.y(), 30, 30);
3002 std::vector
<std::pair
<int, int> > expected
;
3004 // Center is in the center of the tiling.
3005 gfx::Rect
center(origin
.x() + 15, origin
.y() + 15, 1, 1);
3007 // Layout of the tiling data, and expected return order:
3013 expected
.push_back(std::make_pair(2, 1));
3014 expected
.push_back(std::make_pair(2, 0));
3015 expected
.push_back(std::make_pair(1, 0));
3016 expected
.push_back(std::make_pair(0, 0));
3017 expected
.push_back(std::make_pair(0, 1));
3018 expected
.push_back(std::make_pair(0, 2));
3019 expected
.push_back(std::make_pair(1, 2));
3020 expected
.push_back(std::make_pair(2, 2));
3022 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3024 // Center is off to the right side of the tiling (and far away).
3025 center
= gfx::Rect(origin
.x() + 100, origin
.y() + 15, 1, 1);
3027 // Layout of the tiling data, and expected return order:
3034 expected
.push_back(std::make_pair(2, 0));
3035 expected
.push_back(std::make_pair(2, 1));
3036 expected
.push_back(std::make_pair(2, 2));
3037 expected
.push_back(std::make_pair(1, 0));
3038 expected
.push_back(std::make_pair(1, 1));
3039 expected
.push_back(std::make_pair(1, 2));
3040 expected
.push_back(std::make_pair(0, 0));
3041 expected
.push_back(std::make_pair(0, 1));
3042 expected
.push_back(std::make_pair(0, 2));
3044 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3046 // Center is the bottom right corner of the tiling.
3047 center
= gfx::Rect(origin
.x() + 25, origin
.y() + 25, 1, 1);
3049 // Layout of the tiling data, and expected return order:
3056 expected
.push_back(std::make_pair(2, 1));
3057 expected
.push_back(std::make_pair(1, 1));
3058 expected
.push_back(std::make_pair(1, 2));
3059 expected
.push_back(std::make_pair(2, 0));
3060 expected
.push_back(std::make_pair(1, 0));
3061 expected
.push_back(std::make_pair(0, 0));
3062 expected
.push_back(std::make_pair(0, 1));
3063 expected
.push_back(std::make_pair(0, 2));
3065 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3067 // Center is off the top left side of the tiling.
3068 center
= gfx::Rect(origin
.x() - 60, origin
.y() - 50, 1, 1);
3070 // Layout of the tiling data, and expected return order:
3077 expected
.push_back(std::make_pair(0, 0));
3078 expected
.push_back(std::make_pair(1, 0));
3079 expected
.push_back(std::make_pair(0, 1));
3080 expected
.push_back(std::make_pair(1, 1));
3081 expected
.push_back(std::make_pair(2, 1));
3082 expected
.push_back(std::make_pair(2, 0));
3083 expected
.push_back(std::make_pair(0, 2));
3084 expected
.push_back(std::make_pair(1, 2));
3085 expected
.push_back(std::make_pair(2, 2));
3087 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3090 center
= gfx::Rect(origin
.x() + 15, origin
.y() + 15, 1, 10);
3092 // Layout of the tiling data, and expected return order:
3099 expected
.push_back(std::make_pair(2, 2));
3100 expected
.push_back(std::make_pair(2, 1));
3101 expected
.push_back(std::make_pair(2, 0));
3102 expected
.push_back(std::make_pair(1, 0));
3103 expected
.push_back(std::make_pair(0, 0));
3104 expected
.push_back(std::make_pair(0, 1));
3105 expected
.push_back(std::make_pair(0, 2));
3107 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3110 TEST_P(TilingDataTest
, SpiralDifferenceIteratorSmallConsider
) {
3111 gfx::Point origin
= GetParam();
3112 TilingData
tiling_data(
3113 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(50, 50)), false);
3115 std::vector
<std::pair
<int, int> > expected
;
3116 gfx::Rect
center(origin
.x() + 15, origin
.y() + 15, 1, 1);
3118 // Consider is one cell.
3119 gfx::Rect
consider(origin
.x(), origin
.y(), 1, 1);
3121 // Layout of the tiling data, and expected return order:
3129 expected
.push_back(std::make_pair(0, 0));
3131 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3133 // Consider is bottom right corner.
3134 consider
= gfx::Rect(origin
.x() + 25, origin
.y() + 25, 10, 10);
3136 // Layout of the tiling data, and expected return order:
3145 expected
.push_back(std::make_pair(2, 2));
3146 expected
.push_back(std::make_pair(3, 2));
3147 expected
.push_back(std::make_pair(2, 3));
3148 expected
.push_back(std::make_pair(3, 3));
3150 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3152 // Consider is one column.
3153 consider
= gfx::Rect(origin
.x() + 11, origin
.y(), 1, 100);
3155 // Layout of the tiling data, and expected return order:
3164 expected
.push_back(std::make_pair(1, 0));
3165 expected
.push_back(std::make_pair(1, 2));
3166 expected
.push_back(std::make_pair(1, 3));
3167 expected
.push_back(std::make_pair(1, 4));
3169 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3172 TEST_P(TilingDataTest
, SpiralDifferenceIteratorHasIgnore
) {
3173 gfx::Point origin
= GetParam();
3174 TilingData
tiling_data(
3175 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(50, 50)), false);
3176 gfx::Rect
consider(origin
.x(), origin
.y(), 50, 50);
3177 std::vector
<std::pair
<int, int> > expected
;
3178 gfx::Rect
center(origin
.x() + 15, origin
.y() + 15, 1, 1);
3181 gfx::Rect
ignore(origin
.x(), origin
.y(), 50, 50);
3183 // Layout of the tiling data, and expected return order:
3193 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3196 ignore
= gfx::Rect(origin
.x() + 15, origin
.y(), 20, 100);
3198 // Layout of the tiling data, and expected return order:
3208 expected
.push_back(std::make_pair(0, 0));
3209 expected
.push_back(std::make_pair(0, 1));
3210 expected
.push_back(std::make_pair(0, 2));
3211 expected
.push_back(std::make_pair(0, 3));
3212 expected
.push_back(std::make_pair(4, 3));
3213 expected
.push_back(std::make_pair(4, 2));
3214 expected
.push_back(std::make_pair(4, 1));
3215 expected
.push_back(std::make_pair(4, 0));
3216 expected
.push_back(std::make_pair(0, 4));
3217 expected
.push_back(std::make_pair(4, 4));
3219 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3221 // Ignore covers the top half.
3222 ignore
= gfx::Rect(origin
.x(), origin
.y(), 50, 25);
3224 // Layout of the tiling data, and expected return order:
3234 expected
.push_back(std::make_pair(0, 3));
3235 expected
.push_back(std::make_pair(1, 3));
3236 expected
.push_back(std::make_pair(2, 3));
3237 expected
.push_back(std::make_pair(3, 3));
3238 expected
.push_back(std::make_pair(4, 3));
3239 expected
.push_back(std::make_pair(0, 4));
3240 expected
.push_back(std::make_pair(1, 4));
3241 expected
.push_back(std::make_pair(2, 4));
3242 expected
.push_back(std::make_pair(3, 4));
3243 expected
.push_back(std::make_pair(4, 4));
3245 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3248 TEST_P(TilingDataTest
, SpiralDifferenceIteratorRectangleCenter
) {
3249 gfx::Point origin
= GetParam();
3250 TilingData
tiling_data(
3251 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(50, 50)), false);
3252 gfx::Rect
consider(origin
.x(), origin
.y(), 50, 50);
3253 std::vector
<std::pair
<int, int> > expected
;
3257 gfx::Rect
center(origin
.x() + 25, origin
.y() + 25, 1, 10);
3259 // Layout of the tiling data, and expected return order:
3269 expected
.push_back(std::make_pair(3, 3));
3270 expected
.push_back(std::make_pair(3, 2));
3271 expected
.push_back(std::make_pair(3, 1));
3272 expected
.push_back(std::make_pair(2, 1));
3273 expected
.push_back(std::make_pair(1, 1));
3274 expected
.push_back(std::make_pair(1, 2));
3275 expected
.push_back(std::make_pair(1, 3));
3276 expected
.push_back(std::make_pair(1, 4));
3277 expected
.push_back(std::make_pair(2, 4));
3278 expected
.push_back(std::make_pair(3, 4));
3279 expected
.push_back(std::make_pair(4, 4));
3280 expected
.push_back(std::make_pair(4, 3));
3281 expected
.push_back(std::make_pair(4, 2));
3282 expected
.push_back(std::make_pair(4, 1));
3283 expected
.push_back(std::make_pair(4, 0));
3284 expected
.push_back(std::make_pair(3, 0));
3285 expected
.push_back(std::make_pair(2, 0));
3286 expected
.push_back(std::make_pair(1, 0));
3287 expected
.push_back(std::make_pair(0, 0));
3288 expected
.push_back(std::make_pair(0, 1));
3289 expected
.push_back(std::make_pair(0, 2));
3290 expected
.push_back(std::make_pair(0, 3));
3291 expected
.push_back(std::make_pair(0, 4));
3293 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3295 // Three by two center.
3296 center
= gfx::Rect(origin
.x() + 15, origin
.y() + 25, 20, 10);
3298 // Layout of the tiling data, and expected return order:
3308 expected
.push_back(std::make_pair(4, 3));
3309 expected
.push_back(std::make_pair(4, 2));
3310 expected
.push_back(std::make_pair(4, 1));
3311 expected
.push_back(std::make_pair(3, 1));
3312 expected
.push_back(std::make_pair(2, 1));
3313 expected
.push_back(std::make_pair(1, 1));
3314 expected
.push_back(std::make_pair(0, 1));
3315 expected
.push_back(std::make_pair(0, 2));
3316 expected
.push_back(std::make_pair(0, 3));
3317 expected
.push_back(std::make_pair(0, 4));
3318 expected
.push_back(std::make_pair(1, 4));
3319 expected
.push_back(std::make_pair(2, 4));
3320 expected
.push_back(std::make_pair(3, 4));
3321 expected
.push_back(std::make_pair(4, 4));
3322 expected
.push_back(std::make_pair(4, 0));
3323 expected
.push_back(std::make_pair(3, 0));
3324 expected
.push_back(std::make_pair(2, 0));
3325 expected
.push_back(std::make_pair(1, 0));
3326 expected
.push_back(std::make_pair(0, 0));
3328 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3330 // Column center off the left side.
3331 center
= gfx::Rect(origin
.x() - 50, origin
.y(), 30, 50);
3333 // Layout of the tiling data, and expected return order:
3343 expected
.push_back(std::make_pair(0, 4));
3344 expected
.push_back(std::make_pair(0, 3));
3345 expected
.push_back(std::make_pair(0, 2));
3346 expected
.push_back(std::make_pair(0, 1));
3347 expected
.push_back(std::make_pair(0, 0));
3348 expected
.push_back(std::make_pair(1, 4));
3349 expected
.push_back(std::make_pair(1, 3));
3350 expected
.push_back(std::make_pair(1, 2));
3351 expected
.push_back(std::make_pair(1, 1));
3352 expected
.push_back(std::make_pair(1, 0));
3353 expected
.push_back(std::make_pair(2, 4));
3354 expected
.push_back(std::make_pair(2, 3));
3355 expected
.push_back(std::make_pair(2, 2));
3356 expected
.push_back(std::make_pair(2, 1));
3357 expected
.push_back(std::make_pair(2, 0));
3358 expected
.push_back(std::make_pair(3, 4));
3359 expected
.push_back(std::make_pair(3, 3));
3360 expected
.push_back(std::make_pair(3, 2));
3361 expected
.push_back(std::make_pair(3, 1));
3362 expected
.push_back(std::make_pair(3, 0));
3363 expected
.push_back(std::make_pair(4, 4));
3364 expected
.push_back(std::make_pair(4, 3));
3365 expected
.push_back(std::make_pair(4, 2));
3366 expected
.push_back(std::make_pair(4, 1));
3367 expected
.push_back(std::make_pair(4, 0));
3369 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3372 TEST_P(TilingDataTest
, SpiralDifferenceIteratorEdgeCases
) {
3373 gfx::Point origin
= GetParam();
3374 TilingData
tiling_data(
3375 gfx::Size(10, 10), gfx::Rect(origin
, gfx::Size(30, 30)), false);
3376 std::vector
<std::pair
<int, int> > expected
;
3381 // Ignore contains, but is not equal to, consider and center.
3382 ignore
= gfx::Rect(origin
.x() + 15, origin
.y(), 20, 30);
3383 consider
= gfx::Rect(origin
.x() + 20, origin
.y() + 10, 10, 20);
3384 center
= gfx::Rect(origin
.x() + 25, origin
.y(), 5, 5);
3386 // Layout of the tiling data, and expected return order:
3394 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3396 // Center intersects with consider.
3397 ignore
= gfx::Rect();
3398 center
= gfx::Rect(origin
.x(), origin
.y() + 15, 30, 15);
3399 consider
= gfx::Rect(origin
.x(), origin
.y(), 15, 30);
3401 // Layout of the tiling data, and expected return order:
3409 expected
.push_back(std::make_pair(1, 0));
3410 expected
.push_back(std::make_pair(0, 0));
3412 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3414 // Consider and ignore are non-intersecting.
3415 ignore
= gfx::Rect(origin
.x(), origin
.y(), 5, 30);
3416 consider
= gfx::Rect(origin
.x() + 25, origin
.y(), 5, 30);
3417 center
= gfx::Rect(origin
.x() + 15, origin
.y(), 1, 1);
3419 // Layout of the tiling data, and expected return order:
3427 expected
.push_back(std::make_pair(2, 0));
3428 expected
.push_back(std::make_pair(2, 1));
3429 expected
.push_back(std::make_pair(2, 2));
3431 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3433 // Center intersects with ignore.
3434 consider
= gfx::Rect(origin
.x(), origin
.y(), 30, 30);
3435 center
= gfx::Rect(origin
.x() + 15, origin
.y(), 1, 30);
3436 ignore
= gfx::Rect(origin
.x(), origin
.y() + 15, 30, 1);
3438 // Layout of the tiling data, and expected return order:
3446 expected
.push_back(std::make_pair(2, 2));
3447 expected
.push_back(std::make_pair(2, 0));
3448 expected
.push_back(std::make_pair(0, 0));
3449 expected
.push_back(std::make_pair(0, 2));
3451 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3453 // Center and ignore are the same.
3454 consider
= gfx::Rect(origin
.x(), origin
.y(), 30, 30);
3455 center
= gfx::Rect(origin
.x() + 15, origin
.y(), 1, 30);
3458 // Layout of the tiling data, and expected return order:
3466 expected
.push_back(std::make_pair(2, 2));
3467 expected
.push_back(std::make_pair(2, 1));
3468 expected
.push_back(std::make_pair(2, 0));
3469 expected
.push_back(std::make_pair(0, 0));
3470 expected
.push_back(std::make_pair(0, 1));
3471 expected
.push_back(std::make_pair(0, 2));
3473 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3475 // Empty tiling data.
3476 TilingData
empty_data(gfx::Size(0, 0), gfx::Rect(0, 0, 0, 0), false);
3479 TestSpiralIterate(__LINE__
, empty_data
, consider
, ignore
, center
, expected
);
3482 ignore
= gfx::Rect();
3483 center
= gfx::Rect(1, 1, 1, 1);
3484 consider
= gfx::Rect();
3487 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3489 // Empty center. Note: This arbitrarily puts the center to be off the top-left
3491 consider
= gfx::Rect(origin
.x(), origin
.y(), 30, 30);
3492 ignore
= gfx::Rect();
3493 center
= gfx::Rect();
3495 // Layout of the tiling data, and expected return order:
3503 expected
.push_back(std::make_pair(0, 0));
3504 expected
.push_back(std::make_pair(1, 0));
3505 expected
.push_back(std::make_pair(0, 1));
3506 expected
.push_back(std::make_pair(1, 1));
3507 expected
.push_back(std::make_pair(2, 1));
3508 expected
.push_back(std::make_pair(2, 0));
3509 expected
.push_back(std::make_pair(0, 2));
3510 expected
.push_back(std::make_pair(1, 2));
3511 expected
.push_back(std::make_pair(2, 2));
3513 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3515 // Every rect is empty.
3516 ignore
= gfx::Rect();
3517 center
= gfx::Rect();
3518 consider
= gfx::Rect();
3521 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3523 // Center is just to the left of cover, and off of the tiling's left side.
3524 consider
= gfx::Rect(origin
.x(), origin
.y(), 30, 30);
3525 ignore
= gfx::Rect();
3526 center
= gfx::Rect(origin
.x() - 20, origin
.y(), 19, 30);
3528 // Layout of the tiling data, and expected return order:
3536 expected
.push_back(std::make_pair(0, 2));
3537 expected
.push_back(std::make_pair(0, 1));
3538 expected
.push_back(std::make_pair(0, 0));
3539 expected
.push_back(std::make_pair(1, 2));
3540 expected
.push_back(std::make_pair(1, 1));
3541 expected
.push_back(std::make_pair(1, 0));
3542 expected
.push_back(std::make_pair(2, 2));
3543 expected
.push_back(std::make_pair(2, 1));
3544 expected
.push_back(std::make_pair(2, 0));
3546 TestSpiralIterate(__LINE__
, tiling_data
, consider
, ignore
, center
, expected
);
3549 INSTANTIATE_TEST_CASE_P(TilingData
,
3551 ::testing::Values(gfx::Point(42, 17),
3555 gfx::Point(-16, -35),
3556 gfx::Point(-10000, -15000)));