Extract GrDrawTarget::DrState into independent GrDrawState struct.
This is intended to be a first step towards making the stack of states
maintained by GrDrawTarget cheaper to maintain.



git-svn-id: http://skia.googlecode.com/svn/trunk@2544 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 35c4f20..eafe9eb 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -9,6 +9,7 @@
 #include "GrAAHairLinePathRenderer.h"
 
 #include "GrContext.h"
+#include "GrDrawState.h"
 #include "GrGpu.h"
 #include "GrIndexBuffer.h"
 #include "GrPathUtils.h"
@@ -624,7 +625,7 @@
     }
 
     GrVertexLayout layout = GrDrawTarget::kEdge_VertexLayoutBit;
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if ((1 << s) & stages) {
             layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
         }
@@ -701,7 +702,7 @@
     int nBufLines = fLinesIndexBuffer->maxQuads();
     while (lines < fLineSegmentCnt) {
         int n = GrMin(fLineSegmentCnt-lines, nBufLines);
-        fTarget->setVertexEdgeType(GrDrawTarget::kHairLine_EdgeType);
+        fTarget->setVertexEdgeType(GrDrawState::kHairLine_EdgeType);
         fTarget->drawIndexed(kTriangles_PrimitiveType,
                              kVertsPerLineSeg*lines,    // startV
                              0,                         // startI
@@ -714,7 +715,7 @@
     int quads = 0;
     while (quads < fQuadCnt) {
         int n = GrMin(fQuadCnt-quads, kNumQuadsInIdxBuffer);
-        fTarget->setVertexEdgeType(GrDrawTarget::kHairQuad_EdgeType);
+        fTarget->setVertexEdgeType(GrDrawState::kHairQuad_EdgeType);
         fTarget->drawIndexed(kTriangles_PrimitiveType,
                              4*fLineSegmentCnt + kVertsPerQuad*quads, // startV
                              0,                                       // startI
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d9dc3d2..7028c91 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1013,7 +1013,7 @@
 static GrVertexLayout aa_rect_layout(const GrDrawTarget* target,
                                      bool useCoverage) {
     GrVertexLayout layout = 0;
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (NULL != target->getTexture(s)) {
             layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
         }
@@ -1397,8 +1397,8 @@
     target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
 #endif
 
-    const GrRect* srcRects[GrDrawTarget::kNumStages] = {NULL};
-    const GrMatrix* srcMatrices[GrDrawTarget::kNumStages] = {NULL};
+    const GrRect* srcRects[GrDrawState::kNumStages] = {NULL};
+    const GrMatrix* srcMatrices[GrDrawState::kNumStages] = {NULL};
     srcRects[0] = &srcRect;
     srcMatrices[0] = srcMatrix;
 
@@ -1437,7 +1437,7 @@
             GrPrintf("Failed to get space for vertices!\n");
             return;
         }
-        int texOffsets[GrDrawTarget::kMaxTexCoords];
+        int texOffsets[GrDrawState::kMaxTexCoords];
         int colorOffset;
         GrDrawTarget::VertexSizeAndOffsetsByIdx(layout,
                                                 texOffsets,
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index 52decb4..a8f673e 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -9,6 +9,7 @@
 #include "GrDefaultPathRenderer.h"
 
 #include "GrContext.h"
+#include "GrDrawState.h"
 #include "GrPathUtils.h"
 #include "SkString.h"
 #include "SkTrace.h"
@@ -244,7 +245,7 @@
     }
 
     GrVertexLayout layout = 0;
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if ((1 << s) & stages) {
             layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
         }
@@ -406,11 +407,11 @@
     GrDrawTarget::AutoStateRestore asr(fTarget);
     bool colorWritesWereDisabled = fTarget->isColorWriteDisabled();
     // face culling doesn't make sense here
-    GrAssert(GrDrawTarget::kBoth_DrawFace == fTarget->getDrawFace());
+    GrAssert(GrDrawState::kBoth_DrawFace == fTarget->getDrawFace());
 
     int                         passCount = 0;
     const GrStencilSettings*    passes[3];
-    GrDrawTarget::DrawFace      drawFace[3];
+    GrDrawState::DrawFace       drawFace[3];
     bool                        reverse = false;
     bool                        lastPassIsBounds;
 
@@ -422,7 +423,7 @@
             passes[0] = NULL;
         }
         lastPassIsBounds = false;
-        drawFace[0] = GrDrawTarget::kBoth_DrawFace;
+        drawFace[0] = GrDrawState::kBoth_DrawFace;
     } else {
         if (single_pass_path(*fTarget, *fPath, fFill)) {
             passCount = 1;
@@ -431,7 +432,7 @@
             } else {
                 passes[0] = NULL;
             }
-            drawFace[0] = GrDrawTarget::kBoth_DrawFace;
+            drawFace[0] = GrDrawState::kBoth_DrawFace;
             lastPassIsBounds = false;
         } else {
             switch (fFill) {
@@ -452,7 +453,7 @@
                             passes[1] = &gEOColorPass;
                         }
                     }
-                    drawFace[0] = drawFace[1] = GrDrawTarget::kBoth_DrawFace;
+                    drawFace[0] = drawFace[1] = GrDrawState::kBoth_DrawFace;
                     break;
 
                 case kInverseWinding_PathFill:
@@ -466,7 +467,7 @@
                             passes[0] = &gWindStencilSeparateNoWrap;
                         }
                         passCount = 2;
-                        drawFace[0] = GrDrawTarget::kBoth_DrawFace;
+                        drawFace[0] = GrDrawState::kBoth_DrawFace;
                     } else {
                         if (fStencilWrapOps) {
                             passes[0] = &gWindSingleStencilWithWrapInc;
@@ -476,8 +477,8 @@
                             passes[1] = &gWindSingleStencilNoWrapDec;
                         }
                         // which is cw and which is ccw is arbitrary.
-                        drawFace[0] = GrDrawTarget::kCW_DrawFace;
-                        drawFace[1] = GrDrawTarget::kCCW_DrawFace;
+                        drawFace[0] = GrDrawState::kCW_DrawFace;
+                        drawFace[1] = GrDrawState::kCCW_DrawFace;
                         passCount = 3;
                     }
                     if (stencilOnly) {
@@ -485,7 +486,7 @@
                         --passCount;
                     } else {
                         lastPassIsBounds = true;
-                        drawFace[passCount-1] = GrDrawTarget::kBoth_DrawFace;
+                        drawFace[passCount-1] = GrDrawState::kBoth_DrawFace;
                         if (reverse) {
                             passes[passCount-1] = &gInvWindColorPass;
                         } else {
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
new file mode 100644
index 0000000..37baee8
--- /dev/null
+++ b/src/gpu/GrDrawState.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrDrawState_DEFINED
+#define GrDrawState_DEFINED
+
+#include "GrColor.h"
+#include "GrMatrix.h"
+#include "GrSamplerState.h"
+#include "GrStencil.h"
+
+#include "SkXfermode.h"
+
+class GrRenderTarget;
+class GrTexture;
+
+struct GrDrawState {
+
+    /**
+     * Number of texture stages. Each stage takes as input a color and
+     * 2D texture coordinates. The color input to the first enabled stage is the
+     * per-vertex color or the constant color (setColor/setAlpha) if there are
+     * no per-vertex colors. For subsequent stages the input color is the output
+     * color from the previous enabled stage. The output color of each stage is
+     * the input color modulated with the result of a texture lookup. Texture
+     * lookups are specified by a texture a sampler (setSamplerState). Texture
+     * coordinates for each stage come from the vertices based on a
+     * GrVertexLayout bitfield. The output fragment color is the output color of
+     * the last enabled stage. The presence or absence of texture coordinates
+     * for each stage in the vertex layout indicates whether a stage is enabled
+     * or not.
+     */
+    enum {
+        kNumStages = 3,
+        kMaxTexCoords = kNumStages
+    };
+
+    enum DrawFace {
+        kBoth_DrawFace,
+        kCCW_DrawFace,
+        kCW_DrawFace,
+    };
+
+     /**
+     * When specifying edges as vertex data this enum specifies what type of
+     * edges are in use. The edges are always 4 GrScalars in memory, even when
+     * the edge type requires fewer than 4.
+     */
+    enum VertexEdgeType {
+        /* 1-pixel wide line
+           2D implicit line eq (a*x + b*y +c = 0). 4th component unused */
+        kHairLine_EdgeType,
+        /* 1-pixel wide quadratic
+           u^2-v canonical coords (only 2 components used) */
+        kHairQuad_EdgeType
+    };
+
+    /**
+     * The absolute maximum number of edges that may be specified for
+     * a single draw call when performing edge antialiasing.  This is used for
+     * the size of several static buffers, so implementations of getMaxEdges()
+     * (below) should clamp to this value.
+     */
+    enum {
+        kMaxEdges = 32
+    };
+
+    class Edge {
+      public:
+        Edge() {}
+        Edge(float x, float y, float z) : fX(x), fY(y), fZ(z) {}
+        GrPoint intersect(const Edge& other) {
+            return GrPoint::Make(
+                (fY * other.fZ - other.fY * fZ) /
+                  (fX * other.fY - other.fX * fY),
+                (fX * other.fZ - other.fX * fZ) /
+                  (other.fX * fY - fX * other.fY));
+        }
+        float fX, fY, fZ;
+    };
+
+    GrDrawState() {
+        // make sure any pad is zero for memcmp
+        // all GrDrawState members should default to something
+        // valid by the memset
+        memset(this, 0, sizeof(GrDrawState));
+            
+        // memset exceptions
+        fColorFilterXfermode = SkXfermode::kDstIn_Mode;
+        fFirstCoverageStage = kNumStages;
+
+        // pedantic assertion that our ptrs will
+        // be NULL (0 ptr is mem addr 0)
+        GrAssert((intptr_t)(void*)NULL == 0LL);
+
+        // default stencil setting should be disabled
+        GrAssert(fStencilSettings.isDisabled());
+        fFirstCoverageStage = kNumStages;
+    }
+
+    uint32_t                fFlagBits;
+    GrBlendCoeff            fSrcBlend;
+    GrBlendCoeff            fDstBlend;
+    GrColor                 fBlendConstant;
+    GrTexture*              fTextures[kNumStages];
+    GrSamplerState          fSamplerStates[kNumStages];
+    int                     fFirstCoverageStage;
+    GrRenderTarget*         fRenderTarget;
+    GrColor                 fColor;
+    DrawFace                fDrawFace;
+    GrColor                 fColorFilterColor;
+    SkXfermode::Mode        fColorFilterXfermode;
+
+    GrStencilSettings       fStencilSettings;
+    GrMatrix                fViewMatrix;
+    VertexEdgeType          fVertexEdgeType;
+    Edge                    fEdgeAAEdges[kMaxEdges];
+    int                     fEdgeAANumEdges;
+    bool operator ==(const GrDrawState& s) const {
+        return 0 == memcmp(this, &s, sizeof(GrDrawState));
+    }
+    bool operator !=(const GrDrawState& s) const { return !(*this == s); }
+};
+
+#endif
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 986dbd6..97ec3ba 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -24,7 +24,7 @@
            stage_mask_recur<N+1>(stage);
 }
 template<> 
-int stage_mask_recur<GrDrawTarget::kNumStages>(int) { return 0; }
+int stage_mask_recur<GrDrawState::kNumStages>(int) { return 0; }
 
 // mask of all tex coord indices for one stage
 int stage_tex_coord_mask(int stage) {
@@ -45,7 +45,7 @@
            tex_coord_mask_recur<N+1>(texCoordIdx);
 }
 template<> 
-int tex_coord_mask_recur<GrDrawTarget::kMaxTexCoords>(int) { return 0; }
+int tex_coord_mask_recur<GrDrawState::kMaxTexCoords>(int) { return 0; }
 
 // mask of all bits relevant to one texture coordinate index
 int tex_coord_idx_mask(int texCoordIdx) {
@@ -54,7 +54,7 @@
 
 bool check_layout(GrVertexLayout layout) {
     // can only have 1 or 0 bits set for each stage.
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         int stageBits = layout & stage_mask(s);
         if (stageBits && !GrIsPow2(stageBits)) {
             return false;
@@ -66,7 +66,7 @@
 int num_tex_coords(GrVertexLayout layout) {
     int cnt = 0;
     // figure out how many tex coordinates are present
-    for (int t = 0; t < GrDrawTarget::kMaxTexCoords; ++t) {
+    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
         if (tex_coord_idx_mask(t) & layout) {
             ++cnt;
         }
@@ -107,7 +107,7 @@
  * Position
  * Tex Coord 0
  * ...
- * Tex Coord kMaxTexCoords-1
+ * Tex Coord GrDrawState::kMaxTexCoords-1
  * Color
  * Coverage
  */
@@ -185,11 +185,12 @@
     return -1;
 }
 
-int GrDrawTarget::VertexSizeAndOffsetsByIdx(GrVertexLayout vertexLayout,
-                                            int texCoordOffsetsByIdx[kMaxTexCoords],
-                                            int* colorOffset,
-                                            int* coverageOffset,
-                                            int* edgeOffset) {
+int GrDrawTarget::VertexSizeAndOffsetsByIdx(
+        GrVertexLayout vertexLayout,
+        int texCoordOffsetsByIdx[GrDrawState::kMaxTexCoords],
+        int* colorOffset,
+        int* coverageOffset,
+        int* edgeOffset) {
     GrAssert(check_layout(vertexLayout));
 
     int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
@@ -197,7 +198,7 @@
                                                     sizeof(GrPoint);
     int size = vecSize; // position
 
-    for (int t = 0; t < kMaxTexCoords; ++t) {
+    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
         if (tex_coord_idx_mask(t) & vertexLayout) {
             if (NULL != texCoordOffsetsByIdx) {
                 texCoordOffsetsByIdx[t] = size;
@@ -242,14 +243,15 @@
     return size;
 }
 
-int GrDrawTarget::VertexSizeAndOffsetsByStage(GrVertexLayout vertexLayout,
-                                              int texCoordOffsetsByStage[kNumStages],
-                                              int* colorOffset,
-                                              int* coverageOffset,
-                                              int* edgeOffset) {
+int GrDrawTarget::VertexSizeAndOffsetsByStage(
+        GrVertexLayout vertexLayout,
+        int texCoordOffsetsByStage[GrDrawState::kNumStages],
+        int* colorOffset,
+        int* coverageOffset,
+        int* edgeOffset) {
     GrAssert(check_layout(vertexLayout));
 
-    int texCoordOffsetsByIdx[kMaxTexCoords];
+    int texCoordOffsetsByIdx[GrDrawState::kMaxTexCoords];
     int size = VertexSizeAndOffsetsByIdx(vertexLayout,
                                          (NULL == texCoordOffsetsByStage) ?
                                                NULL :
@@ -258,7 +260,7 @@
                                          coverageOffset,
                                          edgeOffset);
     if (NULL != texCoordOffsetsByStage) {
-        for (int s = 0; s < kNumStages; ++s) {
+        for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             int tcIdx;
             if (StagePosAsTexCoordVertexLayoutBit(s) & vertexLayout) {
                 texCoordOffsetsByStage[s] = 0;
@@ -275,20 +277,21 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 bool GrDrawTarget::VertexUsesStage(int stage, GrVertexLayout vertexLayout) {
-    GrAssert(stage < kNumStages);
+    GrAssert(stage < GrDrawState::kNumStages);
     GrAssert(check_layout(vertexLayout));
     return !!(stage_mask(stage) & vertexLayout);
 }
 
 bool GrDrawTarget::VertexUsesTexCoordIdx(int coordIndex,
                                          GrVertexLayout vertexLayout) {
-    GrAssert(coordIndex < kMaxTexCoords);
+    GrAssert(coordIndex < GrDrawState::kMaxTexCoords);
     GrAssert(check_layout(vertexLayout));
     return !!(tex_coord_idx_mask(coordIndex) & vertexLayout);
 }
 
-int GrDrawTarget::VertexTexCoordsForStage(int stage, GrVertexLayout vertexLayout) {
-    GrAssert(stage < kNumStages);
+int GrDrawTarget::VertexTexCoordsForStage(int stage,
+                                          GrVertexLayout vertexLayout) {
+    GrAssert(stage < GrDrawState::kNumStages);
     GrAssert(check_layout(vertexLayout));
     int bit = vertexLayout & stage_tex_coord_mask(stage);
     if (bit) {
@@ -296,7 +299,7 @@
         // bits are ordered T0S0, T0S1, T0S2, ..., T1S0, T1S1, ...
         // and start at bit 0.
         GR_STATIC_ASSERT(sizeof(GrVertexLayout) <= sizeof(uint32_t));
-        return (32 - Gr_clz(bit) - 1) / kNumStages;
+        return (32 - Gr_clz(bit) - 1) / GrDrawState::kNumStages;
     }
     return -1;
 }
@@ -308,31 +311,32 @@
     static bool run;
     if (!run) {
         run = true;
-        for (int s = 0; s < kNumStages; ++s) {
+        for (int s = 0; s < GrDrawState::kNumStages; ++s) {
 
             GrAssert(!VertexUsesStage(s, 0));
             GrAssert(-1 == VertexStageCoordOffset(s, 0));
             GrVertexLayout stageMask = 0;
-            for (int t = 0; t < kMaxTexCoords; ++t) {
+            for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
                 stageMask |= StageTexCoordVertexLayoutBit(s,t);
             }
-            GrAssert(1 == kMaxTexCoords || !check_layout(stageMask));
+            GrAssert(1 == GrDrawState::kMaxTexCoords ||
+                     !check_layout(stageMask));
             GrAssert(stage_tex_coord_mask(s) == stageMask);
             stageMask |= StagePosAsTexCoordVertexLayoutBit(s);
             GrAssert(stage_mask(s) == stageMask);
             GrAssert(!check_layout(stageMask));
         }
-        for (int t = 0; t < kMaxTexCoords; ++t) {
+        for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
             GrVertexLayout tcMask = 0;
             GrAssert(!VertexUsesTexCoordIdx(t, 0));
-            for (int s = 0; s < kNumStages; ++s) {
+            for (int s = 0; s < GrDrawState::kNumStages; ++s) {
                 tcMask |= StageTexCoordVertexLayoutBit(s,t);
                 GrAssert(VertexUsesStage(s, tcMask));
                 GrAssert(sizeof(GrPoint) == VertexStageCoordOffset(s, tcMask));
                 GrAssert(VertexUsesTexCoordIdx(t, tcMask));
                 GrAssert(2*sizeof(GrPoint) == VertexSize(tcMask));
                 GrAssert(t == VertexTexCoordsForStage(s, tcMask));
-                for (int s2 = s + 1; s2 < kNumStages; ++s2) {
+                for (int s2 = s + 1; s2 < GrDrawState::kNumStages; ++s2) {
                     GrAssert(-1 == VertexStageCoordOffset(s2, tcMask));
                     GrAssert(!VertexUsesStage(s2, tcMask));
                     GrAssert(-1 == VertexTexCoordsForStage(s2, tcMask));
@@ -384,18 +388,19 @@
             GrAssert(tex_coord_idx_mask(t) == tcMask);
             GrAssert(check_layout(tcMask));
 
-            int stageOffsets[kNumStages];
+            int stageOffsets[GrDrawState::kNumStages];
             int colorOffset;
             int edgeOffset;
             int coverageOffset;
             int size;
-            size = VertexSizeAndOffsetsByStage(tcMask, stageOffsets, &colorOffset,
+            size = VertexSizeAndOffsetsByStage(tcMask,
+                                               stageOffsets, &colorOffset,
                                                &coverageOffset, &edgeOffset);
             GrAssert(2*sizeof(GrPoint) == size);
             GrAssert(-1 == colorOffset);
             GrAssert(-1 == coverageOffset);
             GrAssert(-1 == edgeOffset);
-            for (int s = 0; s < kNumStages; ++s) {
+            for (int s = 0; s < GrDrawState::kNumStages; ++s) {
                 GrAssert(VertexUsesStage(s, tcMask));
                 GrAssert(sizeof(GrPoint) == stageOffsets[s]);
                 GrAssert(sizeof(GrPoint) == VertexStageCoordOffset(s, tcMask));
@@ -444,17 +449,17 @@
 }
 
 void GrDrawTarget::setTexture(int stage, GrTexture* tex) {
-    GrAssert(stage >= 0 && stage < kNumStages);
+    GrAssert(stage >= 0 && stage < GrDrawState::kNumStages);
     fCurrDrawState.fTextures[stage] = tex;
 }
 
 const GrTexture* GrDrawTarget::getTexture(int stage) const {
-    GrAssert(stage >= 0 && stage < kNumStages);
+    GrAssert(stage >= 0 && stage < GrDrawState::kNumStages);
     return fCurrDrawState.fTextures[stage];
 }
 
 GrTexture* GrDrawTarget::getTexture(int stage) {
-    GrAssert(stage >= 0 && stage < kNumStages);
+    GrAssert(stage >= 0 && stage < GrDrawState::kNumStages);
     return fCurrDrawState.fTextures[stage];
 }
 
@@ -501,7 +506,7 @@
 }
 
 void GrDrawTarget::setSamplerState(int stage, const GrSamplerState& state) {
-    GrAssert(stage >= 0 && stage < kNumStages);
+    GrAssert(stage >= 0 && stage < GrDrawState::kNumStages);
     fCurrDrawState.fSamplerStates[stage] = state;
 }
 
@@ -933,7 +938,7 @@
                        (layout & kCoverage_VertexLayoutBit) ||
                        (layout & kEdge_VertexLayoutBit);
     for (int s = fCurrDrawState.fFirstCoverageStage;
-         !hasCoverage && s < kNumStages;
+         !hasCoverage && s < GrDrawState::kNumStages;
          ++s) {
         if (StageWillBeUsed(s, layout, fCurrDrawState)) {
             hasCoverage = true;
@@ -1021,9 +1026,10 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void GrDrawTarget::setEdgeAAData(const Edge* edges, int numEdges) {
-    GrAssert(numEdges <= kMaxEdges);
-    memcpy(fCurrDrawState.fEdgeAAEdges, edges, numEdges * sizeof(Edge));
+void GrDrawTarget::setEdgeAAData(const GrDrawState::Edge* edges, int numEdges) {
+    GrAssert(numEdges <= GrDrawState::kMaxEdges);
+    memcpy(fCurrDrawState.fEdgeAAEdges, edges,
+           numEdges * sizeof(GrDrawState::Edge));
     fCurrDrawState.fEdgeAANumEdges = numEdges;
 }
 
@@ -1053,7 +1059,7 @@
                                                  const GrRect* srcRects[]) {
     GrVertexLayout layout = 0;
 
-    for (int i = 0; i < kNumStages; ++i) {
+    for (int i = 0; i < GrDrawState::kNumStages; ++i) {
         int numTC = 0;
         if (stageEnableBitfield & (1 << i)) {
             if (NULL != srcRects && NULL != srcRects[i]) {
@@ -1078,7 +1084,7 @@
                                    void* vertices) {
 #if GR_DEBUG
     // check that the layout and srcRects agree
-    for (int i = 0; i < kNumStages; ++i) {
+    for (int i = 0; i < GrDrawState::kNumStages; ++i) {
         if (VertexTexCoordsForStage(i, layout) >= 0) {
             GR_DEBUGASSERT(NULL != srcRects && NULL != srcRects[i]);
         } else {
@@ -1087,7 +1093,7 @@
     }
 #endif
 
-    int stageOffsets[kNumStages];
+    int stageOffsets[GrDrawState::kNumStages];
     int vsize = VertexSizeAndOffsetsByStage(layout, stageOffsets,
                                             NULL, NULL, NULL);
 
@@ -1098,7 +1104,7 @@
         matrix->mapPointsWithStride(GrTCast<GrPoint*>(vertices), vsize, 4);
     }
 
-    for (int i = 0; i < kNumStages; ++i) {
+    for (int i = 0; i < GrDrawState::kNumStages; ++i) {
         if (stageOffsets[i] > 0) {
             GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(vertices) +
                                                 stageOffsets[i]);
@@ -1155,7 +1161,7 @@
     if (fStageMask) {
         GrMatrix invVM;
         if (fViewMatrix.invert(&invVM)) {
-            for (int s = 0; s < kNumStages; ++s) {
+            for (int s = 0; s < GrDrawState::kNumStages; ++s) {
                 if (fStageMask & (1 << s)) {
                     fSamplerMatrices[s] = target->getSamplerMatrix(s);
                 }
@@ -1171,7 +1177,7 @@
 
 GrDrawTarget::AutoDeviceCoordDraw::~AutoDeviceCoordDraw() {
     fDrawTarget->setViewMatrix(fViewMatrix);
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (fStageMask & (1 << s)) {
             fDrawTarget->setSamplerMatrix(s, fSamplerMatrices[s]);
         }
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index c85fc35..16326a9 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -13,6 +13,7 @@
 
 #include "GrClip.h"
 #include "GrColor.h"
+#include "GrDrawState.h"
 #include "GrMatrix.h"
 #include "GrRefCnt.h"
 #include "GrRenderTarget.h"
@@ -61,53 +62,10 @@
     };
 
     /**
-     * Number of texture stages. Each stage takes as input a color and
-     * 2D texture coordinates. The color input to the first enabled stage is the
-     * per-vertex color or the constant color (setColor/setAlpha) if there are
-     * no per-vertex colors. For subsequent stages the input color is the output
-     * color from the previous enabled stage. The output color of each stage is
-     * the input color modulated with the result of a texture lookup. Texture
-     * lookups are specified by a texture a sampler (setSamplerState). Texture
-     * coordinates for each stage come from the vertices based on a
-     * GrVertexLayout bitfield. The output fragment color is the output color of
-     * the last enabled stage. The presence or absence of texture coordinates
-     * for each stage in the vertex layout indicates whether a stage is enabled
-     * or not.
-     */
-    enum {
-        kNumStages = 3,
-        kMaxTexCoords = kNumStages
-    };
-
-    /**
-     * The absolute maximum number of edges that may be specified for
-     * a single draw call when performing edge antialiasing.  This is used for
-     * the size of several static buffers, so implementations of getMaxEdges()
-     * (below) should clamp to this value.
-     */
-    enum {
-        kMaxEdges = 32
-    };
-
-     /**
-     * When specifying edges as vertex data this enum specifies what type of
-     * edges are in use. The edges are always 4 GrScalars in memory, even when
-     * the edge type requires fewer than 4.
-     */
-    enum VertexEdgeType {
-        /* 1-pixel wide line
-           2D implicit line eq (a*x + b*y +c = 0). 4th component unused */
-        kHairLine_EdgeType,
-        /* 1-pixel wide quadratic
-           u^2-v canonical coords (only 2 components used) */
-        kHairQuad_EdgeType
-    };
-
-    /**
      *  Bitfield used to indicate which stages are in use.
      */
     typedef int StageBitfield;
-    GR_STATIC_ASSERT(sizeof(StageBitfield)*8 >= kNumStages);
+    GR_STATIC_ASSERT(sizeof(StageBitfield)*8 >= GrDrawState::kNumStages);
 
     /**
      *  Flags that affect rendering. Controlled using enable/disableState(). All
@@ -144,12 +102,6 @@
         kLastPublicStateBit = kDummyStateBit-1
     };
 
-    enum DrawFace {
-        kBoth_DrawFace,
-        kCCW_DrawFace,
-        kCW_DrawFace,
-    };
-
     /**
      * Sets the stencil settings to use for the next draw.
      * Changing the clip has the side-effect of possibly zeroing
@@ -168,65 +120,6 @@
         fCurrDrawState.fStencilSettings.setDisabled();
     }
 
-    class Edge {
-      public:
-        Edge() {}
-        Edge(float x, float y, float z) : fX(x), fY(y), fZ(z) {}
-        GrPoint intersect(const Edge& other) {
-            return GrPoint::Make(
-                (fY * other.fZ - other.fY * fZ) /
-                  (fX * other.fY - other.fX * fY),
-                (fX * other.fZ - other.fX * fZ) /
-                  (other.fX * fY - fX * other.fY));
-        }
-        float fX, fY, fZ;
-    };
-
-protected:
-
-    struct DrState {
-        DrState() {
-            // make sure any pad is zero for memcmp
-            // all DrState members should default to something
-            // valid by the memset
-            memset(this, 0, sizeof(DrState));
-            
-            // memset exceptions
-            fColorFilterXfermode = SkXfermode::kDstIn_Mode;
-            fFirstCoverageStage = kNumStages;
-
-            // pedantic assertion that our ptrs will
-            // be NULL (0 ptr is mem addr 0)
-            GrAssert((intptr_t)(void*)NULL == 0LL);
-
-            // default stencil setting should be disabled
-            GrAssert(fStencilSettings.isDisabled());
-            fFirstCoverageStage = kNumStages;
-        }
-        uint32_t                fFlagBits;
-        GrBlendCoeff            fSrcBlend;
-        GrBlendCoeff            fDstBlend;
-        GrColor                 fBlendConstant;
-        GrTexture*              fTextures[kNumStages];
-        GrSamplerState          fSamplerStates[kNumStages];
-        int                     fFirstCoverageStage;
-        GrRenderTarget*         fRenderTarget;
-        GrColor                 fColor;
-        DrawFace                fDrawFace;
-        GrColor                 fColorFilterColor;
-        SkXfermode::Mode        fColorFilterXfermode;
-
-        GrStencilSettings       fStencilSettings;
-        GrMatrix                fViewMatrix;
-        VertexEdgeType          fVertexEdgeType;
-        Edge                    fEdgeAAEdges[kMaxEdges];
-        int                     fEdgeAANumEdges;
-        bool operator ==(const DrState& s) const {
-            return 0 == memcmp(this, &s, sizeof(DrState));
-        }
-        bool operator !=(const DrState& s) const { return !(*this == s); }
-    };
-
 public:
     ///////////////////////////////////////////////////////////////////////////
 
@@ -308,7 +201,7 @@
      * @param matrix  the matrix to concat
      */
     void preConcatSamplerMatrix(int stage, const GrMatrix& matrix)  {
-        GrAssert(stage >= 0 && stage < kNumStages);
+        GrAssert(stage >= 0 && stage < GrDrawState::kNumStages);
         fCurrDrawState.fSamplerStates[stage].preConcatMatrix(matrix);
     }
 
@@ -317,7 +210,7 @@
      * matrix
      */
     void preConcatSamplerMatrices(int stageMask, const GrMatrix& matrix) {
-        for (int i = 0; i < kNumStages; ++i) {
+        for (int i = 0; i < GrDrawState::kNumStages; ++i) {
             if ((1 << i) & stageMask) {
                 this->preConcatSamplerMatrix(i, matrix);
             }
@@ -438,7 +331,9 @@
      * Controls whether clockwise, counterclockwise, or both faces are drawn.
      * @param face  the face(s) to draw.
      */
-    void setDrawFace(DrawFace face) { fCurrDrawState.fDrawFace = face; }
+    void setDrawFace(GrDrawState::DrawFace face) {
+        fCurrDrawState.fDrawFace = face;
+    }
 
     /**
      * A common pattern is to compute a color with the initial stages and then
@@ -446,8 +341,8 @@
      * filters, glyph mask, etc). Color-filters, xfermodes, etc should be 
      * computed based on the pre-coverage-modulated color. The division of 
      * stages between color-computing and coverage-computing is specified by 
-     * this method. Initially this is kNumStages (all stages are color-
-     * computing).
+     * this method. Initially this is GrDrawState::kNumStages (all stages
+     * are color-computing).
      */
     void setFirstCoverageStage(int firstCoverageStage) { 
         fCurrDrawState.fFirstCoverageStage = firstCoverageStage; 
@@ -465,7 +360,9 @@
      * or both faces.
      * @return the current draw face(s).
      */
-    DrawFace getDrawFace() const { return fCurrDrawState.fDrawFace; }
+    GrDrawState::DrawFace getDrawFace() const {
+        return fCurrDrawState.fDrawFace;
+    }
 
     /**
      * Enable render state settings.
@@ -564,7 +461,7 @@
       * kEdge_VertexLayoutBit is set (see below). When per-vertex edges are not
       * specified the value of this setting has no effect.
       */
-    void setVertexEdgeType(VertexEdgeType type) {
+    void setVertexEdgeType(GrDrawState::VertexEdgeType type) {
         fCurrDrawState.fVertexEdgeType = type;
     }
 
@@ -573,7 +470,7 @@
      * lines be used (if line primitive type is drawn)? (Note that lines are
      * always 1 pixel wide)
      */
-     bool willUseHWAALines() const;
+    bool willUseHWAALines() const;
 
     /**
      * Sets the edge data required for edge antialiasing.
@@ -581,14 +478,14 @@
      * @param edges       3 * 6 float values, representing the edge
      *                    equations in Ax + By + C form
      */
-     void setEdgeAAData(const Edge* edges, int numEdges);
+    void setEdgeAAData(const GrDrawState::Edge* edges, int numEdges);
 
     /**
      * Used to save and restore the GrGpu's drawing state
      */
     struct SavedDrawState {
     private:
-        DrState fState;
+        GrDrawState fState;
         friend class GrDrawTarget;
     };
 
@@ -623,8 +520,9 @@
     /**
      * The format of vertices is represented as a bitfield of flags.
      * Flags that indicate the layout of vertex data. Vertices always contain
-     * positions and may also contain up to kMaxTexCoords sets of 2D texture
-     * coordinates, per-vertex colors, and per-vertex coverage. Each stage can 
+     * positions and may also contain up to GrDrawState::kMaxTexCoords sets
+     * of 2D texture * coordinates, per-vertex colors, and per-vertex coverage.
+     * Each stage can 
      * use any of the texture coordinates as its input texture coordinates or it
      * may use the positions as texture coordinates.
      *
@@ -651,13 +549,14 @@
      * @return the bit to add to a GrVertexLayout bitfield.
      */
     static int StageTexCoordVertexLayoutBit(int stage, int texCoordIdx) {
-        GrAssert(stage < kNumStages);
-        GrAssert(texCoordIdx < kMaxTexCoords);
-        return 1 << (stage + (texCoordIdx * kNumStages));
+        GrAssert(stage < GrDrawState::kNumStages);
+        GrAssert(texCoordIdx < GrDrawState::kMaxTexCoords);
+        return 1 << (stage + (texCoordIdx * GrDrawState::kNumStages));
     }
 
 private:
-    static const int TEX_COORD_BIT_CNT = kNumStages*kMaxTexCoords;
+    static const int TEX_COORD_BIT_CNT = GrDrawState::kNumStages *
+                                         GrDrawState::kMaxTexCoords;
 
 public:
     /**
@@ -670,12 +569,13 @@
      * @return the bit to add to a GrVertexLayout bitfield.
      */
     static int StagePosAsTexCoordVertexLayoutBit(int stage) {
-        GrAssert(stage < kNumStages);
+        GrAssert(stage < GrDrawState::kNumStages);
         return (1 << (TEX_COORD_BIT_CNT + stage));
     }
 
 private:
-    static const int STAGE_BIT_CNT = TEX_COORD_BIT_CNT + kNumStages;
+    static const int STAGE_BIT_CNT = TEX_COORD_BIT_CNT +
+        GrDrawState::kNumStages;
 
 public:
 
@@ -1040,7 +940,7 @@
     private:
         GrDrawTarget*       fDrawTarget;
         GrMatrix            fViewMatrix;
-        GrMatrix            fSamplerMatrices[kNumStages];
+        GrMatrix            fSamplerMatrices[GrDrawState::kNumStages];
         int                 fStageMask;
     };
 
@@ -1207,10 +1107,10 @@
      * @return size of a single vertex
      */
     static int VertexSizeAndOffsetsByIdx(GrVertexLayout vertexLayout,
-                                         int texCoordOffsetsByIdx[kMaxTexCoords],
-                                         int *colorOffset,
-                                         int *coverageOffset,
-                                         int* edgeOffset);
+                   int texCoordOffsetsByIdx[GrDrawState::kMaxTexCoords],
+                   int *colorOffset,
+                   int *coverageOffset,
+                   int* edgeOffset);
 
     /**
      * Helper function to compute the size of each vertex and the offsets of
@@ -1238,10 +1138,10 @@
      * @return size of a single vertex
      */
     static int VertexSizeAndOffsetsByStage(GrVertexLayout vertexLayout,
-                                           int texCoordOffsetsByStage[kNumStages],
-                                           int *colorOffset,
-                                           int *coverageOffset,
-                                           int* edgeOffset);
+                   int texCoordOffsetsByStage[GrDrawState::kNumStages],
+                   int* colorOffset,
+                   int* coverageOffset,
+                   int* edgeOffset);
 
     /**
      * Accessing positions, texture coords, or colors, of a vertex within an
@@ -1386,7 +1286,7 @@
     
     // given a vertex layout and a draw state, will a stage be used?
     static bool StageWillBeUsed(int stage, GrVertexLayout layout, 
-                                const DrState& state) {
+                                const GrDrawState& state) {
         return NULL != state.fTextures[stage] && VertexUsesStage(stage, layout);
     }
 
@@ -1397,7 +1297,7 @@
 
     StageBitfield enabledStages() const {
         StageBitfield mask = 0;
-        for (int s = 0; s < kNumStages; ++s) {
+        for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             mask |= this->isStageEnabled(s) ? 1 : 0;
         }
         return mask;
@@ -1405,9 +1305,9 @@
 
     // Helpers for GrDrawTarget subclasses that won't have private access to
     // SavedDrawState but need to peek at the state values.
-    static DrState& accessSavedDrawState(SavedDrawState& sds)
+    static GrDrawState& accessSavedDrawState(SavedDrawState& sds)
                                                         { return sds.fState; }
-    static const DrState& accessSavedDrawState(const SavedDrawState& sds)
+    static const GrDrawState& accessSavedDrawState(const SavedDrawState& sds)
                                                         { return sds.fState; }
 
     // implemented by subclass to allocate space for reserved geom
@@ -1462,7 +1362,7 @@
 
     GrClip fClip;
 
-    DrState fCurrDrawState;
+    GrDrawState fCurrDrawState;
 
     Caps fCaps;
 
diff --git a/src/gpu/GrGLProgram.cpp b/src/gpu/GrGLProgram.cpp
index 929ee50..c538054 100644
--- a/src/gpu/GrGLProgram.cpp
+++ b/src/gpu/GrGLProgram.cpp
@@ -501,10 +501,10 @@
         append_varying(GrGLShaderVar::kVec4f_Type, "Edge", segments, &vsName, &fsName);
         segments->fVSAttrs.push_back().set(GrGLShaderVar::kVec4f_Type, EDGE_ATTR_NAME);
         segments->fVSCode.appendf("\t%s = " EDGE_ATTR_NAME ";\n", vsName);
-        if (GrDrawTarget::kHairLine_EdgeType == fProgramDesc.fVertexEdgeType) {
+        if (GrDrawState::kHairLine_EdgeType == fProgramDesc.fVertexEdgeType) {
             segments->fFSCode.appendf("\tfloat edgeAlpha = abs(dot(vec3(gl_FragCoord.xy,1), %s.xyz));\n", fsName);
         } else {
-            GrAssert(GrDrawTarget::kHairQuad_EdgeType == fProgramDesc.fVertexEdgeType);
+            GrAssert(GrDrawState::kHairQuad_EdgeType == fProgramDesc.fVertexEdgeType);
             // for now we know we're not in perspective, so we could compute this
             // per-quadratic rather than per pixel
             segments->fFSCode.appendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
@@ -710,8 +710,8 @@
     segments.fFSCode.append("void main() {\n");
 
     // add texture coordinates that are used to the list of vertex attr decls
-    GrStringBuilder texCoordAttrs[GrDrawTarget::kMaxTexCoords];
-    for (int t = 0; t < GrDrawTarget::kMaxTexCoords; ++t) {
+    GrStringBuilder texCoordAttrs[GrDrawState::kMaxTexCoords];
+    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
         if (GrDrawTarget::VertexUsesTexCoordIdx(t, layout)) {
             tex_attr_name(t, texCoordAttrs + t);
             segments.fVSAttrs.push_back().set(GrGLShaderVar::kVec2f_Type,
@@ -822,7 +822,7 @@
 
         GrStringBuilder outCoverage;
         const int& startStage = fProgramDesc.fFirstCoverageStage;
-        for (int s = startStage; s < GrDrawTarget::kNumStages; ++s) {
+        for (int s = startStage; s < GrDrawState::kNumStages; ++s) {
             if (fProgramDesc.fStages[s].isEnabled()) {
                 // create var to hold stage output
                 outCoverage = "coverage";
@@ -1142,7 +1142,7 @@
     // Bind the attrib locations to same values for all shaders
     GR_GL_CALL(gl, BindAttribLocation(progID, PositionAttributeIdx(),
                                       POS_ATTR_NAME));
-    for (int t = 0; t < GrDrawTarget::kMaxTexCoords; ++t) {
+    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
         if (texCoordAttrNames[t].size()) {
             GR_GL_CALL(gl, BindAttribLocation(progID,
                                               TexCoordAttributeIdx(t),
@@ -1156,7 +1156,7 @@
                                           VIEW_MATRIX_NAME));
     }
 
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         const StageUniLocations& unis = programData->fUniLocations.fStages[s];
         if (kSetAsAttribute == unis.fTextureMatrixUni) {
             GrStringBuilder matName;
@@ -1226,7 +1226,7 @@
         programData->fUniLocations.fEdgesUni = kUnusedUniform;
     }
 
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         StageUniLocations& locations = programData->fUniLocations.fStages[s];
         if (fProgramDesc.fStages[s].isEnabled()) {
             if (kUseUniform == locations.fTextureMatrixUni) {
@@ -1288,7 +1288,7 @@
     GR_GL_CALL(gl, UseProgram(progID));
 
     // init sampler unis and set bogus values for state tracking
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (kUnusedUniform != programData->fUniLocations.fStages[s].fSamplerUni) {
             GR_GL_CALL(gl, Uniform1i(programData->fUniLocations.fStages[s].fSamplerUni, s));
         }
diff --git a/src/gpu/GrGLProgram.h b/src/gpu/GrGLProgram.h
index 1dd1e3e..58e24d9 100644
--- a/src/gpu/GrGLProgram.h
+++ b/src/gpu/GrGLProgram.h
@@ -10,6 +10,7 @@
 #ifndef GrGLProgram_DEFINED
 #define GrGLProgram_DEFINED
 
+#include "GrDrawState.h"
 #include "GrGLInterface.h"
 #include "GrStringBuilder.h"
 #include "GrGpu.h"
@@ -76,17 +77,17 @@
      */
     static int PositionAttributeIdx() { return 0; }
     static int TexCoordAttributeIdx(int tcIdx) { return 1 + tcIdx; }
-    static int ColorAttributeIdx() { return 1 + GrDrawTarget::kMaxTexCoords; }
+    static int ColorAttributeIdx() { return 1 + GrDrawState::kMaxTexCoords; }
     static int CoverageAttributeIdx() {
-        return 2 + GrDrawTarget::kMaxTexCoords;
+        return 2 + GrDrawState::kMaxTexCoords;
     }
-    static int EdgeAttributeIdx() { return 3 + GrDrawTarget::kMaxTexCoords; }
+    static int EdgeAttributeIdx() { return 3 + GrDrawState::kMaxTexCoords; }
 
     static int ViewMatrixAttributeIdx() {
-        return 4 + GrDrawTarget::kMaxTexCoords;
+        return 4 + GrDrawState::kMaxTexCoords;
     }
     static int TextureMatrixAttributeIdx(int stage) {
-        return 7 + GrDrawTarget::kMaxTexCoords + 3 * stage;
+        return 7 + GrDrawState::kMaxTexCoords + 3 * stage;
     }
 
 public:
@@ -172,12 +173,12 @@
             kDualSrcOutputCnt
         };
 
-        GrDrawTarget::VertexEdgeType fVertexEdgeType;
+        GrDrawState::VertexEdgeType fVertexEdgeType;
 
         // stripped of bits that don't affect prog generation
         GrVertexLayout fVertexLayout;
 
-        StageDesc fStages[GrDrawTarget::kNumStages];
+        StageDesc fStages[GrDrawState::kNumStages];
 
         // To enable experimental geometry shader code (not for use in
         // production)
@@ -236,13 +237,13 @@
         GrGLint fColorUni;
         GrGLint fEdgesUni;
         GrGLint fColorFilterUni;
-        StageUniLocations fStages[GrDrawTarget::kNumStages];
+        StageUniLocations fStages[GrDrawState::kNumStages];
         void reset() {
             fViewMatrixUni = kUnusedUniform;
             fColorUni = kUnusedUniform;
             fEdgesUni = kUnusedUniform;
             fColorFilterUni = kUnusedUniform;
-            for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+            for (int s = 0; s < GrDrawState::kNumStages; ++s) {
                 fStages[s].reset();
             }
         }
@@ -276,14 +277,14 @@
         // (GL uniform values travel with program)
         GrColor                     fColor;
         GrColor                     fColorFilterColor;
-        GrMatrix                    fTextureMatrices[GrDrawTarget::kNumStages];
+        GrMatrix                    fTextureMatrices[GrDrawState::kNumStages];
         // width and height used for normalized texel size
-        int                         fTextureWidth[GrDrawTarget::kNumStages];
-        int                         fTextureHeight[GrDrawTarget::kNumStages]; 
-        GrScalar                    fRadial2CenterX1[GrDrawTarget::kNumStages];
-        GrScalar                    fRadial2Radius0[GrDrawTarget::kNumStages];
-        bool                        fRadial2PosRoot[GrDrawTarget::kNumStages];
-        GrRect                      fTextureDomain[GrDrawTarget::kNumStages];
+        int                         fTextureWidth[GrDrawState::kNumStages];
+        int                         fTextureHeight[GrDrawState::kNumStages]; 
+        GrScalar                    fRadial2CenterX1[GrDrawState::kNumStages];
+        GrScalar                    fRadial2Radius0[GrDrawState::kNumStages];
+        bool                        fRadial2PosRoot[GrDrawState::kNumStages];
+        GrRect                      fTextureDomain[GrDrawState::kNumStages];
 
     private:
         enum Constants {
@@ -340,7 +341,7 @@
     // links the program
     bool bindOutputsAttribsAndLinkProgram(
                 const GrGLInterface* gl,
-                GrStringBuilder texCoordAttrNames[GrDrawTarget::kMaxTexCoords],
+                GrStringBuilder texCoordAttrNames[GrDrawState::kMaxTexCoords],
                 bool bindColorOut,
                 bool bindDualSrcOut,
                 CachedData* programData) const;
diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp
index 077cdd9..012fdc1 100644
--- a/src/gpu/GrGpuGL.cpp
+++ b/src/gpu/GrGpuGL.cpp
@@ -20,7 +20,7 @@
 
 // we use a spare texture unit to avoid
 // mucking with the state of any of the stages.
-static const int SPARE_TEX_UNIT = GrGpuGL::kNumStages;
+static const int SPARE_TEX_UNIT = GrDrawState::kNumStages;
 
 #define SKIP_CACHE_CHECK    true
 
@@ -326,11 +326,11 @@
     // checks are > to make sure we have a spare unit.
     if (kES1_GrGLBinding != this->glBinding()) {
         GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
-        GrAssert(maxTextureUnits > kNumStages);
+        GrAssert(maxTextureUnits > GrDrawState::kNumStages);
     }
     if (kES2_GrGLBinding != this->glBinding()) {
         GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
-        GrAssert(maxTextureUnits > kNumStages);
+        GrAssert(maxTextureUnits > GrDrawState::kNumStages);
     }
     if (kES2_GrGLBinding == this->glBinding()) {
         GR_GL_GetIntegerv(fGL, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
@@ -574,7 +574,7 @@
 
     GL_CALL(Disable(GR_GL_CULL_FACE));
     GL_CALL(FrontFace(GR_GL_CCW));
-    fHWDrawState.fDrawFace = kBoth_DrawFace;
+    fHWDrawState.fDrawFace = GrDrawState::kBoth_DrawFace;
 
     GL_CALL(Disable(GR_GL_DITHER));
     if (kDesktop_GrGLBinding == this->glBinding()) {
@@ -605,7 +605,7 @@
 
     fHWDrawState.fViewMatrix = GrMatrix::InvalidMatrix();
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         fHWDrawState.fTextures[s] = NULL;
         fHWDrawState.fSamplerStates[s].setRadial2Params(-GR_ScalarMax,
                                                         -GR_ScalarMax,
@@ -1885,7 +1885,7 @@
     // and bailed if not true.
     GrAssert(NULL != fCurrDrawState.fRenderTarget);
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         // bind texture and set sampler state
         if (this->isStageEnabled(s)) {
             GrGLTexture* nextTexture = (GrGLTexture*)fCurrDrawState.fTextures[s];
@@ -1984,15 +1984,15 @@
 
     if (fHWDrawState.fDrawFace != fCurrDrawState.fDrawFace) {
         switch (fCurrDrawState.fDrawFace) {
-            case kCCW_DrawFace:
+            case GrDrawState::kCCW_DrawFace:
                 GL_CALL(Enable(GR_GL_CULL_FACE));
                 GL_CALL(CullFace(GR_GL_BACK));
                 break;
-            case kCW_DrawFace:
+            case GrDrawState::kCW_DrawFace:
                 GL_CALL(Enable(GR_GL_CULL_FACE));
                 GL_CALL(CullFace(GR_GL_FRONT));
                 break;
-            case kBoth_DrawFace:
+            case GrDrawState::kBoth_DrawFace:
                 GL_CALL(Disable(GR_GL_CULL_FACE));
                 break;
             default:
@@ -2003,7 +2003,7 @@
 
 #if GR_DEBUG
     // check for circular rendering
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         GrAssert(!this->isStageEnabled(s) ||
                  NULL == fCurrDrawState.fRenderTarget ||
                  NULL == fCurrDrawState.fTextures[s] ||
@@ -2056,7 +2056,7 @@
 }
 
 void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) {
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (fCurrDrawState.fTextures[s] == texture) {
             fCurrDrawState.fTextures[s] = NULL;
         }
@@ -2115,7 +2115,7 @@
 }
 
 void GrGpuGL::setTextureUnit(int unit) {
-    GrAssert(unit >= 0 && unit < kNumStages);
+    GrAssert(unit >= 0 && unit < GrDrawState::kNumStages);
     if (fActiveTextureUnitIdx != unit) {
         GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit));
         fActiveTextureUnitIdx = unit;
@@ -2229,7 +2229,8 @@
 int GrGpuGL::getMaxEdges() const {
     // FIXME:  This is a pessimistic estimate based on how many other things
     // want to add uniforms.  This should be centralized somewhere.
-    return GR_CT_MIN(fGLCaps.fMaxFragmentUniformVectors - 8, kMaxEdges);
+    return GR_CT_MIN(fGLCaps.fMaxFragmentUniformVectors - 8,
+                     GrDrawState::kMaxEdges);
 }
 
 void GrGpuGL::GLCaps::print() const {
diff --git a/src/gpu/GrGpuGL.h b/src/gpu/GrGpuGL.h
index a2630c8..2d246e8 100644
--- a/src/gpu/GrGpuGL.h
+++ b/src/gpu/GrGpuGL.h
@@ -11,6 +11,7 @@
 #ifndef GrGpuGL_DEFINED
 #define GrGpuGL_DEFINED
 
+#include "GrDrawState.h"
 #include "GrGpu.h"
 #include "GrGLIndexBuffer.h"
 #include "GrGLIRect.h"
@@ -44,8 +45,8 @@
         bool fSmoothLineEnabled;
     } fHWAAState;
 
-    DrState   fHWDrawState;
-    bool      fHWStencilClip;
+    GrDrawState fHWDrawState;
+    bool        fHWStencilClip;
 
     // As flush of GL state proceeds it updates fHDrawState
     // to reflect the new state. Later parts of the state flush
@@ -56,7 +57,7 @@
         bool fRenderTargetChanged : 1;
         int  fTextureChangedMask;
     } fDirtyFlags;
-    GR_STATIC_ASSERT(8 * sizeof(int) >= kNumStages);
+    GR_STATIC_ASSERT(8 * sizeof(int) >= GrDrawState::kNumStages);
 
     // clears the dirty flags
     void resetDirtyFlags();
diff --git a/src/gpu/GrGpuGLFixed.cpp b/src/gpu/GrGpuGLFixed.cpp
index 336b687..0c01f77 100644
--- a/src/gpu/GrGpuGLFixed.cpp
+++ b/src/gpu/GrGpuGLFixed.cpp
@@ -72,7 +72,7 @@
 
     GL_CALL(Disable(GR_GL_TEXTURE_2D));
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         setTextureUnit(s);
         GL_CALL(EnableClientState(GR_GL_VERTEX_ARRAY));
         GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
@@ -150,9 +150,9 @@
 
 bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
 
-    bool usingTextures[kNumStages];
+    bool usingTextures[GrDrawState::kNumStages];
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         usingTextures[s] = this->isStageEnabled(s);
         if (usingTextures[s] && fCurrDrawState.fSamplerStates[s].isGradient()) {
             unimpl("Fixed pipe doesn't support radial/sweep gradients");
@@ -184,7 +184,7 @@
         flushProjectionMatrix();
     }
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         bool wasUsingTexture = StageWillBeUsed(s, fHWGeometryState.fVertexLayout, fHWDrawState);
         if (usingTextures[s] != wasUsingTexture) {
             setTextureUnit(s);
@@ -220,7 +220,7 @@
     }
 
     // set texture environment, decide whether we are modulating by RGB or A.
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (usingTextures[s]) {
             GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s];
             if (NULL != texture) {
@@ -279,7 +279,7 @@
 
     int newColorOffset;
     int newCoverageOffset;
-    int newTexCoordOffsets[kNumStages];
+    int newTexCoordOffsets[GrDrawState::kNumStages];
     int newEdgeOffset;
 
     GrGLsizei newStride = VertexSizeAndOffsetsByStage(this->getGeomSrc().fVertexLayout,
@@ -292,7 +292,7 @@
 
     int oldColorOffset;
     int oldCoverageOffset;
-    int oldTexCoordOffsets[kNumStages];
+    int oldTexCoordOffsets[GrDrawState::kNumStages];
     int oldEdgeOffset;
     GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout,
                                                       oldTexCoordOffsets,
@@ -340,7 +340,7 @@
         fHWGeometryState.fVertexOffset = vertexOffset;
     }
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         // need to enable array if tex coord offset is 0
         // (using positions as coords)
         if (newTexCoordOffsets[s] >= 0) {
diff --git a/src/gpu/GrGpuGLFixed.h b/src/gpu/GrGpuGLFixed.h
index 0e624b5..ede47aa 100644
--- a/src/gpu/GrGpuGLFixed.h
+++ b/src/gpu/GrGpuGLFixed.h
@@ -11,6 +11,7 @@
 #ifndef GrGpuGLFixed_DEFINED
 #define GrGpuGLFixed_DEFINED
 
+#include "GrDrawState.h"
 #include "GrGpuGL.h"
 
 // Fixed Pipeline OpenGL or OpenGL ES 1.x
@@ -47,7 +48,7 @@
         kAlpha_TextureEnvRGBOperand,
         kColor_TextureEnvRGBOperand,
     };
-    TextureEnvRGBOperands fHWRGBOperand0[kNumStages];
+    TextureEnvRGBOperands fHWRGBOperand0[GrDrawState::kNumStages];
 
     void flushProjectionMatrix();
 
diff --git a/src/gpu/GrGpuGLShaders.cpp b/src/gpu/GrGpuGLShaders.cpp
index 0742c3b..6817580 100644
--- a/src/gpu/GrGpuGLShaders.cpp
+++ b/src/gpu/GrGpuGLShaders.cpp
@@ -210,7 +210,7 @@
         int idx = (int)(random.nextF() * (SkXfermode::kCoeffModesCnt));
         pdesc.fColorFilterXfermode = (SkXfermode::Mode)idx;
 
-        idx = (int)(random.nextF() * (kNumStages+1));
+        idx = (int)(random.nextF() * (GrDrawState::kNumStages + 1));
         pdesc.fFirstCoverageStage = idx;
 
         pdesc.fVertexLayout |= (random.nextF() > .5f) ?
@@ -229,10 +229,10 @@
                 pdesc.fVertexLayout |= GrDrawTarget::kEdge_VertexLayoutBit;
                 if (this->getCaps().fShaderDerivativeSupport) {
                     pdesc.fVertexEdgeType = random.nextF() > 0.5f ?
-                                                        kHairQuad_EdgeType :
-                                                        kHairLine_EdgeType;
+                        GrDrawState::kHairQuad_EdgeType :
+                        GrDrawState::kHairLine_EdgeType;
                 } else {
-                    pdesc.fVertexEdgeType = kHairLine_EdgeType;
+                    pdesc.fVertexEdgeType = GrDrawState::kHairLine_EdgeType;
                 }
                 pdesc.fEdgeAANumEdges = 0;
             } else {
@@ -252,12 +252,12 @@
             pdesc.fDualSrcOutput = ProgramDesc::kNone_DualSrcOutput;
         }
 
-        for (int s = 0; s < kNumStages; ++s) {
+        for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             // enable the stage?
             if (random.nextF() > .5f) {
                 // use separate tex coords?
                 if (random.nextF() > .5f) {
-                    int t = (int)(random.nextF() * kMaxTexCoords);
+                    int t = (int)(random.nextF() * GrDrawState::kMaxTexCoords);
                     pdesc.fVertexLayout |= StageTexCoordVertexLayoutBit(s, t);
                 } else {
                     pdesc.fVertexLayout |= StagePosAsTexCoordVertexLayoutBit(s);
@@ -575,7 +575,7 @@
     const int& uni = fProgramData->fUniLocations.fEdgesUni;
     if (GrGLProgram::kUnusedUniform != uni) {
         int count = fCurrDrawState.fEdgeAANumEdges;
-        Edge edges[kMaxEdges];
+        GrDrawState::Edge edges[GrDrawState::kMaxEdges];
         // Flip the edges in Y
         float height = 
             static_cast<float>(fCurrDrawState.fRenderTarget->height());
@@ -701,7 +701,7 @@
         *currViewMatrix = fCurrDrawState.fViewMatrix;
     }
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         this->flushTextureMatrix(s);
 
         this->flushRadial2(s);
@@ -727,7 +727,7 @@
 
     int newColorOffset;
     int newCoverageOffset;
-    int newTexCoordOffsets[kMaxTexCoords];
+    int newTexCoordOffsets[GrDrawState::kMaxTexCoords];
     int newEdgeOffset;
 
     GrGLsizei newStride = VertexSizeAndOffsetsByIdx(
@@ -738,7 +738,7 @@
                                             &newEdgeOffset);
     int oldColorOffset;
     int oldCoverageOffset;
-    int oldTexCoordOffsets[kMaxTexCoords];
+    int oldTexCoordOffsets[GrDrawState::kMaxTexCoords];
     int oldEdgeOffset;
 
     GrGLsizei oldStride = VertexSizeAndOffsetsByIdx(
@@ -789,7 +789,7 @@
         fHWGeometryState.fVertexOffset = vertexOffset;
     }
 
-    for (int t = 0; t < kMaxTexCoords; ++t) {
+    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
         if (newTexCoordOffsets[t] > 0) {
             GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[t]);
             int idx = GrGLProgram::TexCoordAttributeIdx(t);
@@ -924,10 +924,10 @@
         desc.fVertexEdgeType = fCurrDrawState.fVertexEdgeType;
     } else {
         // use canonical value when not set to avoid cache misses
-        desc.fVertexEdgeType = GrDrawTarget::kHairLine_EdgeType;
+        desc.fVertexEdgeType = GrDrawState::kHairLine_EdgeType;
     }
 
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         StageDesc& stage = desc.fStages[s];
 
         stage.fOptFlags = 0;
@@ -1032,8 +1032,8 @@
     // We set field in the desc to kNumStages when either there are no 
     // coverage stages or the distinction between coverage and color is
     // immaterial.
-    int firstCoverageStage = kNumStages;
-    desc.fFirstCoverageStage = kNumStages;
+    int firstCoverageStage = GrDrawState::kNumStages;
+    desc.fFirstCoverageStage = GrDrawState::kNumStages;
     bool hasCoverage = fCurrDrawState.fFirstCoverageStage <= lastEnabledStage;
     if (hasCoverage) {
         firstCoverageStage = fCurrDrawState.fFirstCoverageStage;
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 5e3c769..db20846 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -324,8 +324,8 @@
     this->resetIndexSource();
     uint32_t numStates = fStates.count();
     for (uint32_t i = 0; i < numStates; ++i) {
-        const DrState& dstate = this->accessSavedDrawState(fStates[i]);
-        for (int s = 0; s < kNumStages; ++s) {
+        const GrDrawState& dstate = this->accessSavedDrawState(fStates[i]);
+        for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             GrSafeUnref(dstate.fTextures[s]);
         }
         GrSafeUnref(dstate.fRenderTarget);
@@ -585,13 +585,13 @@
      if (fStates.empty()) {
         return true;
      } else {
-         const DrState& old = this->accessSavedDrawState(fStates.back());
+        const GrDrawState& old = this->accessSavedDrawState(fStates.back());
         return old != fCurrDrawState;
      }
 }
 
 void GrInOrderDrawBuffer::pushState() {
-    for (int s = 0; s < kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         GrSafeRef(fCurrDrawState.fTextures[s]);
     }
     GrSafeRef(fCurrDrawState.fRenderTarget);
diff --git a/src/gpu/GrTesselatedPathRenderer.cpp b/src/gpu/GrTesselatedPathRenderer.cpp
index 5c5a50e..51cea10 100644
--- a/src/gpu/GrTesselatedPathRenderer.cpp
+++ b/src/gpu/GrTesselatedPathRenderer.cpp
@@ -9,6 +9,7 @@
 
 #include "GrTesselatedPathRenderer.h"
 
+#include "GrDrawState.h"
 #include "GrPathUtils.h"
 #include "GrPoint.h"
 #include "GrTDArray.h"
@@ -18,7 +19,7 @@
 #include <limits.h>
 #include <sk_glu.h>
 
-typedef GrTDArray<GrDrawTarget::Edge> GrEdgeArray;
+typedef GrTDArray<GrDrawState::Edge> GrEdgeArray;
 typedef GrTDArray<GrPoint> GrPointArray;
 typedef GrTDArray<uint16_t> GrIndexArray;
 typedef void (*TESSCB)();
@@ -28,13 +29,13 @@
 // vertex components,
 const float kMaxVertexValue = 1e18f;
 
-static inline GrDrawTarget::Edge computeEdge(const GrPoint& p,
+static inline GrDrawState::Edge computeEdge(const GrPoint& p,
                                              const GrPoint& q,
                                              float sign) {
     GrVec tangent = GrVec::Make(p.fY - q.fY, q.fX - p.fX);
     float scale = sign / tangent.length();
     float cross2 = p.fX * q.fY - q.fX * p.fY;
-    return GrDrawTarget::Edge(tangent.fX * scale,
+    return GrDrawState::Edge(tangent.fX * scale,
                               tangent.fY * scale,
                               cross2 * scale);
 }
@@ -165,7 +166,7 @@
     ~GrEdgePolygonTess() {
         delete[] fEdges;
     }
-    const GrDrawTarget::Edge* edges() const { return fEdges; }
+    const GrDrawState::Edge* edges() const { return fEdges; }
 private:
     void addEdge(int index0, int index1) {
         GrPoint p = fVertices[index0];
@@ -175,15 +176,15 @@
         p = sanitizePoint(p);
         q = sanitizePoint(q);
         if (p == q) return;
-        GrDrawTarget::Edge edge = computeEdge(p, q, 1.0f);
+        GrDrawState::Edge edge = computeEdge(p, q, 1.0f);
         fEdges[index0 * 2 + 1] = edge;
         fEdges[index1 * 2] = edge;
     }
     virtual void begin(GLenum type) {
         GR_DEBUGASSERT(type == GL_TRIANGLES);
         int count = fVertices.count() * 2;
-        fEdges = new GrDrawTarget::Edge[count];
-        memset(fEdges, 0, count * sizeof(GrDrawTarget::Edge));
+        fEdges = new GrDrawState::Edge[count];
+        memset(fEdges, 0, count * sizeof(GrDrawState::Edge));
     }
     virtual void edgeFlag(bool flag) {
         fEdgeFlag = flag;
@@ -215,7 +216,7 @@
     GrMatrix fMatrix;
     bool fEdgeFlag;
     int fEdgeVertex, fTriStartVertex;
-    GrDrawTarget::Edge* fEdges;
+    GrDrawState::Edge* fEdges;
 };
 
 class GrBoundaryTess : public GrTess {
@@ -260,7 +261,7 @@
     return nearlyEqual(a.fX, b.fX) && nearlyEqual(a.fY, b.fY);
 }
 
-static bool parallel(const GrDrawTarget::Edge& a, const GrDrawTarget::Edge& b) {
+static bool parallel(const GrDrawState::Edge& a, const GrDrawState::Edge& b) {
     return (nearlyEqual(a.fX, b.fX) && nearlyEqual(a.fY, b.fY)) ||
            (nearlyEqual(a.fX, -b.fX) && nearlyEqual(a.fY, -b.fY));
 }
@@ -297,7 +298,7 @@
     return v1.cross(v2) < 0;
 }
 
-static bool validEdge(const GrDrawTarget::Edge& edge) {
+static bool validEdge(const GrDrawState::Edge& edge) {
     return !(edge.fX == 0.0f && edge.fY == 0.0f && edge.fZ == 0.0f);
 }
 
@@ -320,7 +321,7 @@
         if (p == q) {
             continue;
         }
-        GrDrawTarget::Edge edge = computeEdge(p, q, sign);
+        GrDrawState::Edge edge = computeEdge(p, q, sign);
         edge.fZ += 0.5f;    // Offset by half a pixel along the tangent.
         *edges->append() = edge;
         p = q;
@@ -329,9 +330,9 @@
     if (count == 0) {
         return 0;
     }
-    GrDrawTarget::Edge prev_edge = edges->at(0);
+    GrDrawState::Edge prev_edge = edges->at(0);
     for (int i = 0; i < count; ++i) {
-        GrDrawTarget::Edge edge = edges->at(i < count - 1 ? i + 1 : 0);
+        GrDrawState::Edge edge = edges->at(i < count - 1 ? i + 1 : 0);
         if (parallel(edge, prev_edge)) {
             // 3 points are collinear; offset by half the tangent instead
             vertices[i].fX -= edge.fX * 0.5f;
@@ -348,7 +349,7 @@
 void GrTesselatedPathRenderer::drawPath(GrDrawTarget::StageBitfield stages) {
     GrDrawTarget::AutoStateRestore asr(fTarget);
     // face culling doesn't make sense here
-    GrAssert(GrDrawTarget::kBoth_DrawFace == fTarget->getDrawFace());
+    GrAssert(GrDrawState::kBoth_DrawFace == fTarget->getDrawFace());
 
     GrMatrix viewM = fTarget->getViewMatrix();
 
@@ -360,7 +361,7 @@
     int maxPts = GrPathUtils::worstCasePointCount(*fPath, &subpathCnt, tol);
 
     GrVertexLayout layout = 0;
-    for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if ((1 << s) & stages) {
             layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
         }
@@ -536,7 +537,7 @@
         fTarget->enableState(GrDrawTarget::kEdgeAAConcave_StateBit);
         const GrPointArray& vertices = ptess.vertices();
         const GrIndexArray& indices = ptess.indices();
-        const GrDrawTarget::Edge* edges = ptess.edges();
+        const GrDrawState::Edge* edges = ptess.edges();
         GR_DEBUGASSERT(indices.count() % 3 == 0);
         for (int i = 0; i < indices.count(); i += 3) {
             GrPoint tri_verts[3];
@@ -546,14 +547,14 @@
             tri_verts[0] = vertices[index0];
             tri_verts[1] = vertices[index1];
             tri_verts[2] = vertices[index2];
-            GrDrawTarget::Edge tri_edges[6];
+            GrDrawState::Edge tri_edges[6];
             int t = 0;
-            const GrDrawTarget::Edge& edge0 = edges[index0 * 2];
-            const GrDrawTarget::Edge& edge1 = edges[index0 * 2 + 1];
-            const GrDrawTarget::Edge& edge2 = edges[index1 * 2];
-            const GrDrawTarget::Edge& edge3 = edges[index1 * 2 + 1];
-            const GrDrawTarget::Edge& edge4 = edges[index2 * 2];
-            const GrDrawTarget::Edge& edge5 = edges[index2 * 2 + 1];
+            const GrDrawState::Edge& edge0 = edges[index0 * 2];
+            const GrDrawState::Edge& edge1 = edges[index0 * 2 + 1];
+            const GrDrawState::Edge& edge2 = edges[index1 * 2];
+            const GrDrawState::Edge& edge3 = edges[index1 * 2 + 1];
+            const GrDrawState::Edge& edge4 = edges[index2 * 2];
+            const GrDrawState::Edge& edge5 = edges[index2 * 2 + 1];
             if (validEdge(edge0) && validEdge(edge1)) {
                 tri_edges[t++] = edge0;
                 tri_edges[t++] = edge1;