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);
     }
diff --git a/experimental/StrokePathRenderer/GrStrokePathRenderer.cpp b/experimental/StrokePathRenderer/GrStrokePathRenderer.cpp
index 03c135d..a8ae917 100644
--- a/experimental/StrokePathRenderer/GrStrokePathRenderer.cpp
+++ b/experimental/StrokePathRenderer/GrStrokePathRenderer.cpp
@@ -111,11 +111,11 @@
 
     // Allocate vertices
     const int nbQuads     = origPath.countPoints() + 1; // Could be "-1" if path is not closed
-    GrVertexLayout layout = 0; // Just 3D points
     const int extraVerts  = isMiter || isBevel ? 1 : 0;
     const int maxVertexCount = nbQuads * (4 + extraVerts);
     const int maxIndexCount  = nbQuads * (6 + extraVerts * 3); // Each extra vert adds a triangle
-    GrDrawTarget::AutoReleaseGeometry arg(target, layout, maxVertexCount, maxIndexCount);
+    target->drawState()->setDefaultVertexAttribs();
+    GrDrawTarget::AutoReleaseGeometry arg(target, maxVertexCount, maxIndexCount);
     if (!arg.succeeded()) {
         return false;
     }
@@ -126,7 +126,7 @@
     // Transform the path into a list of triangles
     SkPath::Iter iter(origPath, false);
     SkPoint pts[4];
-    const SkScalar radius = SkScalarMul(width, 0.5);
+    const SkScalar radius = SkScalarMul(width, 0.5f);
     SkPoint *firstPt = verts, *lastPt = NULL;
     SkVector firstDir, dir;
     firstDir.set(0, 0);