Make GrPrimitiveProcessor::Attribute a class, hide data members.

Change-Id: I008881d79c82fdde6bb68fe2218e62ccc9c538dd
Reviewed-on: https://skia-review.googlesource.com/130600
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index d7a5ea5..1448aec 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -86,7 +86,7 @@
                 varyingHandler->addVarying("color", &varying);
 
                 // There are several optional steps to process the color. Start with the attribute:
-                vertBuilder->codeAppendf("half4 color = %s;", gp.inColor()->fName);
+                vertBuilder->codeAppendf("half4 color = %s;", gp.inColor()->name());
 
                 // Linearize
                 if (gp.linearizeColor()) {
@@ -102,10 +102,10 @@
                                               ": pow((x + 0.055) / 1.055, 2.4);",
                                               &srgbFuncName);
                     vertBuilder->codeAppendf("color = half4(%s(%s.r), %s(%s.g), %s(%s.b), %s.a);",
-                                             srgbFuncName.c_str(), gp.inColor()->fName,
-                                             srgbFuncName.c_str(), gp.inColor()->fName,
-                                             srgbFuncName.c_str(), gp.inColor()->fName,
-                                             gp.inColor()->fName);
+                                             srgbFuncName.c_str(), gp.inColor()->name(),
+                                             srgbFuncName.c_str(), gp.inColor()->name(),
+                                             srgbFuncName.c_str(), gp.inColor()->name(),
+                                             gp.inColor()->name());
                 }
 
                 // For SkColor, do a red/blue swap and premul
