Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/TileGridTest.cpp

Issue 670213002: Cut down SkBBH API more. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: virtual Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 19 matching lines...) Expand all
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;
37 info.fMargin.set(borderPixels, borderPixels); 37 info.fMargin.set(borderPixels, borderPixels);
38 info.fOffset.setZero(); 38 info.fOffset.setZero();
39 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels); 39 info.fTileInterval.set(10 - 2 * borderPixels, 10 - 2 * borderPixels);
40
41 SkAutoTMalloc<SkRect> rects(1);
42 rects[0] = rect;
43
40 SkTileGrid grid(2, 2, info); 44 SkTileGrid grid(2, 2, info);
41 grid.insert(0, rect, false); 45 grid.insert(&rects, 1);
42 REPORTER_ASSERT(reporter, grid.tileCount(0, 0) == 46 REPORTER_ASSERT(reporter, grid.tileCount(0, 0) ==
43 ((tileMask & kTopLeft_Tile)? 1 : 0)); 47 ((tileMask & kTopLeft_Tile)? 1 : 0));
44 REPORTER_ASSERT(reporter, grid.tileCount(1, 0) == 48 REPORTER_ASSERT(reporter, grid.tileCount(1, 0) ==
45 ((tileMask & kTopRight_Tile)? 1 : 0)); 49 ((tileMask & kTopRight_Tile)? 1 : 0));
46 REPORTER_ASSERT(reporter, grid.tileCount(0, 1) == 50 REPORTER_ASSERT(reporter, grid.tileCount(0, 1) ==
47 ((tileMask & kBottomLeft_Tile)? 1 : 0)); 51 ((tileMask & kBottomLeft_Tile)? 1 : 0));
48 REPORTER_ASSERT(reporter, grid.tileCount(1, 1) == 52 REPORTER_ASSERT(reporter, grid.tileCount(1, 1) ==
49 ((tileMask & kBottomRight_Tile)? 1 : 0)); 53 ((tileMask & kBottomRight_Tile)? 1 : 0));
50 } 54 }
51 55
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 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);
242 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);
243 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);
244 248
245 // BBoxes that overlap tiles 249 // BBoxes that overlap tiles
246 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);
247 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);
248 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);
249 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);
250 } 254 }
OLDNEW
« no previous file with comments | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698