Adds local coords to GrEffect system.

Effects can ask the builder for local coords which may or may not be distinct from positions.

GrEffectStage tracks changes to relationship between pos and local coords.

GrGLEffectMatrix and GrSingleTextureEffect can use either pos or textures as intput coords

GrSimpleTextureEffect now allows for an explicit texture coords attribute.
Review URL: https://codereview.chromium.org/12531015

git-svn-id: http://skia.googlecode.com/svn/trunk@8264 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 31b1a57..6966858 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -74,9 +74,8 @@
 
 void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
                                    const SkMatrix* matrix,
-                                   const GrRect* srcRect,
-                                   const SkMatrix* srcMatrix,
-                                   int stage) {
+                                   const GrRect* localRect,
+                                   const SkMatrix* localMatrix) {
 
     GrAttribBindings bindings = GrDrawState::kDefault_AttribBindings;
     GrDrawState::AutoColorRestore acr;
@@ -86,7 +85,7 @@
     GrColor color = drawState->getColor();
     GrVertexAttribArray<3> attribs;
     size_t currentOffset = 0;
-    int colorOffset = -1, texOffset = -1;
+    int colorOffset = -1, localOffset = -1;
 
     // set position attrib
     drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count());
@@ -115,15 +114,13 @@
         acr.set(drawState, 0xFFFFFFFF);
     }
 
-    uint32_t explicitCoordMask = 0;
-    if (NULL != srcRect) {
-        bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage);
-        drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count());
+    if (NULL != localRect) {
+        bindings |= GrDrawState::kLocalCoords_AttribBindingsBit;
+        drawState->setAttribIndex(GrDrawState::kLocalCoords_AttribIndex, attribs.count());
         currAttrib.set(kVec2f_GrVertexAttribType, currentOffset);
         attribs.push_back(currAttrib);
-        texOffset = currentOffset;
+        localOffset = currentOffset;
         currentOffset += sizeof(GrPoint);
-        explicitCoordMask = (1 << stage);
     }
 
     drawState->setVertexAttribs(attribs.begin(), attribs.count());
@@ -145,7 +142,7 @@
     // When the caller has provided an explicit source rect for a stage then we don't want to
     // modify that stage's matrix. Otherwise if the effect is generating its source rect from
     // the vertex positions then we have to account for the view matrix change.
-    GrDrawState::AutoDeviceCoordDraw adcd(drawState, explicitCoordMask);
+    GrDrawState::AutoDeviceCoordDraw adcd(drawState);
     if (!adcd.succeeded()) {
         return;
     }
@@ -161,15 +158,13 @@
     // unnecessary clipping in our onDraw().
     get_vertex_bounds(geo.vertices(), vsize, 4, &devBounds);
 
-    if (texOffset >= 0) {
-        GrAssert(explicitCoordMask != 0);
-        GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
-                                            texOffset);
-        coords->setRectFan(srcRect->fLeft, srcRect->fTop,
-                            srcRect->fRight, srcRect->fBottom,
+    if (localOffset >= 0) {
+        GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) + localOffset);
+        coords->setRectFan(localRect->fLeft, localRect->fTop,
+                           localRect->fRight, localRect->fBottom,
                             vsize);
-        if (NULL != srcMatrix) {
-            srcMatrix->mapPointsWithStride(coords, vsize, 4);
+        if (NULL != localMatrix) {
+            localMatrix->mapPointsWithStride(coords, vsize, 4);
         }
     }