@@ -135,7 +135,7 @@
             this->writeOutputPosition(vertBuilder,
                                       uniformHandler,
                                       gpArgs,
-                                      gp.inPosition()->fName,
+                                      gp.inPosition()->name(),
                                       gp.viewMatrix(),
                                       &fViewMatrixUniform);
 
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index d9852c0..4da4ee3 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -40,23 +40,33 @@
  */
 class GrPrimitiveProcessor : public GrResourceIOProcessor, public GrProgramElement {
 public:
-    struct Attribute {
+    class Attribute {
+    public:
         enum class InputRate : bool {
             kPerVertex,
             kPerInstance
         };
-        GrShaderVar asShaderVar() const {
-            return GrShaderVar(fName, GrVertexAttribTypeToSLType(fType),
-                               GrShaderVar::kIn_TypeModifier);
-        }
-        bool isInitialized() const { return SkToBool(fName); }
-        Attribute() = default;
-        Attribute(const char* name, GrVertexAttribType type, int offset, InputRate rate)
+
+        constexpr Attribute() = default;
+        constexpr Attribute(const char* name, GrVertexAttribType type, int offset, InputRate rate)
                 : fName(name), fType(type), fOffsetInRecord(offset), fInputRate(rate) {}
-        const char*          fName = nullptr;
-        GrVertexAttribType   fType;
-        int                  fOffsetInRecord;
-        InputRate            fInputRate;
+
+        bool isInitialized() const { return SkToBool(fName); }
+
+        const char* name() const { return fName; }
+        GrVertexAttribType type() const { return fType; }
+        int offsetInRecord() const { return fOffsetInRecord; }
+        InputRate inputRate() const { return fInputRate; }
+
+        GrShaderVar asShaderVar() const {
+            return {fName, GrVertexAttribTypeToSLType(fType), GrShaderVar::kIn_TypeModifier};
+        }
+
+    private:
+        const char* fName = nullptr;
+        GrVertexAttribType fType = kFloat_GrVertexAttribType;
+        int fOffsetInRecord = 0;
+        InputRate fInputRate = InputRate::kPerVertex;
     };
 
     GrPrimitiveProcessor(ClassID classID)
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
index 61bb4ec..aa7a8db 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
@@ -32,8 +32,8 @@
 
         // The vertex shader simply forwards transposed x or y values to the geometry shader.
         SkASSERT(1 == proc.numAttribs());
-        gpArgs->fPositionVar.set(GrVertexAttribTypeToSLType(proc.getAttrib(0).fType),
-                                 proc.getAttrib(0).fName);
+        gpArgs->fPositionVar.set(GrVertexAttribTypeToSLType(proc.getAttrib(0).type()),
+                                 proc.getAttrib(0).name());
 
         // Geometry shader.
         GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
@@ -62,7 +62,7 @@
         Shader::CalcWind(proc, g, "pts", wind.c_str());
         if (PrimitiveType::kWeightedTriangles == proc.fPrimitiveType) {
             SkASSERT(3 == numInputPoints);
-            SkASSERT(kFloat4_GrVertexAttribType == proc.getAttrib(0).fType);
+            SkASSERT(kFloat4_GrVertexAttribType == proc.getAttrib(0).type());
             g->codeAppendf("%s *= sk_in[0].sk_Position.w;", wind.c_str());
         }
 
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
index 08b8886..ef2bcd3 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
@@ -259,16 +259,16 @@
 
     int inputWidth = (4 == numInputPoints || proc.hasInputWeight()) ? 4 : 3;
     const char* swizzle = (4 == inputWidth) ? "xyzw" : "xyz";
-    v->codeAppendf("float%ix2 pts = transpose(float2x%i(%s.%s, %s.%s));",
-                   inputWidth, inputWidth, proc.getAttrib(kAttribIdx_X).fName, swizzle,
-                   proc.getAttrib(kAttribIdx_Y).fName, swizzle);
+    v->codeAppendf("float%ix2 pts = transpose(float2x%i(%s.%s, %s.%s));", inputWidth, inputWidth,
+                   proc.getAttrib(kAttribIdx_X).name(), swizzle,
+                   proc.getAttrib(kAttribIdx_Y).name(), swizzle);
 
     v->codeAppend ("half wind;");
     Shader::CalcWind(proc, v, "pts", "wind");
     if (PrimitiveType::kWeightedTriangles == proc.fPrimitiveType) {
         SkASSERT(3 == numInputPoints);
-        SkASSERT(kFloat4_GrVertexAttribType == proc.getAttrib(kAttribIdx_X).fType);
-        v->codeAppendf("wind *= %s.w;", proc.getAttrib(kAttribIdx_X).fName);
+        SkASSERT(kFloat4_GrVertexAttribType == proc.getAttrib(kAttribIdx_X).type());
+        v->codeAppendf("wind *= %s.w;", proc.getAttrib(kAttribIdx_X).name());
     }
 
     float bloat = kAABloatRadius;
@@ -284,12 +284,12 @@
 
     // Reverse all indices if the wind is counter-clockwise: [0, 1, 2] -> [2, 1, 0].
     v->codeAppendf("int clockwise_indices = wind > 0 ? %s : 0x%x - %s;",
-                   proc.getAttrib(kAttribIdx_VertexData).fName,
+                   proc.getAttrib(kAttribIdx_VertexData).name(),
                    ((fNumSides - 1) << kVertexData_LeftNeighborIdShift) |
                    ((fNumSides - 1) << kVertexData_RightNeighborIdShift) |
                    (((1 << kVertexData_RightNeighborIdShift) - 1) ^ 3) |
                    (fNumSides - 1),
-                   proc.getAttrib(kAttribIdx_VertexData).fName);
+                   proc.getAttrib(kAttribIdx_VertexData).name());
 
     // Here we generate conservative raster geometry for the input polygon. It is the convex
     // hull of N pixel-size boxes, one centered on each the input points. Each corner has three
@@ -321,8 +321,8 @@
     v->codeAppend ("float2 rightdir = right - corner;");
     v->codeAppend ("rightdir = (float2(0) != rightdir) ? normalize(rightdir) : float2(1, 0);");
 
-    v->codeAppendf("if (0 != (%s & %i)) {", // Are we a corner?
-                   proc.getAttrib(kAttribIdx_VertexData).fName, kVertexData_IsCornerBit);
+    v->codeAppendf("if (0 != (%s & %i)) {",  // Are we a corner?
+                   proc.getAttrib(kAttribIdx_VertexData).name(), kVertexData_IsCornerBit);
 
                        // In corner boxes, all 4 coverage values will not map linearly.
                        // Therefore it is important to align the box so its diagonal shared
@@ -341,8 +341,8 @@
     // continue rotating 90 degrees clockwise until we reach the desired raster vertex for this
     // invocation. Corners with less than 3 corresponding raster vertices will result in
     // redundant vertices and degenerate triangles.
-    v->codeAppendf("int bloatidx = (%s >> %i) & 3;",
-                   proc.getAttrib(kAttribIdx_VertexData).fName, kVertexData_BloatIdxShift);
+    v->codeAppendf("int bloatidx = (%s >> %i) & 3;", proc.getAttrib(kAttribIdx_VertexData).name(),
+                   kVertexData_BloatIdxShift);
     v->codeAppend ("switch (bloatidx) {");
     v->codeAppend (    "case 3:");
                             // Only corners will have bloatidx=3, and corners always rotate.
@@ -375,13 +375,13 @@
         Shader::CalcEdgeCoverageAtBloatVertex(v, "corner", "right", "bloatdir", "right_coverage");
         v->codeAppend ("}");
 
-        v->codeAppendf("if (0 != (%s & %i)) {", // Are we an edge?
-                       proc.getAttrib(kAttribIdx_VertexData).fName, kVertexData_IsEdgeBit);
+        v->codeAppendf("if (0 != (%s & %i)) {",  // Are we an edge?
+                       proc.getAttrib(kAttribIdx_VertexData).name(), kVertexData_IsEdgeBit);
         v->codeAppend (    "coverage = left_coverage;");
         v->codeAppend ("}");
 
-        v->codeAppendf("if (0 != (%s & %i)) {", // Invert coverage?
-                       proc.getAttrib(kAttribIdx_VertexData).fName,
+        v->codeAppendf("if (0 != (%s & %i)) {",  // Invert coverage?
+                       proc.getAttrib(kAttribIdx_VertexData).name(),
                        kVertexData_InvertNegativeCoverageBit);
         v->codeAppend (    "coverage = -1 - coverage;");
         v->codeAppend ("}");
@@ -390,8 +390,8 @@
     // Non-corner geometry should have zero effect from corner coverage.
     v->codeAppend ("half2 corner_coverage = half2(0);");
 
-    v->codeAppendf("if (0 != (%s & %i)) {", // Are we a corner?
-                   proc.getAttrib(kAttribIdx_VertexData).fName, kVertexData_IsCornerBit);
+    v->codeAppendf("if (0 != (%s & %i)) {",  // Are we a corner?
+                   proc.getAttrib(kAttribIdx_VertexData).name(), kVertexData_IsCornerBit);
                        // We use coverage=-1 to erase what the hull geometry wrote.
                        //
                        // In the context of curves, this effectively means "wind = -wind" and
@@ -502,8 +502,8 @@
         SkASSERT(kAttribIdx_Y == this->numAttribs());
         this->addInstanceAttrib("Y", kFloat4_GrVertexAttribType);
 
-        SkASSERT(offsetof(QuadPointInstance, fX) == this->getAttrib(kAttribIdx_X).fOffsetInRecord);
-        SkASSERT(offsetof(QuadPointInstance, fY) == this->getAttrib(kAttribIdx_Y).fOffsetInRecord);
+        SkASSERT(offsetof(QuadPointInstance, fX) == this->getAttrib(kAttribIdx_X).offsetInRecord());
+        SkASSERT(offsetof(QuadPointInstance, fY) == this->getAttrib(kAttribIdx_Y).offsetInRecord());
         SkASSERT(sizeof(QuadPointInstance) == this->getInstanceStride());
     } else {
         SkASSERT(kAttribIdx_X == this->numAttribs());
@@ -512,8 +512,8 @@
         SkASSERT(kAttribIdx_Y == this->numAttribs());
         this->addInstanceAttrib("Y", kFloat3_GrVertexAttribType);
 
-        SkASSERT(offsetof(TriPointInstance, fX) == this->getAttrib(kAttribIdx_X).fOffsetInRecord);
-        SkASSERT(offsetof(TriPointInstance, fY) == this->getAttrib(kAttribIdx_Y).fOffsetInRecord);
+        SkASSERT(offsetof(TriPointInstance, fX) == this->getAttrib(kAttribIdx_X).offsetInRecord());
+        SkASSERT(offsetof(TriPointInstance, fY) == this->getAttrib(kAttribIdx_Y).offsetInRecord());
         SkASSERT(sizeof(TriPointInstance) == this->getInstanceStride());
     }
 
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index de52726..bbc2b81 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -87,13 +87,13 @@
     this->addInstanceAttrib("color", kUByte4_norm_GrVertexAttribType);
 
     SkASSERT(offsetof(Instance, fDevBounds) ==
-             this->getInstanceAttrib(InstanceAttribs::kDevBounds).fOffsetInRecord);
+             this->getInstanceAttrib(InstanceAttribs::kDevBounds).offsetInRecord());
     SkASSERT(offsetof(Instance, fDevBounds45) ==
-             this->getInstanceAttrib(InstanceAttribs::kDevBounds45).fOffsetInRecord);
+             this->getInstanceAttrib(InstanceAttribs::kDevBounds45).offsetInRecord());
     SkASSERT(offsetof(Instance, fAtlasOffset) ==
-             this->getInstanceAttrib(InstanceAttribs::kAtlasOffset).fOffsetInRecord);
+             this->getInstanceAttrib(InstanceAttribs::kAtlasOffset).offsetInRecord());
     SkASSERT(offsetof(Instance, fColor) ==
-             this->getInstanceAttrib(InstanceAttribs::kColor).fOffsetInRecord);
+             this->getInstanceAttrib(InstanceAttribs::kColor).offsetInRecord());
     SkASSERT(sizeof(Instance) == this->getInstanceStride());
 
     GR_STATIC_ASSERT(4 == kNumInstanceAttribs);
