Home | History | Annotate | Download | only in effects
      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 GrUnpremulInputFragmentProcessor.fp; do not modify.
     10  **************************************************************************************************/
     11 #include "GrUnpremulInputFragmentProcessor.h"
     12 #if SK_SUPPORT_GPU
     13 #include "glsl/GrGLSLFragmentProcessor.h"
     14 #include "glsl/GrGLSLFragmentShaderBuilder.h"
     15 #include "glsl/GrGLSLProgramBuilder.h"
     16 #include "GrTexture.h"
     17 #include "SkSLCPP.h"
     18 #include "SkSLUtil.h"
     19 class GrGLSLUnpremulInputFragmentProcessor : public GrGLSLFragmentProcessor {
     20 public:
     21     GrGLSLUnpremulInputFragmentProcessor() {}
     22     void emitCode(EmitArgs& args) override {
     23         GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
     24         const GrUnpremulInputFragmentProcessor& _outer =
     25                 args.fFp.cast<GrUnpremulInputFragmentProcessor>();
     26         (void)_outer;
     27         fragBuilder->codeAppendf(
     28                 "%s = %s;\nhalf invAlpha = %s.w <= 0.0 ? 0.0 : 1.0 / %s.w;\n%s.xyz *= invAlpha;\n",
     29                 args.fOutputColor, args.fInputColor ? args.fInputColor : "half4(1)",
     30                 args.fInputColor ? args.fInputColor : "half4(1)",
     31                 args.fInputColor ? args.fInputColor : "half4(1)", args.fOutputColor);
     32     }
     33 
     34 private:
     35     void onSetData(const GrGLSLProgramDataManager& pdman,
     36                    const GrFragmentProcessor& _proc) override {}
     37 };
     38 GrGLSLFragmentProcessor* GrUnpremulInputFragmentProcessor::onCreateGLSLInstance() const {
     39     return new GrGLSLUnpremulInputFragmentProcessor();
     40 }
     41 void GrUnpremulInputFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
     42                                                              GrProcessorKeyBuilder* b) const {}
     43 bool GrUnpremulInputFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
     44     const GrUnpremulInputFragmentProcessor& that = other.cast<GrUnpremulInputFragmentProcessor>();
     45     (void)that;
     46     return true;
     47 }
     48 GrUnpremulInputFragmentProcessor::GrUnpremulInputFragmentProcessor(
     49         const GrUnpremulInputFragmentProcessor& src)
     50         : INHERITED(kGrUnpremulInputFragmentProcessor_ClassID, src.optimizationFlags()) {}
     51 std::unique_ptr<GrFragmentProcessor> GrUnpremulInputFragmentProcessor::clone() const {
     52     return std::unique_ptr<GrFragmentProcessor>(new GrUnpremulInputFragmentProcessor(*this));
     53 }
     54 #endif
     55