junov@chromium.org | adc58e4 | 2012-11-07 17:38:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
robertphillips@google.com | 1f2f338 | 2013-08-29 11:54:56 +0000 | [diff] [blame] | 8 | #include "SkCanvas.h" |
robertphillips@google.com | 770963f | 2014-04-18 18:04:41 +0000 | [diff] [blame] | 9 | #include "SkPictureRecorder.h" |
junov@chromium.org | adc58e4 | 2012-11-07 17:38:38 +0000 | [diff] [blame] | 10 | #include "SkTileGrid.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 11 | #include "Test.h" |
junov@chromium.org | adc58e4 | 2012-11-07 17:38:38 +0000 | [diff] [blame] | 12 | |
| 13 | enum Tile { |
| 14 | kTopLeft_Tile = 0x1, |
| 15 | kTopRight_Tile = 0x2, |
| 16 | kBottomLeft_Tile = 0x4, |
| 17 | kBottomRight_Tile = 0x8, |
| 18 | |
| 19 | kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight_Tile, |
| 20 | }; |
| 21 | |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 22 | class MockCanvas : public SkCanvas { |
| 23 | public: |
| 24 | MockCanvas(const SkBitmap& bm) : SkCanvas(bm) {} |
| 25 | |
| 26 | virtual void drawRect(const SkRect& rect, const SkPaint&) { |
| 27 | // This capture occurs before quick reject. |
| 28 | fRects.push(rect); |
| 29 | } |
| 30 | |
| 31 | SkTDArray<SkRect> fRects; |
| 32 | }; |
| 33 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 34 | static void verifyTileHits(skiatest::Reporter* reporter, SkRect rect, |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 35 | uint32_t tileMask, int borderPixels = 0) { |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 36 | SkTileGridFactory::TileGridInfo info; |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 37 | info.fMargin.set(borderPixels, borderPixels); |
| 38 | info.fOffset.setZero(); |
| 39 | info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); |
mtklein | 534cc4c | 2014-08-11 10:09:34 -0700 | [diff] [blame] | 40 | SkTileGrid grid(2, 2, info); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 41 | grid.insert(NULL, rect, false); |
| 42 | REPORTER_ASSERT(reporter, grid.tileCount(0, 0) == |
| 43 | ((tileMask & kTopLeft_Tile)? 1 : 0)); |
| 44 | REPORTER_ASSERT(reporter, grid.tileCount(1, 0) == |
| 45 | ((tileMask & kTopRight_Tile)? 1 : 0)); |
| 46 | REPORTER_ASSERT(reporter, grid.tileCount(0, 1) == |
| 47 | ((tileMask & kBottomLeft_Tile)? 1 : 0)); |
| 48 | REPORTER_ASSERT(reporter, grid.tileCount(1, 1) == |
| 49 | ((tileMask & kBottomRight_Tile)? 1 : 0)); |
| 50 | } |
| 51 | |
| 52 | DEF_TEST(TileGrid_UnalignedQuery, reporter) { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 53 | // Use SkTileGridPicture to generate a SkTileGrid with a helper |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 54 | SkTileGridFactory::TileGridInfo info; |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 55 | info.fMargin.setEmpty(); |
| 56 | info.fOffset.setZero(); |
| 57 | info.fTileInterval.set(10, 10); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 58 | SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), |
| 59 | SkIntToScalar(8), SkIntToScalar(8)); |
| 60 | SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(11), SkIntToScalar(11), |
| 61 | SkIntToScalar(1), SkIntToScalar(1)); |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 62 | SkTileGridFactory factory(info); |
| 63 | SkPictureRecorder recorder; |
| 64 | SkCanvas* canvas = recorder.beginRecording(20, 20, &factory, 0); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 65 | SkPaint paint; |
| 66 | canvas->drawRect(rect1, paint); |
| 67 | canvas->drawRect(rect2, paint); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 68 | SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 69 | |
| 70 | SkBitmap store; |
| 71 | store.allocN32Pixels(1, 1); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 72 | |
| 73 | // Test parts of top-left tile |
| 74 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 75 | MockCanvas mockCanvas(store); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 76 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 77 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 78 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
junov@chromium.org | adc58e4 | 2012-11-07 17:38:38 +0000 | [diff] [blame] | 79 | } |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 80 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 81 | MockCanvas mockCanvas(store); |
| 82 | mockCanvas.translate(-7.99f, -7.99f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 83 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 84 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 85 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
junov@chromium.org | 3cb834b | 2012-12-13 16:39:53 +0000 | [diff] [blame] | 86 | } |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 87 | // Corner overlap |
| 88 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 89 | MockCanvas mockCanvas(store); |
| 90 | mockCanvas.translate(-9.5f, -9.5f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 91 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 92 | REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); |
| 93 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
| 94 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); |
junov@chromium.org | 29b19e5 | 2013-02-27 18:35:16 +0000 | [diff] [blame] | 95 | } |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 96 | // Intersect bottom right tile, but does not overlap rect 2 |
| 97 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 98 | MockCanvas mockCanvas(store); |
| 99 | mockCanvas.translate(-16.0f, -16.0f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 100 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 101 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 102 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); |
junov@chromium.org | adc58e4 | 2012-11-07 17:38:38 +0000 | [diff] [blame] | 103 | } |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 104 | // Out of bounds queries, snap to border tiles |
| 105 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 106 | MockCanvas mockCanvas(store); |
| 107 | mockCanvas.translate(2.0f, 0.0f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 108 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 109 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 110 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 111 | } |
| 112 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 113 | MockCanvas mockCanvas(store); |
| 114 | mockCanvas.translate(0.0f, 2.0f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 115 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 116 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 117 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 118 | } |
| 119 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 120 | MockCanvas mockCanvas(store); |
| 121 | mockCanvas.translate(-22.0f, -16.0f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 122 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 123 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 124 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 125 | } |
| 126 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 127 | MockCanvas mockCanvas(store); |
| 128 | mockCanvas.translate(-16.0f, -22.0f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 129 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 130 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 131 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 132 | } |
| 133 | } |
junov@chromium.org | adc58e4 | 2012-11-07 17:38:38 +0000 | [diff] [blame] | 134 | |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 135 | DEF_TEST(TileGrid_OverlapOffsetQueryAlignment, reporter) { |
| 136 | // Use SkTileGridPicture to generate a SkTileGrid with a helper |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 137 | SkTileGridFactory::TileGridInfo info; |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 138 | info.fMargin.set(1, 1); |
| 139 | info.fOffset.set(-1, -1); |
| 140 | info.fTileInterval.set(8, 8); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 141 | |
| 142 | // rect landing entirely in top left tile |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 143 | SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), |
| 144 | SkIntToScalar(1), SkIntToScalar(1)); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 145 | // rect landing entirely in center tile |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 146 | SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(12), SkIntToScalar(12), |
| 147 | SkIntToScalar(1), SkIntToScalar(1)); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 148 | // rect landing entirely in bottomright tile |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 149 | SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(19), SkIntToScalar(19), |
| 150 | SkIntToScalar(1), SkIntToScalar(1)); |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 151 | SkTileGridFactory factory(info); |
| 152 | SkPictureRecorder recorder; |
| 153 | SkCanvas* canvas = recorder.beginRecording(20, 20, &factory, 0); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 154 | SkPaint paint; |
| 155 | canvas->drawRect(rect1, paint); |
| 156 | canvas->drawRect(rect2, paint); |
| 157 | canvas->drawRect(rect3, paint); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 158 | SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 159 | |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 160 | SkBitmap tileBitmap; |
| 161 | tileBitmap.allocN32Pixels(10, 10); |
| 162 | SkBitmap moreThanATileBitmap; |
| 163 | moreThanATileBitmap.allocN32Pixels(11, 11); |
| 164 | SkBitmap tinyBitmap; |
| 165 | tinyBitmap.allocN32Pixels(2, 2); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 166 | // Test parts of top-left tile |
| 167 | { |
| 168 | // The offset should cancel the top and left borders of the top left tile |
| 169 | // So a look-up at interval 0-10 should be grid aligned, |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 170 | MockCanvas mockCanvas(tileBitmap); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 171 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 172 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 173 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 174 | } |
| 175 | { |
| 176 | // Encroaching border by one pixel |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 177 | MockCanvas mockCanvas(moreThanATileBitmap); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 178 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 179 | REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); |
| 180 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
| 181 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 182 | } |
| 183 | { |
| 184 | // Tile stride is 8 (tileWidth - 2 * border pixels |
| 185 | // so translating by 8, should make query grid-aligned |
| 186 | // with middle tile. |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 187 | MockCanvas mockCanvas(tileBitmap); |
| 188 | mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8)); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 189 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 190 | REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); |
| 191 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 192 | } |
| 193 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 194 | MockCanvas mockCanvas(tileBitmap); |
| 195 | mockCanvas.translate(-7.9f, -7.9f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 196 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 197 | REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); |
| 198 | REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); |
| 199 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 200 | } |
| 201 | { |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 202 | MockCanvas mockCanvas(tileBitmap); |
| 203 | mockCanvas.translate(-8.1f, -8.1f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 204 | picture->draw(&mockCanvas); |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 205 | REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); |
| 206 | REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); |
| 207 | REPORTER_ASSERT(reporter, rect3 == mockCanvas.fRects[1]); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 208 | } |
| 209 | { |
| 210 | // Regression test for crbug.com/234688 |
| 211 | // Once the 2x2 device region is inset by margin, it yields an empty |
| 212 | // adjusted region, sitting right on top of the tile boundary. |
commit-bot@chromium.org | 0e9e6a3 | 2014-03-28 17:57:14 +0000 | [diff] [blame] | 213 | MockCanvas mockCanvas(tinyBitmap); |
| 214 | mockCanvas.translate(-8.0f, -8.0f); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 215 | picture->draw(&mockCanvas); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 216 | // This test passes by not asserting. We do not validate the rects recorded |
| 217 | // because the result is numerically unstable (floating point equality). |
| 218 | // The content of any one of the four tiles of the tilegrid would be a valid |
| 219 | // result since any bbox that covers the center point of the canvas will be |
| 220 | // recorded in all four tiles. |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | DEF_TEST(TileGrid, reporter) { |
| 225 | // Out of bounds |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 226 | verifyTileHits(reporter, SkRect::MakeXYWH(30, 0, 1, 1), 0); |
| 227 | verifyTileHits(reporter, SkRect::MakeXYWH(0, 30, 1, 1), 0); |
| 228 | verifyTileHits(reporter, SkRect::MakeXYWH(-10, 0, 1, 1), 0); |
| 229 | verifyTileHits(reporter, SkRect::MakeXYWH(0, -10, 1, 1), 0); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 230 | |
| 231 | // Dilation for AA consideration |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 232 | verifyTileHits(reporter, SkRect::MakeXYWH(0, 0, 9, 9), kTopLeft_Tile); |
| 233 | verifyTileHits(reporter, SkRect::MakeXYWH(0, 0, 10, 10), kAll_Tile); |
| 234 | verifyTileHits(reporter, SkRect::MakeXYWH(9, 9, 1, 1), kAll_Tile); |
| 235 | verifyTileHits(reporter, SkRect::MakeXYWH(10, 10, 1, 1), kAll_Tile); |
| 236 | verifyTileHits(reporter, SkRect::MakeXYWH(11, 11, 1, 1), kBottomRight_Tile); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 237 | |
| 238 | // BorderPixels |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 239 | verifyTileHits(reporter, SkRect::MakeXYWH(0, 0, 6, 6), kTopLeft_Tile, 1); |
| 240 | verifyTileHits(reporter, SkRect::MakeXYWH(0, 0, 7, 7), kAll_Tile, 1); |
| 241 | verifyTileHits(reporter, SkRect::MakeXYWH(9, 9, 1, 1), kAll_Tile, 1); |
| 242 | verifyTileHits(reporter, SkRect::MakeXYWH(10, 10, 1, 1), kBottomRight_Tile, 1); |
| 243 | verifyTileHits(reporter, SkRect::MakeXYWH(17, 17, 1, 1), kBottomRight_Tile, 1); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 244 | |
| 245 | // BBoxes that overlap tiles |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 246 | verifyTileHits(reporter, SkRect::MakeXYWH(5, 5, 10, 1), kTopLeft_Tile | kTopRight_Tile); |
| 247 | verifyTileHits(reporter, SkRect::MakeXYWH(5, 5, 1, 10), kTopLeft_Tile | |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 248 | kBottomLeft_Tile); |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 249 | verifyTileHits(reporter, SkRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); |
| 250 | verifyTileHits(reporter, SkRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile); |
tfarina@chromium.org | 9f9d582 | 2013-12-18 22:15:12 +0000 | [diff] [blame] | 251 | } |