1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8/**************************************************************************************************
9 *** This file was autogenerated from GrBlurredEdgeFragmentProcessor.fp; do not modify.
10 **************************************************************************************************/
11#include "GrBlurredEdgeFragmentProcessor.h"
12
13#include "src/gpu/GrTexture.h"
14#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
15#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
16#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
17#include "src/sksl/SkSLCPP.h"
18#include "src/sksl/SkSLUtil.h"
19class GrGLSLBlurredEdgeFragmentProcessor : public GrGLSLFragmentProcessor {
20public:
21 GrGLSLBlurredEdgeFragmentProcessor() {}
22 void emitCode(EmitArgs& args) override {
23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
24 const GrBlurredEdgeFragmentProcessor& _outer =
25 args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
26 (void)_outer;
27 auto mode = _outer.mode;
28 (void)mode;
29 fragBuilder->codeAppendf(
30 "half factor = 1.0 - %s.w;\n@switch (%d) {\n case 0:\n factor = "
31 "exp((-factor * factor) * 4.0) - 0.017999999225139618;\n break;\n case "
32 "1:\n factor = smoothstep(1.0, 0.0, factor);\n break;\n}\n%s = "
33 "half4(factor);\n",
34 args.fInputColor, (int)_outer.mode, args.fOutputColor);
35 }
36
37private:
38 void onSetData(const GrGLSLProgramDataManager& pdman,
39 const GrFragmentProcessor& _proc) override {}
40};
41GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance() const {
42 return new GrGLSLBlurredEdgeFragmentProcessor();
43}
44void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
45 GrProcessorKeyBuilder* b) const {
46 b->add32((int32_t)mode);
47}
48bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
49 const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>();
50 (void)that;
51 if (mode != that.mode) return false;
52 return true;
53}
54GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor(
55 const GrBlurredEdgeFragmentProcessor& src)
56 : INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, src.optimizationFlags())
57 , mode(src.mode) {}
58std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
59 return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
60}
61