| 1 | /* | 
|---|
| 2 | * Copyright 2018 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 GrTextureGradientColorizer.fp; do not modify. | 
|---|
| 10 | **************************************************************************************************/ | 
|---|
| 11 | #include "GrTextureGradientColorizer.h" | 
|---|
| 12 |  | 
|---|
| 13 | #include "src/gpu/GrTexture.h" | 
|---|
| 14 | #include "src/gpu/glsl/GrGLSLFragmentProcessor.h" | 
|---|
| 15 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" | 
|---|
| 16 | #include "src/gpu/glsl/GrGLSLProgramBuilder.h" | 
|---|
| 17 | #include "src/sksl/SkSLCPP.h" | 
|---|
| 18 | #include "src/sksl/SkSLUtil.h" | 
|---|
| 19 | class GrGLSLTextureGradientColorizer : public GrGLSLFragmentProcessor { | 
|---|
| 20 | public: | 
|---|
| 21 | GrGLSLTextureGradientColorizer() {} | 
|---|
| 22 | void emitCode(EmitArgs& args) override { | 
|---|
| 23 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 
|---|
| 24 | const GrTextureGradientColorizer& _outer = args.fFp.cast<GrTextureGradientColorizer>(); | 
|---|
| 25 | (void)_outer; | 
|---|
| 26 | fragBuilder->codeAppendf( | 
|---|
| 27 | "half2 coord = half2(%s.x, 0.5);\n%s = sample(%s, float2(coord)).%s;\n", | 
|---|
| 28 | args.fInputColor, args.fOutputColor, | 
|---|
| 29 | fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]), | 
|---|
| 30 | fragBuilder->getProgramBuilder() | 
|---|
| 31 | ->samplerSwizzle(args.fTexSamplers[0]) | 
|---|
| 32 | .asString() | 
|---|
| 33 | .c_str()); | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | private: | 
|---|
| 37 | void onSetData(const GrGLSLProgramDataManager& pdman, | 
|---|
| 38 | const GrFragmentProcessor& _proc) override {} | 
|---|
| 39 | }; | 
|---|
| 40 | GrGLSLFragmentProcessor* GrTextureGradientColorizer::onCreateGLSLInstance() const { | 
|---|
| 41 | return new GrGLSLTextureGradientColorizer(); | 
|---|
| 42 | } | 
|---|
| 43 | void GrTextureGradientColorizer::onGetGLSLProcessorKey(const GrShaderCaps& caps, | 
|---|
| 44 | GrProcessorKeyBuilder* b) const {} | 
|---|
| 45 | bool GrTextureGradientColorizer::onIsEqual(const GrFragmentProcessor& other) const { | 
|---|
| 46 | const GrTextureGradientColorizer& that = other.cast<GrTextureGradientColorizer>(); | 
|---|
| 47 | (void)that; | 
|---|
| 48 | if (gradient != that.gradient) return false; | 
|---|
| 49 | return true; | 
|---|
| 50 | } | 
|---|
| 51 | GrTextureGradientColorizer::GrTextureGradientColorizer(const GrTextureGradientColorizer& src) | 
|---|
| 52 | : INHERITED(kGrTextureGradientColorizer_ClassID, src.optimizationFlags()) | 
|---|
| 53 | , gradient(src.gradient) { | 
|---|
| 54 | this->setTextureSamplerCnt(1); | 
|---|
| 55 | } | 
|---|
| 56 | std::unique_ptr<GrFragmentProcessor> GrTextureGradientColorizer::clone() const { | 
|---|
| 57 | return std::unique_ptr<GrFragmentProcessor>(new GrTextureGradientColorizer(*this)); | 
|---|
| 58 | } | 
|---|
| 59 | const GrFragmentProcessor::TextureSampler& GrTextureGradientColorizer::onTextureSampler( | 
|---|
| 60 | int index) const { | 
|---|
| 61 | return IthTextureSampler(index, gradient); | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|