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.
*/
enum class Mode {
kGaussian = 0,
kSmoothStep = 1
};
in fragmentProcessor inputFP;
layout(key) in Mode mode;
half4 main() {
half inputAlpha = sample(inputFP).a;
half factor = 1.0 - inputAlpha;
@switch (mode) {
case Mode::kGaussian:
factor = half(exp(-factor * factor * 4.0) - 0.018);
break;
case Mode::kSmoothStep:
factor = smoothstep(1.0, 0.0, factor);
break;
}
factor = half(exp(-factor * factor * 4.0) - 0.018);
return half4(factor);
}

View File

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

View File

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