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 #ifndef GrMixerEffect_DEFINED 12 #define GrMixerEffect_DEFINED 13 #include "SkTypes.h" 14 #include "GrFragmentProcessor.h" 15 #include "GrCoordTransform.h" 16 class GrMixerEffect : public GrFragmentProcessor { 17 public: OptFlags(const std::unique_ptr<GrFragmentProcessor> & fp0,const std::unique_ptr<GrFragmentProcessor> & fp1)18 static OptimizationFlags OptFlags(const std::unique_ptr<GrFragmentProcessor>& fp0, 19 const std::unique_ptr<GrFragmentProcessor>& fp1) { 20 auto flags = ProcessorOptimizationFlags(fp0.get()); 21 if (fp1) { 22 flags &= ProcessorOptimizationFlags(fp1.get()); 23 } 24 return flags; 25 } 26 constantOutputForConstantInput(const SkPMColor4f & input)27 SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { 28 const auto c0 = ConstantOutputForConstantInput(this->childProcessor(0), input), 29 c1 = (this->numChildProcessors() > 1) 30 ? ConstantOutputForConstantInput(this->childProcessor(1), input) 31 : input; 32 return {c0.fR + (c1.fR - c0.fR) * fWeight, c0.fG + (c1.fG - c0.fG) * fWeight, 33 c0.fB + (c1.fB - c0.fB) * fWeight, c0.fA + (c1.fA - c0.fA) * fWeight}; 34 } fp0_index()35 int fp0_index() const { return fFp0_index; } fp1_index()36 int fp1_index() const { return fFp1_index; } weight()37 float weight() const { return fWeight; } Make(std::unique_ptr<GrFragmentProcessor> fp0,std::unique_ptr<GrFragmentProcessor> fp1,float weight)38 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp0, 39 std::unique_ptr<GrFragmentProcessor> 40 fp1, 41 float weight) { 42 return std::unique_ptr<GrFragmentProcessor>( 43 new GrMixerEffect(std::move(fp0), std::move(fp1), weight)); 44 } 45 GrMixerEffect(const GrMixerEffect& src); 46 std::unique_ptr<GrFragmentProcessor> clone() const override; name()47 const char* name() const override { return "MixerEffect"; } 48 49 private: GrMixerEffect(std::unique_ptr<GrFragmentProcessor> fp0,std::unique_ptr<GrFragmentProcessor> fp1,float weight)50 GrMixerEffect(std::unique_ptr<GrFragmentProcessor> fp0, 51 std::unique_ptr<GrFragmentProcessor> 52 fp1, 53 float weight) 54 : INHERITED(kGrMixerEffect_ClassID, (OptimizationFlags)OptFlags(fp0, fp1)) 55 , fWeight(weight) { 56 SkASSERT(fp0); 57 fFp0_index = this->numChildProcessors(); 58 this->registerChildProcessor(std::move(fp0)); 59 if (fp1) { 60 fFp1_index = this->numChildProcessors(); 61 this->registerChildProcessor(std::move(fp1)); 62 } 63 } 64 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 65 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; 66 bool onIsEqual(const GrFragmentProcessor&) const override; 67 GR_DECLARE_FRAGMENT_PROCESSOR_TEST 68 int fFp0_index = -1; 69 int fFp1_index = -1; 70 float fWeight; 71 typedef GrFragmentProcessor INHERITED; 72 }; 73 #endif 74