@@ -183,13 +183,13 @@
     //
     // NOTE: "float2x2(float4)" is valid and equivalent to "float2x2(float4.xy, float4.zw)",
     // however Intel compilers crash when we use the former syntax in this shader.
-    v->codeAppendf("float2x2 N = float2x2(%s.xy, %s.zw);",
-                   proc.getEdgeNormsAttrib().fName, proc.getEdgeNormsAttrib().fName);
+    v->codeAppendf("float2x2 N = float2x2(%s.xy, %s.zw);", proc.getEdgeNormsAttrib().name(),
+                   proc.getEdgeNormsAttrib().name());
 
     // N[0] is the normal for the edge we are intersecting from the regular bounding box, pointing
     // out of the octagon.
     v->codeAppendf("float4 devbounds = %s;",
-                   proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName);
+                   proc.getInstanceAttrib(InstanceAttribs::kDevBounds).name());
     v->codeAppend ("float2 refpt = (0 == sk_VertexID >> 2)"
                            "? float2(min(devbounds.x, devbounds.z), devbounds.y)"
                            ": float2(max(devbounds.x, devbounds.z), devbounds.w);");
@@ -198,8 +198,8 @@
     // N[1] is the normal for the edge we are intersecting from the 45-degree bounding box, pointing
     // out of the octagon.
     v->codeAppendf("float2 refpt45 = (0 == ((sk_VertexID + 1) & (1 << 2))) ? %s.xy : %s.zw;",
-                   proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName,
-                   proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName);
+                   proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).name(),
+                   proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).name());
     v->codeAppendf("refpt45 *= float2x2(.5,.5,-.5,.5);"); // transform back to device space.
     v->codeAppendf("refpt45 += N[1] * %f;", kAABloatRadius); // bloat for AA.
 
