Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 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 | |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 8 | /* |
| 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 Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 14 | #include "glsl/GrGLSLFragmentProcessor.h" |
| 15 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 16 | #include "glsl/GrGLSLProgramBuilder.h" |
| 17 | #include "SkSLCPP.h" |
| 18 | #include "SkSLUtil.h" |
| 19 | class GrGLSLBlurredEdgeFragmentProcessor : public GrGLSLFragmentProcessor { |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 20 | public: |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 21 | GrGLSLBlurredEdgeFragmentProcessor() {} |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 22 | void emitCode(EmitArgs& args) override { |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 23 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 24 | 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 Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 31 | "float4(factor);\n", |
| 32 | args.fInputColor ? args.fInputColor : "float4(1)", _outer.mode(), |
| 33 | args.fOutputColor); |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 34 | } |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 35 | |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 36 | private: |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 37 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 38 | const GrFragmentProcessor& _proc) override {} |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 39 | }; |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 40 | GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance() const { |
| 41 | return new GrGLSLBlurredEdgeFragmentProcessor(); |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 42 | } |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 43 | void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 44 | GrProcessorKeyBuilder* b) const { |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 45 | b->add32(fMode); |
| 46 | } |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 47 | bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const { |
| 48 | const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>(); |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 49 | (void)that; |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 50 | if (fMode != that.fMode) return false; |
| 51 | return true; |
Jim Van Verth | 91af727 | 2017-01-27 14:15:54 -0500 | [diff] [blame] | 52 | } |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 53 | GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor( |
| 54 | const GrBlurredEdgeFragmentProcessor& src) |
| 55 | : INHERITED(src.optimizationFlags()), fMode(src.fMode) { |
| 56 | this->initClassID<GrBlurredEdgeFragmentProcessor>(); |
| 57 | } |
| 58 | sk_sp<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const { |
| 59 | return sk_sp<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this)); |
| 60 | } |
Ethan Nicholas | 0274b30 | 2017-07-14 16:17:04 -0400 | [diff] [blame] | 61 | #endif |