Minor geometry processor clarification.
Some renames, comments, and override->final
Change-Id: Iebc7aeee9a64021e958f76bf4278ffff56884a56
Reviewed-on: https://skia-review.googlesource.com/35165
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index 3ab5b68..a390036 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -85,19 +85,19 @@
SkASSERT(i == fInstalledTransforms.count());
}
-void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
- GrGPArgs* gpArgs,
- const char* posName) {
+void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
+ GrGPArgs* gpArgs,
+ const char* posName) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
}
-void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
- GrGLSLUniformHandler* uniformHandler,
- GrGPArgs* gpArgs,
- const char* posName,
- const SkMatrix& mat,
- UniformHandle* viewMatrixUniform) {
+void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
+ GrGLSLUniformHandler* uniformHandler,
+ GrGPArgs* gpArgs,
+ const char* posName,
+ const SkMatrix& mat,
+ UniformHandle* viewMatrixUniform) {
if (mat.isIdentity()) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.h b/src/gpu/glsl/GrGLSLGeometryProcessor.h
index 10a4aa8..17a6779 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.h
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.h
@@ -20,10 +20,10 @@
class GrGLSLGeometryProcessor : public GrGLSLPrimitiveProcessor {
public:
/* Any general emit code goes in the base class emitCode. Subclasses override onEmitCode */
- void emitCode(EmitArgs&) override;
+ void emitCode(EmitArgs&) final;
protected:
- // A helper which subclasses can use if needed and used above in the default setTransformData().
+ // A helper which subclasses can use to upload coord transform matrices in setData().
void setTransformDataHelper(const SkMatrix& localMatrix,
const GrGLSLProgramDataManager& pdman,
FPCoordTransformIter*);
@@ -39,7 +39,7 @@
posVar, localCoords, SkMatrix::I(), handler);
}
- // Emit pre-transformed coords as a vertex attribute per coord-transform.
+ // Emit pre-transformed coords as a varying per coord-transform.
void emitTransforms(GrGLSLVertexBuilder*,
GrGLSLVaryingHandler*,
GrGLSLUniformHandler*,
@@ -49,19 +49,25 @@
FPCoordTransformHandler*);
struct GrGPArgs {
- // The variable used by a GP to store its position. It can be
- // either a float2 or a float3 depending on the presence of perspective.
+ // Used to specify the output variable used by the GP to store its device position. It can
+ // either be a float2 or a float3 (in order to handle perspective). The subclass sets this
+ // in its onEmitCode().
GrShaderVar fPositionVar;
};
- // Create the correct type of position variable given the CTM
- void setupPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
- void setupPosition(GrGLSLVertexBuilder*,
- GrGLSLUniformHandler* uniformHandler,
- GrGPArgs*,
- const char* posName,
- const SkMatrix& mat,
- UniformHandle* viewMatrixUniform);
+ // Helpers for adding code to write the transformed vertex position. The first simple version
+ // just writes a variable named by 'posName' into the position output variable with the
+ // assumption that the position is 2D. The second version transforms the input position by a
+ // view matrix and the output variable is 2D or 3D depending on whether the view matrix is
+ // perspective. Both versions declare the output position variable and will set
+ // GrGPArgs::fPositionVar.
+ void writeOutputPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
+ void writeOutputPosition(GrGLSLVertexBuilder*,
+ GrGLSLUniformHandler* uniformHandler,
+ GrGPArgs*,
+ const char* posName,
+ const SkMatrix& mat,
+ UniformHandle* viewMatrixUniform);
static uint32_t ComputePosKey(const SkMatrix& mat) {
if (mat.isIdentity()) {