Intersect SkPictureImageFilter bounds against clip bounds.
Intersect SkPictureImageFilter bounds against clip bounds
to avoid unnecessary processing. This is how the other
filters work (via applyCropRect()), but SkPictureImageFilter
maintains its own crop.
BUG=skia:
R=bsalomon@google.com
Author: senorblanco@chromium.org
Review URL: https://codereview.chromium.org/428263003
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 0766c15..4ee9f5d 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -567,7 +567,7 @@
canvas.drawPicture(picture);
}
-DEF_TEST(ImageFilterPictureImageFilter, reporter) {
+DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
SkRTreeFactory factory;
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0);
@@ -626,6 +626,30 @@
REPORTER_ASSERT(reporter, pixel != SK_ColorGREEN);
}
+DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {
+ SkRTreeFactory factory;
+ SkPictureRecorder recorder;
+ SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0);
+
+ // Create an SkPicture which simply draws a green 1x1 rectangle.
+ SkPaint greenPaint;
+ greenPaint.setColor(SK_ColorGREEN);
+ recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+
+ SkAutoTUnref<SkImageFilter> imageFilter(
+ SkPictureImageFilter::Create(picture.get()));
+
+ SkBitmap result;
+ SkIPoint offset;
+ SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), NULL);
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(2, 2);
+ SkBitmapDevice device(bitmap);
+ SkDeviceImageFilterProxy proxy(&device);
+ REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &result, &offset));
+}
+
DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
// Even when there's an empty saveLayer()/restore(), ensure that an image
// filter or color filter which affects transparent black still draws.