Implement SkPictureImageFilter bounds computation.
SkPictureImageFilter::onFilterBounds() was unimplemented, causing
incorrect results for SVG filters and impl-side painting (see Chrome
bug https://code.google.com/p/chromium/issues/detail?id=375162).
BUG=skia:
R=reed@google.com
Review URL: https://codereview.chromium.org/306733003
git-svn-id: http://skia.googlecode.com/svn/trunk@15003 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h
index 0a72f71..fe07215 100644
--- a/include/effects/SkPictureImageFilter.h
+++ b/include/effects/SkPictureImageFilter.h
@@ -44,6 +44,8 @@
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
+ virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
+ SkIRect* dst) const SK_OVERRIDE;
private:
SkPicture* fPicture;
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index 0b36b1d..a2f558f 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -92,3 +92,10 @@
offset->fY = bounds.fTop;
return true;
}
+
+bool SkPictureImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ SkIRect* dst) const {
+ *dst = src;
+ return true;
+}
+
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 48e86dd..35585ac 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -25,6 +25,7 @@
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPicture.h"
+#include "SkPictureImageFilter.h"
#include "SkPictureRecorder.h"
#include "SkRect.h"
#include "SkTileImageFilter.h"
@@ -307,6 +308,16 @@
matrix.setTranslate(SK_Scalar1, SK_Scalar1);
matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1);
+ SkRTreeFactory factory;
+ SkPictureRecorder recorder;
+ SkCanvas* recordingCanvas = recorder.beginRecording(64, 64, &factory, 0);
+
+ SkPaint greenPaint;
+ greenPaint.setColor(SK_ColorGREEN);
+ recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), greenPaint);
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ SkAutoTUnref<SkImageFilter> pictureFilter(SkPictureImageFilter::Create(picture.get()));
+
struct {
const char* fName;
SkImageFilter* fFilter;
@@ -335,6 +346,7 @@
SkRect::MakeXYWH(0, 0, 100, 100), NULL) },
{ "matrix", SkMatrixImageFilter::Create(matrix, SkPaint::kLow_FilterLevel) },
{ "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get()) },
+ { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilter.get()) },
};
SkBitmap untiledResult, tiledResult;