| 1 | /* |
| 2 | * Copyright 2019 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 GrMixerEffect.fp; do not modify. |
| 10 | **************************************************************************************************/ |
| 11 | #include "GrMixerEffect.h" |
| 12 | |
| 13 | #include "src/core/SkUtils.h" |
| 14 | #include "src/gpu/GrTexture.h" |
| 15 | #include "src/gpu/glsl/GrGLSLFragmentProcessor.h" |
| 16 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
| 17 | #include "src/gpu/glsl/GrGLSLProgramBuilder.h" |
| 18 | #include "src/sksl/SkSLCPP.h" |
| 19 | #include "src/sksl/SkSLUtil.h" |
| 20 | class GrGLSLMixerEffect : public GrGLSLFragmentProcessor { |
| 21 | public: |
| 22 | GrGLSLMixerEffect() {} |
| 23 | void emitCode(EmitArgs& args) override { |
| 24 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 25 | const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>(); |
| 26 | (void)_outer; |
| 27 | auto weight = _outer.weight; |
| 28 | (void)weight; |
| 29 | weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, |
| 30 | kHalf_GrSLType, "weight" ); |
| 31 | SkString _sample1099 = this->invokeChild(0, args); |
| 32 | fragBuilder->codeAppendf( |
| 33 | R"SkSL(half4 inColor = %s;)SkSL" , _sample1099.c_str()); |
| 34 | SkString _input1138("inColor" ); |
| 35 | SkString _sample1138 = this->invokeChild(1, _input1138.c_str(), args); |
| 36 | SkString _input1160("inColor" ); |
| 37 | SkString _sample1160 = this->invokeChild(2, _input1160.c_str(), args); |
| 38 | fragBuilder->codeAppendf( |
| 39 | R"SkSL( |
| 40 | %s = mix(%s, %s, %s); |
| 41 | )SkSL" , |
| 42 | args.fOutputColor, _sample1138.c_str(), _sample1160.c_str(), |
| 43 | args.fUniformHandler->getUniformCStr(weightVar)); |
| 44 | } |
| 45 | |
| 46 | private: |
| 47 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 48 | const GrFragmentProcessor& _proc) override { |
| 49 | const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>(); |
| 50 | { pdman.set1f(weightVar, (_outer.weight)); } |
| 51 | } |
| 52 | UniformHandle weightVar; |
| 53 | }; |
| 54 | GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const { |
| 55 | return new GrGLSLMixerEffect(); |
| 56 | } |
| 57 | void GrMixerEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 58 | GrProcessorKeyBuilder* b) const {} |
| 59 | bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 60 | const GrMixerEffect& that = other.cast<GrMixerEffect>(); |
| 61 | (void)that; |
| 62 | if (weight != that.weight) return false; |
| 63 | return true; |
| 64 | } |
| 65 | GrMixerEffect::GrMixerEffect(const GrMixerEffect& src) |
| 66 | : INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags()), weight(src.weight) { |
| 67 | this->cloneAndRegisterAllChildProcessors(src); |
| 68 | } |
| 69 | std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const { |
| 70 | return std::make_unique<GrMixerEffect>(*this); |
| 71 | } |
| 72 | #if GR_TEST_UTILS |
| 73 | SkString GrMixerEffect::onDumpInfo() const { return SkStringPrintf("(weight=%f)" , weight); } |
| 74 | #endif |
| 75 | |