OLD | NEW |
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 "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkTileGrid.h" | 11 #include "SkTileGrid.h" |
12 #include "SkTileGridPicture.h" | 12 #include "SkTileGridPicture.h" |
13 | 13 |
14 enum Tile { | 14 enum Tile { |
15 kTopLeft_Tile = 0x1, | 15 kTopLeft_Tile = 0x1, |
16 kTopRight_Tile = 0x2, | 16 kTopRight_Tile = 0x2, |
17 kBottomLeft_Tile = 0x4, | 17 kBottomLeft_Tile = 0x4, |
18 kBottomRight_Tile = 0x8, | 18 kBottomRight_Tile = 0x8, |
19 | 19 |
20 kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight
_Tile, | 20 kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight
_Tile, |
21 }; | 21 }; |
22 | 22 |
23 class MockCanvas : public SkCanvas { | 23 class MockCanvas : public SkCanvas { |
24 public: | 24 public: |
25 MockCanvas(SkBaseDevice* device) : SkCanvas(device) | 25 MockCanvas(SkBaseDevice* device) : SkCanvas(device) |
26 {} | 26 {} |
27 | 27 |
28 virtual void drawRect(const SkRect& rect, const SkPaint&) | 28 SkTDArray<SkRect> fRects; |
| 29 |
| 30 protected: |
| 31 virtual void onDrawRect(const SkRect& rect, const SkPaint&) |
29 { | 32 { |
30 // This capture occurs before quick reject. | 33 // This capture occurs before quick reject. |
31 fRects.push(rect); | 34 fRects.push(rect); |
32 } | 35 } |
33 | |
34 SkTDArray<SkRect> fRects; | |
35 }; | 36 }; |
36 | 37 |
37 class TileGridTest { | 38 class TileGridTest { |
38 public: | 39 public: |
39 static void verifyTileHits(skiatest::Reporter* reporter, SkIRect rect, uint3
2_t tileMask, | 40 static void verifyTileHits(skiatest::Reporter* reporter, SkIRect rect, uint3
2_t tileMask, |
40 int borderPixels = 0) { | 41 int borderPixels = 0) { |
41 SkTileGridPicture::TileGridInfo info; | 42 SkTileGridPicture::TileGridInfo info; |
42 info.fMargin.set(borderPixels, borderPixels); | 43 info.fMargin.set(borderPixels, borderPixels); |
43 info.fOffset.setZero(); | 44 info.fOffset.setZero(); |
44 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); | 45 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); | 271 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); |
271 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile
); | 272 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile
); |
272 | 273 |
273 TestUnalignedQuery(reporter); | 274 TestUnalignedQuery(reporter); |
274 TestOverlapOffsetQueryAlignment(reporter); | 275 TestOverlapOffsetQueryAlignment(reporter); |
275 } | 276 } |
276 }; | 277 }; |
277 | 278 |
278 #include "TestClassDef.h" | 279 #include "TestClassDef.h" |
279 DEFINE_TESTCLASS("TileGrid", TileGridTestClass, TileGridTest::Test) | 280 DEFINE_TESTCLASS("TileGrid", TileGridTestClass, TileGridTest::Test) |
OLD | NEW |