@@ -210,7 +210,7 @@
 
     // Convert to atlas coordinates in order to do our texture lookup.
     v->codeAppendf("float2 atlascoord = octocoord + float2(%s);",
-                   proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
+                   proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).name());
     if (kTopLeft_GrSurfaceOrigin == proc.atlasProxy()->origin()) {
         v->codeAppendf("%s.xy = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
     } else {
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h
index 198bc60..9d97bad 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPathProcessor.h
@@ -62,13 +62,13 @@
     const SkMatrix& localMatrix() const { return fLocalMatrix; }
     const Attribute& getInstanceAttrib(InstanceAttribs attribID) const {
         const Attribute& attrib = this->getAttrib((int)attribID);
-        SkASSERT(Attribute::InputRate::kPerInstance == attrib.fInputRate);
+        SkASSERT(Attribute::InputRate::kPerInstance == attrib.inputRate());
         return attrib;
     }
     const Attribute& getEdgeNormsAttrib() const {
         SkASSERT(1 + kNumInstanceAttribs == this->numAttribs());
         const Attribute& attrib = this->getAttrib(kNumInstanceAttribs);
-        SkASSERT(Attribute::InputRate::kPerVertex == attrib.fInputRate);
+        SkASSERT(Attribute::InputRate::kPerVertex == attrib.inputRate());
         return attrib;
     }
 
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 3fb9012..3dee2f4 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -79,7 +79,7 @@
 
     GrGLSLVarying v(kFloat4_GrSLType);
     varyingHandler->addVarying("ConicCoeffs", &v);
-    vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
+    vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->name());
 
     GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
     // Setup pass through color
@@ -89,7 +89,7 @@
     this->writeOutputPosition(vertBuilder,
                               uniformHandler,
                               gpArgs,
-                              gp.inPosition()->fName,
+                              gp.inPosition()->name(),
                               gp.viewMatrix(),
                               &fViewMatrixUniform);
 
@@ -331,7 +331,7 @@
 
     GrGLSLVarying v(kHalf4_GrSLType);
     varyingHandler->addVarying("HairQuadEdge", &v);
-    vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
+    vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->name());
 
     GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
     // Setup pass through color
@@ -341,7 +341,7 @@
     this->writeOutputPosition(vertBuilder,
                               uniformHandler,
                               gpArgs,
-                              gp.inPosition()->fName,
+                              gp.inPosition()->name(),
                               gp.viewMatrix(),
                               &fViewMatrixUniform);
 
@@ -544,7 +544,7 @@
     this->writeOutputPosition(vertBuilder,
                               uniformHandler,
                               gpArgs,
-                              gp.inPosition()->fName,
+                              gp.inPosition()->name(),
                               gp.viewMatrix(),
                               &fViewMatrixUniform);
 
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 116e223..4089555 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -40,8 +40,8 @@
         GrGLSLVarying uv(kFloat2_GrSLType);
         GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
         GrGLSLVarying texIdx(texIdxType);
-        append_index_uv_varyings(args, btgp.inTextureCoords()->fName, atlasSizeInvName,
-                                 &uv, &texIdx, nullptr);
+        append_index_uv_varyings(args, btgp.inTextureCoords()->name(), atlasSizeInvName, &uv,
+                                 &texIdx, nullptr);
 
         GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
         // Setup pass through color
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 92a53bf..5ac7398 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -69,8 +69,8 @@
         GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
         GrGLSLVarying texIdx(texIdxType);
         GrGLSLVarying st(kFloat2_GrSLType);
-        append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
-                                 &uv, &texIdx, &st);
+        append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->name(), atlasSizeInvName, &uv,
+                                 &texIdx, &st);
 
         bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
                               kUniformScale_DistanceFieldEffectMask;
@@ -337,8 +337,8 @@
         GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
         GrGLSLVarying texIdx(texIdxType);
         GrGLSLVarying st(kFloat2_GrSLType);
