separate arrays for color and coverage effects.
R=robertphillips@google.com
Review URL: https://codereview.chromium.org/16180006
git-svn-id: http://skia.googlecode.com/svn/trunk@9465 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index ce43b71..3534552 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -38,7 +38,8 @@
static GrGLProgram* Create(const GrGLContext& gl,
const GrGLProgramDesc& desc,
- const GrEffectStage* stages[]);
+ const GrEffectStage* colorStages[],
+ const GrEffectStage* coverageStages[]);
virtual ~GrGLProgram();
@@ -103,59 +104,19 @@
/**
* This function uploads uniforms and calls each GrGLEffect's setData. It is called before a
* draw occurs using the program after the program has already been bound. It also uses the
- * GrGpuGL object to bind the textures required by the GrGLEffects.
+ * GrGpuGL object to bind the textures required by the GrGLEffects. The color and coverage
+ * stages come from GrGLProgramDesc::Build().
*/
void setData(GrGpuGL*,
GrDrawState::BlendOptFlags,
- const GrEffectStage* stages[], // output of GrGLProgramDesc:Build()
+ const GrEffectStage* colorStages[],
+ const GrEffectStage* coverageStages[],
const GrDeviceCoordTexture* dstCopy, // can be NULL
SharedGLState*);
private:
- GrGLProgram(const GrGLContext& gl,
- const GrGLProgramDesc& desc,
- const GrEffectStage* stages[]);
-
- bool succeeded() const { return 0 != fProgramID; }
-
- /**
- * This is the heavy initialization routine for building a GLProgram. stages is all the enabled
- * color stages followed by all the enabled coverage stages as output by
- * GrGLProgramDesc::Build()
- */
- bool genProgram(const GrEffectStage* stages[]);
-
- GrSLConstantVec genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
-
- GrSLConstantVec genInputCoverage(GrGLShaderBuilder* builder, SkString* inCoverage);
-
- void genGeometryShader(GrGLShaderBuilder* segments) const;
-
typedef GrGLUniformManager::UniformHandle UniformHandle;
- // Creates a GL program ID, binds shader attributes to GL vertex attrs, and links the program
- bool bindOutputsAttribsAndLinkProgram(const GrGLShaderBuilder& builder,
- bool bindColorOut,
- bool bindDualSrcOut);
-
- // Sets the texture units for samplers
- void initSamplerUniforms();
-
- bool compileShaders(const GrGLShaderBuilder& builder);
-
- const char* adjustInColor(const SkString& inColor) const;
-
- // Helper for setData(). Makes GL calls to specify the initial color when there is not
- // per-vertex colors.
- void setColor(const GrDrawState&, GrColor color, SharedGLState*);
-
- // Helper for setData(). Makes GL calls to specify the initial coverage when there is not
- // per-vertex coverages.
- void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*);
-
- // Helper for setData() that sets the view matrix and loads the render target height uniform
- void setMatrixAndRenderTargetHeight(const GrDrawState&);
-
// handles for uniforms (aside from per-effect samplers)
struct UniformHandles {
UniformHandle fViewMatrixUni;
@@ -195,6 +156,52 @@
TextureUnitSArray fTextureUnits; // texture unit used for each entry of fSamplerUnis
};
+ GrGLProgram(const GrGLContext& gl,
+ const GrGLProgramDesc& desc,
+ const GrEffectStage* colorStages[],
+ const GrEffectStage* coverageStages[]);
+
+ bool succeeded() const { return 0 != fProgramID; }
+
+ /**
+ * This is the heavy initialization routine for building a GLProgram. colorStages and
+ * coverageStages correspond to the output of GrGLProgramDesc::Build().
+ */
+ bool genProgram(const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[]);
+
+ GrSLConstantVec genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
+
+ GrSLConstantVec genInputCoverage(GrGLShaderBuilder* builder, SkString* inCoverage);
+
+ void genGeometryShader(GrGLShaderBuilder* segments) const;
+
+ // Creates a GL program ID, binds shader attributes to GL vertex attrs, and links the program
+ bool bindOutputsAttribsAndLinkProgram(const GrGLShaderBuilder& builder,
+ bool bindColorOut,
+ bool bindDualSrcOut);
+
+ // Sets the texture units for samplers
+ void initSamplerUniforms();
+ void initEffectSamplerUniforms(EffectAndSamplers* effect, int* texUnitIdx);
+
+ bool compileShaders(const GrGLShaderBuilder& builder);
+
+ const char* adjustInColor(const SkString& inColor) const;
+
+ // Helper for setData().
+ void setEffectData(GrGpuGL* gpu, const GrEffectStage& stage, const EffectAndSamplers& effect);
+
+ // Helper for setData(). Makes GL calls to specify the initial color when there is not
+ // per-vertex colors.
+ void setColor(const GrDrawState&, GrColor color, SharedGLState*);
+
+ // Helper for setData(). Makes GL calls to specify the initial coverage when there is not
+ // per-vertex coverages.
+ void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*);
+
+ // Helper for setData() that sets the view matrix and loads the render target height uniform
+ void setMatrixAndRenderTargetHeight(const GrDrawState&);
+
// GL IDs
GrGLuint fVShaderID;
GrGLuint fGShaderID;
@@ -208,7 +215,8 @@
GrColor fColorFilterColor;
int fDstCopyTexUnit;
- SkTArray<EffectAndSamplers> fEffectStates;
+ SkTArray<EffectAndSamplers> fColorEffects;
+ SkTArray<EffectAndSamplers> fCoverageEffects;
GrGLProgramDesc fDesc;
const GrGLContext& fContext;