From 2ec417257b5866b653af1af6ef5e91388cc40f49 Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 22 Aug 2016 09:25:59 -0700 Subject: [PATCH] Revert of Moving SkBlurImageFilter into core (patchset #6 id:100001 of https://codereview.chromium.org/2255803003/ ) Reason for revert: It looks like this breaks our roll into Google3: https://test.corp.google.com/ui#id=OCL:130943857:BASE:130944046:1471881622765:61dbdd3 Original issue's description: > Moving SkBlurImageFilter into core > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255803003 > > Committed: https://skia.googlesource.com/skia/+/dd3259eb95c3b47e11eefa3b176365a112a32b48 TBR=reed@google.com,fmalita@chromium.org,vjiaoblack@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2263283002 --- gyp/core.gypi | 3 - gyp/effects.gypi | 3 + include/core/SkImageFilter.h | 5 -- include/effects/SkBlurImageFilter.h | 32 +++++++++- src/{core => effects}/SkBlurImageFilter.cpp | 62 ++++---------------- src/{core => effects}/SkGpuBlurUtils.cpp | 0 src/{core => effects}/SkGpuBlurUtils.h | 0 src/ports/SkGlobalInitialization_default.cpp | 2 +- 8 files changed, 46 insertions(+), 61 deletions(-) rename src/{core => effects}/SkBlurImageFilter.cpp (82%) rename src/{core => effects}/SkGpuBlurUtils.cpp (100%) rename src/{core => effects}/SkGpuBlurUtils.h (100%) diff --git a/gyp/core.gypi b/gyp/core.gypi index 0a30618da3..8d1dc8d177 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -60,7 +60,6 @@ '<(skia_src_path)/core/SkBlitter_PM4f.cpp', '<(skia_src_path)/core/SkBlitter_RGB16.cpp', '<(skia_src_path)/core/SkBlitter_Sprite.cpp', - '<(skia_src_path)/core/SkBlurImageFilter.cpp', '<(skia_src_path)/core/SkBuffer.cpp', '<(skia_src_path)/core/SkCachedData.cpp', '<(skia_src_path)/core/SkCanvas.cpp', @@ -140,8 +139,6 @@ '<(skia_src_path)/core/SkGlyphCache.cpp', '<(skia_src_path)/core/SkGlyphCache.h', '<(skia_src_path)/core/SkGlyphCache_Globals.h', - '<(skia_src_path)/core/SkGpuBlurUtils.h', - '<(skia_src_path)/core/SkGpuBlurUtils.cpp', '<(skia_src_path)/core/SkGraphics.cpp', '<(skia_src_path)/core/SkHalf.cpp', '<(skia_src_path)/core/SkHalf.h', diff --git a/gyp/effects.gypi b/gyp/effects.gypi index 62c6bfdec4..45eced88e2 100644 --- a/gyp/effects.gypi +++ b/gyp/effects.gypi @@ -26,6 +26,7 @@ '<(skia_src_path)/effects/SkBlurDrawLooper.cpp', '<(skia_src_path)/effects/SkBlurMask.cpp', '<(skia_src_path)/effects/SkBlurMask.h', + '<(skia_src_path)/effects/SkBlurImageFilter.cpp', '<(skia_src_path)/effects/SkBlurMaskFilter.cpp', '<(skia_src_path)/effects/SkColorCubeFilter.cpp', '<(skia_src_path)/effects/SkColorFilterImageFilter.cpp', @@ -44,6 +45,8 @@ '<(skia_src_path)/effects/SkImageSource.cpp', '<(skia_src_path)/effects/SkGammaColorFilter.cpp', '<(skia_src_path)/effects/SkGaussianEdgeShader.cpp', + '<(skia_src_path)/effects/SkGpuBlurUtils.h', + '<(skia_src_path)/effects/SkGpuBlurUtils.cpp', '<(skia_src_path)/effects/SkLayerDrawLooper.cpp', '<(skia_src_path)/effects/SkLayerRasterizer.cpp', '<(skia_src_path)/effects/SkLightingImageFilter.cpp', diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 97f84dc596..6210073bf4 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -152,10 +152,6 @@ public: return this->isColorFilterNode(filterPtr); } - static sk_sp MakeBlur(SkScalar sigmaX, SkScalar sigmaY, - sk_sp input, - const CropRect* cropRect = nullptr); - /** * Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely * replaced by the returned colorfilter. i.e. the two effects will affect drawing in the @@ -233,7 +229,6 @@ public: SK_TO_STRING_PUREVIRT() SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter) - SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() protected: class Common { diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h index 085a13b5b3..9bfa19b875 100644 --- a/include/effects/SkBlurImageFilter.h +++ b/include/effects/SkBlurImageFilter.h @@ -9,14 +9,40 @@ #define SkBlurImageFilter_DEFINED #include "SkImageFilter.h" +#include "SkSize.h" -class SK_API SkBlurImageFilter { +class SK_API SkBlurImageFilter : public SkImageFilter { public: static sk_sp Make(SkScalar sigmaX, SkScalar sigmaY, sk_sp input, - const SkImageFilter::CropRect* cropRect = nullptr) { - return SkImageFilter::MakeBlur(sigmaX, sigmaY, input, cropRect); + const CropRect* cropRect = nullptr); + + SkRect computeFastBounds(const SkRect&) const override; + + SK_TO_STRING_OVERRIDE() + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter) + +#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR + static SkImageFilter* Create(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input = nullptr, + const CropRect* cropRect = nullptr) { + return Make(sigmaX, sigmaY, sk_ref_sp(input), cropRect).release(); } +#endif + +protected: + void flatten(SkWriteBuffer&) const override; + sk_sp onFilterImage(SkSpecialImage* source, const Context&, + SkIPoint* offset) const override; + SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; + +private: + SkBlurImageFilter(SkScalar sigmaX, + SkScalar sigmaY, + sk_sp input, + const CropRect* cropRect); + + SkSize fSigma; + typedef SkImageFilter INHERITED; }; #endif diff --git a/src/core/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp similarity index 82% rename from src/core/SkBlurImageFilter.cpp rename to src/effects/SkBlurImageFilter.cpp index b190554209..37584ab3ad 100644 --- a/src/core/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -5,6 +5,8 @@ * found in the LICENSE file. */ +#include "SkBlurImageFilter.h" + #include "SkAutoPixmapStorage.h" #include "SkColorPriv.h" #include "SkGpuBlurUtils.h" @@ -18,51 +20,13 @@ #include "SkGr.h" #endif -class SkBlurImageFilterImpl : public SkImageFilter { -public: - SkBlurImageFilterImpl(SkScalar sigmaX, - SkScalar sigmaY, - sk_sp input, - const CropRect* cropRect); - - SkRect computeFastBounds(const SkRect&) const override; - - SK_TO_STRING_OVERRIDE() - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilterImpl) - -#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR - static SkImageFilter* Create(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input = nullptr, - const CropRect* cropRect = nullptr) { - return Make(sigmaX, sigmaY, sk_ref_sp(input), cropRect).release(); - } -#endif - -protected: - void flatten(SkWriteBuffer&) const override; - sk_sp onFilterImage(SkSpecialImage* source, const Context&, - SkIPoint* offset) const override; - SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; - -private: - SkSize fSigma; - typedef SkImageFilter INHERITED; - - friend class SkImageFilter; -}; - -SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkImageFilter) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilterImpl) -SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END - -/////////////////////////////////////////////////////////////////////////////// - -sk_sp SkImageFilter::MakeBlur(SkScalar sigmaX, SkScalar sigmaY, +sk_sp SkBlurImageFilter::Make(SkScalar sigmaX, SkScalar sigmaY, sk_sp input, const CropRect* cropRect) { if (0 == sigmaX && 0 == sigmaY && !cropRect) { return input; } - return sk_sp(new SkBlurImageFilterImpl(sigmaX, sigmaY, input, cropRect)); + return sk_sp(new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect)); } // This rather arbitrary-looking value results in a maximum box blur kernel size @@ -80,7 +44,7 @@ static SkVector map_sigma(const SkSize& localSigma, const SkMatrix& ctm) { return sigma; } -SkBlurImageFilterImpl::SkBlurImageFilterImpl(SkScalar sigmaX, +SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX, SkScalar sigmaY, sk_sp input, const CropRect* cropRect) @@ -88,14 +52,14 @@ SkBlurImageFilterImpl::SkBlurImageFilterImpl(SkScalar sigmaX, , fSigma(SkSize::Make(sigmaX, sigmaY)) { } -sk_sp SkBlurImageFilterImpl::CreateProc(SkReadBuffer& buffer) { +sk_sp SkBlurImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkScalar sigmaX = buffer.readScalar(); SkScalar sigmaY = buffer.readScalar(); - return SkImageFilter::MakeBlur(sigmaX, sigmaY, common.getInput(0), &common.cropRect()); + return Make(sigmaX, sigmaY, common.getInput(0), &common.cropRect()); } -void SkBlurImageFilterImpl::flatten(SkWriteBuffer& buffer) const { +void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fSigma.fWidth); buffer.writeScalar(fSigma.fHeight); @@ -116,7 +80,7 @@ static void get_box3_params(SkScalar s, int *kernelSize, int* kernelSize3, int * } } -sk_sp SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* source, +sk_sp SkBlurImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx, SkIPoint* offset) const { SkIPoint inputOffset = SkIPoint::Make(0, 0); @@ -267,14 +231,14 @@ sk_sp SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc } -SkRect SkBlurImageFilterImpl::computeFastBounds(const SkRect& src) const { +SkRect SkBlurImageFilter::computeFastBounds(const SkRect& src) const { SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; bounds.outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), SkScalarMul(fSigma.height(), SkIntToScalar(3))); return bounds; } -SkIRect SkBlurImageFilterImpl::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, +SkIRect SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, MapDirection) const { SkVector sigma = map_sigma(fSigma, ctm); return src.makeOutset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), @@ -282,8 +246,8 @@ SkIRect SkBlurImageFilterImpl::onFilterNodeBounds(const SkIRect& src, const SkMa } #ifndef SK_IGNORE_TO_STRING -void SkBlurImageFilterImpl::toString(SkString* str) const { - str->appendf("SkBlurImageFilterImpl: ("); +void SkBlurImageFilter::toString(SkString* str) const { + str->appendf("SkBlurImageFilter: ("); str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); if (this->getInput(0)) { diff --git a/src/core/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp similarity index 100% rename from src/core/SkGpuBlurUtils.cpp rename to src/effects/SkGpuBlurUtils.cpp diff --git a/src/core/SkGpuBlurUtils.h b/src/effects/SkGpuBlurUtils.h similarity index 100% rename from src/core/SkGpuBlurUtils.h rename to src/effects/SkGpuBlurUtils.h diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp index fdafd9609a..cc697ce0ba 100644 --- a/src/ports/SkGlobalInitialization_default.cpp +++ b/src/ports/SkGlobalInitialization_default.cpp @@ -102,7 +102,7 @@ void SkFlattenable::PrivateInitializer::InitEffects() { SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect) // ImageFilter - SkImageFilter::InitializeFlattenables(); + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter) -- 2.34.1