• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/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:
GrGLSLTextureGradientColorizer()21     GrGLSLTextureGradientColorizer() {}
emitCode(EmitArgs & args)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()->samplerSwizzle(args.fTexSamplers[0]).c_str());
31     }
32 
33 private:
onSetData(const GrGLSLProgramDataManager & pdman,const GrFragmentProcessor & _proc)34     void onSetData(const GrGLSLProgramDataManager& pdman,
35                    const GrFragmentProcessor& _proc) override {}
36 };
onCreateGLSLInstance() const37 GrGLSLFragmentProcessor* GrTextureGradientColorizer::onCreateGLSLInstance() const {
38     return new GrGLSLTextureGradientColorizer();
39 }
onGetGLSLProcessorKey(const GrShaderCaps & caps,GrProcessorKeyBuilder * b) const40 void GrTextureGradientColorizer::onGetGLSLProcessorKey(const GrShaderCaps& caps,
41                                                        GrProcessorKeyBuilder* b) const {}
onIsEqual(const GrFragmentProcessor & other) const42 bool GrTextureGradientColorizer::onIsEqual(const GrFragmentProcessor& other) const {
43     const GrTextureGradientColorizer& that = other.cast<GrTextureGradientColorizer>();
44     (void)that;
45     if (gradient != that.gradient) return false;
46     return true;
47 }
GrTextureGradientColorizer(const GrTextureGradientColorizer & src)48 GrTextureGradientColorizer::GrTextureGradientColorizer(const GrTextureGradientColorizer& src)
49         : INHERITED(kGrTextureGradientColorizer_ClassID, src.optimizationFlags())
50         , gradient(src.gradient) {
51     this->setTextureSamplerCnt(1);
52 }
clone() const53 std::unique_ptr<GrFragmentProcessor> GrTextureGradientColorizer::clone() const {
54     return std::unique_ptr<GrFragmentProcessor>(new GrTextureGradientColorizer(*this));
55 }
onTextureSampler(int index) const56 const GrFragmentProcessor::TextureSampler& GrTextureGradientColorizer::onTextureSampler(
57         int index) const {
58     return IthTextureSampler(index, gradient);
59 }
60