| 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 SkTDArray<SkRect> fRects; | 28 virtual void drawRect(const SkRect& rect, const SkPaint&) |
| 29 | |
| 30 protected: | |
| 31 virtual void onDrawRect(const SkRect& rect, const SkPaint&) | |
| 32 { | 29 { |
| 33 // This capture occurs before quick reject. | 30 // This capture occurs before quick reject. |
| 34 fRects.push(rect); | 31 fRects.push(rect); |
| 35 } | 32 } |
| 33 |
| 34 SkTDArray<SkRect> fRects; |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 class TileGridTest { | 37 class TileGridTest { |
| 39 public: | 38 public: |
| 40 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, |
| 41 int borderPixels = 0) { | 40 int borderPixels = 0) { |
| 42 SkTileGridPicture::TileGridInfo info; | 41 SkTileGridPicture::TileGridInfo info; |
| 43 info.fMargin.set(borderPixels, borderPixels); | 42 info.fMargin.set(borderPixels, borderPixels); |
| 44 info.fOffset.setZero(); | 43 info.fOffset.setZero(); |
| 45 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); | 44 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); | 270 verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); |
| 272 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile
); | 271 verifyTileHits(reporter, SkIRect::MakeXYWH(-10, -10, 40, 40), kAll_Tile
); |
| 273 | 272 |
| 274 TestUnalignedQuery(reporter); | 273 TestUnalignedQuery(reporter); |
| 275 TestOverlapOffsetQueryAlignment(reporter); | 274 TestOverlapOffsetQueryAlignment(reporter); |
| 276 } | 275 } |
| 277 }; | 276 }; |
| 278 | 277 |
| 279 #include "TestClassDef.h" | 278 #include "TestClassDef.h" |
| 280 DEFINE_TESTCLASS("TileGrid", TileGridTestClass, TileGridTest::Test) | 279 DEFINE_TESTCLASS("TileGrid", TileGridTestClass, TileGridTest::Test) |
| OLD | NEW |