Make fragment processor iterators work with range for loops.
When iterating over the coord transforms or texture samplers of a
FP also have access to the owning FP.
Pass a coord transform range to GPs rather than a pointer to an
iterator.
Change-Id: If7c829a67dce6600d7f49e12d6f49f685dcace3a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256216
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index a626f80..7914d77 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -84,8 +84,8 @@
// We must bind to texture units in the same order in which we set the uniforms in
// GrGLProgramDataManager. That is, we bind textures for processors in this order:
// primProc, fragProcs, XP.
- fPrimitiveProcessor->setData(fProgramDataManager, programInfo.primProc(),
- GrFragmentProcessor::CoordTransformIter(programInfo.pipeline()));
+ GrFragmentProcessor::PipelineCoordTransformRange range(programInfo.pipeline());
+ fPrimitiveProcessor->setData(fProgramDataManager, programInfo.primProc(), range);
if (programInfo.hasFixedPrimProcTextures()) {
this->updatePrimitiveProcessorTextureBindings(programInfo.primProc(),
programInfo.fixedPrimProcTextures());
@@ -118,21 +118,17 @@
}
void GrGLProgram::setFragmentData(const GrPipeline& pipeline, int* nextTexSamplerIdx) {
- GrFragmentProcessor::Iter iter(pipeline);
+ GrFragmentProcessor::Iter fpIter(pipeline);
GrGLSLFragmentProcessor::Iter glslIter(fFragmentProcessors.get(), fFragmentProcessorCnt);
- const GrFragmentProcessor* fp = iter.next();
- GrGLSLFragmentProcessor* glslFP = glslIter.next();
- while (fp && glslFP) {
- glslFP->setData(fProgramDataManager, *fp);
- for (int i = 0; i < fp->numTextureSamplers(); ++i) {
- const GrFragmentProcessor::TextureSampler& sampler = fp->textureSampler(i);
+ for (; fpIter && glslIter; ++fpIter, ++glslIter) {
+ glslIter->setData(fProgramDataManager, *fpIter);
+ for (int i = 0; i < fpIter->numTextureSamplers(); ++i) {
+ const GrFragmentProcessor::TextureSampler& sampler = fpIter->textureSampler(i);
fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(), sampler.swizzle(),
static_cast<GrGLTexture*>(sampler.peekTexture()));
}
- fp = iter.next();
- glslFP = glslIter.next();
}
- SkASSERT(!fp && !glslFP);
+ SkASSERT(!fpIter && !glslIter);
}
void GrGLProgram::setRenderTargetState(const GrRenderTarget* rt, GrSurfaceOrigin origin,