blob: 8c0ff64d275ef02e338f152f9eb2ce83e88c6921 [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 = "
Ethan Nicholas5af9ea32017-07-28 15:19:46 -040031 "float4(factor);\n",
32 args.fInputColor ? args.fInputColor : "float4(1)", _outer.mode(),
33 args.fOutputColor);
Jim Van Verth91af7272017-01-27 14:15:54 -050034 }
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040035
Ethan Nicholas0274b302017-07-14 16:17:04 -040036private:
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040037 void onSetData(const GrGLSLProgramDataManager& pdman,
38 const GrFragmentProcessor& _proc) override {}
Jim Van Verth91af7272017-01-27 14:15:54 -050039};
Ethan Nicholas0274b302017-07-14 16:17:04 -040040GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance() const {
41 return new GrGLSLBlurredEdgeFragmentProcessor();
Jim Van Verth91af7272017-01-27 14:15:54 -050042}
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040043void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
44 GrProcessorKeyBuilder* b) const {
Jim Van Verth91af7272017-01-27 14:15:54 -050045 b->add32(fMode);
46}
Ethan Nicholas0274b302017-07-14 16:17:04 -040047bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
48 const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>();
Ethan Nicholasb7e8c3b2017-07-19 13:54:20 -040049 (void)that;
Ethan Nicholas0274b302017-07-14 16:17:04 -040050 if (fMode != that.fMode) return false;
51 return true;
Jim Van Verth91af7272017-01-27 14:15:54 -050052}
Ethan Nicholasf57c0d62017-07-31 11:18:22 -040053GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor(
54 const GrBlurredEdgeFragmentProcessor& src)
55 : INHERITED(src.optimizationFlags()), fMode(src.fMode) {
56 this->initClassID<GrBlurredEdgeFragmentProcessor>();
57}
58sk_sp<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
59 return sk_sp<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
60}
Ethan Nicholas0274b302017-07-14 16:17:04 -040061#endif