Index: tests/ImageFilterTest.cpp |
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp |
index 32822087baef6bf2c4e39f42f82acd10d296760d..7da4a911ef37c821d6da9c61808fe1ee61b51b3e 100644 |
--- a/tests/ImageFilterTest.cpp |
+++ b/tests/ImageFilterTest.cpp |
@@ -409,6 +409,70 @@ DEF_TEST(ImageFilterDrawTiled, reporter) { |
} |
} |
+static void drawBlurredRect(SkCanvas* canvas) { |
+ SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8), 0)); |
+ SkPaint filterPaint; |
+ filterPaint.setColor(SK_ColorWHITE); |
+ filterPaint.setImageFilter(filter); |
+ canvas->saveLayer(NULL, &filterPaint); |
+ SkPaint whitePaint; |
+ whitePaint.setColor(SK_ColorWHITE); |
+ canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); |
+ canvas->restore(); |
+} |
+ |
+static void drawPictureClipped(SkCanvas* canvas, const SkRect& clipRect, const SkPicture* picture) { |
+ canvas->save(); |
+ canvas->clipRect(clipRect); |
+ canvas->drawPicture(picture); |
+ canvas->restore(); |
+} |
+ |
+DEF_TEST(ImageFilterDrawTiledBlurRTree, reporter) { |
+ // Check that the blur filter when recorded with RTree acceleration, |
+ // and drawn tiled (with subsequent clip rects) exactly |
+ // matches the same filter drawn with without RTree acceleration. |
+ // This tests that the "bleed" from the blur into the otherwise-blank |
+ // tiles is correctly rendered. |
+ // Tests pass by not asserting. |
+ |
+ int width = 16, height = 8; |
+ SkBitmap result1, result2; |
+ result1.allocN32Pixels(width, height); |
+ result2.allocN32Pixels(width, height); |
+ SkCanvas canvas1(result1); |
+ SkCanvas canvas2(result2); |
+ int tileSize = 8; |
+ |
+ canvas1.clear(0); |
+ canvas2.clear(0); |
+ |
+ SkRTreeFactory factory; |
+ |
+ SkPictureRecorder recorder1, recorder2; |
+ // The only difference between these two pictures is that one has RTree aceleration. |
+ SkCanvas* recordingCanvas1 = recorder1.beginRecording(width, height, NULL, 0); |
+ SkCanvas* recordingCanvas2 = recorder2.beginRecording(width, height, &factory, 0); |
+ drawBlurredRect(recordingCanvas1); |
+ drawBlurredRect(recordingCanvas2); |
+ SkAutoTUnref<SkPicture> picture1(recorder1.endRecording()); |
+ SkAutoTUnref<SkPicture> picture2(recorder2.endRecording()); |
+ for (int y = 0; y < height; y += tileSize) { |
+ for (int x = 0; x < width; x += tileSize) { |
+ SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, tileSize)); |
+ drawPictureClipped(&canvas1, tileRect, picture1); |
+ drawPictureClipped(&canvas2, tileRect, picture2); |
+ } |
+ } |
+ for (int y = 0; y < height; y++) { |
+ int diffs = memcmp(result1.getAddr32(0, y), result2.getAddr32(0, y), result1.rowBytes()); |
+ REPORTER_ASSERT(reporter, !diffs); |
+ if (diffs) { |
+ break; |
+ } |
+ } |
+} |
+ |
DEF_TEST(ImageFilterMatrixConvolution, reporter) { |
// Check that a 1x3 filter does not cause a spurious assert. |
SkScalar kernel[3] = { |