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
This commit is contained in:
parent
a05fa0669b
commit
910702b564
@ -44,6 +44,8 @@ protected:
|
||||
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;
|
||||
|
@ -92,3 +92,10 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
|
||||
offset->fY = bounds.fTop;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkPictureImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
|
||||
SkIRect* dst) const {
|
||||
*dst = src;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
|
||||
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 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user