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

Unified Diff: tests/ImageFilterTest.cpp

Issue 262363007: Fix for empty saveLayer() with a filter which affects transparent black. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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/SkPictureRecord.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 08277a1ec616e41a3b8ea92247179e4306607e7c..f8492a7b11c900b6ad579583e1d6d8fd741a79a9 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -467,6 +467,61 @@ DEF_TEST(ImageFilterMatrixTest, reporter) {
canvas.drawPicture(*picture);
}
+DEF_TEST(ImageFilterEmptySaveLayerTest, reporter) {
+
+ // Even when there's an empty saveLayer()/restore(), ensure that an image
+ // filter or color filter which affects transparent black still draws.
+
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(10, 10);
+ SkBitmapDevice device(bitmap);
+ SkCanvas canvas(&device);
+
+ SkRTreeFactory factory;
+ SkPictureRecorder recorder;
+
+ SkAutoTUnref<SkColorFilter> green(
+ SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrc_Mode));
+ SkAutoTUnref<SkColorFilterImageFilter> imageFilter(
+ SkColorFilterImageFilter::Create(green.get()));
+ SkPaint imageFilterPaint;
+ imageFilterPaint.setImageFilter(imageFilter.get());
+ SkPaint colorFilterPaint;
+ colorFilterPaint.setColorFilter(green.get());
+
+ SkRect bounds = SkRect::MakeWH(10, 10);
+
+ SkCanvas* recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
+ recordingCanvas->saveLayer(&bounds, &imageFilterPaint);
+ recordingCanvas->restore();
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+
+ canvas.clear(0);
+ canvas.drawPicture(*picture);
+ uint32_t pixel = *bitmap.getAddr32(0, 0);
+ REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
+
+ recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
+ recordingCanvas->saveLayer(NULL, &imageFilterPaint);
+ recordingCanvas->restore();
+ SkAutoTUnref<SkPicture> picture2(recorder.endRecording());
+
+ canvas.clear(0);
+ canvas.drawPicture(*picture2);
+ pixel = *bitmap.getAddr32(0, 0);
+ REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
+
+ recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
+ recordingCanvas->saveLayer(&bounds, &colorFilterPaint);
+ recordingCanvas->restore();
+ SkAutoTUnref<SkPicture> picture3(recorder.endRecording());
+
+ canvas.clear(0);
+ canvas.drawPicture(*picture3);
+ pixel = *bitmap.getAddr32(0, 0);
+ REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
+}
+
static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) {
SkCanvas canvas(device);
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698