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

Unified Diff: tests/ImageFilterTest.cpp

Issue 496963003: Fix saveLayer() with a pixel-moving filter vs SkBBoxHierarchyRecord / SkRecordDraw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simpler, no need to drop the bounds intersection. Created 6 years, 4 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/SkRecordDraw.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 214aed950cd388df429931da5eb4ac9f2e9d88de..f87f99ce98cc4e6dbe9d69daa8b6df1cd3f5c57f 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -421,6 +421,54 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
}
}
+static void drawSaveLayerPicture(int width, int height, int tileSize, SkBBHFactory* factory, SkBitmap* result) {
+
+ SkMatrix matrix;
+ matrix.setTranslate(SkIntToScalar(50), 0);
+
+ SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorWHITE, SkXfermode::kSrc_Mode));
+ SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get()));
+ SkAutoTUnref<SkImageFilter> imageFilter(SkMatrixImageFilter::Create(matrix, SkPaint::kNone_FilterLevel, cfif.get()));
+
+ SkPaint paint;
+ paint.setImageFilter(imageFilter.get());
+ SkPictureRecorder recorder;
+ SkRect bounds = SkRect::Make(SkIRect::MakeXYWH(0, 0, 50, 50));
+ SkCanvas* recordingCanvas = recorder.beginRecording(width, height, factory, 0);
+ recordingCanvas->translate(-55, 0);
+ recordingCanvas->saveLayer(&bounds, &paint);
+ recordingCanvas->restore();
+ SkAutoTUnref<SkPicture> picture1(recorder.endRecording());
+
+ result->allocN32Pixels(width, height);
+ SkCanvas canvas(*result);
+ canvas.clear(0);
+ canvas.clipRect(SkRect::Make(SkIRect::MakeWH(tileSize, tileSize)));
+ canvas.drawPicture(picture1.get());
+}
+
+DEF_TEST(ImageFilterDrawMatrixBBH, reporter) {
+ // Check that matrix filter when drawn tiled with BBH exactly
+ // matches the same thing drawn without BBH.
+ // Tests pass by not asserting.
+
+ const int width = 200, height = 200;
+ const int tileSize = 100;
+ SkBitmap result1, result2;
+ SkRTreeFactory factory;
+
+ drawSaveLayerPicture(width, height, tileSize, &factory, &result1);
+ drawSaveLayerPicture(width, height, tileSize, NULL, &result2);
+
+ 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;
+ }
+ }
+}
+
static void drawBlurredRect(SkCanvas* canvas) {
SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8), 0));
SkPaint filterPaint;
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698