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 #if SK_SUPPORT_GPU 13 #include "glsl/GrGLSLColorSpaceXformHelper.h" 14 #include "glsl/GrGLSLFragmentProcessor.h" 15 #include "glsl/GrGLSLFragmentShaderBuilder.h" 16 #include "glsl/GrGLSLProgramBuilder.h" 17 #include "SkSLCPP.h" 18 #include "SkSLUtil.h" 19 class GrGLSLBlurredEdgeFragmentProcessor : public GrGLSLFragmentProcessor { 20 public: 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 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); 33 } 34 35 private: 36 void onSetData(const GrGLSLProgramDataManager& pdman, 37 const GrFragmentProcessor& _proc) override {} 38 }; 39 GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance() const { 40 return new GrGLSLBlurredEdgeFragmentProcessor(); 41 } 42 void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, 43 GrProcessorKeyBuilder* b) const { 44 b->add32(fMode); 45 } 46 bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const { 47 const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>(); 48 (void)that; 49 if (fMode != that.fMode) return false; 50 return true; 51 } 52 #endif 53