-        append_index_uv_varyings(args, dfPathEffect.inTextureCoords()->fName, atlasSizeInvName, &uv,
-                                 &texIdx, &st);
+        append_index_uv_varyings(args, dfPathEffect.inTextureCoords()->name(), atlasSizeInvName,
+                                 &uv, &texIdx, &st);
 
         // setup pass through color
         varyingHandler->addPassThroughAttribute(dfPathEffect.inColor(), args.fOutputColor);
@@ -348,7 +348,7 @@
             this->writeOutputPosition(vertBuilder,
                                       uniformHandler,
                                       gpArgs,
-                                      dfPathEffect.inPosition()->fName,
+                                      dfPathEffect.inPosition()->name(),
                                       dfPathEffect.matrix(),
                                       &fMatrixUniform);
 
@@ -360,7 +360,7 @@
                                  args.fFPCoordTransformHandler);
         } else {
             // Setup position
-            this->writeOutputPosition(vertBuilder, gpArgs, dfPathEffect.inPosition()->fName);
+            this->writeOutputPosition(vertBuilder, gpArgs, dfPathEffect.inPosition()->name());
 
             // emit transforms
             this->emitTransforms(vertBuilder,
@@ -629,8 +629,8 @@
         GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
         GrGLSLVarying texIdx(texIdxType);
         GrGLSLVarying st(kFloat2_GrSLType);
-        append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
-                                 &uv, &texIdx, &st);
+        append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->name(), atlasSizeInvName, &uv,
+                                 &texIdx, &st);
 
         GrGLSLVarying delta(kFloat_GrSLType);
         varyingHandler->addVarying("Delta", &delta);
diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp
index 7eddaa4..52bf287 100644
--- a/src/gpu/effects/GrShadowGeoProc.cpp
+++ b/src/gpu/effects/GrShadowGeoProc.cpp
@@ -33,7 +33,7 @@
         varyingHandler->addPassThroughAttribute(rsgp.inColor(), args.fOutputColor);
 
         // Setup position
-        this->writeOutputPosition(vertBuilder, gpArgs, rsgp.inPosition()->fName);
+        this->writeOutputPosition(vertBuilder, gpArgs, rsgp.inPosition()->name());
 
         // emit transforms
         this->emitTransforms(vertBuilder,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 36f7ed5..5bfe2e5 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1889,10 +1889,10 @@
     for (int i = 0; i < numAttribs; ++i) {
         using InputRate = GrPrimitiveProcessor::Attribute::InputRate;
         const GrGeometryProcessor::Attribute& attrib = primProc.getAttrib(i);
-        const int divisor = InputRate::kPerInstance == attrib.fInputRate ? 1 : 0;
+        const int divisor = InputRate::kPerInstance == attrib.inputRate() ? 1 : 0;
         const auto& binding = bindings[divisor];
-        attribState->set(this, i, binding.fBuffer, attrib.fType, binding.fStride,
-                         binding.fBufferOffset + attrib.fOffsetInRecord, divisor);
+        attribState->set(this, i, binding.fBuffer, attrib.type(), binding.fStride,
+                         binding.fBufferOffset + attrib.offsetInRecord(), divisor);
     }
 }
 
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index dd982b9..4ffc1ec 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -225,7 +225,7 @@
         if (!useNvpr) {
             int vaCount = primProc.numAttribs();
             for (int i = 0; i < vaCount; i++) {
-                GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName));
+                GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).name()));
             }
         }
 
diff --git a/src/gpu/glsl/GrGLSLVarying.cpp b/src/gpu/glsl/GrGLSLVarying.cpp
index c5cef34..f8ec1c2 100644
--- a/src/gpu/glsl/GrGLSLVarying.cpp
+++ b/src/gpu/glsl/GrGLSLVarying.cpp
@@ -13,10 +13,10 @@
                                                    const char* output,
                                                    Interpolation interpolation) {
     SkASSERT(!fProgramBuilder->primitiveProcessor().willUseGeoShader());
-    GrSLType type = GrVertexAttribTypeToSLType(input->fType);
+    GrSLType type = GrVertexAttribTypeToSLType(input->type());
     GrGLSLVarying v(type);
-    this->addVarying(input->fName, &v, interpolation);
-    fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input->fName);
+    this->addVarying(input->name(), &v, interpolation);
+    fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input->name());
     fProgramBuilder->fFS.codeAppendf("%s = %s;", output, v.fsIn());
 }
 
@@ -70,10 +70,7 @@
     int vaCount = gp.numAttribs();
     for (int i = 0; i < vaCount; i++) {
         const GrGeometryProcessor::Attribute& attr = gp.getAttrib(i);
-        this->addAttribute(GrShaderVar(attr.fName,
-                                       GrVertexAttribTypeToSLType(attr.fType),
-                                       GrShaderVar::kIn_TypeModifier,
-                                       GrShaderVar::kNonArray));
+        this->addAttribute(attr.asShaderVar());
     }
 }
 
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 9803ff0..a1d7392 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -570,7 +570,7 @@
 
             GrGLSLVarying v(kHalf4_GrSLType);
             varyingHandler->addVarying("QuadEdge", &v);
