1 /* 2 * Copyright 2014 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 #ifndef GrGLFragmentOnlyProgramBuilder_DEFINED 9 #define GrGLFragmentOnlyProgramBuilder_DEFINED 10 11 #include "GrGLProgramBuilder.h" 12 13 class GrGLFragmentOnlyProgramBuilder : public GrGLProgramBuilder { 14 public: 15 GrGLFragmentOnlyProgramBuilder(GrGpuGL*, const GrGLProgramDesc&); 16 17 int addTexCoordSets(int count); 18 19 private: 20 virtual void createAndEmitEffects(const GrGeometryStage* geometryProcessor, 21 const GrFragmentStage* colorStages[], 22 const GrFragmentStage* coverageStages[], 23 GrGLSLExpr4* inputColor, 24 GrGLSLExpr4* inputCoverage) SK_OVERRIDE; 25 26 GrGLProgramEffects* onCreateAndEmitEffects(const GrFragmentStage* effectStages[], 27 int effectCnt, 28 const GrGLProgramDesc::EffectKeyProvider&, 29 GrGLSLExpr4* inOutFSColor); 30 31 virtual void emitEffect(const GrProcessorStage& stage, 32 const GrProcessorKey& key, 33 const char* outColor, 34 const char* inColor, 35 int stageIndex) SK_OVERRIDE; 36 37 /** 38 * Helper for emitEffect(). Allocates texture units from the builder for each transform in an 39 * effect. The transforms all use adjacent texture units. They either use two or three of the 40 * coordinates at a given texture unit, depending on if they need perspective interpolation. 41 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[0])') as well as the 42 * types are appended to the TransformedCoordsArray* object, which is in turn passed to the 43 * effect's emitCode() function. 44 */ 45 void setupPathTexGen(const GrProcessorStage&, GrGLProcessor::TransformedCoordsArray*); 46 47 virtual GrGLProgramEffects* getProgramEffects() SK_OVERRIDE { return fProgramEffects.get(); } 48 49 typedef GrGLProgramDesc::EffectKeyProvider EffectKeyProvider; 50 51 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; 52 53 typedef GrGLProgramBuilder INHERITED; 54 }; 55 56 #endif 57