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