-            vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.fInQuadEdge->fName);
+            vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.fInQuadEdge->name());
 
             // Setup pass through color
             varyingHandler->addPassThroughAttribute(qe.fInColor, args.fOutputColor);
@@ -578,7 +578,7 @@
             GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
 
             // Setup position
-            this->writeOutputPosition(vertBuilder, gpArgs, qe.fInPosition->fName);
+            this->writeOutputPosition(vertBuilder, gpArgs, qe.fInPosition->name());
 
             // emit transforms
             this->emitTransforms(vertBuilder,
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index fb559bb..ed2a847 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -912,19 +912,19 @@
     // XY are dashPos, Z is dashInterval
     GrGLSLVarying dashParams(kHalf3_GrSLType);
     varyingHandler->addVarying("DashParam", &dashParams);
-    vertBuilder->codeAppendf("%s = %s;", dashParams.vsOut(), dce.inDashParams()->fName);
+    vertBuilder->codeAppendf("%s = %s;", dashParams.vsOut(), dce.inDashParams()->name());
 
     // x refers to circle radius - 0.5, y refers to cicle's center x coord
     GrGLSLVarying circleParams(kHalf2_GrSLType);
     varyingHandler->addVarying("CircleParams", &circleParams);
-    vertBuilder->codeAppendf("%s = %s;", circleParams.vsOut(), dce.inCircleParams()->fName);
+    vertBuilder->codeAppendf("%s = %s;", circleParams.vsOut(), dce.inCircleParams()->name());
 
     GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
     // Setup pass through color
     this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
 
     // Setup position
-    this->writeOutputPosition(vertBuilder, gpArgs, dce.inPosition()->fName);
+    this->writeOutputPosition(vertBuilder, gpArgs, dce.inPosition()->name());
 
     // emit transforms
     this->emitTransforms(vertBuilder,
@@ -1114,20 +1114,20 @@
     // XY refers to dashPos, Z is the dash interval length
     GrGLSLVarying inDashParams(kFloat3_GrSLType);
     varyingHandler->addVarying("DashParams", &inDashParams);
-    vertBuilder->codeAppendf("%s = %s;", inDashParams.vsOut(), de.inDashParams()->fName);
+    vertBuilder->codeAppendf("%s = %s;", inDashParams.vsOut(), de.inDashParams()->name());
 
     // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
     // respectively.
     GrGLSLVarying inRectParams(kFloat4_GrSLType);
     varyingHandler->addVarying("RectParams", &inRectParams);
-    vertBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->fName);
+    vertBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->name());
 
     GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
     // Setup pass through color
     this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
 
     // Setup position
-    this->writeOutputPosition(vertBuilder, gpArgs, de.inPosition()->fName);
+    this->writeOutputPosition(vertBuilder, gpArgs, de.inPosition()->name());
 
     // emit transforms
     this->emitTransforms(vertBuilder,
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 0d600ed..fec62e9 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -64,7 +64,7 @@
                                                 latticeGP.fColorSpaceXform.get());
 
                 args.fVaryingHandler->emitAttributes(latticeGP);
-                this->writeOutputPosition(args.fVertBuilder, gpArgs, latticeGP.fPositions.fName);
+                this->writeOutputPosition(args.fVertBuilder, gpArgs, latticeGP.fPositions.name());
                 this->emitTransforms(args.fVertBuilder,
                                      args.fVaryingHandler,
                                      args.fUniformHandler,
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 2ff01f4..5761aef 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -152,14 +152,14 @@
                 // This is the cap radius in normalized space where the outer radius is 1 and
                 // circledEdge.w is the normalized inner radius.
                 vertBuilder->codeAppendf("%s = (1.0 - %s.w) / 2.0;", capRadius.vsOut(),
-                                         cgp.fInCircleEdge->fName);
+                                         cgp.fInCircleEdge->name());
             }
 
             // setup pass through color
             varyingHandler->addPassThroughAttribute(cgp.fInColor, args.fOutputColor);
 
             // Setup position
-            this->writeOutputPosition(vertBuilder, gpArgs, cgp.fInPosition->fName);
+            this->writeOutputPosition(vertBuilder, gpArgs, cgp.fInPosition->name());
 
             // emit transforms
             this->emitTransforms(vertBuilder,
@@ -314,7 +314,7 @@
             GrGLSLVarying lastIntervalLength(kHalf_GrSLType);
             varyingHandler->addVarying("lastIntervalLength", &lastIntervalLength,
                                        GrGLSLVaryingHandler::Interpolation::kCanBeFlat);
-            vertBuilder->codeAppendf("float4 dashParams = %s;", bcscgp.fInDashParams->fName);
+            vertBuilder->codeAppendf("float4 dashParams = %s;", bcscgp.fInDashParams->name());
             // Our fragment shader works in on/off intervals as specified by dashParams.xy:
             //     x = length of on interval, y = length of on + off.
             // There are two other parameters in dashParams.zw:
@@ -380,7 +380,7 @@
                     GrGLSLVaryingHandler::Interpolation::kCanBeFlat);
 
             // Setup position
