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

Unified Diff: tests/ImageFilterTest.cpp

Issue 380373003: Fix for saveLayer() with filters vs. the BBox Hierarchy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use SkTDArray::deleteAll() Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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] = {
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698