Replace edge types with GrEdgeEffect. 

This strips out last of the edge types and the fixed function edge attribute and replaces them with using GrEdgeEffect. Also fixes a minor bug when checking attribute counts -- it was using kAttribIndexCount instead of kVertexAttribCnt. 

Original Author: jvanverth@google.com
Review URL: https://codereview.chromium.org/13069003

git-svn-id: http://skia.googlecode.com/svn/trunk@8392 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index cff6324..9f24190 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -16,6 +16,8 @@
 #include "SkStrokeRec.h"
 #include "SkTrace.h"
 
+#include "effects/GrEdgeEffect.h"
+
 GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
 }
 
@@ -446,6 +448,8 @@
     if (path->isEmpty()) {
         return true;
     }
+
+    GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit);
     GrDrawState* drawState = target->drawState();
 
     GrDrawState::AutoDeviceCoordDraw adcd(drawState);
@@ -484,12 +488,21 @@
         {kVec2f_GrVertexAttribType, 0},
         {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
     };
-    static const GrAttribBindings bindings = GrDrawState::kEdge_AttribBindingsBit;
 
     drawState->setVertexAttribs(kAttribs, SK_ARRAY_COUNT(kAttribs));
     drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0);
-    drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1);
-    drawState->setAttribBindings(bindings);
+    drawState->setAttribBindings(GrDrawState::kDefault_AttribBindings);
+
+    enum {
+        // the edge effects share this stage with glyph rendering
+        // (kGlyphMaskStage in GrTextContext) && SW path rendering
+        // (kPathMaskStage in GrSWMaskHelper)
+        kEdgeEffectStage = GrPaint::kTotalStages,
+    };
+    static const int kEdgeAttrIndex = 1;
+    GrEffectRef* quadEffect = GrEdgeEffect::Create(GrEdgeEffect::kQuad_EdgeType);
+    drawState->setEffect(kEdgeEffectStage, quadEffect, kEdgeAttrIndex)->unref();
+
     GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount);
     if (!arg.succeeded()) {
         return false;
@@ -500,14 +513,11 @@
 
     create_vertices(segments, fanPt, verts, idxs);
 
-    GrDrawState::VertexEdgeType oldEdgeType = drawState->getVertexEdgeType();
-    drawState->setVertexEdgeType(GrDrawState::kQuad_EdgeType);
     target->drawIndexed(kTriangles_GrPrimitiveType,
                         0,        // start vertex
                         0,        // start index
                         vCount,
                         iCount);
-    drawState->setVertexEdgeType(oldEdgeType);
 
     return true;
 }