Fix latent bug in fragmentProcessorHasCoordsParam.
Previously, if you passed in a GrFragmentProcessor which didn't
exist in the map, you would get `false` indicating that the
coordinate parameter had been lifted, and an extra entry would be
inadvertently added to the FPCoordsMap.
In practice, I don't think this actually gets called with
unexpected GrFragmentProcessors so we wouldn't have run into
any issues.
Change-Id: I1ace289ada313be326d88feea56dcd333e3c2953
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/761597
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.cpp
index 3c200b2..a9dd893 100644
--- a/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.cpp
@@ -503,8 +503,10 @@
nullptr);
}
-bool GrGLSLProgramBuilder::fragmentProcessorHasCoordsParam(const GrFragmentProcessor* fp) {
- return fFPCoordsMap[fp].hasCoordsParam;
+bool GrGLSLProgramBuilder::fragmentProcessorHasCoordsParam(const GrFragmentProcessor* fp) const {
+ auto iter = fFPCoordsMap.find(fp);
+ return (iter != fFPCoordsMap.end()) ? iter->second.hasCoordsParam
+ : fp->usesSampleCoords();
}
void GrGLSLProgramBuilder::finalizeShaders() {
diff --git a/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h b/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h
index c5feeeb..1c02286 100644
--- a/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h
@@ -89,7 +89,7 @@
* If the FP's coords are unused or all uses have been lifted to interpolated varyings then
* don't put coords in the FP's function signature or call sites.
*/
- bool fragmentProcessorHasCoordsParam(const GrFragmentProcessor*);
+ bool fragmentProcessorHasCoordsParam(const GrFragmentProcessor*) const;
virtual GrGLSLUniformHandler* uniformHandler() = 0;
virtual const GrGLSLUniformHandler* uniformHandler() const = 0;