diff options
author | robertphillips <robertphillips@google.com> | 2016-04-06 07:44:01 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-06 07:44:01 -0700 |
commit | fc0f44a5f0a4001b894ecf357bbed2a0d93058c1 (patch) | |
tree | 824ea5dc223a13b1836bd564f3c0ca5f89a0f1b6 | |
parent | 898235c4864df66aa7f6d32bc2a8b8551040ce1e (diff) |
Update DownSampleImageFilter to sk_sp
TBR=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1864583005
Review URL: https://codereview.chromium.org/1864583005
-rw-r--r-- | fuzz/FilterFuzz.cpp | 2 | ||||
-rw-r--r-- | gm/testimagefilters.cpp | 8 | ||||
-rw-r--r-- | include/effects/SkTestImageFilters.h | 18 | ||||
-rw-r--r-- | samplecode/SampleFilterFuzz.cpp | 2 | ||||
-rwxr-xr-x | src/effects/SkTestImageFilters.cpp | 2 |
5 files changed, 19 insertions, 13 deletions
diff --git a/fuzz/FilterFuzz.cpp b/fuzz/FilterFuzz.cpp index 87653a18bb..db3dc8f8a7 100644 --- a/fuzz/FilterFuzz.cpp +++ b/fuzz/FilterFuzz.cpp @@ -583,7 +583,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { make_scalar(true))); break; case DOWN_SAMPLE: - filter = sk_sp<SkImageFilter>(SkDownSampleImageFilter::Create(make_scalar())); + filter = SkDownSampleImageFilter::Make(make_scalar(), make_image_filter()); break; case XFERMODE: filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), diff --git a/gm/testimagefilters.cpp b/gm/testimagefilters.cpp index 0174fc1d5c..c6742b2a60 100644 --- a/gm/testimagefilters.cpp +++ b/gm/testimagefilters.cpp @@ -22,7 +22,7 @@ #define FILTER_HEIGHT SkIntToScalar(200) static sk_sp<SkImageFilter> make0() { - return sk_sp<SkImageFilter>(SkDownSampleImageFilter::Create(SK_Scalar1 / 5)); + return SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr); } static sk_sp<SkImageFilter> make1() { @@ -42,7 +42,7 @@ static sk_sp<SkImageFilter> make4() { sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16), SkIntToScalar(16), nullptr)); - sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Create(SK_Scalar1 / 5)); + sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr)); return SkComposeImageFilter::Make(std::move(outer), std::move(inner)); } @@ -50,7 +50,7 @@ static sk_sp<SkImageFilter> make5() { sk_sp<SkImageFilter> first(SkOffsetImageFilter::Make(SkIntToScalar(16), SkIntToScalar(16), nullptr)); - sk_sp<SkImageFilter> second(SkDownSampleImageFilter::Create(SK_Scalar1 / 5)); + sk_sp<SkImageFilter> second(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr)); return SkMergeImageFilter::Make(std::move(first), std::move(second)); } @@ -58,7 +58,7 @@ static sk_sp<SkImageFilter> make6() { sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16), SkIntToScalar(16), nullptr)); - sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Create(SK_Scalar1 / 5)); + sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr)); sk_sp<SkImageFilter> compose(SkComposeImageFilter::Make(std::move(outer), std::move(inner))); sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode)); diff --git a/include/effects/SkTestImageFilters.h b/include/effects/SkTestImageFilters.h index 943bb53356..0f89759c1c 100644 --- a/include/effects/SkTestImageFilters.h +++ b/include/effects/SkTestImageFilters.h @@ -14,20 +14,26 @@ // Fun mode that scales down (only) and then scales back up to look pixelated class SK_API SkDownSampleImageFilter : public SkImageFilter { public: - static SkImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) { + static sk_sp<SkImageFilter> Make(SkScalar scale, sk_sp<SkImageFilter> input) { if (!SkScalarIsFinite(scale)) { - return NULL; + return nullptr; } // we don't support scale in this range if (scale > SK_Scalar1 || scale <= 0) { - return NULL; + return nullptr; } - return new SkDownSampleImageFilter(scale, input); + return sk_sp<SkImageFilter>(new SkDownSampleImageFilter(scale, std::move(input))); } SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter) +#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR + static SkImageFilter* Create(SkScalar scale, SkImageFilter* input = nullptr) { + return Make(scale, sk_ref_sp<SkImageFilter>(input)).release(); + } +#endif + protected: void flatten(SkWriteBuffer&) const override; @@ -35,8 +41,8 @@ protected: SkIPoint* offset) const override; private: - SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) - : INHERITED(1, &input), fScale(scale) {} + SkDownSampleImageFilter(SkScalar scale, sk_sp<SkImageFilter> input) + : INHERITED(&input, 1, nullptr), fScale(scale) {} SkScalar fScale; diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 67c17fbe4c..685ad90da6 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -586,7 +586,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { make_scalar(true))); break; case DOWN_SAMPLE: - filter = sk_sp<SkImageFilter>(SkDownSampleImageFilter::Create(make_scalar())); + filter = SkDownSampleImageFilter::Make(make_scalar(), make_image_filter()); break; case XFERMODE: filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), diff --git a/src/effects/SkTestImageFilters.cpp b/src/effects/SkTestImageFilters.cpp index d62fc725cc..5cc890c848 100755 --- a/src/effects/SkTestImageFilters.cpp +++ b/src/effects/SkTestImageFilters.cpp @@ -82,7 +82,7 @@ sk_sp<SkSpecialImage> SkDownSampleImageFilter::onFilterImage(SkSpecialImage* sou sk_sp<SkFlattenable> SkDownSampleImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); - return sk_sp<SkFlattenable>(Create(buffer.readScalar(), common.getInput(0).get())); + return Make(buffer.readScalar(), common.getInput(0)); } void SkDownSampleImageFilter::flatten(SkWriteBuffer& buffer) const { |