-            this->writeOutputPosition(vertBuilder, gpArgs, bcscgp.fInPosition->fName);
+            this->writeOutputPosition(vertBuilder, gpArgs, bcscgp.fInPosition->name());
 
             // emit transforms
             this->emitTransforms(vertBuilder,
@@ -549,18 +549,18 @@
             GrGLSLVarying ellipseOffsets(kHalf2_GrSLType);
             varyingHandler->addVarying("EllipseOffsets", &ellipseOffsets);
             vertBuilder->codeAppendf("%s = %s;", ellipseOffsets.vsOut(),
-                                     egp.fInEllipseOffset->fName);
+                                     egp.fInEllipseOffset->name());
 
             GrGLSLVarying ellipseRadii(kHalf4_GrSLType);
             varyingHandler->addVarying("EllipseRadii", &ellipseRadii);
-            vertBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(), egp.fInEllipseRadii->fName);
+            vertBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(), egp.fInEllipseRadii->name());
 
             GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
             // setup pass through color
             varyingHandler->addPassThroughAttribute(egp.fInColor, args.fOutputColor);
 
             // Setup position
-            this->writeOutputPosition(vertBuilder, gpArgs, egp.fInPosition->fName);
+            this->writeOutputPosition(vertBuilder, gpArgs, egp.fInPosition->name());
 
             // emit transforms
             this->emitTransforms(vertBuilder,
@@ -688,11 +688,13 @@
 
             GrGLSLVarying offsets0(kHalf2_GrSLType);
             varyingHandler->addVarying("EllipseOffsets0", &offsets0);
-            vertBuilder->codeAppendf("%s = %s;", offsets0.vsOut(), diegp.fInEllipseOffsets0->fName);
+            vertBuilder->codeAppendf("%s = %s;", offsets0.vsOut(),
+                                     diegp.fInEllipseOffsets0->name());
 
             GrGLSLVarying offsets1(kHalf2_GrSLType);
             varyingHandler->addVarying("EllipseOffsets1", &offsets1);
-            vertBuilder->codeAppendf("%s = %s;", offsets1.vsOut(), diegp.fInEllipseOffsets1->fName);
+            vertBuilder->codeAppendf("%s = %s;", offsets1.vsOut(),
+                                     diegp.fInEllipseOffsets1->name());
 
             GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
             varyingHandler->addPassThroughAttribute(diegp.fInColor, args.fOutputColor);
@@ -701,7 +703,7 @@
             this->writeOutputPosition(vertBuilder,
                                       uniformHandler,
                                       gpArgs,
-                                      diegp.fInPosition->fName,
+                                      diegp.fInPosition->name(),
                                       diegp.fViewMatrix,
                                       &fViewMatrixUniform);
 
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 5c0eaf0..1bb4782 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -125,7 +125,7 @@
     void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {
         b->add32(GrColorSpaceXform::XformKey(fColorSpaceXform.get()));
         uint32_t x = this->usesCoverageEdgeAA() ? 0 : 1;
-        x |= kFloat3_GrVertexAttribType == fPositions.fType ? 0 : 2;
+        x |= kFloat3_GrVertexAttribType == fPositions.type() ? 0 : 2;
         x |= fDomain.isInitialized() ? 4 : 0;
         b->add32(x);
     }
@@ -148,7 +148,7 @@
                 const auto& textureGP = args.fGP.cast<TextureGeometryProcessor>();
                 fColorSpaceXformHelper.emitCode(
                         args.fUniformHandler, textureGP.fColorSpaceXform.get());
-                if (kFloat2_GrVertexAttribType == textureGP.fPositions.fType) {
+                if (kFloat2_GrVertexAttribType == textureGP.fPositions.type()) {
                     args.fVaryingHandler->setNoPerspective();
                 }
                 args.fVaryingHandler->emitAttributes(textureGP);
@@ -175,7 +175,7 @@
                 }
                 if (textureGP.numTextureSamplers() > 1) {
                     // If this changes to float, reconsider Interpolation::kMustBeFlat.
-                    SkASSERT(kInt_GrVertexAttribType == textureGP.fTextureIdx.fType);
+                    SkASSERT(kInt_GrVertexAttribType == textureGP.fTextureIdx.type());
                     SkASSERT(args.fShaderCaps->integerSupport());
                     args.fFragBuilder->codeAppend("int texIdx;");
                     args.fVaryingHandler->addPassThroughAttribute(&textureGP.fTextureIdx, "texIdx",
@@ -209,7 +209,7 @@
                     if (!args.fShaderCaps->interpolantsAreInaccurate()) {
                         GrGLSLVarying aaDistVarying(kFloat4_GrSLType,
                                                     GrGLSLVarying::Scope::kVertToFrag);
-                        if (kFloat3_GrVertexAttribType == textureGP.fPositions.fType) {
+                        if (kFloat3_GrVertexAttribType == textureGP.fPositions.type()) {
                             args.fVaryingHandler->addVarying("aaDists", &aaDistVarying);
                             // The distance from edge equation e to homogenous point p=sk_Position
                             // is e.x*p.x/p.wx + e.y*p.y/p.w + e.z. However, we want screen space
@@ -219,9 +219,9 @@
                             args.fVertBuilder->codeAppendf(
                                     R"(%s = float4(dot(aaEdge0, %s), dot(aaEdge1, %s),
                                                    dot(aaEdge2, %s), dot(aaEdge3, %s));)",
-                                    aaDistVarying.vsOut(), textureGP.fPositions.fName,
-                                    textureGP.fPositions.fName, textureGP.fPositions.fName,
-                                    textureGP.fPositions.fName);
+                                    aaDistVarying.vsOut(), textureGP.fPositions.name(),
+                                    textureGP.fPositions.name(), textureGP.fPositions.name(),
+                                    textureGP.fPositions.name());
                             mulByFragCoordW = true;
                         } else {
                             args.fVaryingHandler->addVarying("aaDists", &aaDistVarying);
@@ -230,9 +230,9 @@
                                                    dot(aaEdge1.xy, %s.xy) + aaEdge1.z,
                                                    dot(aaEdge2.xy, %s.xy) + aaEdge2.z,
                                                    dot(aaEdge3.xy, %s.xy) + aaEdge3.z);)",
-                                    aaDistVarying.vsOut(), textureGP.fPositions.fName,
-                                    textureGP.fPositions.fName, textureGP.fPositions.fName,
-                                    textureGP.fPositions.fName);
+                                    aaDistVarying.vsOut(), textureGP.fPositions.name(),
+                                    textureGP.fPositions.name(), textureGP.fPositions.name(),
+                                    textureGP.fPositions.name());
                         }
                         aaDistName = aaDistVarying.fsIn();
                     } else {
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index a70a785..b72b05b 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -85,10 +85,10 @@
             const GrGeometryProcessor::Attribute& attrib = primProc.getAttrib(attribIndex);
             VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
             vkAttrib.location = attribIndex; // for now assume location = attribIndex
-            vkAttrib.binding = InputRate::kPerInstance == attrib.fInputRate ? instanceBinding
-                                                                            : vertexBinding;
-            vkAttrib.format = attrib_type_to_vkformat(attrib.fType);
-            vkAttrib.offset = attrib.fOffsetInRecord;
+            vkAttrib.binding =
+                    InputRate::kPerInstance == attrib.inputRate() ? instanceBinding : vertexBinding;
+            vkAttrib.format = attrib_type_to_vkformat(attrib.type());
+            vkAttrib.offset = attrib.offsetInRecord();
         }
     }
 
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index 5afe562..d9ffca5 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -330,15 +330,15 @@
 
         GrGLSLVertexBuilder* v = args.fVertBuilder;
         if (!mp.fInstanceLocation) {
-            v->codeAppendf("float2 vertex = %s;", mp.fVertex->fName);
+            v->codeAppendf("float2 vertex = %s;", mp.fVertex->name());
         } else {
             if (mp.fVertex) {
-                v->codeAppendf("float2 offset = %s;", mp.fVertex->fName);
+                v->codeAppendf("float2 offset = %s;", mp.fVertex->name());
             } else {
                 v->codeAppend ("float2 offset = float2(sk_VertexID / 2, sk_VertexID % 2);");
             }
-            v->codeAppendf("float2 vertex = %s + offset * %i;",
-                           mp.fInstanceLocation->fName, kBoxSize);
+            v->codeAppendf("float2 vertex = %s + offset * %i;", mp.fInstanceLocation->name(),
+                           kBoxSize);
         }
         gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex");
 
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 7db0d94..4272957 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -90,7 +90,7 @@
         varyingHandler->addPassThroughAttribute(&mp.fColor, args.fOutputColor);
 
         GrGLSLVertexBuilder* v = args.fVertBuilder;
-        v->codeAppendf("float2 vertex = %s;", mp.fVertex.fName);
+        v->codeAppendf("float2 vertex = %s;", mp.fVertex.name());
         gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex");
 
         GrGLSLFPFragmentBuilder* f = args.fFragBuilder;
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 3a9ab8d..95855e0 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -73,7 +73,8 @@
                     void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
                         const GP& gp = args.fGP.cast<GP>();
                         args.fVaryingHandler->emitAttributes(gp);
-                        this->writeOutputPosition(args.fVertBuilder, gpArgs, gp.getAttrib(0).fName);
+                        this->writeOutputPosition(args.fVertBuilder, gpArgs,
+                                                  gp.getAttrib(0).name());
                         GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
                         fragBuilder->codeAppendf("%s = half4(1);", args.fOutputColor);
                         fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);