| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkPictureRecorder.h" | 9 #include "SkPictureRecorder.h" |
| 10 #include "SkTileGrid.h" | 10 #include "SkTileGrid.h" |
| 11 #include "Test.h" | 11 #include "Test.h" |
| 12 | 12 |
| 13 enum Tile { | 13 enum Tile { |
| 14 kTopLeft_Tile = 0x1, | 14 kTopLeft_Tile = 0x1, |
| 15 kTopRight_Tile = 0x2, | 15 kTopRight_Tile = 0x2, |
| 16 kBottomLeft_Tile = 0x4, | 16 kBottomLeft_Tile = 0x4, |
| 17 kBottomRight_Tile = 0x8, | 17 kBottomRight_Tile = 0x8, |
| 18 | 18 |
| 19 kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight
_Tile, | 19 kAll_Tile = kTopLeft_Tile | kTopRight_Tile | kBottomLeft_Tile | kBottomRight
_Tile, |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 class MockCanvas : public SkCanvas { | 22 class MockCanvas : public SkCanvas { |
| 23 public: | 23 public: |
| 24 MockCanvas(const SkBitmap& bm) : SkCanvas(bm) {} | 24 MockCanvas(const SkBitmap& bm) : SkCanvas(bm) {} |
| 25 | 25 |
| 26 void onDrawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE { | 26 virtual void drawRect(const SkRect& rect, const SkPaint&) { |
| 27 // This capture occurs before quick reject. | 27 // This capture occurs before quick reject. |
| 28 fRects.push(rect); | 28 fRects.push(rect); |
| 29 } | 29 } |
| 30 | 30 |
| 31 SkTDArray<SkRect> fRects; | 31 SkTDArray<SkRect> fRects; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 static void verify_tile_hits(skiatest::Reporter* reporter, SkRect rect, | 34 static void verify_tile_hits(skiatest::Reporter* reporter, SkRect rect, |
| 35 uint32_t tileMask, int borderPixels = 0) { | 35 uint32_t tileMask, int borderPixels = 0) { |
| 36 SkTileGridFactory::TileGridInfo info; | 36 SkTileGridFactory::TileGridInfo info; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 verify_tile_hits(reporter, SkRect::MakeXYWH(9, 9, 1, 1), kAll_Tile,
1); | 245 verify_tile_hits(reporter, SkRect::MakeXYWH(9, 9, 1, 1), kAll_Tile,
1); |
| 246 verify_tile_hits(reporter, SkRect::MakeXYWH(10, 10, 1, 1), kBottomRight_Tile
, 1); | 246 verify_tile_hits(reporter, SkRect::MakeXYWH(10, 10, 1, 1), kBottomRight_Tile
, 1); |
| 247 verify_tile_hits(reporter, SkRect::MakeXYWH(17, 17, 1, 1), kBottomRight_Tile
, 1); | 247 verify_tile_hits(reporter, SkRect::MakeXYWH(17, 17, 1, 1), kBottomRight_Tile
, 1); |
| 248 | 248 |
| 249 // BBoxes that overlap tiles | 249 // BBoxes that overlap tiles |
| 250 verify_tile_hits(reporter, SkRect::MakeXYWH(5, 5, 10, 1), kTopLeft_Tile
| kTopRight_Tile); | 250 verify_tile_hits(reporter, SkRect::MakeXYWH(5, 5, 10, 1), kTopLeft_Tile
| kTopRight_Tile); |
| 251 verify_tile_hits(reporter, SkRect::MakeXYWH(5, 5, 1, 10), kTopLeft_Tile
| kBottomLeft_Tile); | 251 verify_tile_hits(reporter, SkRect::MakeXYWH(5, 5, 1, 10), kTopLeft_Tile
| kBottomLeft_Tile); |
| 252 verify_tile_hits(reporter, SkRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); | 252 verify_tile_hits(reporter, SkRect::MakeXYWH(5, 5, 10, 10), kAll_Tile); |
| 253 verify_tile_hits(reporter, SkRect::MakeXYWH(-10, -10, 40, 40),kAll_Tile); | 253 verify_tile_hits(reporter, SkRect::MakeXYWH(-10, -10, 40, 40),kAll_Tile); |
| 254 } | 254 } |
| OLD | NEW |