Index: src/gpu/gl/GrGLProgram.cpp |
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp |
index e0d4939323b0f2438944fcaad78712d7b6120d63..e49016e2f215db7ed36f50abffd7e8b786098732 100644 |
--- a/src/gpu/gl/GrGLProgram.cpp |
+++ b/src/gpu/gl/GrGLProgram.cpp |
@@ -24,7 +24,7 @@ |
/** |
* Retrieves the final matrix that a transform needs to apply to its source coords. |
*/ |
-static SkMatrix get_transform_matrix(const GrProcessorStage& processorStage, |
+static SkMatrix get_transform_matrix(const GrFragmentStage& processorStage, |
bool useExplicitLocalCoords, |
int transformIdx) { |
const GrCoordTransform& coordTransform = |
@@ -114,10 +114,10 @@ void GrGLProgram::initSamplers(GrGLInstalledProcessors* ip, int* texUnitIdx) { |
} |
} |
-void GrGLProgram::bindTextures(const GrGLInstalledProcessors* ip, |
+void GrGLProgram::bindTextures(const GrGLInstalledProcessors& ip, |
const GrProcessor& processor, |
int effectIdx) { |
- const SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip->fSamplers[effectIdx]; |
+ const SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip.fSamplers[effectIdx]; |
int numSamplers = samplers.count(); |
SkASSERT(numSamplers == processor.numTextures()); |
for (int s = 0; s < numSamplers; ++s) { |
@@ -132,11 +132,20 @@ void GrGLProgram::bindTextures(const GrGLInstalledProcessors* ip, |
/////////////////////////////////////////////////////////////////////////////// |
+struct ColorStageMapper { |
+ static const GrFragmentStage& GetStage(const GrOptDrawState& optState, int index) { |
+ return optState.getColorStage(index); |
+ } |
+}; |
+ |
+struct CoverageStageMapper { |
+ static const GrFragmentStage& GetStage(const GrOptDrawState& optState, int index) { |
+ return optState.getCoverageStage(index); |
+ } |
+}; |
+ |
void GrGLProgram::setData(const GrOptDrawState& optState, |
GrGpu::DrawType drawType, |
- const GrGeometryStage* geometryProcessor, |
- const GrFragmentStage* colorStages[], |
- const GrFragmentStage* coverageStages[], |
const GrDeviceCoordTexture* dstCopy, |
SharedGLState* sharedState) { |
GrColor color = optState.getColor(); |
@@ -170,17 +179,23 @@ void GrGLProgram::setData(const GrOptDrawState& optState, |
// we set the textures, and uniforms for installed processors in a generic way, but subclasses |
// of GLProgram determine how to set coord transforms |
if (fGeometryProcessor.get()) { |
- SkASSERT(geometryProcessor); |
- this->setData<GrGeometryStage>(&geometryProcessor, fGeometryProcessor.get()); |
+ SkASSERT(optState.hasGeometryProcessor()); |
bsalomon
2014/10/09 18:35:45
Something feels off here... all these asserts make
|
+ const GrGLInstalledProcessors& ip = *fGeometryProcessor.get(); |
+ SkASSERT(1 == ip.fGLProcessors.count()); |
+ // GPs do not have coord transforms |
+ SkASSERT(0 == ip.fTransforms.count()); |
+ SkASSERT(1 == ip.fSamplers.count()); |
+ ip.fGLProcessors[0]->setData(fProgramDataManager, *optState.getGeometryProcessor()); |
+ this->bindTextures(ip, *optState.getGeometryProcessor(), 0); |
} |
- this->setData<GrFragmentStage>(colorStages, fColorEffects.get()); |
- this->setData<GrFragmentStage>(coverageStages, fCoverageEffects.get()); |
+ this->setData<ColorStageMapper>(optState, fColorEffects.get()); |
+ this->setData<CoverageStageMapper>(optState, fCoverageEffects.get()); |
// Some of GrGLProgram subclasses need to update state here |
this->didSetData(drawType); |
} |
-void GrGLProgram::setTransformData(const GrProcessorStage& processor, |
+void GrGLProgram::setTransformData(const GrFragmentStage& processor, |
int effectIdx, |
GrGLInstalledProcessors* ip) { |
SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransforms[effectIdx]; |
@@ -365,7 +380,7 @@ void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) { |
SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); |
} |
-void GrGLNvprProgram::setTransformData(const GrProcessorStage& processor, |
+void GrGLNvprProgram::setTransformData(const GrFragmentStage& processor, |
int effectIdx, |
GrGLInstalledProcessors* ip) { |
SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransforms[effectIdx]; |
@@ -409,7 +424,7 @@ void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) { |
fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); |
} |
-void GrGLLegacyNvprProgram::setTransformData(const GrProcessorStage& processorStage, |
+void GrGLLegacyNvprProgram::setTransformData(const GrFragmentStage& processorStage, |
int effectIdx, |
GrGLInstalledProcessors* ip) { |
// We've hidden the texcoord index in the first entry of the transforms array for each effect |