blob: aa39d95a7907b42feda9fe50b0b6babcc165b959 [file] [log] [blame]
Jim Van Verth91af7272017-01-27 14:15:54 -05001/*
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
Ethan Nicholas0274b302017-07-14 16:17:04 -04008/*
9 * This file was autogenerated from GrBlurredEdgeFragmentProcessor.fp; do not modify.
10 */
11#include "GrBlurredEdgeFragmentProcessor.h"
12#if SK_SUPPORT_GPU
13#include "glsl/GrGLSLColorSpaceXformHelper.h"
Jim Van Verth91af7272017-01-27 14:15:54 -050014#include "glsl/GrGLSLFragmentProcessor.h"
15#include "glsl/GrGLSLFragmentShaderBuilder.h"
Ethan Nicholas0274b302017-07-14 16:17:04 -040016#include "glsl/GrGLSLProgramBuilder.h"
17#include "SkSLCPP.h"
18#include "SkSLUtil.h"
19class GrGLSLBlurredEdgeFragmentProcessor : public GrGLSLFragmentProcessor {
Jim Van Verth91af7272017-01-27 14:15:54 -050020public:
Ethan Nicholas0274b302017-07-14 16:17:04 -040021 GrGLSLBlurredEdgeFragmentProcessor() {}
Jim Van Verth91af7272017-01-27 14:15:54 -050022 void emitCode(EmitArgs& args) override {
Jim Van Verth91af7272017-01-27 14:15:54 -050023 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040024 const GrBlurredEdgeFragmentProcessor& _outer =
25 args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
26 (void)_outer;
27 fragBuilder->codeAppendf(
28 "float factor = 1.0 - %s.w;\n@switch (%d) {\n case 0:\n factor = "
29 "exp((-factor * factor) * 4.0) - 0.017999999999999999;\n break;\n case "
30 "1:\n factor = smoothstep(1.0, 0.0, factor);\n break;\n}\n%s = "
31 "vec4(factor);\n",
32 args.fInputColor ? args.fInputColor : "vec4(1)", _outer.mode(), args.fOutputColor);
Jim Van Verth91af7272017-01-27 14:15:54 -050033 }
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040034
Ethan Nicholas0274b302017-07-14 16:17:04 -040035private:
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040036 void onSetData(const GrGLSLProgramDataManager& pdman,
37 const GrFragmentProcessor& _proc) override {}
Jim Van Verth91af7272017-01-27 14:15:54 -050038};
Ethan Nicholas0274b302017-07-14 16:17:04 -040039GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance() const {
40 return new GrGLSLBlurredEdgeFragmentProcessor();
Jim Van Verth91af7272017-01-27 14:15:54 -050041}
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040042void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
43 GrProcessorKeyBuilder* b) const {
Jim Van Verth91af7272017-01-27 14:15:54 -050044 b->add32(fMode);
45}
Ethan Nicholas0274b302017-07-14 16:17:04 -040046bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
47 const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>();
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040048 (void)that;
Ethan Nicholas0274b302017-07-14 16:17:04 -040049 if (fMode != that.fMode) return false;
50 return true;
Jim Van Verth91af7272017-01-27 14:15:54 -050051}
Ethan Nicholas0274b302017-07-14 16:17:04 -040052#endif