blob: a66de57e7a7ab9ad2f010c5dabe68c502e66775c [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 Nicholas0274b302017-07-14 16:17:04 -040024 const GrBlurredEdgeFragmentProcessor& _outer = args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
25 (void) _outer;
26 fragBuilder->codeAppendf("float factor = 1.0 - %s.w;\n@switch (%d) {\n case 0:\n factor = exp((-factor * factor) * 4.0) - 0.017999999999999999;\n break;\n case 1:\n factor = smoothstep(1.0, 0.0, factor);\n break;\n}\n%s = vec4(factor);\n", args.fInputColor ? args.fInputColor : "vec4(1)", _outer.mode(), args.fOutputColor);
Jim Van Verth91af7272017-01-27 14:15:54 -050027 }
Ethan Nicholas0274b302017-07-14 16:17:04 -040028private:
29 void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
30 }
Jim Van Verth91af7272017-01-27 14:15:54 -050031};
Ethan Nicholas0274b302017-07-14 16:17:04 -040032GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance() const {
33 return new GrGLSLBlurredEdgeFragmentProcessor();
Jim Van Verth91af7272017-01-27 14:15:54 -050034}
Ethan Nicholas0274b302017-07-14 16:17:04 -040035void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
Jim Van Verth91af7272017-01-27 14:15:54 -050036 b->add32(fMode);
37}
Ethan Nicholas0274b302017-07-14 16:17:04 -040038bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
39 const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>();
40 (void) that;
41 if (fMode != that.fMode) return false;
42 return true;
Jim Van Verth91af7272017-01-27 14:15:54 -050043}
Ethan Nicholas0274b302017-07-14 16:17:04 -040044#endif