diff options
-rw-r--r-- | fuzz/FilterFuzz.cpp | 6 | ||||
-rw-r--r-- | gm/imagefiltersbase.cpp | 1 | ||||
-rw-r--r-- | gm/imagefilterscropped.cpp | 1 | ||||
-rw-r--r-- | gm/imagefiltersgraph.cpp | 1 | ||||
-rw-r--r-- | gm/testimagefilters.cpp | 142 | ||||
-rw-r--r-- | gyp/effects.gypi | 1 | ||||
-rw-r--r-- | include/effects/SkTestImageFilters.h | 43 | ||||
-rw-r--r-- | samplecode/SampleFilterFuzz.cpp | 6 | ||||
-rwxr-xr-x | src/effects/SkTestImageFilters.cpp | 109 | ||||
-rw-r--r-- | src/ports/SkGlobalInitialization_default.cpp | 2 |
10 files changed, 2 insertions, 310 deletions
diff --git a/fuzz/FilterFuzz.cpp b/fuzz/FilterFuzz.cpp index cf92eae4d5..3255b4be4c 100644 --- a/fuzz/FilterFuzz.cpp +++ b/fuzz/FilterFuzz.cpp @@ -41,7 +41,6 @@ #include "SkPoint3.h" #include "SkRandom.h" #include "SkTableColorFilter.h" -#include "SkTestImageFilters.h" #include "SkTileImageFilter.h" #include "SkTypeface.h" #include "SkXfermodeImageFilter.h" @@ -541,7 +540,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { } enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER, - DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, + XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, PAINT, NUM_FILTERS }; @@ -581,9 +580,6 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { make_scalar(true), make_image_filter()); break; - case DOWN_SAMPLE: - filter = SkDownSampleImageFilter::Make(make_scalar(), make_image_filter()); - break; case XFERMODE: filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), make_image_filter(), diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp index f35357fe34..b30267a67c 100644 --- a/gm/imagefiltersbase.cpp +++ b/gm/imagefiltersbase.cpp @@ -15,7 +15,6 @@ #include "SkColorFilterImageFilter.h" #include "SkDropShadowImageFilter.h" #include "SkSpecialImage.h" -#include "SkTestImageFilters.h" class FailImageFilter : public SkImageFilter { public: diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp index 0c04e52b48..0f36c83f33 100644 --- a/gm/imagefilterscropped.cpp +++ b/gm/imagefilterscropped.cpp @@ -16,7 +16,6 @@ #include "SkColorFilterImageFilter.h" #include "SkMergeImageFilter.h" #include "SkOffsetImageFilter.h" -#include "SkTestImageFilters.h" /////////////////////////////////////////////////////////////////////////////// diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp index d9ab4d025e..0f3dcd10c9 100644 --- a/gm/imagefiltersgraph.cpp +++ b/gm/imagefiltersgraph.cpp @@ -22,7 +22,6 @@ #include "SkWriteBuffer.h" #include "SkMergeImageFilter.h" #include "SkMorphologyImageFilter.h" -#include "SkTestImageFilters.h" #include "SkXfermodeImageFilter.h" class ImageFiltersGraphGM : public skiagm::GM { diff --git a/gm/testimagefilters.cpp b/gm/testimagefilters.cpp deleted file mode 100644 index c6742b2a60..0000000000 --- a/gm/testimagefilters.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "gm.h" -#include "SkCanvas.h" -#include "SkColorFilter.h" -#include "SkColorPriv.h" -#include "SkShader.h" - -#include "SkBlurImageFilter.h" -#include "SkColorFilterImageFilter.h" -#include "SkComposeImageFilter.h" -#include "SkMergeImageFilter.h" -#include "SkOffsetImageFilter.h" -#include "SkTestImageFilters.h" - -#define FILTER_WIDTH SkIntToScalar(150) -#define FILTER_HEIGHT SkIntToScalar(200) - -static sk_sp<SkImageFilter> make0() { - return SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr); -} - -static sk_sp<SkImageFilter> make1() { - return SkOffsetImageFilter::Make(SkIntToScalar(16), SkIntToScalar(16), nullptr); -} - -static sk_sp<SkImageFilter> make2() { - sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode)); - return SkColorFilterImageFilter::Make(std::move(cf), nullptr); -} - -static sk_sp<SkImageFilter> make3() { - return SkBlurImageFilter::Make(8, 0, nullptr); -} - -static sk_sp<SkImageFilter> make4() { - sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16), - SkIntToScalar(16), - nullptr)); - sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr)); - return SkComposeImageFilter::Make(std::move(outer), std::move(inner)); -} - -static sk_sp<SkImageFilter> make5() { - sk_sp<SkImageFilter> first(SkOffsetImageFilter::Make(SkIntToScalar(16), - SkIntToScalar(16), - nullptr)); - sk_sp<SkImageFilter> second(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr)); - return SkMergeImageFilter::Make(std::move(first), std::move(second)); -} - -static sk_sp<SkImageFilter> make6() { - sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16), - SkIntToScalar(16), - nullptr)); - 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)); - sk_sp<SkImageFilter> blue(SkColorFilterImageFilter::Make(std::move(cf), nullptr)); - - return SkMergeImageFilter::Make(std::move(compose), std::move(blue)); -} - -static sk_sp<SkImageFilter> make7() { - sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16), - SkIntToScalar(16), - nullptr)); - sk_sp<SkImageFilter> inner(make3()); - sk_sp<SkImageFilter> compose(SkComposeImageFilter::Make(std::move(outer), std::move(inner))); - - sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode)); - sk_sp<SkImageFilter> blue(SkColorFilterImageFilter::Make(std::move(cf), nullptr)); - - return SkMergeImageFilter::Make(std::move(compose), std::move(blue)); -} - -static void draw0(SkCanvas* canvas) { - SkPaint p; - p.setAntiAlias(true); - SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT); - r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12); - p.setColor(SK_ColorRED); - canvas->drawOval(r, p); -} - -class TestImageFiltersGM : public skiagm::GM { -public: - TestImageFiltersGM () {} - -protected: - - SkString onShortName() override { - return SkString("testimagefilters"); - } - - SkISize onISize() override { return SkISize::Make(700, 460); } - - void onDraw(SkCanvas* canvas) override { -// this->drawSizeBounds(canvas, 0xFFCCCCCC); - - static sk_sp<SkImageFilter> (*gFilterProc[])() = { - make0, make1, make2, make3, make4, make5, make6, make7 - }; - - const SkRect bounds = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT); - - const SkScalar dx = bounds.width() * 8 / 7; - const SkScalar dy = bounds.height() * 8 / 7; - - canvas->translate(SkIntToScalar(8), SkIntToScalar(8)); - - for (int i = 0; i < (int)SK_ARRAY_COUNT(gFilterProc); ++i) { - int ix = i % 4; - int iy = i / 4; - - SkAutoCanvasRestore acr(canvas, true); - canvas->translate(ix * dx, iy * dy); - - SkPaint p; - p.setStyle(SkPaint::kStroke_Style); - canvas->drawRect(bounds, p); - - SkPaint paint; - paint.setImageFilter(gFilterProc[i]()); - canvas->saveLayer(&bounds, &paint); - draw0(canvas); - } - } - -private: - typedef GM INHERITED; -}; - -////////////////////////////////////////////////////////////////////////////// - -DEF_GM( return new TestImageFiltersGM; ) diff --git a/gyp/effects.gypi b/gyp/effects.gypi index 0106f84e2e..33c8c13d41 100644 --- a/gyp/effects.gypi +++ b/gyp/effects.gypi @@ -62,7 +62,6 @@ '<(skia_src_path)/effects/SkPictureImageFilter.cpp', '<(skia_src_path)/effects/SkTableColorFilter.cpp', '<(skia_src_path)/effects/SkTableMaskFilter.cpp', - '<(skia_src_path)/effects/SkTestImageFilters.cpp', '<(skia_src_path)/effects/SkTileImageFilter.cpp', '<(skia_src_path)/effects/SkXfermodeImageFilter.cpp', diff --git a/include/effects/SkTestImageFilters.h b/include/effects/SkTestImageFilters.h deleted file mode 100644 index 4aa30083dd..0000000000 --- a/include/effects/SkTestImageFilters.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef _SkTestImageFilters_h -#define _SkTestImageFilters_h - -#include "SkImageFilter.h" -#include "SkPoint.h" - -// Fun mode that scales down (only) and then scales back up to look pixelated -class SK_API SkDownSampleImageFilter : public SkImageFilter { -public: - static sk_sp<SkImageFilter> Make(SkScalar scale, sk_sp<SkImageFilter> 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; - - sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, - SkIPoint* offset) const override; - -private: - SkDownSampleImageFilter(SkScalar scale, sk_sp<SkImageFilter> input) - : INHERITED(&input, 1, nullptr), fScale(scale) {} - - SkScalar fScale; - - typedef SkImageFilter INHERITED; -}; - -#endif diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 78bc67386f..7a53f4f18e 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -41,7 +41,6 @@ #include "SkPoint3.h" #include "SkRandom.h" #include "SkTableColorFilter.h" -#include "SkTestImageFilters.h" #include "SkTileImageFilter.h" #include "SkTypeface.h" #include "SkView.h" @@ -545,7 +544,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { } enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER, - DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, + XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, PAINT, NUM_FILTERS }; @@ -585,9 +584,6 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { make_scalar(true), make_image_filter()); break; - case DOWN_SAMPLE: - filter = SkDownSampleImageFilter::Make(make_scalar(), make_image_filter()); - break; case XFERMODE: filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), make_image_filter(), diff --git a/src/effects/SkTestImageFilters.cpp b/src/effects/SkTestImageFilters.cpp deleted file mode 100755 index 208053b90e..0000000000 --- a/src/effects/SkTestImageFilters.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkTestImageFilters.h" -#include "SkCanvas.h" -#include "SkReadBuffer.h" -#include "SkSpecialImage.h" -#include "SkSpecialSurface.h" -#include "SkWriteBuffer.h" - -/////////////////////////////////////////////////////////////////////////////// - -sk_sp<SkImageFilter> SkDownSampleImageFilter::Make(SkScalar scale, sk_sp<SkImageFilter> input) { - if (!SkScalarIsFinite(scale)) { - return nullptr; - } - // we don't support scale in this range - if (scale > SK_Scalar1 || scale <= 0) { - return nullptr; - } - return sk_sp<SkImageFilter>(new SkDownSampleImageFilter(scale, std::move(input))); -} - -sk_sp<SkSpecialImage> SkDownSampleImageFilter::onFilterImage(SkSpecialImage* source, - const Context& ctx, - SkIPoint* offset) const { - if (fScale > SK_Scalar1 || fScale <= 0) { - return nullptr; - } - - int dstW = SkScalarRoundToInt(source->width() * fScale); - int dstH = SkScalarRoundToInt(source->height() * fScale); - if (dstW < 1) { - dstW = 1; - } - if (dstH < 1) { - dstH = 1; - } - - sk_sp<SkSpecialImage> tmp; - - // downsample - { - const SkImageInfo info = SkImageInfo::MakeN32Premul(dstW, dstH); - - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); - if (!surf) { - return nullptr; - } - - SkCanvas* canvas = surf->getCanvas(); - SkASSERT(canvas); - - canvas->clear(0x0); - - SkPaint paint; - paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); - paint.setFilterQuality(kLow_SkFilterQuality); - - canvas->scale(fScale, fScale); - source->draw(canvas, 0, 0, &paint); - - tmp = surf->makeImageSnapshot(); - } - - // upscale - { - const SkImageInfo info = SkImageInfo::MakeN32Premul(source->width(), source->height()); - - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); - if (!surf) { - return nullptr; - } - - SkCanvas* canvas = surf->getCanvas(); - SkASSERT(canvas); - - canvas->clear(0x0); - - SkPaint paint; - paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); - - canvas->scale(SkScalarInvert(fScale), SkScalarInvert(fScale)); - tmp->draw(canvas, 0, 0, &paint); - - return surf->makeImageSnapshot(); - } -} - -sk_sp<SkFlattenable> SkDownSampleImageFilter::CreateProc(SkReadBuffer& buffer) { - SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); - return Make(buffer.readScalar(), common.getInput(0)); -} - -void SkDownSampleImageFilter::flatten(SkWriteBuffer& buffer) const { - this->INHERITED::flatten(buffer); - buffer.writeScalar(fScale); -} - -#ifndef SK_IGNORE_TO_STRING -void SkDownSampleImageFilter::toString(SkString* str) const { - str->appendf("SkDownSampleImageFilter: ("); - str->append(")"); -} -#endif diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp index 37904a0d4b..933973eb93 100644 --- a/src/ports/SkGlobalInitialization_default.cpp +++ b/src/ports/SkGlobalInitialization_default.cpp @@ -41,7 +41,6 @@ #include "SkPerlinNoiseShader.h" #include "SkPictureImageFilter.h" #include "SkTableColorFilter.h" -#include "SkTestImageFilters.h" #include "SkTileImageFilter.h" #include "SkXfermodeImageFilter.h" @@ -119,6 +118,5 @@ void SkFlattenable::PrivateInitializer::InitEffects() { SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter) SkLightingImageFilter::InitializeFlattenables(); } |