Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / cc / base / tiling_data_unittest.cc
blob667719b3b1f6fa933fa34df023dea2450018d691
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, ExpandRectIgnoringBordersToTileBoundsEmpty) {
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.ExpandRectIgnoringBordersToTileBounds(gfx::Rect()));
781 EXPECT_RECT_EQ(gfx::Rect(),
782 empty_total_size.ExpandRectIgnoringBordersToTileBounds(
783 gfx::Rect(100, 100, 100, 100)));
784 EXPECT_RECT_EQ(gfx::Rect(),
785 empty_total_size.ExpandRectIgnoringBordersToTileBounds(
786 gfx::Rect(100, 100)));
788 TilingData empty_max_texture_size(gfx::Size(8, 8), gfx::Size(0, 0), true);
789 EXPECT_RECT_EQ(gfx::Rect(),
790 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
791 gfx::Rect()));
792 EXPECT_RECT_EQ(gfx::Rect(),
793 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
794 gfx::Rect(100, 100, 100, 100)));
795 EXPECT_RECT_EQ(gfx::Rect(),
796 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
797 gfx::Rect(100, 100)));
800 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBounds) {
801 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true);
803 // Small rect at origin rounds up to tile 0, 0.
804 gfx::Rect at_origin_src(1, 1);
805 gfx::Rect at_origin_result(data.TileBounds(0, 0));
806 EXPECT_NE(at_origin_src, at_origin_result);
807 EXPECT_RECT_EQ(at_origin_result,
808 data.ExpandRectIgnoringBordersToTileBounds(at_origin_src));
810 // Arbitrary internal rect.
811 gfx::Rect rect_src(6, 6, 1, 3);
812 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
813 // Tile 2, 3 => gfx::Rect(4, 6, 4, 4)
814 gfx::Rect rect_result(
815 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(2, 3)));
816 EXPECT_NE(rect_src, rect_result);
817 EXPECT_RECT_EQ(rect_result,
818 data.ExpandRectIgnoringBordersToTileBounds(rect_src));
820 // On tile bounds does not round up to next tile (ignores the border).
821 gfx::Rect border_rect_src(
822 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
823 gfx::Rect border_rect_result(
824 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
825 EXPECT_RECT_EQ(border_rect_result,
826 data.ExpandRectIgnoringBordersToTileBounds(border_rect_src));
828 // Equal to tiling rect.
829 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
830 data.ExpandRectIgnoringBordersToTileBounds(
831 gfx::Rect(data.tiling_size())));
833 // Containing, but larger than tiling rect.
834 EXPECT_RECT_EQ(
835 gfx::Rect(data.tiling_size()),
836 data.ExpandRectIgnoringBordersToTileBounds(gfx::Rect(100, 100)));
838 // Non-intersecting with tiling rect.
839 gfx::Rect non_intersect(200, 200, 100, 100);
840 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size())));
841 EXPECT_RECT_EQ(gfx::Rect(),
842 data.ExpandRectIgnoringBordersToTileBounds(non_intersect));
844 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true);
846 // Inside other tile border texels doesn't include other tiles.
847 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
848 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
849 gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
850 gfx::Rect expanded =
851 data2.ExpandRectIgnoringBordersToTileBounds(inner_rect_src);
852 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
855 TEST(TilingDataTest, ExpandRectToTileBounds) {
856 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true);
858 // Small rect at origin rounds up to tile 0, 0.
859 gfx::Rect at_origin_src(1, 1);
860 gfx::Rect at_origin_result(data.TileBounds(0, 0));
861 EXPECT_NE(at_origin_src, at_origin_result);
862 EXPECT_RECT_EQ(at_origin_result, data.ExpandRectToTileBounds(at_origin_src));
864 // Arbitrary internal rect.
865 gfx::Rect rect_src(6, 6, 1, 3);
866 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
867 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
868 gfx::Rect rect_result(
869 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(3, 4)));
870 EXPECT_NE(rect_src, rect_result);
871 EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBounds(rect_src));
873 // On tile bounds rounds up to next tile (since border overlaps).
874 gfx::Rect border_rect_src(
875 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
876 gfx::Rect border_rect_result(
877 gfx::UnionRects(data.TileBounds(0, 1), data.TileBounds(4, 5)));
878 EXPECT_RECT_EQ(border_rect_result,
879 data.ExpandRectToTileBounds(border_rect_src));
881 // Equal to tiling rect.
882 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
883 data.ExpandRectToTileBounds(gfx::Rect(data.tiling_size())));
885 // Containing, but larger than tiling rect.
886 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()),
887 data.ExpandRectToTileBounds(gfx::Rect(100, 100)));
889 // Non-intersecting with tiling rect.
890 gfx::Rect non_intersect(200, 200, 100, 100);
891 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size())));
892 EXPECT_RECT_EQ(gfx::Rect(), data.ExpandRectToTileBounds(non_intersect));
894 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true);
896 // Inside other tile border texels doesn't include other tiles.
897 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
898 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
899 gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
900 gfx::Rect expanded = data2.ExpandRectToTileBounds(inner_rect_src);
901 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
904 TEST(TilingDataTest, Assignment) {
906 TilingData source(gfx::Size(8, 8), gfx::Size(16, 32), true);
907 TilingData dest = source;
908 EXPECT_EQ(source.border_texels(), dest.border_texels());
909 EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
910 EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
911 EXPECT_EQ(source.num_tiles_y(), dest.num_tiles_y());
912 EXPECT_EQ(source.tiling_size(), dest.tiling_size());
915 TilingData source(gfx::Size(7, 3), gfx::Size(6, 100), false);
916 TilingData dest(source);
917 EXPECT_EQ(source.border_texels(), dest.border_texels());
918 EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
919 EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
920 EXPECT_EQ(source.num_tiles_y(), dest.num_tiles_y());
921 EXPECT_EQ(source.tiling_size(), dest.tiling_size());
925 TEST(TilingDataTest, SetBorderTexels) {
926 TilingData data(gfx::Size(8, 8), gfx::Size(16, 32), false);
927 EXPECT_EQ(2, data.num_tiles_x());
928 EXPECT_EQ(4, data.num_tiles_y());
930 data.SetHasBorderTexels(true);
931 EXPECT_EQ(3, data.num_tiles_x());
932 EXPECT_EQ(5, data.num_tiles_y());
934 data.SetHasBorderTexels(false);
935 EXPECT_EQ(2, data.num_tiles_x());
936 EXPECT_EQ(4, data.num_tiles_y());
939 TEST(TilingDataTest, LargeBorders) {
940 TilingData data(gfx::Size(100, 80), gfx::Size(200, 145), 30);
941 EXPECT_EQ(30, data.border_texels());
943 EXPECT_EQ(70, data.TileSizeX(0));
944 EXPECT_EQ(40, data.TileSizeX(1));
945 EXPECT_EQ(40, data.TileSizeX(2));
946 EXPECT_EQ(50, data.TileSizeX(3));
947 EXPECT_EQ(4, data.num_tiles_x());
949 EXPECT_EQ(50, data.TileSizeY(0));
950 EXPECT_EQ(20, data.TileSizeY(1));
951 EXPECT_EQ(20, data.TileSizeY(2));
952 EXPECT_EQ(20, data.TileSizeY(3));
953 EXPECT_EQ(35, data.TileSizeY(4));
954 EXPECT_EQ(5, data.num_tiles_y());
956 EXPECT_RECT_EQ(gfx::Rect(70, 50), data.TileBounds(0, 0));
957 EXPECT_RECT_EQ(gfx::Rect(70, 50, 40, 20), data.TileBounds(1, 1));
958 EXPECT_RECT_EQ(gfx::Rect(110, 110, 40, 35), data.TileBounds(2, 4));
959 EXPECT_RECT_EQ(gfx::Rect(150, 70, 50, 20), data.TileBounds(3, 2));
960 EXPECT_RECT_EQ(gfx::Rect(150, 110, 50, 35), data.TileBounds(3, 4));
962 EXPECT_RECT_EQ(gfx::Rect(100, 80), data.TileBoundsWithBorder(0, 0));
963 EXPECT_RECT_EQ(gfx::Rect(40, 20, 100, 80), data.TileBoundsWithBorder(1, 1));
964 EXPECT_RECT_EQ(gfx::Rect(80, 80, 100, 65), data.TileBoundsWithBorder(2, 4));
965 EXPECT_RECT_EQ(gfx::Rect(120, 40, 80, 80), data.TileBoundsWithBorder(3, 2));
966 EXPECT_RECT_EQ(gfx::Rect(120, 80, 80, 65), data.TileBoundsWithBorder(3, 4));
968 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(0));
969 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(69));
970 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(70));
971 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(109));
972 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(110));
973 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(149));
974 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(150));
975 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(199));
977 EXPECT_EQ(0, data.TileYIndexFromSrcCoord(0));
978 EXPECT_EQ(0, data.TileYIndexFromSrcCoord(49));
979 EXPECT_EQ(1, data.TileYIndexFromSrcCoord(50));
980 EXPECT_EQ(1, data.TileYIndexFromSrcCoord(69));
981 EXPECT_EQ(2, data.TileYIndexFromSrcCoord(70));
982 EXPECT_EQ(2, data.TileYIndexFromSrcCoord(89));
983 EXPECT_EQ(3, data.TileYIndexFromSrcCoord(90));
984 EXPECT_EQ(3, data.TileYIndexFromSrcCoord(109));
985 EXPECT_EQ(4, data.TileYIndexFromSrcCoord(110));
986 EXPECT_EQ(4, data.TileYIndexFromSrcCoord(144));
988 EXPECT_EQ(0, data.FirstBorderTileXIndexFromSrcCoord(0));
989 EXPECT_EQ(0, data.FirstBorderTileXIndexFromSrcCoord(99));
990 EXPECT_EQ(1, data.FirstBorderTileXIndexFromSrcCoord(100));
991 EXPECT_EQ(1, data.FirstBorderTileXIndexFromSrcCoord(139));
992 EXPECT_EQ(2, data.FirstBorderTileXIndexFromSrcCoord(140));
993 EXPECT_EQ(2, data.FirstBorderTileXIndexFromSrcCoord(179));
994 EXPECT_EQ(3, data.FirstBorderTileXIndexFromSrcCoord(180));
995 EXPECT_EQ(3, data.FirstBorderTileXIndexFromSrcCoord(199));
997 EXPECT_EQ(0, data.FirstBorderTileYIndexFromSrcCoord(0));
998 EXPECT_EQ(0, data.FirstBorderTileYIndexFromSrcCoord(79));
999 EXPECT_EQ(1, data.FirstBorderTileYIndexFromSrcCoord(80));
1000 EXPECT_EQ(1, data.FirstBorderTileYIndexFromSrcCoord(99));
1001 EXPECT_EQ(2, data.FirstBorderTileYIndexFromSrcCoord(100));
1002 EXPECT_EQ(2, data.FirstBorderTileYIndexFromSrcCoord(119));
1003 EXPECT_EQ(3, data.FirstBorderTileYIndexFromSrcCoord(120));
1004 EXPECT_EQ(3, data.FirstBorderTileYIndexFromSrcCoord(139));
1005 EXPECT_EQ(4, data.FirstBorderTileYIndexFromSrcCoord(140));
1006 EXPECT_EQ(4, data.FirstBorderTileYIndexFromSrcCoord(144));
1008 EXPECT_EQ(0, data.LastBorderTileXIndexFromSrcCoord(0));
1009 EXPECT_EQ(0, data.LastBorderTileXIndexFromSrcCoord(39));
1010 EXPECT_EQ(1, data.LastBorderTileXIndexFromSrcCoord(40));
1011 EXPECT_EQ(1, data.LastBorderTileXIndexFromSrcCoord(79));
1012 EXPECT_EQ(2, data.LastBorderTileXIndexFromSrcCoord(80));
1013 EXPECT_EQ(2, data.LastBorderTileXIndexFromSrcCoord(119));
1014 EXPECT_EQ(3, data.LastBorderTileXIndexFromSrcCoord(120));
1015 EXPECT_EQ(3, data.LastBorderTileXIndexFromSrcCoord(199));
1017 EXPECT_EQ(0, data.LastBorderTileYIndexFromSrcCoord(0));
1018 EXPECT_EQ(0, data.LastBorderTileYIndexFromSrcCoord(19));
1019 EXPECT_EQ(1, data.LastBorderTileYIndexFromSrcCoord(20));
1020 EXPECT_EQ(1, data.LastBorderTileYIndexFromSrcCoord(39));
1021 EXPECT_EQ(2, data.LastBorderTileYIndexFromSrcCoord(40));
1022 EXPECT_EQ(2, data.LastBorderTileYIndexFromSrcCoord(59));
1023 EXPECT_EQ(3, data.LastBorderTileYIndexFromSrcCoord(60));
1024 EXPECT_EQ(3, data.LastBorderTileYIndexFromSrcCoord(79));
1025 EXPECT_EQ(4, data.LastBorderTileYIndexFromSrcCoord(80));
1026 EXPECT_EQ(4, data.LastBorderTileYIndexFromSrcCoord(144));
1029 void TestIterate(const TilingData& data,
1030 gfx::Rect rect,
1031 int expect_left,
1032 int expect_top,
1033 int expect_right,
1034 int expect_bottom,
1035 bool include_borders) {
1036 EXPECT_GE(expect_left, 0);
1037 EXPECT_GE(expect_top, 0);
1038 EXPECT_LT(expect_right, data.num_tiles_x());
1039 EXPECT_LT(expect_bottom, data.num_tiles_y());
1041 std::vector<std::pair<int, int>> original_expected;
1042 for (int x = 0; x < data.num_tiles_x(); ++x) {
1043 for (int y = 0; y < data.num_tiles_y(); ++y) {
1044 gfx::Rect bounds;
1045 if (include_borders)
1046 bounds = data.TileBoundsWithBorder(x, y);
1047 else
1048 bounds = data.TileBounds(x, y);
1049 if (x >= expect_left && x <= expect_right &&
1050 y >= expect_top && y <= expect_bottom) {
1051 EXPECT_TRUE(bounds.Intersects(rect));
1052 original_expected.push_back(std::make_pair(x, y));
1053 } else {
1054 EXPECT_FALSE(bounds.Intersects(rect));
1059 // Verify with vanilla iterator.
1061 std::vector<std::pair<int, int>> expected = original_expected;
1062 for (TilingData::Iterator iter(&data, rect, include_borders); iter;
1063 ++iter) {
1064 bool found = false;
1065 for (size_t i = 0; i < expected.size(); ++i) {
1066 if (expected[i] == iter.index()) {
1067 expected[i] = expected.back();
1068 expected.pop_back();
1069 found = true;
1070 break;
1073 EXPECT_TRUE(found);
1075 EXPECT_EQ(0u, expected.size());
1078 // Make sure this also works with a difference iterator and an empty ignore.
1079 // The difference iterator never includes borders, so ignore it otherwise.
1080 if (!include_borders) {
1081 std::vector<std::pair<int, int>> expected = original_expected;
1082 for (TilingData::DifferenceIterator iter(&data, rect, gfx::Rect()); iter;
1083 ++iter) {
1084 bool found = false;
1085 for (size_t i = 0; i < expected.size(); ++i) {
1086 if (expected[i] == iter.index()) {
1087 expected[i] = expected.back();
1088 expected.pop_back();
1089 found = true;
1090 break;
1093 EXPECT_TRUE(found);
1095 EXPECT_EQ(0u, expected.size());
1099 void TestIterateBorders(const TilingData& data,
1100 gfx::Rect rect,
1101 int expect_left,
1102 int expect_top,
1103 int expect_right,
1104 int expect_bottom) {
1105 bool include_borders = true;
1106 TestIterate(data,
1107 rect,
1108 expect_left,
1109 expect_top,
1110 expect_right,
1111 expect_bottom,
1112 include_borders);
1115 void TestIterateNoBorders(const TilingData& data,
1116 gfx::Rect rect,
1117 int expect_left,
1118 int expect_top,
1119 int expect_right,
1120 int expect_bottom) {
1121 bool include_borders = false;
1122 TestIterate(data,
1123 rect,
1124 expect_left,
1125 expect_top,
1126 expect_right,
1127 expect_bottom,
1128 include_borders);
1131 void TestIterateAll(const TilingData& data,
1132 gfx::Rect rect,
1133 int expect_left,
1134 int expect_top,
1135 int expect_right,
1136 int expect_bottom) {
1137 TestIterateBorders(
1138 data, rect, expect_left, expect_top, expect_right, expect_bottom);
1139 TestIterateNoBorders(
1140 data, rect, expect_left, expect_top, expect_right, expect_bottom);
1143 TEST(TilingDataTest, IteratorNoBorderTexels) {
1144 TilingData data(gfx::Size(10, 10), gfx::Size(40, 25), false);
1145 // X border index by src coord: [0-10), [10-20), [20, 30), [30, 40)
1146 // Y border index by src coord: [0-10), [10-20), [20, 25)
1147 TestIterateAll(data, gfx::Rect(40, 25), 0, 0, 3, 2);
1148 TestIterateAll(data, gfx::Rect(15, 15, 8, 8), 1, 1, 2, 2);
1150 // Oversized.
1151 TestIterateAll(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 3, 2);
1152 TestIterateAll(data, gfx::Rect(-100, 20, 1000, 1), 0, 2, 3, 2);
1153 TestIterateAll(data, gfx::Rect(29, -100, 31, 1000), 2, 0, 3, 2);
1154 // Nonintersecting.
1155 TestIterateAll(data, gfx::Rect(60, 80, 100, 100), 0, 0, -1, -1);
1158 TEST(TilingDataTest, BordersIteratorOneBorderTexel) {
1159 TilingData data(gfx::Size(10, 20), gfx::Size(25, 45), true);
1160 // X border index by src coord: [0-10), [8-18), [16-25)
1161 // Y border index by src coord: [0-20), [18-38), [36-45)
1162 TestIterateBorders(data, gfx::Rect(25, 45), 0, 0, 2, 2);
1163 TestIterateBorders(data, gfx::Rect(18, 19, 3, 17), 2, 0, 2, 1);
1164 TestIterateBorders(data, gfx::Rect(10, 20, 6, 16), 1, 1, 1, 1);
1165 TestIterateBorders(data, gfx::Rect(9, 19, 8, 18), 0, 0, 2, 2);
1166 // Oversized.
1167 TestIterateBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 2);
1168 TestIterateBorders(data, gfx::Rect(-100, 20, 1000, 1), 0, 1, 2, 1);
1169 TestIterateBorders(data, gfx::Rect(18, -100, 6, 1000), 2, 0, 2, 2);
1170 // Nonintersecting.
1171 TestIterateBorders(data, gfx::Rect(60, 80, 100, 100), 0, 0, -1, -1);
1174 TEST(TilingDataTest, NoBordersIteratorOneBorderTexel) {
1175 TilingData data(gfx::Size(10, 20), gfx::Size(25, 45), true);
1176 // X index by src coord: [0-9), [9-17), [17-25)
1177 // Y index by src coord: [0-19), [19-37), [37-45)
1178 TestIterateNoBorders(data, gfx::Rect(25, 45), 0, 0, 2, 2);
1179 TestIterateNoBorders(data, gfx::Rect(17, 19, 3, 18), 2, 1, 2, 1);
1180 TestIterateNoBorders(data, gfx::Rect(17, 19, 3, 19), 2, 1, 2, 2);
1181 TestIterateNoBorders(data, gfx::Rect(8, 18, 9, 19), 0, 0, 1, 1);
1182 TestIterateNoBorders(data, gfx::Rect(9, 19, 9, 19), 1, 1, 2, 2);
1183 // Oversized.
1184 TestIterateNoBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 2);
1185 TestIterateNoBorders(data, gfx::Rect(-100, 20, 1000, 1), 0, 1, 2, 1);
1186 TestIterateNoBorders(data, gfx::Rect(18, -100, 6, 1000), 2, 0, 2, 2);
1187 // Nonintersecting.
1188 TestIterateNoBorders(data, gfx::Rect(60, 80, 100, 100), 0, 0, -1, -1);
1191 TEST(TilingDataTest, BordersIteratorManyBorderTexels) {
1192 TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
1193 // X border index by src coord: [0-50), [10-60), [20-65)
1194 // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
1195 TestIterateBorders(data, gfx::Rect(65, 110), 0, 0, 2, 3);
1196 TestIterateBorders(data, gfx::Rect(50, 60, 15, 65), 1, 1, 2, 3);
1197 TestIterateBorders(data, gfx::Rect(60, 30, 2, 10), 2, 0, 2, 1);
1198 // Oversized.
1199 TestIterateBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 3);
1200 TestIterateBorders(data, gfx::Rect(-100, 10, 1000, 10), 0, 0, 2, 0);
1201 TestIterateBorders(data, gfx::Rect(10, -100, 10, 1000), 0, 0, 1, 3);
1202 // Nonintersecting.
1203 TestIterateBorders(data, gfx::Rect(65, 110, 100, 100), 0, 0, -1, -1);
1206 TEST(TilingDataTest, NoBordersIteratorManyBorderTexels) {
1207 TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
1208 // X index by src coord: [0-30), [30-40), [40, 65)
1209 // Y index by src coord: [0-40), [40-60), [60, 80), [80-110)
1210 TestIterateNoBorders(data, gfx::Rect(65, 110), 0, 0, 2, 3);
1211 TestIterateNoBorders(data, gfx::Rect(30, 40, 15, 65), 1, 1, 2, 3);
1212 TestIterateNoBorders(data, gfx::Rect(60, 20, 2, 21), 2, 0, 2, 1);
1213 // Oversized.
1214 TestIterateNoBorders(data, gfx::Rect(-100, -100, 1000, 1000), 0, 0, 2, 3);
1215 TestIterateNoBorders(data, gfx::Rect(-100, 10, 1000, 10), 0, 0, 2, 0);
1216 TestIterateNoBorders(data, gfx::Rect(10, -100, 10, 1000), 0, 0, 0, 3);
1217 // Nonintersecting.
1218 TestIterateNoBorders(data, gfx::Rect(65, 110, 100, 100), 0, 0, -1, -1);
1221 TEST(TilingDataTest, IteratorOneTile) {
1222 TilingData no_border(gfx::Size(1000, 1000), gfx::Size(30, 40), false);
1223 TestIterateAll(no_border, gfx::Rect(30, 40), 0, 0, 0, 0);
1224 TestIterateAll(no_border, gfx::Rect(10, 10, 20, 20), 0, 0, 0, 0);
1225 TestIterateAll(no_border, gfx::Rect(30, 40, 100, 100), 0, 0, -1, -1);
1227 TilingData one_border(gfx::Size(1000, 1000), gfx::Size(30, 40), true);
1228 TestIterateAll(one_border, gfx::Rect(30, 40), 0, 0, 0, 0);
1229 TestIterateAll(one_border, gfx::Rect(10, 10, 20, 20), 0, 0, 0, 0);
1230 TestIterateAll(one_border, gfx::Rect(30, 40, 100, 100), 0, 0, -1, -1);
1232 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50);
1233 TestIterateAll(big_border, gfx::Rect(30, 40), 0, 0, 0, 0);
1234 TestIterateAll(big_border, gfx::Rect(10, 10, 20, 20), 0, 0, 0, 0);
1235 TestIterateAll(big_border, gfx::Rect(30, 40, 100, 100), 0, 0, -1, -1);
1238 TEST(TilingDataTest, IteratorNoTiles) {
1239 TilingData data(gfx::Size(100, 100), gfx::Size(), false);
1240 TestIterateAll(data, gfx::Rect(100, 100), 0, 0, -1, -1);
1243 void TestDiff(const TilingData& data,
1244 gfx::Rect consider,
1245 gfx::Rect ignore,
1246 size_t num_tiles) {
1247 std::vector<std::pair<int, int>> expected;
1248 for (int y = 0; y < data.num_tiles_y(); ++y) {
1249 for (int x = 0; x < data.num_tiles_x(); ++x) {
1250 gfx::Rect bounds = data.TileBounds(x, y);
1251 if (bounds.Intersects(consider) && !bounds.Intersects(ignore))
1252 expected.push_back(std::make_pair(x, y));
1256 // Sanity check the test.
1257 EXPECT_EQ(num_tiles, expected.size());
1259 for (TilingData::DifferenceIterator iter(&data, consider, ignore); iter;
1260 ++iter) {
1261 bool found = false;
1262 for (size_t i = 0; i < expected.size(); ++i) {
1263 if (expected[i] == iter.index()) {
1264 expected[i] = expected.back();
1265 expected.pop_back();
1266 found = true;
1267 break;
1270 EXPECT_TRUE(found);
1272 EXPECT_EQ(0u, expected.size());
1275 TEST(TilingDataTest, DifferenceIteratorIgnoreGeometry) {
1276 // This test is checking that the iterator can handle different geometries of
1277 // ignore rects relative to the consider rect. The consider rect indices
1278 // themselves are mostly tested by the non-difference iterator tests, so the
1279 // full rect is mostly used here for simplicity.
1281 // X border index by src coord: [0-10), [10-20), [20, 30), [30, 40)
1282 // Y border index by src coord: [0-10), [10-20), [20, 25)
1283 TilingData data(gfx::Size(10, 10), gfx::Size(40, 25), false);
1285 // Fully ignored
1286 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(40, 25), 0);
1287 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-100, -100, 200, 200), 0);
1288 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(9, 9, 30, 15), 0);
1289 TestDiff(data, gfx::Rect(15, 15, 8, 8), gfx::Rect(15, 15, 8, 8), 0);
1291 // Fully un-ignored
1292 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(-30, -20, 8, 8), 12);
1293 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(), 12);
1295 // Top left, remove 2x2 tiles
1296 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 19), 8);
1297 // Bottom right, remove 2x2 tiles
1298 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 15, 20, 6), 8);
1299 // Bottom left, remove 2x2 tiles
1300 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 15, 20, 6), 8);
1301 // Top right, remove 2x2 tiles
1302 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(20, 0, 20, 19), 8);
1303 // Center, remove only one tile
1304 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(10, 10, 5, 5), 11);
1306 // Left column, flush left, removing two columns
1307 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 25), 6);
1308 // Middle column, removing two columns
1309 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(11, 0, 11, 25), 6);
1310 // Right column, flush right, removing one column
1311 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(30, 0, 2, 25), 9);
1313 // Top row, flush top, removing one row
1314 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 5, 40, 5), 8);
1315 // Middle row, removing one row
1316 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 5), 8);
1317 // Bottom row, flush bottom, removing two rows
1318 TestDiff(data, gfx::Rect(40, 25), gfx::Rect(0, 13, 40, 12), 4);
1320 // Non-intersecting, but still touching two of the same tiles.
1321 TestDiff(data, gfx::Rect(8, 0, 32, 25), gfx::Rect(0, 12, 5, 12), 10);
1323 // Intersecting, but neither contains the other. 2x3 with one overlap.
1324 TestDiff(data, gfx::Rect(5, 2, 20, 10), gfx::Rect(25, 15, 5, 10), 5);
1327 TEST(TilingDataTest, DifferenceIteratorManyBorderTexels) {
1328 // X border index by src coord: [0-50), [10-60), [20-65)
1329 // Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
1330 // X tile bounds by src coord: [0-30), [30-40), [40-65)
1331 // Y tile bounds by src coord: [0-40), [40-60), [60-80), [80-110)
1332 TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
1334 // Knock out two rows, but not the left column.
1335 TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(30, 59, 20, 2), 8);
1337 // Knock out one row.
1338 TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(29, 59, 20, 1), 9);
1340 // Overlap all tiles with ignore rect.
1341 TestDiff(data, gfx::Rect(65, 110), gfx::Rect(29, 39, 12, 42), 0);
1343 gfx::Rect tile = data.TileBounds(1, 1);
1345 // Ignore one tile.
1346 TestDiff(data, gfx::Rect(20, 30, 45, 80), tile, 11);
1348 // Include one tile.
1349 TestDiff(data, tile, gfx::Rect(), 1);
1352 TEST(TilingDataTest, DifferenceIteratorOneTile) {
1353 TilingData no_border(gfx::Size(1000, 1000), gfx::Size(30, 40), false);
1354 TestDiff(no_border, gfx::Rect(30, 40), gfx::Rect(), 1);
1355 TestDiff(no_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1357 TilingData one_border(gfx::Size(1000, 1000), gfx::Size(30, 40), true);
1358 TestDiff(one_border, gfx::Rect(30, 40), gfx::Rect(), 1);
1359 TestDiff(one_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1361 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50);
1362 TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1);
1363 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1366 TEST(TilingDataTest, DifferenceIteratorNoTiles) {
1367 TilingData data(gfx::Size(100, 100), gfx::Size(), false);
1368 TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0);
1371 void TestSpiralIterate(int source_line_number,
1372 const TilingData& tiling_data,
1373 const gfx::Rect& consider,
1374 const gfx::Rect& ignore,
1375 const gfx::Rect& center,
1376 const std::vector<std::pair<int, int>>& expected) {
1377 std::vector<std::pair<int, int>> actual_forward;
1378 for (TilingData::SpiralDifferenceIterator it(
1379 &tiling_data, consider, ignore, center);
1381 ++it) {
1382 actual_forward.push_back(it.index());
1385 EXPECT_EQ(expected.size(), actual_forward.size()) << "error from line "
1386 << source_line_number;
1387 for (size_t i = 0; i < std::min(expected.size(), actual_forward.size());
1388 ++i) {
1389 EXPECT_EQ(expected[i].first, actual_forward[i].first)
1390 << "i: " << i << " error from line: " << source_line_number;
1391 EXPECT_EQ(expected[i].second, actual_forward[i].second)
1392 << "i: " << i << " error from line: " << source_line_number;
1395 std::vector<std::pair<int, int>> actual_reverse;
1396 for (TilingData::ReverseSpiralDifferenceIterator it(
1397 &tiling_data, consider, ignore, center);
1399 ++it) {
1400 actual_reverse.push_back(it.index());
1403 std::vector<std::pair<int, int>> reversed_expected = expected;
1404 std::reverse(reversed_expected.begin(), reversed_expected.end());
1405 EXPECT_EQ(reversed_expected.size(), actual_reverse.size())
1406 << "error from line " << source_line_number;
1407 for (size_t i = 0;
1408 i < std::min(reversed_expected.size(), actual_reverse.size());
1409 ++i) {
1410 EXPECT_EQ(reversed_expected[i].first, actual_reverse[i].first)
1411 << "i: " << i << " error from line: " << source_line_number;
1412 EXPECT_EQ(reversed_expected[i].second, actual_reverse[i].second)
1413 << "i: " << i << " error from line: " << source_line_number;
1417 TEST(TilingDataTest, SpiralDifferenceIteratorNoIgnoreFullConsider) {
1418 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false);
1419 gfx::Rect consider(30, 30);
1420 gfx::Rect ignore;
1421 std::vector<std::pair<int, int>> expected;
1423 // Center is in the center of the tiling.
1424 gfx::Rect center(15, 15, 1, 1);
1426 // Layout of the tiling data, and expected return order:
1427 // x 0 1 2
1428 // y.------
1429 // 0| 4 3 2
1430 // 1| 5 * 1
1431 // 2| 6 7 8
1432 expected.push_back(std::make_pair(2, 1));
1433 expected.push_back(std::make_pair(2, 0));
1434 expected.push_back(std::make_pair(1, 0));
1435 expected.push_back(std::make_pair(0, 0));
1436 expected.push_back(std::make_pair(0, 1));
1437 expected.push_back(std::make_pair(0, 2));
1438 expected.push_back(std::make_pair(1, 2));
1439 expected.push_back(std::make_pair(2, 2));
1441 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1443 // Center is off to the right side of the tiling (and far away).
1444 center = gfx::Rect(100, 15, 1, 1);
1446 // Layout of the tiling data, and expected return order:
1447 // x 0 1 2
1448 // y.------
1449 // 0| 7 4 1
1450 // 1| 8 5 2 *
1451 // 2| 9 6 3
1452 expected.clear();
1453 expected.push_back(std::make_pair(2, 0));
1454 expected.push_back(std::make_pair(2, 1));
1455 expected.push_back(std::make_pair(2, 2));
1456 expected.push_back(std::make_pair(1, 0));
1457 expected.push_back(std::make_pair(1, 1));
1458 expected.push_back(std::make_pair(1, 2));
1459 expected.push_back(std::make_pair(0, 0));
1460 expected.push_back(std::make_pair(0, 1));
1461 expected.push_back(std::make_pair(0, 2));
1463 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1465 // Center is the bottom right corner of the tiling.
1466 center = gfx::Rect(25, 25, 1, 1);
1468 // Layout of the tiling data, and expected return order:
1469 // x 0 1 2
1470 // y.------
1471 // 0| 6 5 4
1472 // 1| 7 2 1
1473 // 2| 8 3 *
1474 expected.clear();
1475 expected.push_back(std::make_pair(2, 1));
1476 expected.push_back(std::make_pair(1, 1));
1477 expected.push_back(std::make_pair(1, 2));
1478 expected.push_back(std::make_pair(2, 0));
1479 expected.push_back(std::make_pair(1, 0));
1480 expected.push_back(std::make_pair(0, 0));
1481 expected.push_back(std::make_pair(0, 1));
1482 expected.push_back(std::make_pair(0, 2));
1484 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1486 // Center is off the top left side of the tiling.
1487 center = gfx::Rect(-60, -50, 1, 1);
1489 // Layout of the tiling data, and expected return order:
1490 // * x 0 1 2
1491 // y.------
1492 // 0| 1 2 6
1493 // 1| 3 4 5
1494 // 2| 7 8 9
1495 expected.clear();
1496 expected.push_back(std::make_pair(0, 0));
1497 expected.push_back(std::make_pair(1, 0));
1498 expected.push_back(std::make_pair(0, 1));
1499 expected.push_back(std::make_pair(1, 1));
1500 expected.push_back(std::make_pair(2, 1));
1501 expected.push_back(std::make_pair(2, 0));
1502 expected.push_back(std::make_pair(0, 2));
1503 expected.push_back(std::make_pair(1, 2));
1504 expected.push_back(std::make_pair(2, 2));
1506 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1508 // Two tile center.
1509 center = gfx::Rect(15, 15, 1, 10);
1511 // Layout of the tiling data, and expected return order:
1512 // x 0 1 2
1513 // y.------
1514 // 0| 5 4 3
1515 // 1| 6 * 2
1516 // 2| 7 * 1
1517 expected.clear();
1518 expected.push_back(std::make_pair(2, 2));
1519 expected.push_back(std::make_pair(2, 1));
1520 expected.push_back(std::make_pair(2, 0));
1521 expected.push_back(std::make_pair(1, 0));
1522 expected.push_back(std::make_pair(0, 0));
1523 expected.push_back(std::make_pair(0, 1));
1524 expected.push_back(std::make_pair(0, 2));
1526 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1529 TEST(TilingDataTest, SpiralDifferenceIteratorSmallConsider) {
1530 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false);
1531 gfx::Rect ignore;
1532 std::vector<std::pair<int, int>> expected;
1533 gfx::Rect center(15, 15, 1, 1);
1535 // Consider is one cell.
1536 gfx::Rect consider(1, 1);
1538 // Layout of the tiling data, and expected return order:
1539 // x 0 1 2 3 4
1540 // y.----------
1541 // 0| 1
1542 // 1| *
1543 // 2|
1544 // 3|
1545 // 4|
1546 expected.push_back(std::make_pair(0, 0));
1548 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1550 // Consider is bottom right corner.
1551 consider = gfx::Rect(25, 25, 10, 10);
1553 // Layout of the tiling data, and expected return order:
1554 // x 0 1 2 3 4
1555 // y.----------
1556 // 0|
1557 // 1| *
1558 // 2| 1 2
1559 // 3| 3 4
1560 // 4|
1561 expected.clear();
1562 expected.push_back(std::make_pair(2, 2));
1563 expected.push_back(std::make_pair(3, 2));
1564 expected.push_back(std::make_pair(2, 3));
1565 expected.push_back(std::make_pair(3, 3));
1567 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1569 // Consider is one column.
1570 consider = gfx::Rect(11, 0, 1, 100);
1572 // Layout of the tiling data, and expected return order:
1573 // x 0 1 2 3 4
1574 // y.----------
1575 // 0| 2
1576 // 1| *
1577 // 2| 3
1578 // 3| 4
1579 // 4| 5
1580 expected.clear();
1581 expected.push_back(std::make_pair(1, 0));
1582 expected.push_back(std::make_pair(1, 2));
1583 expected.push_back(std::make_pair(1, 3));
1584 expected.push_back(std::make_pair(1, 4));
1586 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1589 TEST(TilingDataTest, SpiralDifferenceIteratorHasIgnore) {
1590 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false);
1591 gfx::Rect consider(50, 50);
1592 std::vector<std::pair<int, int>> expected;
1593 gfx::Rect center(15, 15, 1, 1);
1595 // Full ignore.
1596 gfx::Rect ignore(50, 50);
1598 // Layout of the tiling data, and expected return order:
1599 // x 0 1 2 3 4
1600 // y.----------
1601 // 0| . . . . .
1602 // 1| . * . . .
1603 // 2| . . . . .
1604 // 3| . . . . .
1605 // 4| . . . . .
1606 expected.clear();
1608 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1610 // 3 column ignore.
1611 ignore = gfx::Rect(15, 0, 20, 100);
1613 // Layout of the tiling data, and expected return order:
1614 // x 0 1 2 3 4
1615 // y.----------
1616 // 0| 1 . . . 8
1617 // 1| 2 * . . 7
1618 // 2| 3 . . . 6
1619 // 3| 4 . . . 5
1620 // 4| 9 . . . 10
1621 expected.clear();
1623 expected.push_back(std::make_pair(0, 0));
1624 expected.push_back(std::make_pair(0, 1));
1625 expected.push_back(std::make_pair(0, 2));
1626 expected.push_back(std::make_pair(0, 3));
1627 expected.push_back(std::make_pair(4, 3));
1628 expected.push_back(std::make_pair(4, 2));
1629 expected.push_back(std::make_pair(4, 1));
1630 expected.push_back(std::make_pair(4, 0));
1631 expected.push_back(std::make_pair(0, 4));
1632 expected.push_back(std::make_pair(4, 4));
1634 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1636 // Ignore covers the top half.
1637 ignore = gfx::Rect(50, 25);
1639 // Layout of the tiling data, and expected return order:
1640 // x 0 1 2 3 4
1641 // y.----------
1642 // 0| . . . . .
1643 // 1| . * . . .
1644 // 2| . . . . .
1645 // 3| 1 2 3 4 5
1646 // 4| 6 7 8 9 10
1647 expected.clear();
1649 expected.push_back(std::make_pair(0, 3));
1650 expected.push_back(std::make_pair(1, 3));
1651 expected.push_back(std::make_pair(2, 3));
1652 expected.push_back(std::make_pair(3, 3));
1653 expected.push_back(std::make_pair(4, 3));
1654 expected.push_back(std::make_pair(0, 4));
1655 expected.push_back(std::make_pair(1, 4));
1656 expected.push_back(std::make_pair(2, 4));
1657 expected.push_back(std::make_pair(3, 4));
1658 expected.push_back(std::make_pair(4, 4));
1660 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1663 TEST(TilingDataTest, SpiralDifferenceIteratorRectangleCenter) {
1664 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false);
1665 gfx::Rect consider(50, 50);
1666 std::vector<std::pair<int, int>> expected;
1667 gfx::Rect ignore;
1669 // Two cell center
1670 gfx::Rect center(25, 25, 1, 10);
1672 // Layout of the tiling data, and expected return order:
1673 // x 0 1 2 3 4
1674 // y.----------
1675 // 0| J I H G F
1676 // 1| K 5 4 3 E
1677 // 2| L 6 * 2 D
1678 // 3| M 7 * 1 C
1679 // 4| N 8 9 A B
1680 expected.clear();
1682 expected.push_back(std::make_pair(3, 3));
1683 expected.push_back(std::make_pair(3, 2));
1684 expected.push_back(std::make_pair(3, 1));
1685 expected.push_back(std::make_pair(2, 1));
1686 expected.push_back(std::make_pair(1, 1));
1687 expected.push_back(std::make_pair(1, 2));
1688 expected.push_back(std::make_pair(1, 3));
1689 expected.push_back(std::make_pair(1, 4));
1690 expected.push_back(std::make_pair(2, 4));
1691 expected.push_back(std::make_pair(3, 4));
1692 expected.push_back(std::make_pair(4, 4));
1693 expected.push_back(std::make_pair(4, 3));
1694 expected.push_back(std::make_pair(4, 2));
1695 expected.push_back(std::make_pair(4, 1));
1696 expected.push_back(std::make_pair(4, 0));
1697 expected.push_back(std::make_pair(3, 0));
1698 expected.push_back(std::make_pair(2, 0));
1699 expected.push_back(std::make_pair(1, 0));
1700 expected.push_back(std::make_pair(0, 0));
1701 expected.push_back(std::make_pair(0, 1));
1702 expected.push_back(std::make_pair(0, 2));
1703 expected.push_back(std::make_pair(0, 3));
1704 expected.push_back(std::make_pair(0, 4));
1706 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1708 // Three by two center.
1709 center = gfx::Rect(15, 25, 20, 10);
1711 // Layout of the tiling data, and expected return order:
1712 // x 0 1 2 3 4
1713 // y.----------
1714 // 0| J I H G F
1715 // 1| 7 6 5 4 3
1716 // 2| 8 * * * 2
1717 // 3| 9 * * * 1
1718 // 4| A B C D E
1719 expected.clear();
1721 expected.push_back(std::make_pair(4, 3));
1722 expected.push_back(std::make_pair(4, 2));
1723 expected.push_back(std::make_pair(4, 1));
1724 expected.push_back(std::make_pair(3, 1));
1725 expected.push_back(std::make_pair(2, 1));
1726 expected.push_back(std::make_pair(1, 1));
1727 expected.push_back(std::make_pair(0, 1));
1728 expected.push_back(std::make_pair(0, 2));
1729 expected.push_back(std::make_pair(0, 3));
1730 expected.push_back(std::make_pair(0, 4));
1731 expected.push_back(std::make_pair(1, 4));
1732 expected.push_back(std::make_pair(2, 4));
1733 expected.push_back(std::make_pair(3, 4));
1734 expected.push_back(std::make_pair(4, 4));
1735 expected.push_back(std::make_pair(4, 0));
1736 expected.push_back(std::make_pair(3, 0));
1737 expected.push_back(std::make_pair(2, 0));
1738 expected.push_back(std::make_pair(1, 0));
1739 expected.push_back(std::make_pair(0, 0));
1741 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1743 // Column center off the left side.
1744 center = gfx::Rect(-50, 0, 30, 50);
1746 // Layout of the tiling data, and expected return order:
1747 // x 0 1 2 3 4
1748 // y.----------
1749 // * 0| 5 A F K P
1750 // * 1| 4 9 E J O
1751 // * 2| 3 8 D I N
1752 // * 3| 2 7 C H M
1753 // * 4| 1 6 B G L
1754 expected.clear();
1756 expected.push_back(std::make_pair(0, 4));
1757 expected.push_back(std::make_pair(0, 3));
1758 expected.push_back(std::make_pair(0, 2));
1759 expected.push_back(std::make_pair(0, 1));
1760 expected.push_back(std::make_pair(0, 0));
1761 expected.push_back(std::make_pair(1, 4));
1762 expected.push_back(std::make_pair(1, 3));
1763 expected.push_back(std::make_pair(1, 2));
1764 expected.push_back(std::make_pair(1, 1));
1765 expected.push_back(std::make_pair(1, 0));
1766 expected.push_back(std::make_pair(2, 4));
1767 expected.push_back(std::make_pair(2, 3));
1768 expected.push_back(std::make_pair(2, 2));
1769 expected.push_back(std::make_pair(2, 1));
1770 expected.push_back(std::make_pair(2, 0));
1771 expected.push_back(std::make_pair(3, 4));
1772 expected.push_back(std::make_pair(3, 3));
1773 expected.push_back(std::make_pair(3, 2));
1774 expected.push_back(std::make_pair(3, 1));
1775 expected.push_back(std::make_pair(3, 0));
1776 expected.push_back(std::make_pair(4, 4));
1777 expected.push_back(std::make_pair(4, 3));
1778 expected.push_back(std::make_pair(4, 2));
1779 expected.push_back(std::make_pair(4, 1));
1780 expected.push_back(std::make_pair(4, 0));
1782 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1785 TEST(TilingDataTest, SpiralDifferenceIteratorEdgeCases) {
1786 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false);
1787 std::vector<std::pair<int, int>> expected;
1788 gfx::Rect center;
1789 gfx::Rect consider;
1790 gfx::Rect ignore;
1792 // Ignore contains, but is not equal to, consider and center.
1793 ignore = gfx::Rect(15, 0, 20, 30);
1794 consider = gfx::Rect(20, 10, 10, 20);
1795 center = gfx::Rect(25, 0, 5, 5);
1797 // Layout of the tiling data, and expected return order:
1798 // x 0 1 2
1799 // y.------
1800 // 0| . *
1801 // 1| . .
1802 // 2| . .
1803 expected.clear();
1805 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1807 // Center intersects with consider.
1808 ignore = gfx::Rect();
1809 center = gfx::Rect(0, 15, 30, 15);
1810 consider = gfx::Rect(15, 30);
1812 // Layout of the tiling data, and expected return order:
1813 // x 0 1 2
1814 // y.------
1815 // 0| 2 1
1816 // 1| * * *
1817 // 2| * * *
1818 expected.clear();
1820 expected.push_back(std::make_pair(1, 0));
1821 expected.push_back(std::make_pair(0, 0));
1823 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1825 // Consider and ignore are non-intersecting.
1826 ignore = gfx::Rect(5, 30);
1827 consider = gfx::Rect(25, 0, 5, 30);
1828 center = gfx::Rect(15, 0, 1, 1);
1830 // Layout of the tiling data, and expected return order:
1831 // x 0 1 2
1832 // y.------
1833 // 0| . * 1
1834 // 1| . 2
1835 // 2| . 3
1836 expected.clear();
1838 expected.push_back(std::make_pair(2, 0));
1839 expected.push_back(std::make_pair(2, 1));
1840 expected.push_back(std::make_pair(2, 2));
1842 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1844 // Center intersects with ignore.
1845 consider = gfx::Rect(30, 30);
1846 center = gfx::Rect(15, 0, 1, 30);
1847 ignore = gfx::Rect(0, 15, 30, 1);
1849 // Layout of the tiling data, and expected return order:
1850 // x 0 1 2
1851 // y.------
1852 // 0| 3 * 2
1853 // 1| . * .
1854 // 2| 4 * 1
1855 expected.clear();
1857 expected.push_back(std::make_pair(2, 2));
1858 expected.push_back(std::make_pair(2, 0));
1859 expected.push_back(std::make_pair(0, 0));
1860 expected.push_back(std::make_pair(0, 2));
1862 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1864 // Center and ignore are the same.
1865 consider = gfx::Rect(30, 30);
1866 center = gfx::Rect(15, 0, 1, 30);
1867 ignore = center;
1869 // Layout of the tiling data, and expected return order:
1870 // x 0 1 2
1871 // y.------
1872 // 0| 4 * 3
1873 // 1| 5 * 2
1874 // 2| 6 * 1
1875 expected.clear();
1877 expected.push_back(std::make_pair(2, 2));
1878 expected.push_back(std::make_pair(2, 1));
1879 expected.push_back(std::make_pair(2, 0));
1880 expected.push_back(std::make_pair(0, 0));
1881 expected.push_back(std::make_pair(0, 1));
1882 expected.push_back(std::make_pair(0, 2));
1884 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1886 // Empty tiling data.
1887 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false);
1889 expected.clear();
1890 TestSpiralIterate(__LINE__, empty_data, consider, ignore, center, expected);
1892 // Empty consider.
1893 ignore = gfx::Rect();
1894 center = gfx::Rect(1, 1, 1, 1);
1895 consider = gfx::Rect();
1897 expected.clear();
1898 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1900 // Empty center. Note: This arbitrarily puts the center to be off the top-left
1901 // corner.
1902 consider = gfx::Rect(30, 30);
1903 ignore = gfx::Rect();
1904 center = gfx::Rect();
1906 // Layout of the tiling data, and expected return order:
1907 // * x 0 1 2
1908 // y.------
1909 // 0| 1 2 6
1910 // 1| 3 4 5
1911 // 2| 7 8 9
1912 expected.clear();
1914 expected.push_back(std::make_pair(0, 0));
1915 expected.push_back(std::make_pair(1, 0));
1916 expected.push_back(std::make_pair(0, 1));
1917 expected.push_back(std::make_pair(1, 1));
1918 expected.push_back(std::make_pair(2, 1));
1919 expected.push_back(std::make_pair(2, 0));
1920 expected.push_back(std::make_pair(0, 2));
1921 expected.push_back(std::make_pair(1, 2));
1922 expected.push_back(std::make_pair(2, 2));
1924 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1926 // Every rect is empty.
1927 ignore = gfx::Rect();
1928 center = gfx::Rect();
1929 consider = gfx::Rect();
1931 expected.clear();
1932 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1934 // Center is just to the left of cover, and off of the tiling's left side.
1935 consider = gfx::Rect(30, 30);
1936 ignore = gfx::Rect();
1937 center = gfx::Rect(-20, 0, 19, 30);
1939 // Layout of the tiling data, and expected return order:
1940 // x 0 1 2
1941 // y.------
1942 // *0| 3 6 9
1943 // *1| 2 5 8
1944 // *2| 1 4 7
1945 expected.clear();
1947 expected.push_back(std::make_pair(0, 2));
1948 expected.push_back(std::make_pair(0, 1));
1949 expected.push_back(std::make_pair(0, 0));
1950 expected.push_back(std::make_pair(1, 2));
1951 expected.push_back(std::make_pair(1, 1));
1952 expected.push_back(std::make_pair(1, 0));
1953 expected.push_back(std::make_pair(2, 2));
1954 expected.push_back(std::make_pair(2, 1));
1955 expected.push_back(std::make_pair(2, 0));
1957 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1960 } // namespace
1962 } // namespace cc