Delete deprecated blur filter header

This also deletes the type conversions between the legacy
tile mode and SkTileMode and cleans up the serialization
logic around that just a little bit.

Bug: skia:11230
Change-Id: If404a73e13f42055a0fe7638dcd9f58cf7e9b896
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368243
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Michael Ludwig 2021-02-09 10:01:37 -05:00
parent 3370d68067
commit b604452761
7 changed files with 29 additions and 105 deletions

View File

@ -14,7 +14,6 @@ skia_effects_imagefilter_sources = [
"$_src/effects/imagefilters/SkArithmeticImageFilter.cpp",
"$_src/effects/imagefilters/SkBlendImageFilter.cpp",
"$_src/effects/imagefilters/SkBlurImageFilter.cpp",
"$_src/effects/imagefilters/SkBlurImageFilter.h",
"$_src/effects/imagefilters/SkColorFilterImageFilter.cpp",
"$_src/effects/imagefilters/SkColorFilterImageFilter.h",
"$_src/effects/imagefilters/SkComposeImageFilter.cpp",

View File

@ -486,5 +486,6 @@ static inline const SkImageFilter_Base* as_IFB(const SkImageFilter* filter) {
void SkRegisterAlphaThresholdImageFilterFlattenable();
void SkRegisterArithmeticImageFilterFlattenable();
void SkRegisterBlendImageFilterFlattenable();
void SkRegisterBlurImageFilterFlattenable();
#endif // SkImageFilter_Base_DEFINED

View File

@ -5,12 +5,11 @@
* found in the LICENSE file.
*/
#include "src/effects/imagefilters/SkBlurImageFilter.h"
#include <algorithm>
#include "include/core/SkBitmap.h"
#include "include/core/SkTileMode.h"
#include "include/effects/SkImageFilters.h"
#include "include/private/SkColorData.h"
#include "include/private/SkNx.h"
#include "include/private/SkTFitsIn.h"
@ -31,10 +30,10 @@
namespace {
class SkBlurImageFilterImpl final : public SkImageFilter_Base {
class SkBlurImageFilter final : public SkImageFilter_Base {
public:
SkBlurImageFilterImpl(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
sk_sp<SkImageFilter> input, const SkRect* cropRect)
SkBlurImageFilter(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
sk_sp<SkImageFilter> input, const SkRect* cropRect)
: INHERITED(&input, 1, cropRect)
, fSigma{sigmaX, sigmaY}
, fTileMode(tileMode) {}
@ -48,8 +47,8 @@ protected:
MapDirection, const SkIRect* inputRect) const override;
private:
friend void SkBlurImageFilter::RegisterFlattenables();
SK_FLATTENABLE_HOOKS(SkBlurImageFilterImpl)
friend void ::SkRegisterBlurImageFilterFlattenable();
SK_FLATTENABLE_HOOKS(SkBlurImageFilter)
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> gpuFilter(
@ -66,63 +65,41 @@ private:
} // end namespace
static SkTileMode to_sktilemode(SkBlurImageFilter::TileMode tileMode) {
switch(tileMode) {
case SkBlurImageFilter::kClamp_TileMode:
return SkTileMode::kClamp;
case SkBlurImageFilter::kRepeat_TileMode:
return SkTileMode::kRepeat;
case SkBlurImageFilter::kClampToBlack_TileMode:
// Fall through
default:
return SkTileMode::kDecal;
}
}
sk_sp<SkImageFilter> SkBlurImageFilter::Make(SkScalar sigmaX, SkScalar sigmaY,
sk_sp<SkImageFilter> input,
const SkRect* cropRect,
TileMode tileMode) {
return Make(sigmaX, sigmaY, to_sktilemode(tileMode), std::move(input), cropRect);
}
sk_sp<SkImageFilter> SkBlurImageFilter::Make(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
sk_sp<SkImageFilter> input,
const SkRect* cropRect) {
sk_sp<SkImageFilter> SkImageFilters::Blur(
SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp<SkImageFilter> input,
const CropRect& cropRect) {
if (sigmaX < SK_ScalarNearlyZero && sigmaY < SK_ScalarNearlyZero && !cropRect) {
return input;
}
return sk_sp<SkImageFilter>(
new SkBlurImageFilterImpl(sigmaX, sigmaY, tileMode, input, cropRect));
new SkBlurImageFilter(sigmaX, sigmaY, tileMode, input, cropRect));
}
void SkBlurImageFilter::RegisterFlattenables() { SK_REGISTER_FLATTENABLE(SkBlurImageFilterImpl); }
void SkRegisterBlurImageFilterFlattenable() {
SK_REGISTER_FLATTENABLE(SkBlurImageFilter);
SkFlattenable::Register("SkBlurImageFilterImpl", SkBlurImageFilter::CreateProc);
}
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkFlattenable> SkBlurImageFilterImpl::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkFlattenable> SkBlurImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar sigmaX = buffer.readScalar();
SkScalar sigmaY = buffer.readScalar();
SkTileMode tileMode = buffer.read32LE(SkTileMode::kLastTileMode);
static_assert(SkBlurImageFilter::kLast_TileMode == 2, "CreateProc");
return SkBlurImageFilter::Make(
return SkImageFilters::Blur(
sigmaX, sigmaY, tileMode, 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);
static_assert((int) SkTileMode::kLastTileMode == 3 && SkBlurImageFilter::kLast_TileMode == 2,
"SkBlurImageFilterImpl::flatten");
SkASSERT(fTileMode <= SkTileMode::kLastTileMode);
buffer.writeInt(static_cast<int>(fTileMode));
}
///////////////////////////////////////////////////////////////////////////////
// This is defined by the SVG spec:
// https://drafts.fxtf.org/filter-effects/#feGaussianBlurElement
static int calculate_window(double sigma) {
@ -552,8 +529,8 @@ static SkVector map_sigma(const SkSize& localSigma, const SkMatrix& ctm) {
return sigma;
}
sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(const Context& ctx,
SkIPoint* offset) const {
sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(const Context& ctx,
SkIPoint* offset) const {
SkIPoint inputOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> input(this->filterInput(0, ctx, &inputOffset));
@ -624,7 +601,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(const Context& ctx,
}
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
sk_sp<SkSpecialImage> SkBlurImageFilter::gpuFilter(
const Context& ctx, SkVector sigma, const sk_sp<SkSpecialImage> &input, SkIRect inputBounds,
SkIRect dstBounds, SkIPoint inputOffset, SkIPoint* offset) const {
if (SkGpuBlurUtils::IsEffectivelyZeroSigma(sigma.x()) &&
@ -670,14 +647,14 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
}
#endif
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(fSigma.width() * 3, fSigma.height() * 3);
return bounds;
}
SkIRect SkBlurImageFilterImpl::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const {
SkIRect SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const {
SkVector sigma = map_sigma(fSigma, ctm);
return src.makeOutset(SkScalarCeilToInt(sigma.x() * 3), SkScalarCeilToInt(sigma.y() * 3));
}

View File

@ -1,46 +0,0 @@
/*
* Copyright 2011 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBlurImageFilter_DEFINED
#define SkBlurImageFilter_DEFINED
#include "include/core/SkImageFilter.h"
enum class SkTileMode;
// DEPRECATED: Use include/effects/SkImageFilters::Blur
class SK_API SkBlurImageFilter {
public:
/*! \enum TileMode
* DEPRECATED: Use SkTileMode instead. */
enum TileMode {
kClamp_TileMode = 0, /*!< Clamp to the image's edge pixels. */
/*!< This re-weights the filter so samples outside have no effect */
kRepeat_TileMode, /*!< Wrap around to the image's opposite edge. */
kClampToBlack_TileMode, /*!< Fill with transparent black. */
kLast_TileMode = kClampToBlack_TileMode,
// TODO: remove kMax - it is non-standard but Chromium uses it
kMax_TileMode = kClampToBlack_TileMode
};
static sk_sp<SkImageFilter> Make(SkScalar sigmaX, SkScalar sigmaY,
sk_sp<SkImageFilter> input,
const SkRect* cropRect = nullptr,
TileMode tileMode = TileMode::kClampToBlack_TileMode);
// EXPERIMENTAL: kMirror is not yet supported
static sk_sp<SkImageFilter> Make(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode,
sk_sp<SkImageFilter> input,
const SkRect* cropRect = nullptr);
static void RegisterFlattenables();
private:
SkBlurImageFilter() = delete;
};
#endif

View File

@ -8,12 +8,12 @@
#include "src/effects/imagefilters/SkDropShadowImageFilter.h"
#include "include/core/SkCanvas.h"
#include "include/effects/SkImageFilters.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkSpecialImage.h"
#include "src/core/SkSpecialSurface.h"
#include "src/core/SkWriteBuffer.h"
#include "src/effects/imagefilters/SkBlurImageFilter.h"
namespace {
@ -130,7 +130,7 @@ sk_sp<SkSpecialImage> SkDropShadowImageFilterImpl::onFilterImage(const Context&
SkPaint paint;
paint.setAntiAlias(true);
paint.setImageFilter(SkBlurImageFilter::Make(sigma.fX, sigma.fY, nullptr));
paint.setImageFilter(SkImageFilters::Blur(sigma.fX, sigma.fY, nullptr));
paint.setColorFilter(SkColorFilters::Blend(fColor, SkBlendMode::kSrcIn));
SkVector offsetVec = SkVector::Make(fDx, fDy);

View File

@ -9,7 +9,6 @@
#include "include/core/SkPaint.h"
#include "src/effects/imagefilters/SkBlurImageFilter.h"
#include "src/effects/imagefilters/SkColorFilterImageFilter.h"
#include "src/effects/imagefilters/SkComposeImageFilter.h"
#include "src/effects/imagefilters/SkDisplacementMapEffect.h"
@ -30,7 +29,6 @@
#include "src/core/SkMatrixImageFilter.h"
void SkImageFilters::RegisterFlattenables() {
SkBlurImageFilter::RegisterFlattenables();
SkColorFilterImageFilter::RegisterFlattenables();
SkComposeImageFilter::RegisterFlattenables();
SkDilateImageFilter::RegisterFlattenables();
@ -49,12 +47,6 @@ void SkImageFilters::RegisterFlattenables() {
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkImageFilter> SkImageFilters::Blur(
SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp<SkImageFilter> input,
const CropRect& cropRect) {
return SkBlurImageFilter::Make(sigmaX, sigmaY, tileMode, std::move(input), cropRect);
}
sk_sp<SkImageFilter> SkImageFilters::ColorFilter(
sk_sp<SkColorFilter> cf, sk_sp<SkImageFilter> input, const CropRect& cropRect) {
return SkColorFilterImageFilter::Make(std::move(cf), std::move(input), cropRect);

View File

@ -123,6 +123,7 @@
SkRegisterAlphaThresholdImageFilterFlattenable();
SkRegisterArithmeticImageFilterFlattenable();
SkRegisterBlendImageFilterFlattenable();
SkRegisterBlurImageFilterFlattenable();
SK_REGISTER_FLATTENABLE(SkLocalMatrixImageFilter);
SK_REGISTER_FLATTENABLE(SkMatrixImageFilter);
}