Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / cc / base / tiling_data_unittest.cc
blob60e5a21e89f7311c69d4c79bbb1d4a2ced456009
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"
7 #include <algorithm>
8 #include <vector>
10 #include "cc/test/geometry_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace cc {
14 namespace {
16 int NumTiles(const gfx::Size& max_texture_size,
17 const gfx::Size& tiling_size,
18 bool has_border_texels) {
19 TilingData tiling(max_texture_size, tiling_size, 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);
24 if (num_tiles > 0)
25 EXPECT_EQ(num_tiles / tiling.num_tiles_x(), tiling.num_tiles_y());
27 return num_tiles;
30 int XIndex(const gfx::Size& max_texture_size,
31 const gfx::Size& tiling_size,
32 bool has_border_texels,
33 int x_coord) {
34 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
35 return tiling.TileXIndexFromSrcCoord(x_coord);
38 int YIndex(const gfx::Size& max_texture_size,
39 const gfx::Size& tiling_size,
40 bool has_border_texels,
41 int y_coord) {
42 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
43 return tiling.TileYIndexFromSrcCoord(y_coord);
46 int MinBorderXIndex(const gfx::Size& max_texture_size,
47 const gfx::Size& tiling_size,
48 bool has_border_texels,
49 int x_coord) {
50 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
51 return tiling.FirstBorderTileXIndexFromSrcCoord(x_coord);
54 int MinBorderYIndex(const gfx::Size& max_texture_size,
55 const gfx::Size& tiling_size,
56 bool has_border_texels,
57 int y_coord) {
58 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
59 return tiling.FirstBorderTileYIndexFromSrcCoord(y_coord);
62 int MaxBorderXIndex(const gfx::Size& max_texture_size,
63 const gfx::Size& tiling_size,
64 bool has_border_texels,
65 int x_coord) {
66 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
67 return tiling.LastBorderTileXIndexFromSrcCoord(x_coord);
70 int MaxBorderYIndex(const gfx::Size& max_texture_size,
71 const gfx::Size& tiling_size,
72 bool has_border_texels,
73 int y_coord) {
74 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
75 return tiling.LastBorderTileYIndexFromSrcCoord(y_coord);
78 int PosX(const gfx::Size& max_texture_size,
79 const gfx::Size& tiling_size,
80 bool has_border_texels,
81 int x_index) {
82 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
83 return tiling.TilePositionX(x_index);
86 int PosY(const gfx::Size& max_texture_size,
87 const gfx::Size& tiling_size,
88 bool has_border_texels,
89 int y_index) {
90 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
91 return tiling.TilePositionY(y_index);
94 int SizeX(const gfx::Size& max_texture_size,
95 const gfx::Size& tiling_size,
96 bool has_border_texels,
97 int x_index) {
98 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
99 return tiling.TileSizeX(x_index);
102 int SizeY(const gfx::Size& max_texture_size,
103 const gfx::Size& tiling_size,
104 bool has_border_texels,
105 int y_index) {
106 TilingData tiling(max_texture_size, tiling_size, has_border_texels);
107 return tiling.TileSizeY(y_index);
110 class TilingDataTest : public ::testing::TestWithParam<gfx::Point> {};
112 TEST(TilingDataTest, NumTiles_NoTiling) {
113 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), false));
114 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(15, 15), true));
115 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), true));
116 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(1, 16), false));
117 EXPECT_EQ(1, NumTiles(gfx::Size(15, 15), gfx::Size(15, 15), true));
118 EXPECT_EQ(1, NumTiles(gfx::Size(32, 16), gfx::Size(32, 16), false));
119 EXPECT_EQ(1, NumTiles(gfx::Size(32, 16), gfx::Size(32, 16), true));
122 TEST(TilingDataTest, NumTiles_TilingNoBorders) {
123 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(0, 0), false));
124 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(4, 0), false));
125 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(0, 4), false));
126 EXPECT_EQ(0, NumTiles(gfx::Size(4, 4), gfx::Size(4, 0), false));
127 EXPECT_EQ(0, NumTiles(gfx::Size(4, 4), gfx::Size(0, 4), false));
128 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(1, 1), false));
130 EXPECT_EQ(1, NumTiles(gfx::Size(1, 1), gfx::Size(1, 1), false));
131 EXPECT_EQ(2, NumTiles(gfx::Size(1, 1), gfx::Size(1, 2), false));
132 EXPECT_EQ(2, NumTiles(gfx::Size(1, 1), gfx::Size(2, 1), false));
133 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(1, 1), false));
134 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(1, 2), false));
135 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(2, 1), false));
136 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(2, 2), false));
137 EXPECT_EQ(1, NumTiles(gfx::Size(3, 3), gfx::Size(3, 3), false));
139 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(1, 4), false));
140 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(2, 4), false));
141 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(3, 4), false));
142 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(4, 4), false));
143 EXPECT_EQ(2, NumTiles(gfx::Size(4, 4), gfx::Size(5, 4), false));
144 EXPECT_EQ(2, NumTiles(gfx::Size(4, 4), gfx::Size(6, 4), false));
145 EXPECT_EQ(2, NumTiles(gfx::Size(4, 4), gfx::Size(7, 4), false));
146 EXPECT_EQ(2, NumTiles(gfx::Size(4, 4), gfx::Size(8, 4), false));
147 EXPECT_EQ(3, NumTiles(gfx::Size(4, 4), gfx::Size(9, 4), false));
148 EXPECT_EQ(3, NumTiles(gfx::Size(4, 4), gfx::Size(10, 4), false));
149 EXPECT_EQ(3, NumTiles(gfx::Size(4, 4), gfx::Size(11, 4), false));
151 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(1, 5), false));
152 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(2, 5), false));
153 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(3, 5), false));
154 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(4, 5), false));
155 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(5, 5), false));
156 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(6, 5), false));
157 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(7, 5), false));
158 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(8, 5), false));
159 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(9, 5), false));
160 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(10, 5), false));
161 EXPECT_EQ(3, NumTiles(gfx::Size(5, 5), gfx::Size(11, 5), false));
163 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), false));
164 EXPECT_EQ(1, NumTiles(gfx::Size(17, 17), gfx::Size(16, 16), false));
165 EXPECT_EQ(4, NumTiles(gfx::Size(15, 15), gfx::Size(16, 16), false));
166 EXPECT_EQ(4, NumTiles(gfx::Size(8, 8), gfx::Size(16, 16), false));
167 EXPECT_EQ(6, NumTiles(gfx::Size(8, 8), gfx::Size(17, 16), false));
169 EXPECT_EQ(8, NumTiles(gfx::Size(5, 8), gfx::Size(17, 16), false));
172 TEST(TilingDataTest, NumTiles_TilingWithBorders) {
173 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(0, 0), true));
174 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(4, 0), true));
175 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(0, 4), true));
176 EXPECT_EQ(0, NumTiles(gfx::Size(4, 4), gfx::Size(4, 0), true));
177 EXPECT_EQ(0, NumTiles(gfx::Size(4, 4), gfx::Size(0, 4), true));
178 EXPECT_EQ(0, NumTiles(gfx::Size(0, 0), gfx::Size(1, 1), true));
180 EXPECT_EQ(1, NumTiles(gfx::Size(1, 1), gfx::Size(1, 1), true));
181 EXPECT_EQ(0, NumTiles(gfx::Size(1, 1), gfx::Size(1, 2), true));
182 EXPECT_EQ(0, NumTiles(gfx::Size(1, 1), gfx::Size(2, 1), true));
183 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(1, 1), true));
184 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(1, 2), true));
185 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(2, 1), true));
186 EXPECT_EQ(1, NumTiles(gfx::Size(2, 2), gfx::Size(2, 2), true));
188 EXPECT_EQ(1, NumTiles(gfx::Size(3, 3), gfx::Size(1, 3), true));
189 EXPECT_EQ(1, NumTiles(gfx::Size(3, 3), gfx::Size(2, 3), true));
190 EXPECT_EQ(1, NumTiles(gfx::Size(3, 3), gfx::Size(3, 3), true));
191 EXPECT_EQ(2, NumTiles(gfx::Size(3, 3), gfx::Size(4, 3), true));
192 EXPECT_EQ(3, NumTiles(gfx::Size(3, 3), gfx::Size(5, 3), true));
193 EXPECT_EQ(4, NumTiles(gfx::Size(3, 3), gfx::Size(6, 3), true));
194 EXPECT_EQ(5, NumTiles(gfx::Size(3, 3), gfx::Size(7, 3), true));
196 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(1, 4), true));
197 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(2, 4), true));
198 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(3, 4), true));
199 EXPECT_EQ(1, NumTiles(gfx::Size(4, 4), gfx::Size(4, 4), true));
200 EXPECT_EQ(2, NumTiles(gfx::Size(4, 4), gfx::Size(5, 4), true));
201 EXPECT_EQ(2, NumTiles(gfx::Size(4, 4), gfx::Size(6, 4), true));
202 EXPECT_EQ(3, NumTiles(gfx::Size(4, 4), gfx::Size(7, 4), true));
203 EXPECT_EQ(3, NumTiles(gfx::Size(4, 4), gfx::Size(8, 4), true));
204 EXPECT_EQ(4, NumTiles(gfx::Size(4, 4), gfx::Size(9, 4), true));
205 EXPECT_EQ(4, NumTiles(gfx::Size(4, 4), gfx::Size(10, 4), true));
206 EXPECT_EQ(5, NumTiles(gfx::Size(4, 4), gfx::Size(11, 4), true));
208 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(1, 5), true));
209 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(2, 5), true));
210 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(3, 5), true));
211 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(4, 5), true));
212 EXPECT_EQ(1, NumTiles(gfx::Size(5, 5), gfx::Size(5, 5), true));
213 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(6, 5), true));
214 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(7, 5), true));
215 EXPECT_EQ(2, NumTiles(gfx::Size(5, 5), gfx::Size(8, 5), true));
216 EXPECT_EQ(3, NumTiles(gfx::Size(5, 5), gfx::Size(9, 5), true));
217 EXPECT_EQ(3, NumTiles(gfx::Size(5, 5), gfx::Size(10, 5), true));
218 EXPECT_EQ(3, NumTiles(gfx::Size(5, 5), gfx::Size(11, 5), true));
220 EXPECT_EQ(30, NumTiles(gfx::Size(8, 5), gfx::Size(16, 32), true));
223 TEST(TilingDataTest, TileXIndexFromSrcCoord) {
224 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
225 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
226 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
227 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
228 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
229 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
230 EXPECT_EQ(2, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
231 EXPECT_EQ(2, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
232 EXPECT_EQ(2, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
233 EXPECT_EQ(3, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
234 EXPECT_EQ(3, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
235 EXPECT_EQ(3, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
237 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
238 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
239 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
240 EXPECT_EQ(2, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
241 EXPECT_EQ(3, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
242 EXPECT_EQ(4, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
243 EXPECT_EQ(5, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
244 EXPECT_EQ(6, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
245 EXPECT_EQ(7, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
246 EXPECT_EQ(7, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
247 EXPECT_EQ(7, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
248 EXPECT_EQ(7, XIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
250 EXPECT_EQ(0, XIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
251 EXPECT_EQ(0, XIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
252 EXPECT_EQ(0, XIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
253 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
254 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
255 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
257 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 0));
258 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 1));
259 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 2));
260 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 3));
262 EXPECT_EQ(0, XIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
263 EXPECT_EQ(0, XIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
264 EXPECT_EQ(0, XIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
265 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
266 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
267 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
269 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 0));
270 EXPECT_EQ(0, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 1));
271 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 2));
272 EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 3));
275 TEST(TilingDataTest, FirstBorderTileXIndexFromSrcCoord) {
276 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
277 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
278 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
279 EXPECT_EQ(1, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
280 EXPECT_EQ(1, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
281 EXPECT_EQ(1, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
282 EXPECT_EQ(2, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
283 EXPECT_EQ(2, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
284 EXPECT_EQ(2, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
285 EXPECT_EQ(3, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
286 EXPECT_EQ(3, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
287 EXPECT_EQ(3, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
289 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
290 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
291 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
292 EXPECT_EQ(1, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
293 EXPECT_EQ(2, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
294 EXPECT_EQ(3, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
295 EXPECT_EQ(4, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
296 EXPECT_EQ(5, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
297 EXPECT_EQ(6, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
298 EXPECT_EQ(7, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
299 EXPECT_EQ(7, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
300 EXPECT_EQ(7, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
302 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
303 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
304 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
305 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
306 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
307 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
309 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 0));
310 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 1));
311 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 2));
312 EXPECT_EQ(1, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 3));
314 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
315 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
316 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
317 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
318 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
319 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
321 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 0));
322 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 1));
323 EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 2));
324 EXPECT_EQ(1, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 3));
327 TEST(TilingDataTest, LastBorderTileXIndexFromSrcCoord) {
328 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
329 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
330 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
331 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
332 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
333 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
334 EXPECT_EQ(2, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
335 EXPECT_EQ(2, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
336 EXPECT_EQ(2, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
337 EXPECT_EQ(3, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
338 EXPECT_EQ(3, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
339 EXPECT_EQ(3, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
341 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
342 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
343 EXPECT_EQ(2, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
344 EXPECT_EQ(3, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
345 EXPECT_EQ(4, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
346 EXPECT_EQ(5, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
347 EXPECT_EQ(6, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
348 EXPECT_EQ(7, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
349 EXPECT_EQ(7, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
350 EXPECT_EQ(7, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
351 EXPECT_EQ(7, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
352 EXPECT_EQ(7, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
354 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
355 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
356 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
357 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
358 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
359 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
361 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 0));
362 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 1));
363 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 2));
364 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 3));
366 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
367 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
368 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
369 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
370 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
371 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
373 EXPECT_EQ(0, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 0));
374 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 1));
375 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 2));
376 EXPECT_EQ(1, MaxBorderXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 3));
379 TEST(TilingDataTest, TileYIndexFromSrcCoord) {
380 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
381 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
382 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
383 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
384 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
385 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
386 EXPECT_EQ(2, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
387 EXPECT_EQ(2, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
388 EXPECT_EQ(2, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
389 EXPECT_EQ(3, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
390 EXPECT_EQ(3, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
391 EXPECT_EQ(3, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
393 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
394 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
395 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
396 EXPECT_EQ(2, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
397 EXPECT_EQ(3, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
398 EXPECT_EQ(4, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
399 EXPECT_EQ(5, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
400 EXPECT_EQ(6, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
401 EXPECT_EQ(7, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
402 EXPECT_EQ(7, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
403 EXPECT_EQ(7, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
404 EXPECT_EQ(7, YIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
406 EXPECT_EQ(0, YIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
407 EXPECT_EQ(0, YIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
408 EXPECT_EQ(0, YIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
409 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
410 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
411 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
413 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 0));
414 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 1));
415 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 2));
416 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 3));
418 EXPECT_EQ(0, YIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
419 EXPECT_EQ(0, YIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
420 EXPECT_EQ(0, YIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
421 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
422 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
423 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
425 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 0));
426 EXPECT_EQ(0, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 1));
427 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 2));
428 EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 3));
431 TEST(TilingDataTest, FirstBorderTileYIndexFromSrcCoord) {
432 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
433 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
434 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
435 EXPECT_EQ(1, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
436 EXPECT_EQ(1, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
437 EXPECT_EQ(1, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
438 EXPECT_EQ(2, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
439 EXPECT_EQ(2, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
440 EXPECT_EQ(2, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
441 EXPECT_EQ(3, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
442 EXPECT_EQ(3, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
443 EXPECT_EQ(3, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
445 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
446 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
447 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
448 EXPECT_EQ(1, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
449 EXPECT_EQ(2, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
450 EXPECT_EQ(3, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
451 EXPECT_EQ(4, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
452 EXPECT_EQ(5, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
453 EXPECT_EQ(6, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
454 EXPECT_EQ(7, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
455 EXPECT_EQ(7, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
456 EXPECT_EQ(7, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
458 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
459 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
460 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
461 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
462 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
463 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
465 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 0));
466 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 1));
467 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 2));
468 EXPECT_EQ(1, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 3));
470 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
471 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
472 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
473 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
474 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
475 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
477 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 0));
478 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 1));
479 EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 2));
480 EXPECT_EQ(1, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 3));
483 TEST(TilingDataTest, LastBorderTileYIndexFromSrcCoord) {
484 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
485 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
486 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
487 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
488 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
489 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
490 EXPECT_EQ(2, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
491 EXPECT_EQ(2, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
492 EXPECT_EQ(2, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
493 EXPECT_EQ(3, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
494 EXPECT_EQ(3, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
495 EXPECT_EQ(3, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
497 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
498 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
499 EXPECT_EQ(2, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
500 EXPECT_EQ(3, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
501 EXPECT_EQ(4, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
502 EXPECT_EQ(5, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
503 EXPECT_EQ(6, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
504 EXPECT_EQ(7, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
505 EXPECT_EQ(7, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
506 EXPECT_EQ(7, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
507 EXPECT_EQ(7, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
508 EXPECT_EQ(7, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
510 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
511 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
512 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
513 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
514 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
515 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
517 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 0));
518 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 1));
519 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 2));
520 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 3));
522 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
523 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
524 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
525 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
526 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
527 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
529 EXPECT_EQ(0, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 0));
530 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 1));
531 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 2));
532 EXPECT_EQ(1, MaxBorderYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 3));
535 TEST(TilingDataTest, TileSizeX) {
536 EXPECT_EQ(5, SizeX(gfx::Size(5, 5), gfx::Size(5, 5), false, 0));
537 EXPECT_EQ(5, SizeX(gfx::Size(5, 5), gfx::Size(5, 5), true, 0));
539 EXPECT_EQ(5, SizeX(gfx::Size(5, 5), gfx::Size(6, 6), false, 0));
540 EXPECT_EQ(1, SizeX(gfx::Size(5, 5), gfx::Size(6, 6), false, 1));
541 EXPECT_EQ(4, SizeX(gfx::Size(5, 5), gfx::Size(6, 6), true, 0));
542 EXPECT_EQ(2, SizeX(gfx::Size(5, 5), gfx::Size(6, 6), true, 1));
544 EXPECT_EQ(5, SizeX(gfx::Size(5, 5), gfx::Size(8, 8), false, 0));
545 EXPECT_EQ(3, SizeX(gfx::Size(5, 5), gfx::Size(8, 8), false, 1));
546 EXPECT_EQ(4, SizeX(gfx::Size(5, 5), gfx::Size(8, 8), true, 0));
547 EXPECT_EQ(4, SizeX(gfx::Size(5, 5), gfx::Size(8, 8), true, 1));
549 EXPECT_EQ(5, SizeX(gfx::Size(5, 5), gfx::Size(10, 10), false, 0));
550 EXPECT_EQ(5, SizeX(gfx::Size(5, 5), gfx::Size(10, 10), false, 1));
551 EXPECT_EQ(4, SizeX(gfx::Size(5, 5), gfx::Size(10, 10), true, 0));
552 EXPECT_EQ(3, SizeX(gfx::Size(5, 5), gfx::Size(10, 10), true, 1));
553 EXPECT_EQ(3, SizeX(gfx::Size(5, 5), gfx::Size(10, 10), true, 2));
555 EXPECT_EQ(4, SizeX(gfx::Size(5, 5), gfx::Size(11, 11), true, 2));
556 EXPECT_EQ(3, SizeX(gfx::Size(5, 5), gfx::Size(12, 12), true, 2));
558 EXPECT_EQ(3, SizeX(gfx::Size(5, 9), gfx::Size(12, 17), true, 2));
561 TEST(TilingDataTest, TileSizeY) {
562 EXPECT_EQ(5, SizeY(gfx::Size(5, 5), gfx::Size(5, 5), false, 0));
563 EXPECT_EQ(5, SizeY(gfx::Size(5, 5), gfx::Size(5, 5), true, 0));
565 EXPECT_EQ(5, SizeY(gfx::Size(5, 5), gfx::Size(6, 6), false, 0));
566 EXPECT_EQ(1, SizeY(gfx::Size(5, 5), gfx::Size(6, 6), false, 1));
567 EXPECT_EQ(4, SizeY(gfx::Size(5, 5), gfx::Size(6, 6), true, 0));
568 EXPECT_EQ(2, SizeY(gfx::Size(5, 5), gfx::Size(6, 6), true, 1));
570 EXPECT_EQ(5, SizeY(gfx::Size(5, 5), gfx::Size(8, 8), false, 0));
571 EXPECT_EQ(3, SizeY(gfx::Size(5, 5), gfx::Size(8, 8), false, 1));
572 EXPECT_EQ(4, SizeY(gfx::Size(5, 5), gfx::Size(8, 8), true, 0));
573 EXPECT_EQ(4, SizeY(gfx::Size(5, 5), gfx::Size(8, 8), true, 1));
575 EXPECT_EQ(5, SizeY(gfx::Size(5, 5), gfx::Size(10, 10), false, 0));
576 EXPECT_EQ(5, SizeY(gfx::Size(5, 5), gfx::Size(10, 10), false, 1));
577 EXPECT_EQ(4, SizeY(gfx::Size(5, 5), gfx::Size(10, 10), true, 0));
578 EXPECT_EQ(3, SizeY(gfx::Size(5, 5), gfx::Size(10, 10), true, 1));
579 EXPECT_EQ(3, SizeY(gfx::Size(5, 5), gfx::Size(10, 10), true, 2));
581 EXPECT_EQ(4, SizeY(gfx::Size(5, 5), gfx::Size(11, 11), true, 2));
582 EXPECT_EQ(3, SizeY(gfx::Size(5, 5), gfx::Size(12, 12), true, 2));
584 EXPECT_EQ(3, SizeY(gfx::Size(9, 5), gfx::Size(17, 12), true, 2));
587 TEST(TilingDataTest, TileSizeX_and_TilePositionX) {
588 // Single tile cases:
589 EXPECT_EQ(1, SizeX(gfx::Size(3, 3), gfx::Size(1, 1), false, 0));
590 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(1, 1), false, 0));
591 EXPECT_EQ(1, SizeX(gfx::Size(3, 3), gfx::Size(1, 100), false, 0));
592 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(1, 100), false, 0));
593 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(3, 1), false, 0));
594 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(3, 1), false, 0));
595 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(3, 100), false, 0));
596 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(3, 100), false, 0));
597 EXPECT_EQ(1, SizeX(gfx::Size(3, 3), gfx::Size(1, 1), true, 0));
598 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(1, 1), true, 0));
599 EXPECT_EQ(1, SizeX(gfx::Size(3, 3), gfx::Size(1, 100), true, 0));
600 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(1, 100), true, 0));
601 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(3, 1), true, 0));
602 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(3, 1), true, 0));
603 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(3, 100), true, 0));
604 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(3, 100), true, 0));
606 // Multiple tiles:
607 // no border
608 // positions 0, 3
609 EXPECT_EQ(2, NumTiles(gfx::Size(3, 3), gfx::Size(6, 1), false));
610 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(6, 1), false, 0));
611 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(6, 1), false, 1));
612 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(6, 1), false, 0));
613 EXPECT_EQ(3, PosX(gfx::Size(3, 3), gfx::Size(6, 1), false, 1));
614 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(6, 100), false, 0));
615 EXPECT_EQ(3, SizeX(gfx::Size(3, 3), gfx::Size(6, 100), false, 1));
616 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(6, 100), false, 0));
617 EXPECT_EQ(3, PosX(gfx::Size(3, 3), gfx::Size(6, 100), false, 1));
619 // Multiple tiles:
620 // with border
621 // positions 0, 2, 3, 4
622 EXPECT_EQ(4, NumTiles(gfx::Size(3, 3), gfx::Size(6, 1), true));
623 EXPECT_EQ(2, SizeX(gfx::Size(3, 3), gfx::Size(6, 1), true, 0));
624 EXPECT_EQ(1, SizeX(gfx::Size(3, 3), gfx::Size(6, 1), true, 1));
625 EXPECT_EQ(1, SizeX(gfx::Size(3, 3), gfx::Size(6, 1), true, 2));
626 EXPECT_EQ(2, SizeX(gfx::Size(3, 3), gfx::Size(6, 1), true, 3));
627 EXPECT_EQ(0, PosX(gfx::Size(3, 3), gfx::Size(6, 1), true, 0));
628 EXPECT_EQ(2, PosX(gfx::Size(3, 3), gfx::Size(6, 1), true, 1));
629 EXPECT_EQ(3, PosX(gfx::Size(3, 3), gfx::Size(6, 1), true, 2));
630 EXPECT_EQ(4, PosX(gfx::Size(3, 3), gfx::Size(6, 1), true, 3));
631 EXPECT_EQ(2, SizeX(gfx::Size(3, 7), gfx::Size(6, 100), true, 0));
632 EXPECT_EQ(1, SizeX(gfx::Size(3, 7), gfx::Size(6, 100), true, 1));
633 EXPECT_EQ(1, SizeX(gfx::Size(3, 7), gfx::Size(6, 100), true, 2));
634 EXPECT_EQ(2, SizeX(gfx::Size(3, 7), gfx::Size(6, 100), true, 3));
635 EXPECT_EQ(0, PosX(gfx::Size(3, 7), gfx::Size(6, 100), true, 0));
636 EXPECT_EQ(2, PosX(gfx::Size(3, 7), gfx::Size(6, 100), true, 1));
637 EXPECT_EQ(3, PosX(gfx::Size(3, 7), gfx::Size(6, 100), true, 2));
638 EXPECT_EQ(4, PosX(gfx::Size(3, 7), gfx::Size(6, 100), true, 3));
641 TEST(TilingDataTest, TileSizeY_and_TilePositionY) {
642 // Single tile cases:
643 EXPECT_EQ(1, SizeY(gfx::Size(3, 3), gfx::Size(1, 1), false, 0));
644 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(1, 1), false, 0));
645 EXPECT_EQ(1, SizeY(gfx::Size(3, 3), gfx::Size(100, 1), false, 0));
646 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(100, 1), false, 0));
647 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(1, 3), false, 0));
648 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(1, 3), false, 0));
649 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(100, 3), false, 0));
650 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(100, 3), false, 0));
651 EXPECT_EQ(1, SizeY(gfx::Size(3, 3), gfx::Size(1, 1), true, 0));
652 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(1, 1), true, 0));
653 EXPECT_EQ(1, SizeY(gfx::Size(3, 3), gfx::Size(100, 1), true, 0));
654 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(100, 1), true, 0));
655 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(1, 3), true, 0));
656 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(1, 3), true, 0));
657 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(100, 3), true, 0));
658 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(100, 3), true, 0));
660 // Multiple tiles:
661 // no border
662 // positions 0, 3
663 EXPECT_EQ(2, NumTiles(gfx::Size(3, 3), gfx::Size(1, 6), false));
664 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(1, 6), false, 0));
665 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(1, 6), false, 1));
666 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(1, 6), false, 0));
667 EXPECT_EQ(3, PosY(gfx::Size(3, 3), gfx::Size(1, 6), false, 1));
668 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(100, 6), false, 0));
669 EXPECT_EQ(3, SizeY(gfx::Size(3, 3), gfx::Size(100, 6), false, 1));
670 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(100, 6), false, 0));
671 EXPECT_EQ(3, PosY(gfx::Size(3, 3), gfx::Size(100, 6), false, 1));
673 // Multiple tiles:
674 // with border
675 // positions 0, 2, 3, 4
676 EXPECT_EQ(4, NumTiles(gfx::Size(3, 3), gfx::Size(1, 6), true));
677 EXPECT_EQ(2, SizeY(gfx::Size(3, 3), gfx::Size(1, 6), true, 0));
678 EXPECT_EQ(1, SizeY(gfx::Size(3, 3), gfx::Size(1, 6), true, 1));
679 EXPECT_EQ(1, SizeY(gfx::Size(3, 3), gfx::Size(1, 6), true, 2));
680 EXPECT_EQ(2, SizeY(gfx::Size(3, 3), gfx::Size(1, 6), true, 3));
681 EXPECT_EQ(0, PosY(gfx::Size(3, 3), gfx::Size(1, 6), true, 0));
682 EXPECT_EQ(2, PosY(gfx::Size(3, 3), gfx::Size(1, 6), true, 1));
683 EXPECT_EQ(3, PosY(gfx::Size(3, 3), gfx::Size(1, 6), true, 2));
684 EXPECT_EQ(4, PosY(gfx::Size(3, 3), gfx::Size(1, 6), true, 3));
685 EXPECT_EQ(2, SizeY(gfx::Size(7, 3), gfx::Size(100, 6), true, 0));
686 EXPECT_EQ(1, SizeY(gfx::Size(7, 3), gfx::Size(100, 6), true, 1));
687 EXPECT_EQ(1, SizeY(gfx::Size(7, 3), gfx::Size(100, 6), true, 2));
688 EXPECT_EQ(2, SizeY(gfx::Size(7, 3), gfx::Size(100, 6), true, 3));
689 EXPECT_EQ(0, PosY(gfx::Size(7, 3), gfx::Size(100, 6), true, 0));
690 EXPECT_EQ(2, PosY(gfx::Size(7, 3), gfx::Size(100, 6), true, 1));
691 EXPECT_EQ(3, PosY(gfx::Size(7, 3), gfx::Size(100, 6), true, 2));
692 EXPECT_EQ(4, PosY(gfx::Size(7, 3), gfx::Size(100, 6), true, 3));
695 TEST(TilingDataTest, SetTotalSize) {
696 TilingData data(gfx::Size(5, 5), gfx::Size(5, 5), false);
697 EXPECT_EQ(5, data.tiling_size().width());
698 EXPECT_EQ(5, data.tiling_size().height());
699 EXPECT_EQ(1, data.num_tiles_x());
700 EXPECT_EQ(5, data.TileSizeX(0));
701 EXPECT_EQ(1, data.num_tiles_y());
702 EXPECT_EQ(5, data.TileSizeY(0));
704 data.SetTilingSize(gfx::Size(6, 5));
705 EXPECT_EQ(6, data.tiling_size().width());
706 EXPECT_EQ(5, data.tiling_size().height());
707 EXPECT_EQ(2, data.num_tiles_x());
708 EXPECT_EQ(5, data.TileSizeX(0));
709 EXPECT_EQ(1, data.TileSizeX(1));
710 EXPECT_EQ(1, data.num_tiles_y());
711 EXPECT_EQ(5, data.TileSizeY(0));
713 data.SetTilingSize(gfx::Size(5, 12));
714 EXPECT_EQ(5, data.tiling_size().width());
715 EXPECT_EQ(12, data.tiling_size().height());
716 EXPECT_EQ(1, data.num_tiles_x());
717 EXPECT_EQ(5, data.TileSizeX(0));
718 EXPECT_EQ(3, data.num_tiles_y());
719 EXPECT_EQ(5, data.TileSizeY(0));
720 EXPECT_EQ(5, data.TileSizeY(1));
721 EXPECT_EQ(2, data.TileSizeY(2));
724 TEST(TilingDataTest, SetMaxTextureSizeNoBorders) {
725 TilingData data(gfx::Size(8, 8), gfx::Size(16, 32), false);
726 EXPECT_EQ(2, data.num_tiles_x());
727 EXPECT_EQ(4, data.num_tiles_y());
729 data.SetMaxTextureSize(gfx::Size(32, 32));
730 EXPECT_EQ(gfx::Size(32, 32), data.max_texture_size());
731 EXPECT_EQ(1, data.num_tiles_x());
732 EXPECT_EQ(1, data.num_tiles_y());
734 data.SetMaxTextureSize(gfx::Size(2, 2));
735 EXPECT_EQ(gfx::Size(2, 2), data.max_texture_size());
736 EXPECT_EQ(8, data.num_tiles_x());
737 EXPECT_EQ(16, data.num_tiles_y());
739 data.SetMaxTextureSize(gfx::Size(5, 5));
740 EXPECT_EQ(gfx::Size(5, 5), data.max_texture_size());
741 EXPECT_EQ(4, data.num_tiles_x());
742 EXPECT_EQ(7, data.num_tiles_y());
744 data.SetMaxTextureSize(gfx::Size(8, 5));
745 EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size());
746 EXPECT_EQ(2, data.num_tiles_x());
747 EXPECT_EQ(7, data.num_tiles_y());
750 TEST(TilingDataTest, SetMaxTextureSizeBorders) {
751 TilingData data(gfx::Size(8, 8), gfx::Size(16, 32), true);
752 EXPECT_EQ(3, data.num_tiles_x());
753 EXPECT_EQ(5, data.num_tiles_y());
755 data.SetMaxTextureSize(gfx::Size(32, 32));
756 EXPECT_EQ(gfx::Size(32, 32), data.max_texture_size());
757 EXPECT_EQ(1, data.num_tiles_x());
758 EXPECT_EQ(1, data.num_tiles_y());
760 data.SetMaxTextureSize(gfx::Size(2, 2));
761 EXPECT_EQ(gfx::Size(2, 2), data.max_texture_size());
762 EXPECT_EQ(0, data.num_tiles_x());
763 EXPECT_EQ(0, data.num_tiles_y());
765 data.SetMaxTextureSize(gfx::Size(5, 5));
766 EXPECT_EQ(gfx::Size(5, 5), data.max_texture_size());
767 EXPECT_EQ(5, data.num_tiles_x());
768 EXPECT_EQ(10, data.num_tiles_y());
770 data.SetMaxTextureSize(gfx::Size(8, 5));
771 EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size());
772 EXPECT_EQ(3, data.num_tiles_x());
773 EXPECT_EQ(10, data.num_tiles_y());
776 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsWithBordersEmpty) {
777 TilingData empty_total_size(gfx::Size(0, 0), gfx::Size(8, 8), true);
778 EXPECT_RECT_EQ(
779 gfx::Rect(),
780 empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
781 gfx::Rect()));
782 EXPECT_RECT_EQ(
783 gfx::Rect(),
784 empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
785 gfx::Rect(100, 100, 100, 100)));
786 EXPECT_RECT_EQ(
787 gfx::Rect(),
788 empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
789 gfx::Rect(100, 100)));
791 TilingData empty_max_texture_size(gfx::Size(8, 8), gfx::Size(0, 0), true);
792 EXPECT_RECT_EQ(
793 gfx::Rect(),
794 empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
795 gfx::Rect()));
796 EXPECT_RECT_EQ(
797 gfx::Rect(),
798 empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
799 gfx::Rect(100, 100, 100, 100)));
800 EXPECT_RECT_EQ(
801 gfx::Rect(),
802 empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
803 gfx::Rect(100, 100)));
806 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsWithBorders) {
807 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true);
809 // Small rect at origin rounds up to tile 0, 0.
810 gfx::Rect at_origin_src(1, 1);
811 gfx::Rect at_origin_result(data.TileBoundsWithBorder(0, 0));
812 EXPECT_NE(at_origin_src, at_origin_result);
813 EXPECT_RECT_EQ(
814 at_origin_result,
815 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(at_origin_src));
817 // Arbitrary internal rect.
818 gfx::Rect rect_src(6, 6, 1, 3);
819 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
820 // Tile 2, 3 => gfx::Rect(4, 6, 4, 4)
821 gfx::Rect rect_result(gfx::UnionRects(data.TileBoundsWithBorder(2, 2),
822 data.TileBoundsWithBorder(2, 3)));
823 EXPECT_NE(rect_src, rect_result);
824 EXPECT_RECT_EQ(
825 rect_result,
826 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(rect_src));
828 // On tile bounds does not round up to next tile (ignores the border).
829 gfx::Rect border_rect_src(
830 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
831 gfx::Rect border_rect_result(gfx::UnionRects(
832 data.TileBoundsWithBorder(1, 2), data.TileBoundsWithBorder(3, 4)));
833 EXPECT_RECT_EQ(
834 border_rect_result,
835 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(border_rect_src));
837 // Equal to tiling rect.
838 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
839 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(
840 gfx::Rect(data.tiling_size())));
842 // Containing, but larger than tiling rect.
843 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
844 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(
845 gfx::Rect(100, 100)));
847 // Non-intersecting with tiling rect.
848 gfx::Rect non_intersect(200, 200, 100, 100);
849 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size())));
850 EXPECT_RECT_EQ(
851 gfx::Rect(),
852 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(non_intersect));
854 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true);
856 // Inside other tile border texels doesn't include other tiles.
857 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
858 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
859 gfx::Rect inner_rect_result(data2.TileBoundsWithBorder(1, 1));
860 gfx::Rect expanded =
861 data2.ExpandRectIgnoringBordersToTileBoundsWithBorders(inner_rect_src);
862 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
865 TEST(TilingDataTest, ExpandRectToTileBounds) {
866 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true);
868 // Small rect at origin rounds up to tile 0, 0.
869 gfx::Rect at_origin_src(1, 1);
870 gfx::Rect at_origin_result(data.TileBounds(0, 0));
871 EXPECT_NE(at_origin_src, at_origin_result);
872 EXPECT_RECT_EQ(at_origin_result, data.ExpandRectToTileBounds(at_origin_src));
874 // Arbitrary internal rect.
875 gfx::Rect rect_src(6, 6, 1, 3);
876 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
877 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
878 gfx::Rect rect_result(
879 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(3, 4)));
880 EXPECT_NE(rect_src, rect_result);
881 EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBounds(rect_src));
883 // On tile bounds rounds up to next tile (since border overlaps).
884 gfx::Rect border_rect_src(
885 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
886 gfx::Rect border_rect_result(
887 gfx::UnionRects(data.TileBounds(0, 1), data.TileBounds(4, 5)));
888 EXPECT_RECT_EQ(border_rect_result,
889 data.ExpandRectToTileBounds(border_rect_src));
891 // Equal to tiling rect.
892 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
893 data.ExpandRectToTileBounds(gfx::Rect(data.tiling_size())));
895 // Containing, but larger than tiling rect.
896 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
897 data.ExpandRectToTileBounds(gfx::Rect(100, 100)));
899 // Non-intersecting with tiling rect.
900 gfx::Rect non_intersect(200, 200, 100, 100);
901 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size())));
902 EXPECT_RECT_EQ(gfx::Rect(), data.ExpandRectToTileBounds(non_intersect));
904 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true);
906 // Inside other tile border texels doesn't include other tiles.
907 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
908 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
909 gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
910 gfx::Rect expanded = data2.ExpandRectToTileBounds(inner_rect_src);
911 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
914 TEST(TilingDataTest, Assignment) {
916 TilingData source(gfx::Size(8, 8), gfx::Size(16, 32), true);
917 TilingData dest = source;
918 EXPECT_EQ(source.border_texels(), dest.border_texels());
919 EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
920 EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
921 EXPECT_EQ(source.num_tiles_y(), dest.num_tiles_y());
922 EXPECT_EQ(source.tiling_size(), dest.tiling_size());
925 TilingData source(gfx::Size(7, 3), gfx::Size(6, 100), false);
926 TilingData dest(source);
927 EXPECT_EQ(source.border_texels(), dest.border_texels());
928 EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
929 EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
930 EXPECT_EQ(source.num_tiles_y(), dest.num_tiles_y());
931 EXPECT_EQ(source.tiling_size(), dest.tiling_size());
935 TEST(TilingDataTest, SetBorderTexels) {
936 TilingData data(gfx::Size(8, 8), gfx::Size(16, 32), false);
937 EXPECT_EQ(2, data.num_tiles_x());
938 EXPECT_EQ(4, data.num_tiles_y());
940 data.SetHasBorderTexels(true);
941 EXPECT_EQ(3, data.num_tiles_x());
942 EXPECT_EQ(5, data.num_tiles_y());
944 data.SetHasBorderTexels(false);
945 EXPECT_EQ(2, data.num_tiles_x());
946 EXPECT_EQ(4, data.num_tiles_y());
949 TEST(TilingDataTest, LargeBorders) {
950 TilingData data(gfx::Size(100, 80), gfx::Size(200, 145), 30);
951 EXPECT_EQ(30, data.border_texels());
953 EXPECT_EQ(70, data.TileSizeX(0));
954 EXPECT_EQ(40, data.TileSizeX(1));
955 EXPECT_EQ(40, data.TileSizeX(2));
956 EXPECT_EQ(50, data.TileSizeX(3));
957 EXPECT_EQ(4, data.num_tiles_x());
959 EXPECT_EQ(50, data.TileSizeY(0));
960 EXPECT_EQ(20, data.TileSizeY(1));
961 EXPECT_EQ(20, data.TileSizeY(2));
962 EXPECT_EQ(20, data.TileSizeY(3));
963 EXPECT_EQ(35, data.TileSizeY(4));
964 EXPECT_EQ(5, data.num_tiles_y());
966 EXPECT_RECT_EQ(gfx::Rect(70, 50), data.TileBounds(0, 0));
967 EXPECT_RECT_EQ(gfx::Rect(70, 50, 40, 20), data.TileBounds(1, 1));
968 EXPECT_RECT_EQ(gfx::Rect(110, 110, 40, 35), data.TileBounds(2, 4));
969 EXPECT_RECT_EQ(gfx::Rect(150, 70, 50, 20), data.TileBounds(3, 2));
970 EXPECT_RECT_EQ(gfx::Rect(150, 110, 50, 35), data.TileBounds(3, 4));
972 EXPECT_RECT_EQ(gfx::Rect(100, 80), data.TileBoundsWithBorder(0, 0));
973 EXPECT_RECT_EQ(gfx::Rect(40, 20, 100, 80), data.TileBoundsWithBorder(1, 1));
974 EXPECT_RECT_EQ(gfx::Rect(80, 80, 100, 65), data.TileBoundsWithBorder(2, 4));
975 EXPECT_RECT_EQ(gfx::Rect(120, 40, 80, 80), data.TileBoundsWithBorder(3, 2));
976 EXPECT_RECT_EQ(gfx::Rect(120, 80, 80, 65), data.TileBoundsWithBorder(3, 4));
978 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(0));
979 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(69));
980 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(70));
981 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(109));
982 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(110));
983 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(149));
984 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(150));
985 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(199));
987 EXPECT_EQ(0, data.TileYIndexFromSrcCoord(0));
988 EXPECT_EQ(0, data.TileYIndexFromSrcCoord(49));
989 EXPECT_EQ(1, data.TileYIndexFromSrcCoord(50));
990 EXPECT_EQ(1, data.TileYIndexFromSrcCoord(69));
991 EXPECT_EQ(2, data.TileYIndexFromSrcCoord(70));
992 EXPECT_EQ(2, data.TileYIndexFromSrcCoord(89));
993 EXPECT_EQ(3, data.TileYIndexFromSrcCoord(90));
994 EXPECT_EQ(3, data.TileYIndexFromSrcCoord(109));
995 EXPECT_EQ(4, data.TileYIndexFromSrcCoord(110));
996 EXPECT_EQ(4, data.TileYIndexFromSrcCoord(144));
998 EXPECT_EQ(0, data.FirstBorderTileXIndexFromSrcCoord(0));
999 EXPECT_EQ(0, data.FirstBorderTileXIndexFromSrcCoord(99));
1000 EXPECT_EQ(1, data.FirstBorderTileXIndexFromSrcCoord(100));
1001 EXPECT_EQ(1, data.FirstBorderTileXIndexFromSrcCoord(139));
1002 EXPECT_EQ(2, data.FirstBorderTileXIndexFromSrcCoord(140));
1003 EXPECT_EQ(2, data.FirstBorderTileXIndexFromSrcCoord(179));
1004 EXPECT_EQ(3, data.FirstBorderTileXIndexFromSrcCoord(180));
1005 EXPECT_EQ(3, data.FirstBorderTileXIndexFromSrcCoord(199));
1007 EXPECT_EQ(0, data.FirstBorderTileYIndexFromSrcCoord(0));
1008 EXPECT_EQ(0, data.FirstBorderTileYIndexFromSrcCoord(79));
1009 EXPECT_EQ(1, data.FirstBorderTileYIndexFromSrcCoord(80));
1010 EXPECT_EQ(1, data.FirstBorderTileYIndexFromSrcCoord(99));
1011 EXPECT_EQ(2, data.FirstBorderTileYIndexFromSrcCoord(100));
1012 EXPECT_EQ(2, data.FirstBorderTileYIndexFromSrcCoord(119));
1013 EXPECT_EQ(3, data.FirstBorderTileYIndexFromSrcCoord(120));
1014 EXPECT_EQ(3, data.FirstBorderTileYIndexFromSrcCoord(139));
1015 EXPECT_EQ(4, data.FirstBorderTileYIndexFromSrcCoord(140));
1016 EXPECT_EQ(4, data.FirstBorderTileYIndexFromSrcCoord(144));
1018 EXPECT_EQ(0, data.LastBorderTileXIndexFromSrcCoord(0));
1019 EXPECT_EQ(0, data.LastBorderTileXIndexFromSrcCoord(39));
1020 EXPECT_EQ(1, data.LastBorderTileXIndexFromSrcCoord(40));
1021 EXPECT_EQ(1, data.LastBorderTileXIndexFromSrcCoord(79));
1022 EXPECT_EQ(2, data.LastBorderTileXIndexFromSrcCoord(80));
1023 EXPECT_EQ(2, data.LastBorderTileXIndexFromSrcCoord(119));
1024 EXPECT_EQ(3, data.LastBorderTileXIndexFromSrcCoord(120));
1025 EXPECT_EQ(3, data.LastBorderTileXIndexFromSrcCoord(199));
1027 EXPECT_EQ(0, data.LastBorderTileYIndexFromSrcCoord(0));
1028 EXPECT_EQ(0, data.LastBorderTileYIndexFromSrcCoord(19));
1029 EXPECT_EQ(1, data.LastBorderTileYIndexFromSrcCoord(20));
1030 EXPECT_EQ(1, data.LastBorderTileYIndexFromSrcCoord(39));
1031 EXPECT_EQ(2, data.LastBorderTileYIndexFromSrcCoord(40));
1032 EXPECT_EQ(2, data.LastBorderTileYIndexFromSrcCoord(59));
1033 EXPECT_EQ(3, data.LastBorderTileYIndexFromSrcCoord(60));
1034 EXPECT_EQ(3, data.LastBorderTileYIndexFromSrcCoord(79));
1035 EXPECT_EQ(4, data.LastBorderTileYIndexFromSrcCoord(80));
1036 EXPECT_EQ(4, data.LastBorderTileYIndexFromSrcCoord(144));
1039 void TestIterate(const TilingData& data,
1040 gfx::Rect rect,
1041 int expect_left,
1042 int expect_top,
1043 int expect_right,
1044 int expect_bottom,
1045 bool include_borders) {
1046 EXPECT_GE(expect_left, 0);
1047 EXPECT_GE(expect_top, 0);
1048 EXPECT_LT(expect_right, data.num_tiles_x());
1049 EXPECT_LT(expect_bottom, data.num_tiles_y());
1051 std::vector<std::pair<int, int> > original_expected;
1052 for (int x = 0; x < data.num_tiles_x(); ++x) {
1053 for (int y = 0; y < data.num_tiles_y(); ++y) {
1054 gfx::Rect bounds;
1055 if (include_borders)
1056 bounds = data.TileBoundsWithBorder(x, y);
1057 else
1058 bounds = data.TileBounds(x, y);
1059 if (x >= expect_left && x <= expect_right &&
1060 y >= expect_top && y <= expect_bottom) {
1061 EXPECT_TRUE(bounds.Intersects(rect));
1062 original_expected.push_back(std::make_pair(x, y));
1063 } else {
1064 EXPECT_FALSE(bounds.Intersects(rect));
1069 // Verify with vanilla iterator.
1071 std::vector<std::pair<int, int> > expected = original_expected;
1072 for (TilingData::Iterator iter(&data, rect, include_borders); iter;
1073 ++iter) {
1074 bool found = false;
1075 for (size_t i = 0; i < expected.size(); ++i) {
1076 if (expected[i] == iter.index()) {
1077 expected[i] = expected.back();
1078 expected.pop_back();
1079 found = true;
1080 break;
1083 EXPECT_TRUE(found);
1085 EXPECT_EQ(0u, expected.size());
1088 // Make sure this also works with a difference iterator and an empty ignore.
1089 // The difference iterator always includes borders, so ignore it otherwise.
1090 if (include_borders) {
1091 std::vector<std::pair<int, int> > expected = original_expected;
1092 for (TilingData::DifferenceIterator iter(&data, rect, gfx::Rect());
1093 iter; ++iter) {
1094 bool found = false;
1095 for (size_t i = 0; i < expected.size(); ++i) {
1096 if (expected[i] == iter.index()) {
1097 expected[i] = expected.back();
1098 expected.pop_back();
1099 found = true;
1100 break;
1103 EXPECT_TRUE(found);
1105 EXPECT_EQ(0u, expected.size());
1109 void TestIterateBorders(const TilingData& data,
1110 gfx::Rect rect,
1111 int expect_left,
1112 int expect_top,
1113 int expect_right,
1114 int expect_bottom) {
1115 bool include_borders = true;
1116 TestIterate(data,
1117 rect,
1118 expect_left,
1119 expect_top,
1120 expect_right,
1121 expect_bottom,
1122 include_borders);
1125 void TestIterateNoBorders(const TilingData& data,
1126 gfx::Rect rect,
1127 int expect_left,
1128 int expect_top,
1129 int expect_right,
1130 int expect_bottom) {
1131 bool include_borders = false;
1132 TestIterate(data,
1133 rect,
1134 expect_left,
1135 expect_top,
1136 expect_right,
1137 expect_bottom,
1138 include_borders);
1141 void TestIterateAll(const TilingData& data,
1142 gfx::Rect rect,
1143 int expect_left,
1144 int expect_top,
1145 int expect_right,
1146 int expect_bottom) {
1147 TestIterateBorders(
1148 data, rect, expect_left, expect_top, expect_right, expect_bottom);
1149 TestIterateNoBorders(
1150 data, rect, expect_left, expect_top, expect_right, expect_bottom);
1153 TEST(TilingDataTest, IteratorNoBorderTexels) {
1154 TilingData data(gfx::Size(10, 10), gfx::Size(40, 25), false);
1155 // X border index by src coord: [0-10), [10-20), [20, 30), [30, 40)
1156 // Y border index by src coord: [0-10), [10-20), [20, 25)
1157 TestIterateAll(data, gfx::Rect(40, 25), 0, 0, 3, 2);
1158 TestIterateAll(data, gfx::Rect(15, 15, 8, 8), 1, 1, 2, 2);
1160 // Oversized.
1161 TestIterateAll(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 3, 2);
1162 TestIterateAll(data, gfx::Rect(-100, 20, 1000, 1), 0, 2, 3, 2);
1163 TestIterateAll(data, gfx::Rect(29, -100, 31, 1000), 2, 0, 3, 2);
1164 // Nonintersecting.
1165 TestIterateAll(data, gfx::Rect(60, 80, 100, 100), 0, 0, -1, -1);
1168 TEST(TilingDataTest, BordersIteratorOneBorderTexel) {
1169 TilingData data(gfx::Size(10, 20), gfx::Size(25, 45), true);
1170 // X border index by src coord: [0-10), [8-18), [16-25)
1171 // Y border index by src coord: [0-20), [18-38), [36-45)
1172 TestIterateBorders(data, gfx::Rect(25, 45), 0, 0, 2, 2);
1173 TestIterateBorders(data, gfx::Rect(18, 19, 3, 17), 2, 0, 2, 1);
1174 TestIterateBorders(data, gfx::Rect(10, 20, 6, 16), 1, 1, 1, 1);
1175 TestIterateBorders(data, gfx::Rect(9, 19, 8, 18), 0, 0, 2, 2);
1176 // Oversized.
1177 TestIterateBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 2);
1178 TestIterateBorders(data, gfx::Rect(-100, 20, 1000, 1), 0, 1, 2, 1);
1179 TestIterateBorders(data, gfx::Rect(18, -100, 6, 1000), 2, 0, 2, 2);
1180 // Nonintersecting.
1181 TestIterateBorders(data, gfx::Rect(60, 80, 100, 100), 0, 0, -1, -1);
1184 TEST(TilingDataTest, NoBordersIteratorOneBorderTexel) {
1185 TilingData data(gfx::Size(10, 20), gfx::Size(25, 45), true);
1186 // X index by src coord: [0-9), [9-17), [17-25)
1187 // Y index by src coord: [0-19), [19-37), [37-45)
1188 TestIterateNoBorders(data, gfx::Rect(25, 45), 0, 0, 2, 2);
1189 TestIterateNoBorders(data, gfx::Rect(17, 19, 3, 18), 2, 1, 2, 1);
1190 TestIterateNoBorders(data, gfx::Rect(17, 19, 3, 19), 2, 1, 2, 2);
1191 TestIterateNoBorders(data, gfx::Rect(8, 18, 9, 19), 0, 0, 1, 1);
1192 TestIterateNoBorders(data, gfx::Rect(9, 19, 9, 19), 1, 1, 2, 2);
1193 // Oversized.
1194 TestIterateNoBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 2);
1195 TestIterateNoBorders(data, gfx::Rect(-100, 20, 1000, 1), 0, 1, 2, 1);
1196 TestIterateNoBorders(data, gfx::Rect(18, -100, 6, 1000), 2, 0, 2, 2);
1197 // Nonintersecting.
1198 TestIterateNoBorders(data, gfx::Rect(60, 80, 100, 100), 0, 0, -1, -1);
1201 TEST(TilingDataTest, BordersIteratorManyBorderTexels) {
1202 TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
1203 // X border index by src coord: [0-50), [10-60), [20-65)
1204 // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
1205 TestIterateBorders(data, gfx::Rect(65, 110), 0, 0, 2, 3);
1206 TestIterateBorders(data, gfx::Rect(50, 60, 15, 65), 1, 1, 2, 3);
1207 TestIterateBorders(data, gfx::Rect(60, 30, 2, 10), 2, 0, 2, 1);
1208 // Oversized.
1209 TestIterateBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 3);
1210 TestIterateBorders(data, gfx::Rect(-100, 10, 1000, 10), 0, 0, 2, 0);
1211 TestIterateBorders(data, gfx::Rect(10, -100, 10, 1000), 0, 0, 1, 3);
1212 // Nonintersecting.
1213 TestIterateBorders(data, gfx::Rect(65, 110, 100, 100), 0, 0, -1, -1);
1216 TEST(TilingDataTest, NoBordersIteratorManyBorderTexels) {
1217 TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
1218 // X index by src coord: [0-30), [30-40), [40, 65)
1219 // Y index by src coord: [0-40), [40-60), [60, 80), [80-110)
1220 TestIterateNoBorders(data, gfx::Rect(65, 110), 0, 0, 2, 3);
1221 TestIterateNoBorders(data, gfx::Rect(30, 40, 15, 65), 1, 1, 2, 3);
1222 TestIterateNoBorders(data, gfx::Rect(60, 20, 2, 21), 2, 0, 2, 1);
1223 // Oversized.
1224 TestIterateNoBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 3);
1225 TestIterateNoBorders(data, gfx::Rect(-100, 10, 1000, 10), 0, 0, 2, 0);
1226 TestIterateNoBorders(data, gfx::Rect(10, -100, 10, 1000), 0, 0, 0, 3);
1227 // Nonintersecting.
1228 TestIterateNoBorders(data, gfx::Rect(65, 110, 100, 100), 0, 0, -1, -1);
1231 TEST(TilingDataTest, IteratorOneTile) {
1232 TilingData no_border(gfx::Size(1000, 1000), gfx::Size(30, 40), false);
1233 TestIterateAll(no_border, gfx::Rect(30, 40), 0, 0, 0, 0);
1234 TestIterateAll(no_border, gfx::Rect(10, 10, 20, 20), 0, 0, 0, 0);
1235 TestIterateAll(no_border, gfx::Rect(30, 40, 100, 100), 0, 0, -1, -1);
1237 TilingData one_border(gfx::Size(1000, 1000), gfx::Size(30, 40), true);
1238 TestIterateAll(one_border, gfx::Rect(30, 40), 0, 0, 0, 0);
1239 TestIterateAll(one_border, gfx::Rect(10, 10, 20, 20), 0, 0, 0, 0);
1240 TestIterateAll(one_border, gfx::Rect(30, 40, 100, 100), 0, 0, -1, -1);
1242 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50);
1243 TestIterateAll(big_border, gfx::Rect(30, 40), 0, 0, 0, 0);
1244 TestIterateAll(big_border, gfx::Rect(10, 10, 20, 20), 0, 0, 0, 0);
1245 TestIterateAll(big_border, gfx::Rect(30, 40, 100, 100), 0, 0, -1, -1);
1248 TEST(TilingDataTest, IteratorNoTiles) {
1249 TilingData data(gfx::Size(100, 100), gfx::Size(), false);
1250 TestIterateAll(data, gfx::Rect(100, 100), 0, 0, -1, -1);
1253 void TestDiff(
1254 const TilingData& data,
1255 gfx::Rect consider,
1256 gfx::Rect ignore,
1257 size_t num_tiles) {
1259 std::vector<std::pair<int, int> > expected;
1260 for (int y = 0; y < data.num_tiles_y(); ++y) {
1261 for (int x = 0; x < data.num_tiles_x(); ++x) {
1262 gfx::Rect bounds = data.TileBoundsWithBorder(x, y);
1263 if (bounds.Intersects(consider) && !bounds.Intersects(ignore))
1264 expected.push_back(std::make_pair(x, y));
1268 // Sanity check the test.
1269 EXPECT_EQ(num_tiles, expected.size());
1271 for (TilingData::DifferenceIterator iter(&data, consider, ignore);
1272 iter; ++iter) {
1273 bool found = false;
1274 for (size_t i = 0; i < expected.size(); ++i) {
1275 if (expected[i] == iter.index()) {
1276 expected[i] = expected.back();
1277 expected.pop_back();
1278 found = true;
1279 break;
1282 EXPECT_TRUE(found);
1284 EXPECT_EQ(0u, expected.size());
1287 TEST(TilingDataTest, DifferenceIteratorIgnoreGeometry) {
1288 // This test is checking that the iterator can handle different geometries of
1289 // ignore rects relative to the consider rect. The consider rect indices
1290 // themselves are mostly tested by the non-difference iterator tests, so the
1291 // full rect is mostly used here for simplicity.
1293 // X border index by src coord: [0-10), [10-20), [20, 30), [30, 40)
1294 // Y border index by src coord: [0-10), [10-20), [20, 25)
1295 TilingData data(gfx::Size(10, 10), gfx::Size(40, 25), false);
1297 // Fully ignored
1298 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(40, 25), 0);
1299 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-100, -100, 200, 200), 0);
1300 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(9, 9, 30, 15), 0);
1301 TestDiff(data, gfx::Rect(15, 15, 8, 8), gfx::Rect(15, 15, 8, 8), 0);
1303 // Fully un-ignored
1304 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-30, -20, 8, 8), 12);
1305 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(), 12);
1307 // Top left, remove 2x2 tiles
1308 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 19), 8);
1309 // Bottom right, remove 2x2 tiles
1310 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 15, 20, 6), 8);
1311 // Bottom left, remove 2x2 tiles
1312 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 15, 20, 6), 8);
1313 // Top right, remove 2x2 tiles
1314 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 0, 20, 19), 8);
1315 // Center, remove only one tile
1316 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(10, 10, 5, 5), 11);
1318 // Left column, flush left, removing two columns
1319 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 25), 6);
1320 // Middle column, removing two columns
1321 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 0, 11, 25), 6);
1322 // Right column, flush right, removing one column
1323 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(30, 0, 2, 25), 9);
1325 // Top row, flush top, removing one row
1326 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 5, 40, 5), 8);
1327 // Middle row, removing one row
1328 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 5), 8);
1329 // Bottom row, flush bottom, removing two rows
1330 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 12), 4);
1332 // Non-intersecting, but still touching two of the same tiles.
1333 TestDiff(data, gfx::Rect(8, 0, 32, 25), gfx::Rect(0, 12, 5, 12), 10);
1335 // Intersecting, but neither contains the other. 2x3 with one overlap.
1336 TestDiff(data, gfx::Rect(5, 2, 20, 10), gfx::Rect(25, 15, 5, 10), 5);
1339 TEST(TilingDataTest, DifferenceIteratorManyBorderTexels) {
1340 // X border index by src coord: [0-50), [10-60), [20-65)
1341 // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
1342 TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
1344 // Ignore one column, three rows
1345 TestDiff(data, gfx::Rect(0, 30, 55, 80), gfx::Rect(5, 30, 5, 15), 9);
1347 // Knock out three columns, leaving only one.
1348 TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(30, 59, 20, 1), 3);
1350 // Overlap all tiles with ignore rect.
1351 TestDiff(data, gfx::Rect(65, 110), gfx::Rect(30, 59, 1, 2), 0);
1354 TEST(TilingDataTest, DifferenceIteratorOneTile) {
1355 TilingData no_border(gfx::Size(1000, 1000), gfx::Size(30, 40), false);
1356 TestDiff(no_border, gfx::Rect(30, 40), gfx::Rect(), 1);
1357 TestDiff(no_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1359 TilingData one_border(gfx::Size(1000, 1000), gfx::Size(30, 40), true);
1360 TestDiff(one_border, gfx::Rect(30, 40), gfx::Rect(), 1);
1361 TestDiff(one_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1363 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50);
1364 TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1);
1365 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1368 TEST(TilingDataTest, DifferenceIteratorNoTiles) {
1369 TilingData data(gfx::Size(100, 100), gfx::Size(), false);
1370 TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0);
1373 void TestSpiralIterate(int source_line_number,
1374 const TilingData& tiling_data,
1375 const gfx::Rect& consider,
1376 const gfx::Rect& ignore,
1377 const gfx::Rect& center,
1378 const std::vector<std::pair<int, int> >& expected) {
1379 std::vector<std::pair<int, int> > actual;
1380 for (TilingData::SpiralDifferenceIterator it(
1381 &tiling_data, consider, ignore, center);
1383 ++it) {
1384 actual.push_back(it.index());
1387 EXPECT_EQ(expected.size(), actual.size()) << "error from line "
1388 << source_line_number;
1389 for (size_t i = 0; i < std::min(expected.size(), actual.size()); ++i) {
1390 EXPECT_EQ(expected[i].first, actual[i].first)
1391 << "i: " << i << " error from line: " << source_line_number;
1392 EXPECT_EQ(expected[i].second, actual[i].second)
1393 << "i: " << i << " error from line: " << source_line_number;
1397 TEST(TilingDataTest, SpiralDifferenceIteratorNoIgnoreFullConsider) {
1398 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false);
1399 gfx::Rect consider(30, 30);
1400 gfx::Rect ignore;
1401 std::vector<std::pair<int, int> > expected;
1403 // Center is in the center of the tiling.
1404 gfx::Rect center(15, 15, 1, 1);
1406 // Layout of the tiling data, and expected return order:
1407 // x 0 1 2
1408 // y.------
1409 // 0| 4 3 2
1410 // 1| 5 * 1
1411 // 2| 6 7 8
1412 expected.push_back(std::make_pair(2, 1));
1413 expected.push_back(std::make_pair(2, 0));
1414 expected.push_back(std::make_pair(1, 0));
1415 expected.push_back(std::make_pair(0, 0));
1416 expected.push_back(std::make_pair(0, 1));
1417 expected.push_back(std::make_pair(0, 2));
1418 expected.push_back(std::make_pair(1, 2));
1419 expected.push_back(std::make_pair(2, 2));
1421 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1423 // Center is off to the right side of the tiling (and far away).
1424 center = gfx::Rect(100, 15, 1, 1);
1426 // Layout of the tiling data, and expected return order:
1427 // x 0 1 2
1428 // y.------
1429 // 0| 7 4 1
1430 // 1| 8 5 2 *
1431 // 2| 9 6 3
1432 expected.clear();
1433 expected.push_back(std::make_pair(2, 0));
1434 expected.push_back(std::make_pair(2, 1));
1435 expected.push_back(std::make_pair(2, 2));
1436 expected.push_back(std::make_pair(1, 0));
1437 expected.push_back(std::make_pair(1, 1));
1438 expected.push_back(std::make_pair(1, 2));
1439 expected.push_back(std::make_pair(0, 0));
1440 expected.push_back(std::make_pair(0, 1));
1441 expected.push_back(std::make_pair(0, 2));
1443 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1445 // Center is the bottom right corner of the tiling.
1446 center = gfx::Rect(25, 25, 1, 1);
1448 // Layout of the tiling data, and expected return order:
1449 // x 0 1 2
1450 // y.------
1451 // 0| 6 5 4
1452 // 1| 7 2 1
1453 // 2| 8 3 *
1454 expected.clear();
1455 expected.push_back(std::make_pair(2, 1));
1456 expected.push_back(std::make_pair(1, 1));
1457 expected.push_back(std::make_pair(1, 2));
1458 expected.push_back(std::make_pair(2, 0));
1459 expected.push_back(std::make_pair(1, 0));
1460 expected.push_back(std::make_pair(0, 0));
1461 expected.push_back(std::make_pair(0, 1));
1462 expected.push_back(std::make_pair(0, 2));
1464 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1466 // Center is off the top left side of the tiling.
1467 center = gfx::Rect(-60, -50, 1, 1);
1469 // Layout of the tiling data, and expected return order:
1470 // * x 0 1 2
1471 // y.------
1472 // 0| 1 2 6
1473 // 1| 3 4 5
1474 // 2| 7 8 9
1475 expected.clear();
1476 expected.push_back(std::make_pair(0, 0));
1477 expected.push_back(std::make_pair(1, 0));
1478 expected.push_back(std::make_pair(0, 1));
1479 expected.push_back(std::make_pair(1, 1));
1480 expected.push_back(std::make_pair(2, 1));
1481 expected.push_back(std::make_pair(2, 0));
1482 expected.push_back(std::make_pair(0, 2));
1483 expected.push_back(std::make_pair(1, 2));
1484 expected.push_back(std::make_pair(2, 2));
1486 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1488 // Two tile center.
1489 center = gfx::Rect(15, 15, 1, 10);
1491 // Layout of the tiling data, and expected return order:
1492 // x 0 1 2
1493 // y.------
1494 // 0| 5 4 3
1495 // 1| 6 * 2
1496 // 2| 7 * 1
1497 expected.clear();
1498 expected.push_back(std::make_pair(2, 2));
1499 expected.push_back(std::make_pair(2, 1));
1500 expected.push_back(std::make_pair(2, 0));
1501 expected.push_back(std::make_pair(1, 0));
1502 expected.push_back(std::make_pair(0, 0));
1503 expected.push_back(std::make_pair(0, 1));
1504 expected.push_back(std::make_pair(0, 2));
1506 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1509 TEST(TilingDataTest, SpiralDifferenceIteratorSmallConsider) {
1510 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false);
1511 gfx::Rect ignore;
1512 std::vector<std::pair<int, int> > expected;
1513 gfx::Rect center(15, 15, 1, 1);
1515 // Consider is one cell.
1516 gfx::Rect consider(1, 1);
1518 // Layout of the tiling data, and expected return order:
1519 // x 0 1 2 3 4
1520 // y.----------
1521 // 0| 1
1522 // 1| *
1523 // 2|
1524 // 3|
1525 // 4|
1526 expected.push_back(std::make_pair(0, 0));
1528 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1530 // Consider is bottom right corner.
1531 consider = gfx::Rect(25, 25, 10, 10);
1533 // Layout of the tiling data, and expected return order:
1534 // x 0 1 2 3 4
1535 // y.----------
1536 // 0|
1537 // 1| *
1538 // 2| 1 2
1539 // 3| 3 4
1540 // 4|
1541 expected.clear();
1542 expected.push_back(std::make_pair(2, 2));
1543 expected.push_back(std::make_pair(3, 2));
1544 expected.push_back(std::make_pair(2, 3));
1545 expected.push_back(std::make_pair(3, 3));
1547 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1549 // Consider is one column.
1550 consider = gfx::Rect(11, 0, 1, 100);
1552 // Layout of the tiling data, and expected return order:
1553 // x 0 1 2 3 4
1554 // y.----------
1555 // 0| 2
1556 // 1| *
1557 // 2| 3
1558 // 3| 4
1559 // 4| 5
1560 expected.clear();
1561 expected.push_back(std::make_pair(1, 0));
1562 expected.push_back(std::make_pair(1, 2));
1563 expected.push_back(std::make_pair(1, 3));
1564 expected.push_back(std::make_pair(1, 4));
1566 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1569 TEST(TilingDataTest, SpiralDifferenceIteratorHasIgnore) {
1570 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false);
1571 gfx::Rect consider(50, 50);
1572 std::vector<std::pair<int, int> > expected;
1573 gfx::Rect center(15, 15, 1, 1);
1575 // Full ignore.
1576 gfx::Rect ignore(50, 50);
1578 // Layout of the tiling data, and expected return order:
1579 // x 0 1 2 3 4
1580 // y.----------
1581 // 0| . . . . .
1582 // 1| . * . . .
1583 // 2| . . . . .
1584 // 3| . . . . .
1585 // 4| . . . . .
1586 expected.clear();
1588 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1590 // 3 column ignore.
1591 ignore = gfx::Rect(15, 0, 20, 100);
1593 // Layout of the tiling data, and expected return order:
1594 // x 0 1 2 3 4
1595 // y.----------
1596 // 0| 1 . . . 8
1597 // 1| 2 * . . 7
1598 // 2| 3 . . . 6
1599 // 3| 4 . . . 5
1600 // 4| 9 . . . 10
1601 expected.clear();
1603 expected.push_back(std::make_pair(0, 0));
1604 expected.push_back(std::make_pair(0, 1));
1605 expected.push_back(std::make_pair(0, 2));
1606 expected.push_back(std::make_pair(0, 3));
1607 expected.push_back(std::make_pair(4, 3));
1608 expected.push_back(std::make_pair(4, 2));
1609 expected.push_back(std::make_pair(4, 1));
1610 expected.push_back(std::make_pair(4, 0));
1611 expected.push_back(std::make_pair(0, 4));
1612 expected.push_back(std::make_pair(4, 4));
1614 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1616 // Ignore covers the top half.
1617 ignore = gfx::Rect(50, 25);
1619 // Layout of the tiling data, and expected return order:
1620 // x 0 1 2 3 4
1621 // y.----------
1622 // 0| . . . . .
1623 // 1| . * . . .
1624 // 2| . . . . .
1625 // 3| 1 2 3 4 5
1626 // 4| 6 7 8 9 10
1627 expected.clear();
1629 expected.push_back(std::make_pair(0, 3));
1630 expected.push_back(std::make_pair(1, 3));
1631 expected.push_back(std::make_pair(2, 3));
1632 expected.push_back(std::make_pair(3, 3));
1633 expected.push_back(std::make_pair(4, 3));
1634 expected.push_back(std::make_pair(0, 4));
1635 expected.push_back(std::make_pair(1, 4));
1636 expected.push_back(std::make_pair(2, 4));
1637 expected.push_back(std::make_pair(3, 4));
1638 expected.push_back(std::make_pair(4, 4));
1640 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1643 TEST(TilingDataTest, SpiralDifferenceIteratorRectangleCenter) {
1644 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false);
1645 gfx::Rect consider(50, 50);
1646 std::vector<std::pair<int, int> > expected;
1647 gfx::Rect ignore;
1649 // Two cell center
1650 gfx::Rect center(25, 25, 1, 10);
1652 // Layout of the tiling data, and expected return order:
1653 // x 0 1 2 3 4
1654 // y.----------
1655 // 0| J I H G F
1656 // 1| K 5 4 3 E
1657 // 2| L 6 * 2 D
1658 // 3| M 7 * 1 C
1659 // 4| N 8 9 A B
1660 expected.clear();
1662 expected.push_back(std::make_pair(3, 3));
1663 expected.push_back(std::make_pair(3, 2));
1664 expected.push_back(std::make_pair(3, 1));
1665 expected.push_back(std::make_pair(2, 1));
1666 expected.push_back(std::make_pair(1, 1));
1667 expected.push_back(std::make_pair(1, 2));
1668 expected.push_back(std::make_pair(1, 3));
1669 expected.push_back(std::make_pair(1, 4));
1670 expected.push_back(std::make_pair(2, 4));
1671 expected.push_back(std::make_pair(3, 4));
1672 expected.push_back(std::make_pair(4, 4));
1673 expected.push_back(std::make_pair(4, 3));
1674 expected.push_back(std::make_pair(4, 2));
1675 expected.push_back(std::make_pair(4, 1));
1676 expected.push_back(std::make_pair(4, 0));
1677 expected.push_back(std::make_pair(3, 0));
1678 expected.push_back(std::make_pair(2, 0));
1679 expected.push_back(std::make_pair(1, 0));
1680 expected.push_back(std::make_pair(0, 0));
1681 expected.push_back(std::make_pair(0, 1));
1682 expected.push_back(std::make_pair(0, 2));
1683 expected.push_back(std::make_pair(0, 3));
1684 expected.push_back(std::make_pair(0, 4));
1686 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1688 // Three by two center.
1689 center = gfx::Rect(15, 25, 20, 10);
1691 // Layout of the tiling data, and expected return order:
1692 // x 0 1 2 3 4
1693 // y.----------
1694 // 0| J I H G F
1695 // 1| 7 6 5 4 3
1696 // 2| 8 * * * 2
1697 // 3| 9 * * * 1
1698 // 4| A B C D E
1699 expected.clear();
1701 expected.push_back(std::make_pair(4, 3));
1702 expected.push_back(std::make_pair(4, 2));
1703 expected.push_back(std::make_pair(4, 1));
1704 expected.push_back(std::make_pair(3, 1));
1705 expected.push_back(std::make_pair(2, 1));
1706 expected.push_back(std::make_pair(1, 1));
1707 expected.push_back(std::make_pair(0, 1));
1708 expected.push_back(std::make_pair(0, 2));
1709 expected.push_back(std::make_pair(0, 3));
1710 expected.push_back(std::make_pair(0, 4));
1711 expected.push_back(std::make_pair(1, 4));
1712 expected.push_back(std::make_pair(2, 4));
1713 expected.push_back(std::make_pair(3, 4));
1714 expected.push_back(std::make_pair(4, 4));
1715 expected.push_back(std::make_pair(4, 0));
1716 expected.push_back(std::make_pair(3, 0));
1717 expected.push_back(std::make_pair(2, 0));
1718 expected.push_back(std::make_pair(1, 0));
1719 expected.push_back(std::make_pair(0, 0));
1721 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1723 // Column center off the left side.
1724 center = gfx::Rect(-50, 0, 30, 50);
1726 // Layout of the tiling data, and expected return order:
1727 // x 0 1 2 3 4
1728 // y.----------
1729 // * 0| 5 A F K P
1730 // * 1| 4 9 E J O
1731 // * 2| 3 8 D I N
1732 // * 3| 2 7 C H M
1733 // * 4| 1 6 B G L
1734 expected.clear();
1736 expected.push_back(std::make_pair(0, 4));
1737 expected.push_back(std::make_pair(0, 3));
1738 expected.push_back(std::make_pair(0, 2));
1739 expected.push_back(std::make_pair(0, 1));
1740 expected.push_back(std::make_pair(0, 0));
1741 expected.push_back(std::make_pair(1, 4));
1742 expected.push_back(std::make_pair(1, 3));
1743 expected.push_back(std::make_pair(1, 2));
1744 expected.push_back(std::make_pair(1, 1));
1745 expected.push_back(std::make_pair(1, 0));
1746 expected.push_back(std::make_pair(2, 4));
1747 expected.push_back(std::make_pair(2, 3));
1748 expected.push_back(std::make_pair(2, 2));
1749 expected.push_back(std::make_pair(2, 1));
1750 expected.push_back(std::make_pair(2, 0));
1751 expected.push_back(std::make_pair(3, 4));
1752 expected.push_back(std::make_pair(3, 3));
1753 expected.push_back(std::make_pair(3, 2));
1754 expected.push_back(std::make_pair(3, 1));
1755 expected.push_back(std::make_pair(3, 0));
1756 expected.push_back(std::make_pair(4, 4));
1757 expected.push_back(std::make_pair(4, 3));
1758 expected.push_back(std::make_pair(4, 2));
1759 expected.push_back(std::make_pair(4, 1));
1760 expected.push_back(std::make_pair(4, 0));
1762 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1765 TEST(TilingDataTest, SpiralDifferenceIteratorEdgeCases) {
1766 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false);
1767 std::vector<std::pair<int, int> > expected;
1768 gfx::Rect center;
1769 gfx::Rect consider;
1770 gfx::Rect ignore;
1772 // Ignore contains, but is not equal to, consider and center.
1773 ignore = gfx::Rect(15, 0, 20, 30);
1774 consider = gfx::Rect(20, 10, 10, 20);
1775 center = gfx::Rect(25, 0, 5, 5);
1777 // Layout of the tiling data, and expected return order:
1778 // x 0 1 2
1779 // y.------
1780 // 0| . *
1781 // 1| . .
1782 // 2| . .
1783 expected.clear();
1785 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1787 // Center intersects with consider.
1788 ignore = gfx::Rect();
1789 center = gfx::Rect(0, 15, 30, 15);
1790 consider = gfx::Rect(15, 30);
1792 // Layout of the tiling data, and expected return order:
1793 // x 0 1 2
1794 // y.------
1795 // 0| 2 1
1796 // 1| * * *
1797 // 2| * * *
1798 expected.clear();
1800 expected.push_back(std::make_pair(1, 0));
1801 expected.push_back(std::make_pair(0, 0));
1803 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1805 // Consider and ignore are non-intersecting.
1806 ignore = gfx::Rect(5, 30);
1807 consider = gfx::Rect(25, 0, 5, 30);
1808 center = gfx::Rect(15, 0, 1, 1);
1810 // Layout of the tiling data, and expected return order:
1811 // x 0 1 2
1812 // y.------
1813 // 0| . * 1
1814 // 1| . 2
1815 // 2| . 3
1816 expected.clear();
1818 expected.push_back(std::make_pair(2, 0));
1819 expected.push_back(std::make_pair(2, 1));
1820 expected.push_back(std::make_pair(2, 2));
1822 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1824 // Center intersects with ignore.
1825 consider = gfx::Rect(30, 30);
1826 center = gfx::Rect(15, 0, 1, 30);
1827 ignore = gfx::Rect(0, 15, 30, 1);
1829 // Layout of the tiling data, and expected return order:
1830 // x 0 1 2
1831 // y.------
1832 // 0| 3 * 2
1833 // 1| . * .
1834 // 2| 4 * 1
1835 expected.clear();
1837 expected.push_back(std::make_pair(2, 2));
1838 expected.push_back(std::make_pair(2, 0));
1839 expected.push_back(std::make_pair(0, 0));
1840 expected.push_back(std::make_pair(0, 2));
1842 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1844 // Center and ignore are the same.
1845 consider = gfx::Rect(30, 30);
1846 center = gfx::Rect(15, 0, 1, 30);
1847 ignore = center;
1849 // Layout of the tiling data, and expected return order:
1850 // x 0 1 2
1851 // y.------
1852 // 0| 4 * 3
1853 // 1| 5 * 2
1854 // 2| 6 * 1
1855 expected.clear();
1857 expected.push_back(std::make_pair(2, 2));
1858 expected.push_back(std::make_pair(2, 1));
1859 expected.push_back(std::make_pair(2, 0));
1860 expected.push_back(std::make_pair(0, 0));
1861 expected.push_back(std::make_pair(0, 1));
1862 expected.push_back(std::make_pair(0, 2));
1864 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1866 // Empty tiling data.
1867 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false);
1869 expected.clear();
1870 TestSpiralIterate(__LINE__, empty_data, consider, ignore, center, expected);
1872 // Empty consider.
1873 ignore = gfx::Rect();
1874 center = gfx::Rect(1, 1, 1, 1);
1875 consider = gfx::Rect();
1877 expected.clear();
1878 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1880 // Empty center. Note: This arbitrarily puts the center to be off the top-left
1881 // corner.
1882 consider = gfx::Rect(30, 30);
1883 ignore = gfx::Rect();
1884 center = gfx::Rect();
1886 // Layout of the tiling data, and expected return order:
1887 // * x 0 1 2
1888 // y.------
1889 // 0| 1 2 6
1890 // 1| 3 4 5
1891 // 2| 7 8 9
1892 expected.clear();
1894 expected.push_back(std::make_pair(0, 0));
1895 expected.push_back(std::make_pair(1, 0));
1896 expected.push_back(std::make_pair(0, 1));
1897 expected.push_back(std::make_pair(1, 1));
1898 expected.push_back(std::make_pair(2, 1));
1899 expected.push_back(std::make_pair(2, 0));
1900 expected.push_back(std::make_pair(0, 2));
1901 expected.push_back(std::make_pair(1, 2));
1902 expected.push_back(std::make_pair(2, 2));
1904 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1906 // Every rect is empty.
1907 ignore = gfx::Rect();
1908 center = gfx::Rect();
1909 consider = gfx::Rect();
1911 expected.clear();
1912 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1914 // Center is just to the left of cover, and off of the tiling's left side.
1915 consider = gfx::Rect(30, 30);
1916 ignore = gfx::Rect();
1917 center = gfx::Rect(-20, 0, 19, 30);
1919 // Layout of the tiling data, and expected return order:
1920 // x 0 1 2
1921 // y.------
1922 // *0| 3 6 9
1923 // *1| 2 5 8
1924 // *2| 1 4 7
1925 expected.clear();
1927 expected.push_back(std::make_pair(0, 2));
1928 expected.push_back(std::make_pair(0, 1));
1929 expected.push_back(std::make_pair(0, 0));
1930 expected.push_back(std::make_pair(1, 2));
1931 expected.push_back(std::make_pair(1, 1));
1932 expected.push_back(std::make_pair(1, 0));
1933 expected.push_back(std::make_pair(2, 2));
1934 expected.push_back(std::make_pair(2, 1));
1935 expected.push_back(std::make_pair(2, 0));
1937 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1940 } // namespace
1942 } // namespace cc