Fix bounds computation of all 0-input filters.

The SkRectShaderImageFilter had the same bug as previously fixed for
SkBitmapSource and SkPictureImageFilter. Rather than copy-and-paste
the implementation, this change makes all filters with 0 inputs return
their source bounds, instead of returning false.

BUG=427251

Review URL: https://codereview.chromium.org/681643003
This commit is contained in:
senorblanco 2014-10-29 12:36:32 -07:00 committed by Commit bot
parent a5cf665997
commit 8f3937d9fc
7 changed files with 12 additions and 17 deletions

View File

@ -36,6 +36,10 @@
# robertphillips - skia:2995
blurrects
# senorblanco https://codereview.chromium.org/681643003/
# minor pixel diffs from bounds change
testimagefilters
# sugoi https://codereview.chromium.org/646213004/
# New shadow only option in SkDropShadowImageFilter
dropshadowimagefilter

View File

@ -34,7 +34,6 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const SK_OVERRIDE;
private:
SkBitmap fBitmap;

View File

@ -46,8 +46,6 @@ 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:
const SkPicture* fPicture;

View File

@ -342,7 +342,8 @@ bool SkImageFilter::applyCropRect(const Context& ctx, Proxy* proxy, const SkBitm
bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
if (fInputCount < 1) {
return false;
*dst = src;
return true;
}
SkIRect bounds;

View File

@ -97,9 +97,3 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const {
*dst = fDstRect;
}
bool SkBitmapSource::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
*dst = src;
return true;
}

View File

@ -110,10 +110,3 @@ 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;
}

View File

@ -23,11 +23,13 @@
#include "SkMergeImageFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPerlinNoiseShader.h"
#include "SkPicture.h"
#include "SkPictureImageFilter.h"
#include "SkPictureRecorder.h"
#include "SkReadBuffer.h"
#include "SkRect.h"
#include "SkRectShaderImageFilter.h"
#include "SkTileImageFilter.h"
#include "SkXfermodeImageFilter.h"
#include "Test.h"
@ -399,6 +401,9 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), greenPaint);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
SkAutoTUnref<SkImageFilter> pictureFilter(SkPictureImageFilter::Create(picture.get()));
SkAutoTUnref<SkShader> shader(SkPerlinNoiseShader::CreateTurbulence(SK_Scalar1, SK_Scalar1, 1, 0));
SkAutoTUnref<SkImageFilter> rectShaderFilter(SkRectShaderImageFilter::Create(shader.get()));
struct {
const char* fName;
@ -430,6 +435,7 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
{ "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()) },
{ "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShaderFilter.get()) },
};
SkBitmap untiledResult, tiledResult;