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 GrOverrideInputFragmentProcessor.fp; do not modify. 10 **************************************************************************************************/ 11 #ifndef GrOverrideInputFragmentProcessor_DEFINED 12 #define GrOverrideInputFragmentProcessor_DEFINED 13 #include "include/core/SkTypes.h" 14 #include "include/core/SkM44.h" 15 16 #include "src/gpu/GrCoordTransform.h" 17 #include "src/gpu/GrFragmentProcessor.h" 18 class GrOverrideInputFragmentProcessor : public GrFragmentProcessor { 19 public: OptFlags(const std::unique_ptr<GrFragmentProcessor> & fp,const SkPMColor4f & color)20 static OptimizationFlags OptFlags(const std::unique_ptr<GrFragmentProcessor>& fp, 21 const SkPMColor4f& color) { 22 auto childFlags = ProcessorOptimizationFlags(fp.get()); 23 auto flags = kNone_OptimizationFlags; 24 if (childFlags & kConstantOutputForConstantInput_OptimizationFlag) { 25 flags |= kConstantOutputForConstantInput_OptimizationFlag; 26 } 27 if ((childFlags & kPreservesOpaqueInput_OptimizationFlag) && color.isOpaque()) { 28 flags |= kPreservesOpaqueInput_OptimizationFlag; 29 } 30 return flags; 31 } 32 constantOutputForConstantInput(const SkPMColor4f & input)33 SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { 34 return ConstantOutputForConstantInput(this->childProcessor(0), uniformColor); 35 } 36 37 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp, 38 const SkPMColor4f& color, 39 bool useUniform = true) { 40 return std::unique_ptr<GrFragmentProcessor>( 41 new GrOverrideInputFragmentProcessor(std::move(fp), useUniform, color, color)); 42 } 43 GrOverrideInputFragmentProcessor(const GrOverrideInputFragmentProcessor& src); 44 std::unique_ptr<GrFragmentProcessor> clone() const override; name()45 const char* name() const override { return "OverrideInputFragmentProcessor"; } 46 int fp_index = -1; 47 bool useUniform; 48 SkPMColor4f uniformColor; 49 SkPMColor4f literalColor; 50 51 private: GrOverrideInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp,bool useUniform,SkPMColor4f uniformColor,SkPMColor4f literalColor)52 GrOverrideInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp, 53 bool useUniform, 54 SkPMColor4f uniformColor, 55 SkPMColor4f literalColor) 56 : INHERITED(kGrOverrideInputFragmentProcessor_ClassID, 57 (OptimizationFlags)OptFlags(fp, useUniform ? uniformColor : literalColor)) 58 , useUniform(useUniform) 59 , uniformColor(uniformColor) 60 , literalColor(literalColor) { 61 SkASSERT(fp); 62 fp_index = this->numChildProcessors(); 63 this->registerChildProcessor(std::move(fp)); 64 } 65 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 66 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; 67 bool onIsEqual(const GrFragmentProcessor&) const override; 68 GR_DECLARE_FRAGMENT_PROCESSOR_TEST 69 typedef GrFragmentProcessor INHERITED; 70 }; 71 #endif 72