| 1 | /* |
| 2 | * Copyright 2019 Google LLC. |
| 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 GrComposeLerpEffect.fp; do not modify. |
| 10 | **************************************************************************************************/ |
| 11 | #include "GrComposeLerpEffect.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 GrGLSLComposeLerpEffect : public GrGLSLFragmentProcessor { |
| 21 | public: |
| 22 | GrGLSLComposeLerpEffect() {} |
| 23 | void emitCode(EmitArgs& args) override { |
| 24 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 25 | const GrComposeLerpEffect& _outer = args.fFp.cast<GrComposeLerpEffect>(); |
| 26 | (void)_outer; |
| 27 | auto weight = _outer.weight; |
| 28 | (void)weight; |
| 29 | weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, |
| 30 | kFloat_GrSLType, "weight" ); |
| 31 | SkString _sample273 = this->invokeChild(0, args); |
| 32 | SkString _sample289 = this->invokeChild(1, args); |
| 33 | fragBuilder->codeAppendf( |
| 34 | R"SkSL(%s = mix(%s, %s, half(%s)); |
| 35 | )SkSL" , |
| 36 | args.fOutputColor, _sample273.c_str(), _sample289.c_str(), |
| 37 | args.fUniformHandler->getUniformCStr(weightVar)); |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | void onSetData(const GrGLSLProgramDataManager& pdman, |
| 42 | const GrFragmentProcessor& _proc) override { |
| 43 | const GrComposeLerpEffect& _outer = _proc.cast<GrComposeLerpEffect>(); |
| 44 | { pdman.set1f(weightVar, (_outer.weight)); } |
| 45 | } |
| 46 | UniformHandle weightVar; |
| 47 | }; |
| 48 | GrGLSLFragmentProcessor* GrComposeLerpEffect::onCreateGLSLInstance() const { |
| 49 | return new GrGLSLComposeLerpEffect(); |
| 50 | } |
| 51 | void GrComposeLerpEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 52 | GrProcessorKeyBuilder* b) const {} |
| 53 | bool GrComposeLerpEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 54 | const GrComposeLerpEffect& that = other.cast<GrComposeLerpEffect>(); |
| 55 | (void)that; |
| 56 | if (weight != that.weight) return false; |
| 57 | return true; |
| 58 | } |
| 59 | GrComposeLerpEffect::GrComposeLerpEffect(const GrComposeLerpEffect& src) |
| 60 | : INHERITED(kGrComposeLerpEffect_ClassID, src.optimizationFlags()), weight(src.weight) { |
| 61 | this->cloneAndRegisterAllChildProcessors(src); |
| 62 | } |
| 63 | std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const { |
| 64 | return std::make_unique<GrComposeLerpEffect>(*this); |
| 65 | } |
| 66 | #if GR_TEST_UTILS |
| 67 | SkString GrComposeLerpEffect::onDumpInfo() const { return SkStringPrintf("(weight=%f)" , weight); } |
| 68 | #endif |
| 69 | |