Add new vertex attribute array specification.

This changes the old method of setting vertex layout to a new one where we
specify vertex attribute data separately from attribute bindings (i.e. program
functionality). Attribute data is now set up via an array of generic attribute
types and offsets, and this is mapped to the old program functionality by
setting specific attribute indices. This allows us to create more general 
inputs to shaders.


git-svn-id: http://skia.googlecode.com/svn/trunk@7899 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/AndroidPathRenderer/GrAndroidPathRenderer.cpp b/experimental/AndroidPathRenderer/GrAndroidPathRenderer.cpp
index 2050f09..66cb93a 100644
--- a/experimental/AndroidPathRenderer/GrAndroidPathRenderer.cpp
+++ b/experimental/AndroidPathRenderer/GrAndroidPathRenderer.cpp
@@ -36,12 +36,25 @@
     android::uirenderer::PathRenderer::ConvexPathVertices(origPath, stroke, antiAlias, NULL,
                                                           &vertices);
 
-    // set vertex layout depending on anti-alias
-    GrVertexLayout layout = antiAlias ? GrDrawState::kCoverage_VertexLayoutBit : 0;
+    // set vertex attributes depending on anti-alias
+    GrDrawState* drawState = target->drawState();
+    if (antiAlias) {
+        // position + coverage
+        GrVertexAttrib attribs[] = {
+            GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
+            GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint))
+        };
+        drawState->setVertexAttribs(attribs, SK_ARRAY_COUNT(attribs));
+        drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0);
+        drawState->setAttribIndex(GrDrawState::kCoverage_AttribIndex, 1);
+        drawState->setAttribBindings(GrDrawState::kCoverage_AttribBindingsBit);
+    } else {
+        drawState->setDefaultVertexAttribs();
+    }
 
     // allocate our vert buffer
     int vertCount = vertices.getSize();
-    GrDrawTarget::AutoReleaseGeometry geo(target, layout, vertCount, 0);
+    GrDrawTarget::AutoReleaseGeometry geo(target, vertCount, 0);
     if (!geo.succeeded()) {
         GrPrintf("Failed to get space for vertices!\n");
         return false;
@@ -49,6 +62,7 @@
 
     // copy android verts to our vertex buffer
     if (antiAlias) {
+        GrAssert(sizeof(ColorVertex) == drawState->getVertexSize());
         ColorVertex* outVert = reinterpret_cast<ColorVertex*>(geo.vertices());
         android::uirenderer::AlphaVertex* inVert =
             reinterpret_cast<android::uirenderer::AlphaVertex*>(vertices.getBuffer());
@@ -63,7 +77,7 @@
             ++inVert;
         }
     } else {
-       size_t vsize = GrDrawState::VertexSize(layout);
+       size_t vsize = drawState->getVertexSize();
        size_t copySize = vsize*vertCount;
        memcpy(geo.vertices(), vertices.getBuffer(), copySize);
     }