Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: tests/TileGridTest.cpp

Issue 114563003: Get rid of DEFINE_TESTCLASS() macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tileCount() Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/TestClassDef.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h"
9 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
10 #include "SkCanvas.h" 11 #include "SkCanvas.h"
11 #include "SkTileGrid.h" 12 #include "SkTileGrid.h"
12 #include "SkTileGridPicture.h" 13 #include "SkTileGridPicture.h"
13 14
14 enum Tile { 15 enum Tile {
15 kTopLeft_Tile = 0x1, 16 kTopLeft_Tile = 0x1,
16 kTopRight_Tile = 0x2, 17 kTopRight_Tile = 0x2,
17 kBottomLeft_Tile = 0x4, 18 kBottomLeft_Tile = 0x4,
18 kBottomRight_Tile = 0x8, 19 kBottomRight_Tile = 0x8,
19 20
20 kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight _Tile, 21 kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight _Tile,
21 }; 22 };
22 23
23 class MockCanvas : public SkCanvas { 24 class MockCanvas : public SkCanvas {
24 public: 25 public:
25 MockCanvas(SkBaseDevice* device) : SkCanvas(device) 26 MockCanvas(SkBaseDevice* device) : SkCanvas(device)
26 {} 27 {}
27 28
28 virtual void drawRect(const SkRect& rect, const SkPaint&) 29 virtual void drawRect(const SkRect& rect, const SkPaint&)
29 { 30 {
30 // This capture occurs before quick reject. 31 // This capture occurs before quick reject.
31 fRects.push(rect); 32 fRects.push(rect);
32 } 33 }
33 34
34 SkTDArray<SkRect> fRects; 35 SkTDArray<SkRect> fRects;
35 }; 36 };
36 37
37 class TileGridTest { 38 static void verifyTileHits(skiatest::Reporter* reporter, SkIRect rect,
38 public: 39 uint32_t tileMask, int borderPixels = 0) {
39 static void verifyTileHits(skiatest::Reporter* reporter, SkIRect rect, uint3 2_t tileMask, 40 SkTileGridPicture::TileGridInfo info;
40 int borderPixels = 0) { 41 info.fMargin.set(borderPixels, borderPixels);
41 SkTileGridPicture::TileGridInfo info; 42 info.fOffset.setZero();
42 info.fMargin.set(borderPixels, borderPixels); 43 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels);
43 info.fOffset.setZero(); 44 SkTileGrid grid(2, 2, info, NULL);
44 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); 45 grid.insert(NULL, rect, false);
45 SkTileGrid grid(2, 2, info, NULL); 46 REPORTER_ASSERT(reporter, grid.tileCount(0, 0) ==
46 grid.insert(NULL, rect, false); 47 ((tileMask & kTopLeft_Tile)? 1 : 0));
47 REPORTER_ASSERT(reporter, grid.tile(0,0).count() == 48 REPORTER_ASSERT(reporter, grid.tileCount(1, 0) ==
48 ((tileMask & kTopLeft_Tile)? 1 : 0)); 49 ((tileMask & kTopRight_Tile)? 1 : 0));
49 REPORTER_ASSERT(reporter, grid.tile(1,0).count() == 50 REPORTER_ASSERT(reporter, grid.tileCount(0, 1) ==
50 ((tileMask & kTopRight_Tile)? 1 : 0)); 51 ((tileMask & kBottomLeft_Tile)? 1 : 0));
51 REPORTER_ASSERT(reporter, grid.tile(0,1).count() == 52 REPORTER_ASSERT(reporter, grid.tileCount(1, 1) ==
52 ((tileMask & kBottomLeft_Tile)? 1 : 0)); 53 ((tileMask & kBottomRight_Tile)? 1 : 0));
53 REPORTER_ASSERT(reporter, grid.tile(1,1).count() == 54 }
54 ((tileMask & kBottomRight_Tile)? 1 : 0)); 55
55 } 56 DEF_TEST(TileGrid_UnalignedQuery, reporter) {
56 57 // Use SkTileGridPicture to generate a SkTileGrid with a helper
57 static void TestUnalignedQuery(skiatest::Reporter* reporter) { 58 SkTileGridPicture::TileGridInfo info;
58 // Use SkTileGridPicture to generate a SkTileGrid with a helper 59 info.fMargin.setEmpty();
59 SkTileGridPicture::TileGridInfo info; 60 info.fOffset.setZero();
60 info.fMargin.setEmpty(); 61 info.fTileInterval.set(10, 10);
61 info.fOffset.setZero(); 62 SkTileGridPicture picture(20, 20, info);
62 info.fTileInterval.set(10, 10); 63 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
63 SkTileGridPicture picture(20, 20, info); 64 SkIntToScalar(8), SkIntToScalar(8));
64 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), 65 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(11), SkIntToScalar(11),
65 SkIntToScalar(8), SkIntToScalar(8)); 66 SkIntToScalar(1), SkIntToScalar(1));
66 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(11), SkIntToScalar(11), 67 SkCanvas* canvas = picture.beginRecording(20, 20, SkPicture::kOptimizeForCli ppedPlayback_RecordingFlag);
67 SkIntToScalar(1), SkIntToScalar(1)); 68 SkPaint paint;
68 SkCanvas* canvas = picture.beginRecording(20, 20, SkPicture::kOptimizeFo rClippedPlayback_RecordingFlag); 69 canvas->drawRect(rect1, paint);
69 SkPaint paint; 70 canvas->drawRect(rect2, paint);
70 canvas->drawRect(rect1, paint); 71 picture.endRecording();
71 canvas->drawRect(rect2, paint); 72
72 picture.endRecording(); 73 SkBitmap store;
73 74 store.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
74 SkBitmap store; 75 store.allocPixels();
75 store.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); 76
76 store.allocPixels(); 77 // Test parts of top-left tile
77 78 {
78 // Test parts of top-left tile 79 SkBitmapDevice device(store);
79 { 80 MockCanvas mockCanvas(&device);
80 SkBitmapDevice device(store); 81 picture.draw(&mockCanvas);
81 MockCanvas mockCanvas(&device); 82 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
82 picture.draw(&mockCanvas); 83 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
83 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 84 }
84 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 85 {
85 } 86 SkBitmapDevice device(store);
86 { 87 MockCanvas mockCanvas(&device);
87 SkBitmapDevice device(store); 88 mockCanvas.translate(-7.99f, -7.99f);
88 MockCanvas mockCanvas(&device); 89 picture.draw(&mockCanvas);
89 mockCanvas.translate(-7.99f, -7.99f); 90 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
90 picture.draw(&mockCanvas); 91 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
91 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 92 }
92 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 93 // Corner overlap
93 } 94 {
94 // Corner overlap 95 SkBitmapDevice device(store);
95 { 96 MockCanvas mockCanvas(&device);
96 SkBitmapDevice device(store); 97 mockCanvas.translate(-9.5f, -9.5f);
97 MockCanvas mockCanvas(&device); 98 picture.draw(&mockCanvas);
98 mockCanvas.translate(-9.5f, -9.5f); 99 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
99 picture.draw(&mockCanvas); 100 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
100 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); 101 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
101 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 102 }
102 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); 103 // Intersect bottom right tile, but does not overlap rect 2
103 } 104 {
104 // Intersect bottom right tile, but does not overlap rect 2 105 SkBitmapDevice device(store);
105 { 106 MockCanvas mockCanvas(&device);
106 SkBitmapDevice device(store); 107 mockCanvas.translate(-16.0f, -16.0f);
107 MockCanvas mockCanvas(&device); 108 picture.draw(&mockCanvas);
108 mockCanvas.translate(-16.0f, -16.0f); 109 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
109 picture.draw(&mockCanvas); 110 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
110 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 111 }
111 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); 112 // Out of bounds queries, snap to border tiles
112 } 113 {
113 // Out of bounds queries, snap to border tiles 114 SkBitmapDevice device(store);
114 { 115 MockCanvas mockCanvas(&device);
115 SkBitmapDevice device(store); 116 mockCanvas.translate(2.0f, 0.0f);
116 MockCanvas mockCanvas(&device); 117 picture.draw(&mockCanvas);
117 mockCanvas.translate(2.0f, 0.0f); 118 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
118 picture.draw(&mockCanvas); 119 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
119 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 120 }
120 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 121 {
121 } 122 SkBitmapDevice device(store);
122 { 123 MockCanvas mockCanvas(&device);
123 SkBitmapDevice device(store); 124 mockCanvas.translate(0.0f, 2.0f);
124 MockCanvas mockCanvas(&device); 125 picture.draw(&mockCanvas);
125 mockCanvas.translate(0.0f, 2.0f); 126 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
126 picture.draw(&mockCanvas); 127 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
127 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 128 }
128 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 129 {
129 } 130 SkBitmapDevice device(store);
130 { 131 MockCanvas mockCanvas(&device);
131 SkBitmapDevice device(store); 132 mockCanvas.translate(-22.0f, -16.0f);
132 MockCanvas mockCanvas(&device); 133 picture.draw(&mockCanvas);
133 mockCanvas.translate(-22.0f, -16.0f); 134 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
134 picture.draw(&mockCanvas); 135 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
135 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 136 }
136 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); 137 {
137 } 138 SkBitmapDevice device(store);
138 { 139 MockCanvas mockCanvas(&device);
139 SkBitmapDevice device(store); 140 mockCanvas.translate(-16.0f, -22.0f);
140 MockCanvas mockCanvas(&device); 141 picture.draw(&mockCanvas);
141 mockCanvas.translate(-16.0f, -22.0f); 142 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
142 picture.draw(&mockCanvas); 143 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
143 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 144 }
144 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); 145 }
145 } 146
146 } 147 DEF_TEST(TileGrid_OverlapOffsetQueryAlignment, reporter) {
147 148 // Use SkTileGridPicture to generate a SkTileGrid with a helper
148 static void TestOverlapOffsetQueryAlignment(skiatest::Reporter* reporter) { 149 SkTileGridPicture::TileGridInfo info;
149 // Use SkTileGridPicture to generate a SkTileGrid with a helper 150 info.fMargin.set(1, 1);
150 SkTileGridPicture::TileGridInfo info; 151 info.fOffset.set(-1, -1);
151 info.fMargin.set(1, 1); 152 info.fTileInterval.set(8, 8);
152 info.fOffset.set(-1, -1); 153 SkTileGridPicture picture(20, 20, info);
153 info.fTileInterval.set(8, 8); 154
154 SkTileGridPicture picture(20, 20, info); 155 // rect landing entirely in top left tile
155 156 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
156 // rect landing entirely in top left tile 157 SkIntToScalar(1), SkIntToScalar(1));
157 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), 158 // rect landing entirely in center tile
158 SkIntToScalar(1), SkIntToScalar(1)); 159 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(12), SkIntToScalar(12),
159 // rect landing entirely in center tile 160 SkIntToScalar(1), SkIntToScalar(1));
160 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(12), SkIntToScalar(12), 161 // rect landing entirely in bottomright tile
161 SkIntToScalar(1), SkIntToScalar(1)); 162 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(19), SkIntToScalar(19),
162 // rect landing entirely in bottomright tile 163 SkIntToScalar(1), SkIntToScalar(1));
163 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(19), SkIntToScalar(19), 164 SkCanvas* canvas = picture.beginRecording(20, 20, SkPicture::kOptimizeForCli ppedPlayback_RecordingFlag);
164 SkIntToScalar(1), SkIntToScalar(1)); 165 SkPaint paint;
165 SkCanvas* canvas = picture.beginRecording(20, 20, SkPicture::kOptimizeFo rClippedPlayback_RecordingFlag); 166 canvas->drawRect(rect1, paint);
166 SkPaint paint; 167 canvas->drawRect(rect2, paint);
167 canvas->drawRect(rect1, paint); 168 canvas->drawRect(rect3, paint);
168 canvas->drawRect(rect2, paint); 169 picture.endRecording();
169 canvas->drawRect(rect3, paint); 170
170 picture.endRecording(); 171 SkBitmap tileBitmap;
171 172 tileBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
172 SkBitmap tileBitmap; 173 tileBitmap.allocPixels();
173 tileBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 174 SkBitmap moreThanATileBitmap;
174 tileBitmap.allocPixels(); 175 moreThanATileBitmap.setConfig(SkBitmap::kARGB_8888_Config, 11, 11);
175 SkBitmap moreThanATileBitmap; 176 moreThanATileBitmap.allocPixels();
176 moreThanATileBitmap.setConfig(SkBitmap::kARGB_8888_Config, 11, 11); 177 SkBitmap tinyBitmap;
177 moreThanATileBitmap.allocPixels(); 178 tinyBitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
178 SkBitmap tinyBitmap; 179 tinyBitmap.allocPixels();
179 tinyBitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); 180 // Test parts of top-left tile
180 tinyBitmap.allocPixels(); 181 {
181 // Test parts of top-left tile 182 // The offset should cancel the top and left borders of the top left til e
182 { 183 // So a look-up at interval 0-10 should be grid aligned,
183 // The offset should cancel the top and left borders of the top left tile 184 SkBitmapDevice device(tileBitmap);
184 // So a look-up at interval 0-10 should be grid aligned, 185 MockCanvas mockCanvas(&device);
185 SkBitmapDevice device(tileBitmap); 186 picture.draw(&mockCanvas);
186 MockCanvas mockCanvas(&device); 187 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
187 picture.draw(&mockCanvas); 188 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
188 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 189 }
189 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 190 {
190 } 191 // Encroaching border by one pixel
191 { 192 SkBitmapDevice device(moreThanATileBitmap);
192 // Encroaching border by one pixel 193 MockCanvas mockCanvas(&device);
193 SkBitmapDevice device(moreThanATileBitmap); 194 picture.draw(&mockCanvas);
194 MockCanvas mockCanvas(&device); 195 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
195 picture.draw(&mockCanvas); 196 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
196 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); 197 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
197 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 198 }
198 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); 199 {
199 } 200 // Tile stride is 8 (tileWidth - 2 * border pixels
200 { 201 // so translating by 8, should make query grid-aligned
201 // Tile stride is 8 (tileWidth - 2 * border pixels 202 // with middle tile.
202 // so translating by 8, should make query grid-aligned 203 SkBitmapDevice device(tileBitmap);
203 // with middle tile. 204 MockCanvas mockCanvas(&device);
204 SkBitmapDevice device(tileBitmap); 205 mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8));
205 MockCanvas mockCanvas(&device); 206 picture.draw(&mockCanvas);
206 mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8)); 207 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
207 picture.draw(&mockCanvas); 208 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
208 REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); 209 }
209 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); 210 {
210 } 211 SkBitmapDevice device(tileBitmap);
211 { 212 MockCanvas mockCanvas(&device);
212 SkBitmapDevice device(tileBitmap); 213 mockCanvas.translate(-7.9f, -7.9f);
213 MockCanvas mockCanvas(&device); 214 picture.draw(&mockCanvas);
214 mockCanvas.translate(-7.9f, -7.9f); 215 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
215 picture.draw(&mockCanvas); 216 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
216 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); 217 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
217 REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); 218 }
218 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); 219 {
219 } 220 SkBitmapDevice device(tileBitmap);
220 { 221 MockCanvas mockCanvas(&device);
221 SkBitmapDevice device(tileBitmap); 222 mockCanvas.translate(-8.1f, -8.1f);
222 MockCanvas mockCanvas(&device); 223 picture.draw(&mockCanvas);
223 mockCanvas.translate(-8.1f, -8.1f); 224 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
224 picture.draw(&mockCanvas); 225 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
225 REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); 226 REPORTER_ASSERT(reporter, rect3 == mockCanvas.fRects[1]);
226 REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); 227 }
227 REPORTER_ASSERT(reporter, rect3 == mockCanvas.fRects[1]); 228 {
228 } 229 // Regression test for crbug.com/234688
229 { 230 // Once the 2x2 device region is inset by margin, it yields an empty
230 // Regression test for crbug.com/234688 231 // adjusted region, sitting right on top of the tile boundary.
231 // Once the 2x2 device region is inset by margin, it yields an empty 232 SkBitmapDevice device(tinyBitmap);
232 // adjusted region, sitting right on top of the tile boundary. 233 MockCanvas mockCanvas(&device);
233 SkBitmapDevice device(tinyBitmap); 234 mockCanvas.translate(-8.0f, -8.0f);
234 MockCanvas mockCanvas(&device); 235 picture.draw(&mockCanvas);
235 mockCanvas.translate(-8.0f, -8.0f); 236 // This test passes by not asserting. We do not validate the rects recor ded
236 picture.draw(&mockCanvas); 237 // because the result is numerically unstable (floating point equality).
237 // This test passes by not asserting. We do not validate the rects r ecorded 238 // The content of any one of the four tiles of the tilegrid would be a v alid
238 // because the result is numerically unstable (floating point equali ty). 239 // result since any bbox that covers the center point of the canvas will be
239 // The content of any one of the four tiles of the tilegrid would be a valid 240 // recorded in all four tiles.
240 // result since any bbox that covers the center point of the canvas will be 241 }
241 // recorded in all four tiles. 242 }
242 } 243
243 } 244 DEF_TEST(TileGrid, reporter) {
244 245 // Out of bounds
245 static void Test(skiatest::Reporter* reporter) { 246 verifyTileHits(reporter, SkIRect::MakeXYWH(30, 0, 1, 1), 0);
246 // Out of bounds 247 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 30, 1, 1), 0);
247 verifyTileHits(reporter, SkIRect::MakeXYWH(30, 0, 1, 1), 0); 248 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, 0, 1, 1), 0);
248 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 30, 1, 1), 0); 249 verifyTileHits(reporter, SkIRect::MakeXYWH(0, -10, 1, 1), 0);
249 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, 0, 1, 1), 0); 250
250 verifyTileHits(reporter, SkIRect::MakeXYWH(0, -10, 1, 1), 0); 251 // Dilation for AA consideration
251 252 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 9, 9), kTopLeft_Tile);
252 // Dilation for AA consideration 253 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 10, 10), kAll_Tile);
253 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 9, 9), kTopLeft_Tile); 254 verifyTileHits(reporter, SkIRect::MakeXYWH(9, 9, 1, 1), kAll_Tile);
254 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 10, 10), kAll_Tile); 255 verifyTileHits(reporter, SkIRect::MakeXYWH(10, 10, 1, 1), kAll_Tile);
255 verifyTileHits(reporter, SkIRect::MakeXYWH(9, 9, 1, 1), kAll_Tile); 256 verifyTileHits(reporter, SkIRect::MakeXYWH(11, 11, 1, 1), kBottomRight_Tile );
256 verifyTileHits(reporter, SkIRect::MakeXYWH(10, 10, 1, 1), kAll_Tile); 257
257 verifyTileHits(reporter, SkIRect::MakeXYWH(11, 11, 1, 1), kBottomRight_ Tile); 258 // BorderPixels
258 259 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 6, 6), kTopLeft_Tile, 1);
259 // BorderPixels 260 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 7, 7), kAll_Tile, 1);
260 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 6, 6), kTopLeft_Tile, 1); 261 verifyTileHits(reporter, SkIRect::MakeXYWH(9, 9, 1, 1), kAll_Tile, 1);
261 verifyTileHits(reporter, SkIRect::MakeXYWH(0, 0, 7, 7), kAll_Tile, 1); 262 verifyTileHits(reporter, SkIRect::MakeXYWH(10, 10, 1, 1), kBottomRight_Tile , 1);
262 verifyTileHits(reporter, SkIRect::MakeXYWH(9, 9, 1, 1), kAll_Tile, 1); 263 verifyTileHits(reporter, SkIRect::MakeXYWH(17, 17, 1, 1), kBottomRight_Tile , 1);
263 verifyTileHits(reporter, SkIRect::MakeXYWH(10, 10, 1, 1), kBottomRight_ Tile, 1); 264
264 verifyTileHits(reporter, SkIRect::MakeXYWH(17, 17, 1, 1), kBottomRight_ Tile, 1); 265 // BBoxes that overlap tiles
265 266 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 1), kTopLeft_Tile | kT opRight_Tile);
266 // BBoxes that overlap tiles 267 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 1, 10), kTopLeft_Tile |
267 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 1), kTopLeft_Tile | kTopRight_Tile); 268 kBottomLeft_Tile);
268 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 1, 10), kTopLeft_Tile | 269 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 10), kAll_Tile);
269 kBottomLeft_Tile); 270 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile);
270 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); 271 }
271 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile );
272
273 TestUnalignedQuery(reporter);
274 TestOverlapOffsetQueryAlignment(reporter);
275 }
276 };
277
278 #include "TestClassDef.h"
279 DEFINE_TESTCLASS("TileGrid", TileGridTestClass, TileGridTest::Test)
OLDNEW
« no previous file with comments | « tests/TestClassDef.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698