Pass GrCustomStage to key-generation functions and emitCode().
R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6819046
git-svn-id: http://skia.googlecode.com/svn/branches/gpu_dev@6182 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index ba36abe..6d6110d 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -33,7 +33,7 @@
}
GrGLProgram* GrGpuGL::ProgramCache::getProgram(const ProgramDesc& desc,
- const GrEffect** stages) {
+ const GrEffectStage* stages[]) {
Entry newEntry;
newEntry.fKey.setKeyData(desc.asKey());
@@ -345,11 +345,14 @@
return false;
}
- const GrEffect* effects[GrDrawState::kNumStages];
+ const GrEffectStage* stages[GrDrawState::kNumStages];
+ for (int i = 0; i < GrDrawState::kNumStages; ++i) {
+ stages[i] = drawState.isStageEnabled(i) ? &drawState.getStage(i) : NULL;
+ }
GrGLProgram::Desc desc;
- this->buildProgram(kDrawPoints_DrawType == type, blendOpts, dstCoeff, effects, &desc);
+ this->buildProgram(kDrawPoints_DrawType == type, blendOpts, dstCoeff, &desc);
- fCurrentProgram.reset(fProgramCache->getProgram(desc, effects));
+ fCurrentProgram.reset(fProgramCache->getProgram(desc, stages));
if (NULL == fCurrentProgram.get()) {
GrAssert(!"Failed to create program!");
return false;
@@ -558,30 +561,9 @@
fHWGeometryState.fArrayPtrsDirty = false;
}
-namespace {
-
-void setup_effect(GrGLProgram::Desc::StageDesc* stageDesc,
- const GrEffectStage& stage,
- const GrGLCaps& caps,
- const GrEffect** effects,
- GrGLProgram* program, int index) {
- const GrEffect* effect = stage.getEffect();
- if (effect) {
- const GrBackendEffectFactory& factory = effect->getFactory();
- stageDesc->fEffectKey = factory.glEffectKey(*effect, caps);
- effects[index] = effect;
- } else {
- stageDesc->fEffectKey = 0;
- effects[index] = NULL;
- }
-}
-
-}
-
void GrGpuGL::buildProgram(bool isPoints,
BlendOptFlags blendOpts,
GrBlendCoeff dstCoeff,
- const GrEffect** effects,
ProgramDesc* desc) {
const GrDrawState& drawState = this->getDrawState();
@@ -687,12 +669,11 @@
// This will go away when effects manage their own texture matrix.
stageDesc.fOptFlags |= StageDesc::kIdentityMatrix_OptFlagBit;
}
- setup_effect(&stageDesc, stage, this->glCaps(), effects, fCurrentProgram.get(), s);
-
+ const GrBackendEffectFactory& factory = effect->getFactory();
+ stageDesc.fEffectKey = factory.glEffectKey(stage, this->glCaps());
} else {
stageDesc.fOptFlags = 0;
stageDesc.fEffectKey = 0;
- effects[s] = NULL;
}
}