aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-09 16:13:09 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-09 16:13:09 +0000
commitef5b81142600510b89184fd6f69202ecb92be724 (patch)
tree4e5cc64b307581f317fda880e7d2ddbc301d532f /tests
parent54c69147f96eedb10e430df72d71419795e81d3a (diff)
Fixing SkTileGrid to clamp rather than clip content and querries that are outside the bounds of the grid
This fix prevents border padding and offsets on the tile grid structure from resulting in bad clipping. The job of clipping contents is left to the playback canvas. BUG=https://code.google.com/p/skia/issues/detail?id=1209 TEST=TileGrid unit test, Review URL: https://codereview.chromium.org/13493016 git-svn-id: http://skia.googlecode.com/svn/trunk@8576 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/TileGridTest.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/TileGridTest.cpp b/tests/TileGridTest.cpp
index 11407634c5..78620b48aa 100644
--- a/tests/TileGridTest.cpp
+++ b/tests/TileGridTest.cpp
@@ -113,6 +113,39 @@ public:
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
+ // Out of bounds queries, snap to border tiles
+ {
+ SkDevice device(store);
+ MockCanvas mockCanvas(&device);
+ mockCanvas.translate(SkFloatToScalar(2.0f), SkFloatToScalar(0.0f));
+ picture.draw(&mockCanvas);
+ REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
+ REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
+ }
+ {
+ SkDevice device(store);
+ MockCanvas mockCanvas(&device);
+ mockCanvas.translate(SkFloatToScalar(0.0f), SkFloatToScalar(2.0f));
+ picture.draw(&mockCanvas);
+ REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
+ REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
+ }
+ {
+ SkDevice device(store);
+ MockCanvas mockCanvas(&device);
+ mockCanvas.translate(SkFloatToScalar(-22.0f), SkFloatToScalar(-16.0f));
+ picture.draw(&mockCanvas);
+ REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
+ REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
+ }
+ {
+ SkDevice device(store);
+ MockCanvas mockCanvas(&device);
+ mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-22.0f));
+ picture.draw(&mockCanvas);
+ REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
+ REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
+ }
}
static void TestOverlapOffsetQueryAlignment(skiatest::Reporter* reporter) {
@@ -215,7 +248,6 @@ public:
verifyTileHits(reporter, SkIRect::MakeXYWH(9, 9, 1, 1), kAll_Tile, 1);
verifyTileHits(reporter, SkIRect::MakeXYWH(10, 10, 1, 1), kBottomRight_Tile, 1);
verifyTileHits(reporter, SkIRect::MakeXYWH(17, 17, 1, 1), kBottomRight_Tile, 1);
- verifyTileHits(reporter, SkIRect::MakeXYWH(18, 18, 1, 1), 0, 1);
// BBoxes that overlap tiles
verifyTileHits(reporter, SkIRect::MakeXYWH(5, 5, 10, 1), kTopLeft_Tile | kTopRight_Tile);