remove unused Mode from GrBlurredEdgeFP

Only Mode::kGaussian is used, so fold that through.

Change-Id: Ic87f66c913e4e64c28dade2f65a9034b163af3ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375941
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2021-02-25 13:32:56 -06:00 committed by Skia Commit-Bot
parent b321a07f16
commit c63d1668c3
4 changed files with 11 additions and 44 deletions

View File

@ -5,24 +5,11 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
enum class Mode {
kGaussian = 0,
kSmoothStep = 1
};
in fragmentProcessor inputFP; in fragmentProcessor inputFP;
layout(key) in Mode mode;
half4 main() { half4 main() {
half inputAlpha = sample(inputFP).a; half inputAlpha = sample(inputFP).a;
half factor = 1.0 - inputAlpha; half factor = 1.0 - inputAlpha;
@switch (mode) {
case Mode::kGaussian:
factor = half(exp(-factor * factor * 4.0) - 0.018); factor = half(exp(-factor * factor * 4.0) - 0.018);
break;
case Mode::kSmoothStep:
factor = smoothstep(1.0, 0.0, factor);
break;
}
return half4(factor); return half4(factor);
} }

View File

@ -25,23 +25,14 @@ public:
const GrBlurredEdgeFragmentProcessor& _outer = const GrBlurredEdgeFragmentProcessor& _outer =
args.fFp.cast<GrBlurredEdgeFragmentProcessor>(); args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
(void)_outer; (void)_outer;
auto mode = _outer.mode;
(void)mode;
SkString _sample0 = this->invokeChild(0, args); SkString _sample0 = this->invokeChild(0, args);
fragBuilder->codeAppendf( fragBuilder->codeAppendf(
R"SkSL(half inputAlpha = %s.w; R"SkSL(half inputAlpha = %s.w;
half factor = 1.0 - inputAlpha; half factor = 1.0 - inputAlpha;
@switch (%d) { factor = exp((-factor * factor) * 4.0) - 0.017999999225139618;
case 0:
factor = exp((-factor * factor) * 4.0) - 0.017999999225139618;
break;
case 1:
factor = smoothstep(1.0, 0.0, factor);
break;
}
return half4(factor); return half4(factor);
)SkSL", )SkSL",
_sample0.c_str(), (int)_outer.mode); _sample0.c_str());
} }
private: private:
@ -52,26 +43,20 @@ std::unique_ptr<GrGLSLFragmentProcessor> GrBlurredEdgeFragmentProcessor::onMakeP
return std::make_unique<GrGLSLBlurredEdgeFragmentProcessor>(); return std::make_unique<GrGLSLBlurredEdgeFragmentProcessor>();
} }
void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const { GrProcessorKeyBuilder* b) const {}
b->add32((uint32_t)mode);
}
bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const { bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>(); const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>();
(void)that; (void)that;
if (mode != that.mode) return false;
return true; return true;
} }
GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor( GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor(
const GrBlurredEdgeFragmentProcessor& src) const GrBlurredEdgeFragmentProcessor& src)
: INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, src.optimizationFlags()) : INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, src.optimizationFlags()) {
, mode(src.mode) {
this->cloneAndRegisterAllChildProcessors(src); this->cloneAndRegisterAllChildProcessors(src);
} }
std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const { std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
return std::make_unique<GrBlurredEdgeFragmentProcessor>(*this); return std::make_unique<GrBlurredEdgeFragmentProcessor>(*this);
} }
#if GR_TEST_UTILS #if GR_TEST_UTILS
SkString GrBlurredEdgeFragmentProcessor::onDumpInfo() const { SkString GrBlurredEdgeFragmentProcessor::onDumpInfo() const { return SkString(); }
return SkStringPrintf("(mode=%d)", (int)mode);
}
#endif #endif

View File

@ -18,21 +18,17 @@
class GrBlurredEdgeFragmentProcessor : public GrFragmentProcessor { class GrBlurredEdgeFragmentProcessor : public GrFragmentProcessor {
public: public:
enum class Mode { kGaussian = 0, kSmoothStep = 1 }; static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> inputFP) {
static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> inputFP,
Mode mode) {
return std::unique_ptr<GrFragmentProcessor>( return std::unique_ptr<GrFragmentProcessor>(
new GrBlurredEdgeFragmentProcessor(std::move(inputFP), mode)); new GrBlurredEdgeFragmentProcessor(std::move(inputFP)));
} }
GrBlurredEdgeFragmentProcessor(const GrBlurredEdgeFragmentProcessor& src); GrBlurredEdgeFragmentProcessor(const GrBlurredEdgeFragmentProcessor& src);
std::unique_ptr<GrFragmentProcessor> clone() const override; std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "BlurredEdgeFragmentProcessor"; } const char* name() const override { return "BlurredEdgeFragmentProcessor"; }
Mode mode;
private: private:
GrBlurredEdgeFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP, Mode mode) GrBlurredEdgeFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP)
: INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, kNone_OptimizationFlags) : INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, kNone_OptimizationFlags) {
, mode(mode) {
this->registerChild(std::move(inputFP), SkSL::SampleUsage::PassThrough()); this->registerChild(std::move(inputFP), SkSL::SampleUsage::PassThrough());
} }
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override; std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;

View File

@ -87,8 +87,7 @@ sk_sp<SkFlattenable> SkGaussianColorFilter::CreateProc(SkReadBuffer&) {
GrFPResult SkGaussianColorFilter::asFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP, GrFPResult SkGaussianColorFilter::asFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP,
GrRecordingContext*, GrRecordingContext*,
const GrColorInfo&) const { const GrColorInfo&) const {
return GrFPSuccess(GrBlurredEdgeFragmentProcessor::Make( return GrFPSuccess(GrBlurredEdgeFragmentProcessor::Make(std::move(inputFP)));
std::move(inputFP), GrBlurredEdgeFragmentProcessor::Mode::kGaussian));
} }
#endif #endif