| Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 1 | /* | 
| Ethan Nicholas | 130fb3f | 2018-02-01 12:14:34 -0500 | [diff] [blame] | 2 | * Copyright 2018 Google Inc. | 
| Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 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 | 130fb3f | 2018-02-01 12:14:34 -0500 | [diff] [blame] | 8 | /************************************************************************************************** | 
|  | 9 | *** This file was autogenerated from GrOverdrawFragmentProcessor.fp; do not modify. | 
|  | 10 | **************************************************************************************************/ | 
| Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 11 | #include "GrOverdrawFragmentProcessor.h" | 
| Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 12 | #include "glsl/GrGLSLFragmentProcessor.h" | 
|  | 13 | #include "glsl/GrGLSLFragmentShaderBuilder.h" | 
|  | 14 | #include "glsl/GrGLSLProgramBuilder.h" | 
| Ethan Nicholas | 2d5f9b3 | 2017-12-13 14:36:14 -0500 | [diff] [blame] | 15 | #include "GrTexture.h" | 
| Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 16 | #include "SkSLCPP.h" | 
|  | 17 | #include "SkSLUtil.h" | 
|  | 18 | class GrGLSLOverdrawFragmentProcessor : public GrGLSLFragmentProcessor { | 
|  | 19 | public: | 
|  | 20 | GrGLSLOverdrawFragmentProcessor() {} | 
|  | 21 | void emitCode(EmitArgs& args) override { | 
|  | 22 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 
|  | 23 | const GrOverdrawFragmentProcessor& _outer = args.fFp.cast<GrOverdrawFragmentProcessor>(); | 
|  | 24 | (void)_outer; | 
|  | 25 | auto color0 = _outer.color0(); | 
|  | 26 | (void)color0; | 
|  | 27 | auto color1 = _outer.color1(); | 
|  | 28 | (void)color1; | 
|  | 29 | auto color2 = _outer.color2(); | 
|  | 30 | (void)color2; | 
|  | 31 | auto color3 = _outer.color3(); | 
|  | 32 | (void)color3; | 
|  | 33 | auto color4 = _outer.color4(); | 
|  | 34 | (void)color4; | 
|  | 35 | auto color5 = _outer.color5(); | 
|  | 36 | (void)color5; | 
|  | 37 | fragBuilder->codeAppendf( | 
|  | 38 | "half alpha = half(255.0 * float(%s.w));\nif (float(alpha) < 0.5) {\n    %s = " | 
|  | 39 | "half4(%f, %f, %f, %f);\n} else if (float(alpha) < 1.5) {\n    %s = half4(%f, %f, " | 
|  | 40 | "%f, %f);\n} else if (float(alpha) < 2.5) {\n    %s = half4(%f, %f, %f, %f);\n} " | 
|  | 41 | "else if (float(alpha) < 3.5) {\n    %s = half4(%f, %f, %f, %f);\n} else if " | 
|  | 42 | "(float(alpha) < 4.5) {\n    %s = half4(%f, %f, %f, %f);\n} else {\n    %s = " | 
|  | 43 | "half4(%f, %f, %f, %f);\n}\n", | 
| Michael Ludwig | 231de03 | 2018-08-30 14:33:01 -0400 | [diff] [blame] | 44 | args.fInputColor, args.fOutputColor, SkGetPackedR32(_outer.color0()) / 255.0, | 
|  | 45 | SkGetPackedG32(_outer.color0()) / 255.0, SkGetPackedB32(_outer.color0()) / 255.0, | 
|  | 46 | SkGetPackedA32(_outer.color0()) / 255.0, args.fOutputColor, | 
|  | 47 | SkGetPackedR32(_outer.color1()) / 255.0, SkGetPackedG32(_outer.color1()) / 255.0, | 
|  | 48 | SkGetPackedB32(_outer.color1()) / 255.0, SkGetPackedA32(_outer.color1()) / 255.0, | 
|  | 49 | args.fOutputColor, SkGetPackedR32(_outer.color2()) / 255.0, | 
|  | 50 | SkGetPackedG32(_outer.color2()) / 255.0, SkGetPackedB32(_outer.color2()) / 255.0, | 
|  | 51 | SkGetPackedA32(_outer.color2()) / 255.0, args.fOutputColor, | 
|  | 52 | SkGetPackedR32(_outer.color3()) / 255.0, SkGetPackedG32(_outer.color3()) / 255.0, | 
|  | 53 | SkGetPackedB32(_outer.color3()) / 255.0, SkGetPackedA32(_outer.color3()) / 255.0, | 
|  | 54 | args.fOutputColor, SkGetPackedR32(_outer.color4()) / 255.0, | 
|  | 55 | SkGetPackedG32(_outer.color4()) / 255.0, SkGetPackedB32(_outer.color4()) / 255.0, | 
|  | 56 | SkGetPackedA32(_outer.color4()) / 255.0, args.fOutputColor, | 
|  | 57 | SkGetPackedR32(_outer.color5()) / 255.0, SkGetPackedG32(_outer.color5()) / 255.0, | 
|  | 58 | SkGetPackedB32(_outer.color5()) / 255.0, SkGetPackedA32(_outer.color5()) / 255.0); | 
| Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 59 | } | 
|  | 60 |  | 
|  | 61 | private: | 
|  | 62 | void onSetData(const GrGLSLProgramDataManager& pdman, | 
|  | 63 | const GrFragmentProcessor& _proc) override {} | 
|  | 64 | }; | 
|  | 65 | GrGLSLFragmentProcessor* GrOverdrawFragmentProcessor::onCreateGLSLInstance() const { | 
|  | 66 | return new GrGLSLOverdrawFragmentProcessor(); | 
|  | 67 | } | 
|  | 68 | void GrOverdrawFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, | 
|  | 69 | GrProcessorKeyBuilder* b) const {} | 
|  | 70 | bool GrOverdrawFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const { | 
|  | 71 | const GrOverdrawFragmentProcessor& that = other.cast<GrOverdrawFragmentProcessor>(); | 
|  | 72 | (void)that; | 
|  | 73 | if (fColor0 != that.fColor0) return false; | 
|  | 74 | if (fColor1 != that.fColor1) return false; | 
|  | 75 | if (fColor2 != that.fColor2) return false; | 
|  | 76 | if (fColor3 != that.fColor3) return false; | 
|  | 77 | if (fColor4 != that.fColor4) return false; | 
|  | 78 | if (fColor5 != that.fColor5) return false; | 
|  | 79 | return true; | 
|  | 80 | } | 
|  | 81 | GrOverdrawFragmentProcessor::GrOverdrawFragmentProcessor(const GrOverdrawFragmentProcessor& src) | 
|  | 82 | : INHERITED(kGrOverdrawFragmentProcessor_ClassID, src.optimizationFlags()) | 
|  | 83 | , fColor0(src.fColor0) | 
|  | 84 | , fColor1(src.fColor1) | 
|  | 85 | , fColor2(src.fColor2) | 
|  | 86 | , fColor3(src.fColor3) | 
|  | 87 | , fColor4(src.fColor4) | 
|  | 88 | , fColor5(src.fColor5) {} | 
|  | 89 | std::unique_ptr<GrFragmentProcessor> GrOverdrawFragmentProcessor::clone() const { | 
|  | 90 | return std::unique_ptr<GrFragmentProcessor>(new GrOverdrawFragmentProcessor(*this)); | 
|  | 91 | } |