Index: tests/PictureTest.cpp |
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp |
index fa4dc101421da570449bbeba487624365bf5a091..85dbe65cfa0daf427f47949ea1ad226e22dea570 100644 |
--- a/tests/PictureTest.cpp |
+++ b/tests/PictureTest.cpp |
@@ -1535,6 +1535,56 @@ static void test_draw_empty(skiatest::Reporter* reporter) { |
} |
} |
+static void test_draw_empty_clip(skiatest::Reporter* reporter) { |
+ SkBitmap result; |
+ make_bm(&result, 2, 2, SK_ColorGREEN, false); |
+ |
+ // Test playing a non-empty picture into a canvas with an empty clip |
+ SkCanvas destinationCanvas(result); |
+ destinationCanvas.clipRect(SkRect::MakeXYWH(10, 10, 1, 1), SkRegion::kIntersect_Op); |
+ SkPaint paint; |
+ |
+ { |
+ // stock SkPicture |
+ SkPictureRecorder recorder; |
+ SkCanvas* canvas = recorder.beginRecording(3, 3); |
reed1
2014/10/28 17:39:51
we seem to make this picture three times, but only
|
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, 3, 3), paint); |
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
+ |
+ destinationCanvas.drawPicture(picture); |
+ REPORTER_ASSERT(reporter, SK_ColorGREEN == result.getColor(0, 0)); |
+ } |
+ |
+ { |
+ // tile grid |
+ SkTileGridFactory::TileGridInfo gridInfo; |
+ gridInfo.fMargin.setEmpty(); |
+ gridInfo.fOffset.setZero(); |
+ gridInfo.fTileInterval.set(1, 1); |
+ |
+ SkTileGridFactory factory(gridInfo); |
+ SkPictureRecorder recorder; |
+ SkCanvas* canvas = recorder.beginRecording(3, 3, &factory); |
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, 3, 3), paint); |
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
+ |
+ destinationCanvas.drawPicture(picture); |
+ REPORTER_ASSERT(reporter, SK_ColorGREEN == result.getColor(0, 0)); |
+ } |
+ |
+ { |
+ // RTree |
+ SkRTreeFactory factory; |
+ SkPictureRecorder recorder; |
+ SkCanvas* canvas = recorder.beginRecording(3, 3, &factory); |
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, 3, 3), paint); |
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
+ |
+ destinationCanvas.drawPicture(picture); |
+ REPORTER_ASSERT(reporter, SK_ColorGREEN == result.getColor(0, 0)); |
+ } |
+} |
+ |
static void test_clip_bound_opt(skiatest::Reporter* reporter) { |
// Test for crbug.com/229011 |
SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), |
@@ -1766,6 +1816,7 @@ DEF_TEST(Picture, reporter) { |
test_gatherpixelrefsandrects(reporter); |
test_bitmap_with_encoded_data(reporter); |
test_draw_empty(reporter); |
+ test_draw_empty_clip(reporter); |
test_clip_bound_opt(reporter); |
test_clip_expansion(reporter); |
test_hierarchical(reporter); |