Delete deprecated alpha threshold header
Bug: skia:11230
Change-Id: Icd927cfdcca71a48dce16bcd6c40489dad92a259
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368238
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/gn/effects_imagefilters.gni b/gn/effects_imagefilters.gni
index 639939e..2c2c846 100644
--- a/gn/effects_imagefilters.gni
+++ b/gn/effects_imagefilters.gni
@@ -10,8 +10,7 @@
skia_effects_imagefilter_public = [ "$_include/effects/SkImageFilters.h" ]
skia_effects_imagefilter_sources = [
- "$_src/effects/imagefilters/SkAlphaThresholdFilter.cpp",
- "$_src/effects/imagefilters/SkAlphaThresholdFilter.h",
+ "$_src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp",
"$_src/effects/imagefilters/SkArithmeticImageFilter.cpp",
"$_src/effects/imagefilters/SkArithmeticImageFilter.h",
"$_src/effects/imagefilters/SkBlurImageFilter.cpp",
diff --git a/src/core/SkImageFilter_Base.h b/src/core/SkImageFilter_Base.h
index f84719d..3975536 100644
--- a/src/core/SkImageFilter_Base.h
+++ b/src/core/SkImageFilter_Base.h
@@ -477,4 +477,12 @@
} \
} while (0)
+
+/**
+ * All image filter implementations defined for the include/effects/SkImageFilters.h factories
+ * are entirely encapsulated within their own CPP files. SkFlattenable deserialization needs a hook
+ * into these types, so their registration functions are exposed here.
+ */
+void SkRegisterAlphaThresholdImageFilterFlattenable();
+
#endif // SkImageFilter_Base_DEFINED
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.h b/src/effects/imagefilters/SkAlphaThresholdFilter.h
deleted file mode 100644
index 5e7137f..0000000
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkAlphaThresholdFilter_DEFINED
-#define SkAlphaThresholdFilter_DEFINED
-
-#include "include/core/SkImageFilter.h"
-
-class SkRegion;
-
-// DEPRECATED: Use include/effects/SkImageFilters::AlphaThreshold
-class SK_API SkAlphaThresholdFilter {
-public:
- /**
- * Creates an image filter that samples a region. If the sample is inside the
- * region the alpha of the image is boosted up to a threshold value. If it is
- * outside the region then the alpha is decreased to the threshold value.
- * The 0,0 point of the region corresponds to the upper left corner of the
- * source image.
- */
- static sk_sp<SkImageFilter> Make(const SkRegion& region, SkScalar innerMin,
- SkScalar outerMax, sk_sp<SkImageFilter> input,
- const SkRect* cropRect = nullptr);
-
-
- static void RegisterFlattenables();
-
-private:
- SkAlphaThresholdFilter() = delete;
-};
-
-#endif
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp
similarity index 80%
rename from src/effects/imagefilters/SkAlphaThresholdFilter.cpp
rename to src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp
index 48981be..a43a566 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdImageFilter.cpp
@@ -5,10 +5,9 @@
* found in the LICENSE file.
*/
-#include "src/effects/imagefilters/SkAlphaThresholdFilter.h"
-
#include "include/core/SkBitmap.h"
#include "include/core/SkRegion.h"
+#include "include/effects/SkImageFilters.h"
#include "include/private/SkTPin.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkReadBuffer.h"
@@ -28,11 +27,11 @@
namespace {
-class SkAlphaThresholdFilterImpl final : public SkImageFilter_Base {
+class SkAlphaThresholdImageFilter final : public SkImageFilter_Base {
public:
- SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold,
- SkScalar outerThreshold, sk_sp<SkImageFilter> input,
- const SkRect* cropRect = nullptr)
+ SkAlphaThresholdImageFilter(const SkRegion& region, SkScalar innerThreshold,
+ SkScalar outerThreshold, sk_sp<SkImageFilter> input,
+ const SkRect* cropRect = nullptr)
: INHERITED(&input, 1, cropRect)
, fRegion(region)
, fInnerThreshold(innerThreshold)
@@ -50,8 +49,8 @@
#endif
private:
- friend void SkAlphaThresholdFilter::RegisterFlattenables();
- SK_FLATTENABLE_HOOKS(SkAlphaThresholdFilterImpl)
+ friend void ::SkRegisterAlphaThresholdImageFilterFlattenable();
+ SK_FLATTENABLE_HOOKS(SkAlphaThresholdImageFilter)
SkRegion fRegion;
SkScalar fInnerThreshold;
@@ -62,46 +61,45 @@
}; // end namespace
-sk_sp<SkImageFilter> SkAlphaThresholdFilter::Make(const SkRegion& region, SkScalar innerThreshold,
- SkScalar outerThreshold,
- sk_sp<SkImageFilter> input,
- const SkRect* cropRect) {
- innerThreshold = SkTPin(innerThreshold, 0.f, 1.f);
- outerThreshold = SkTPin(outerThreshold, 0.f, 1.f);
- if (!SkScalarIsFinite(innerThreshold) || !SkScalarIsFinite(outerThreshold)) {
+sk_sp<SkImageFilter> SkImageFilters::AlphaThreshold(
+ const SkRegion& region, SkScalar innerMin, SkScalar outerMax, sk_sp<SkImageFilter> input,
+ const CropRect& cropRect) {
+ innerMin = SkTPin(innerMin, 0.f, 1.f);
+ outerMax = SkTPin(outerMax, 0.f, 1.f);
+ if (!SkScalarIsFinite(innerMin) || !SkScalarIsFinite(outerMax)) {
return nullptr;
}
- return sk_sp<SkImageFilter>(new SkAlphaThresholdFilterImpl(
- region, innerThreshold, outerThreshold, std::move(input), cropRect));
- }
-
-void SkAlphaThresholdFilter::RegisterFlattenables() {
- SK_REGISTER_FLATTENABLE(SkAlphaThresholdFilterImpl);
+ return sk_sp<SkImageFilter>(new SkAlphaThresholdImageFilter(
+ region, innerMin, outerMax, std::move(input), cropRect));
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
+void SkRegisterAlphaThresholdImageFilterFlattenable() {
+ SK_REGISTER_FLATTENABLE(SkAlphaThresholdImageFilter);
+ SkFlattenable::Register("SkAlphaThresholdFilterImpl", SkAlphaThresholdImageFilter::CreateProc);
+}
-sk_sp<SkFlattenable> SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkAlphaThresholdImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar inner = buffer.readScalar();
SkScalar outer = buffer.readScalar();
SkRegion rgn;
buffer.readRegion(&rgn);
- return SkAlphaThresholdFilter::Make(rgn, inner, outer, common.getInput(0),
- common.cropRect());
+ return SkImageFilters::AlphaThreshold(rgn, inner, outer, common.getInput(0), common.cropRect());
}
-void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
+void SkAlphaThresholdImageFilter::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fInnerThreshold);
buffer.writeScalar(fOuterThreshold);
buffer.writeRegion(fRegion);
}
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
#if SK_SUPPORT_GPU
-GrSurfaceProxyView SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context,
- const SkMatrix& inMatrix,
- const SkIRect& bounds) const {
+GrSurfaceProxyView SkAlphaThresholdImageFilter::createMaskTexture(GrRecordingContext* context,
+ const SkMatrix& inMatrix,
+ const SkIRect& bounds) const {
auto rtContext = GrSurfaceDrawContext::MakeWithFallback(
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size());
if (!rtContext) {
@@ -126,8 +124,8 @@
}
#endif
-sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& ctx,
- SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkAlphaThresholdImageFilter::onFilterImage(const Context& ctx,
+ SkIPoint* offset) const {
SkIPoint inputOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> input(this->filterInput(0, ctx, &inputOffset));
if (!input) {
diff --git a/src/effects/imagefilters/SkImageFilters.cpp b/src/effects/imagefilters/SkImageFilters.cpp
index 0274573..fd17dcb 100644
--- a/src/effects/imagefilters/SkImageFilters.cpp
+++ b/src/effects/imagefilters/SkImageFilters.cpp
@@ -9,7 +9,6 @@
#include "include/core/SkPaint.h"
-#include "src/effects/imagefilters/SkAlphaThresholdFilter.h"
#include "src/effects/imagefilters/SkArithmeticImageFilter.h"
#include "src/effects/imagefilters/SkBlurImageFilter.h"
#include "src/effects/imagefilters/SkColorFilterImageFilter.h"
@@ -37,7 +36,6 @@
constexpr SkRect SkImageFilters::CropRect::kNoCropRect;
void SkImageFilters::RegisterFlattenables() {
- SkAlphaThresholdFilter::RegisterFlattenables();
SkArithmeticImageFilter::RegisterFlattenables();
SkBlurImageFilter::RegisterFlattenables();
SkColorFilterImageFilter::RegisterFlattenables();
@@ -59,12 +57,6 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-sk_sp<SkImageFilter> SkImageFilters::AlphaThreshold(
- const SkRegion& region, SkScalar innerMin, SkScalar outerMax, sk_sp<SkImageFilter> input,
- const CropRect& cropRect) {
- return SkAlphaThresholdFilter::Make(region, innerMin, outerMax, std::move(input), cropRect);
-}
-
sk_sp<SkImageFilter> SkImageFilters::Arithmetic(
SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor,
sk_sp<SkImageFilter> background, sk_sp<SkImageFilter> foreground,
diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp
index 9a50ccc..3bd9336 100644
--- a/src/ports/SkGlobalInitialization_default.cpp
+++ b/src/ports/SkGlobalInitialization_default.cpp
@@ -30,6 +30,7 @@
#include "include/effects/SkShaderMaskFilter.h"
#include "include/effects/SkTableColorFilter.h"
#include "src/core/SkColorFilter_Matrix.h"
+ #include "src/core/SkImageFilter_Base.h"
#include "src/core/SkRecordedDrawable.h"
#include "src/effects/SkDashImpl.h"
#include "src/effects/SkEmbossMaskFilter.h"
@@ -119,6 +120,7 @@
*/
void SkFlattenable::PrivateInitializer::InitImageFilters() {
SkImageFilters::RegisterFlattenables();
+ SkRegisterAlphaThresholdImageFilterFlattenable();
SK_REGISTER_FLATTENABLE(SkLocalMatrixImageFilter);
SK_REGISTER_FLATTENABLE(SkMatrixImageFilter);
}