remove drawtype

BUG=skia:

Review URL: https://codereview.chromium.org/862933005
diff --git a/src/gpu/GrGeometryProcessor.cpp b/src/gpu/GrGeometryProcessor.cpp
index 3980767..75e6ed8 100644
--- a/src/gpu/GrGeometryProcessor.cpp
+++ b/src/gpu/GrGeometryProcessor.cpp
@@ -503,7 +503,7 @@
 GrPathProcessor::GrPathProcessor(GrColor color,
                                  const SkMatrix& viewMatrix,
                                  const SkMatrix& localMatrix)
-    : INHERITED(viewMatrix, localMatrix)
+    : INHERITED(viewMatrix, localMatrix, true)
     , fColor(color) {
     this->initClassID<GrPathProcessor>();
 }
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index 97271b9..c55b9af 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -169,12 +169,16 @@
     virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
                                                      const GrGLCaps& caps) const = 0;
 
+    bool isPathRendering() const { return fIsPathRendering; }
+
 protected:
-    GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix)
+    GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
+                         bool isPathRendering)
         : fNumAttribs(0)
         , fVertexStride(0)
         , fViewMatrix(viewMatrix)
-        , fLocalMatrix(localMatrix) {}
+        , fLocalMatrix(localMatrix)
+        , fIsPathRendering(isPathRendering) {}
 
     /*
      * CanCombineOutput will return true if two draws are 'batchable' from a color perspective.
@@ -215,6 +219,7 @@
 
     const SkMatrix fViewMatrix;
     SkMatrix fLocalMatrix;
+    bool fIsPathRendering;
 
     typedef GrProcessor INHERITED;
 };
@@ -234,7 +239,7 @@
                         const SkMatrix& viewMatrix = SkMatrix::I(),
                         const SkMatrix& localMatrix = SkMatrix::I(),
                         bool opaqueVertexColors = false)
-        : INHERITED(viewMatrix, localMatrix)
+        : INHERITED(viewMatrix, localMatrix, false)
         , fColor(color)
         , fOpaqueVertexColors(opaqueVertexColors)
         , fWillUseGeoShader(false)
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 53ac9c3..5bbc3dc 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -302,25 +302,12 @@
     // is dirty.
     ResetTimestamp getResetTimestamp() const { return fResetTimestamp; }
 
-    enum DrawType {
-        kDrawPoints_DrawType,
-        kDrawLines_DrawType,
-        kDrawTriangles_DrawType,
-        kDrawPath_DrawType,
-        kDrawPaths_DrawType,
-    };
-
-    static bool IsPathRenderingDrawType(DrawType type) {
-        return kDrawPath_DrawType == type || kDrawPaths_DrawType == type;
-    }
-
     GrContext::GPUStats* gpuStats() { return &fGPUStats; }
 
     virtual void buildProgramDesc(GrProgramDesc*,
                                   const GrPrimitiveProcessor&,
                                   const GrOptDrawState&,
                                   const GrProgramDesc::DescInfo&,
-                                  GrGpu::DrawType,
                                   const GrBatchTracker&) const = 0;
 
     /**
@@ -366,20 +353,17 @@
         DrawArgs(const GrPrimitiveProcessor* primProc,
                  const GrOptDrawState* optState,
                  const GrProgramDesc* desc,
-                 const GrBatchTracker* batchTracker,
-                 DrawType drawType)
+                 const GrBatchTracker* batchTracker)
             : fPrimitiveProcessor(primProc)
             , fOptState(optState)
             , fDesc(desc)
-            , fBatchTracker(batchTracker)
-            , fDrawType(drawType) {
+            , fBatchTracker(batchTracker) {
             SkASSERT(primProc && optState && desc && batchTracker);
         }
         const GrPrimitiveProcessor* fPrimitiveProcessor;
         const GrOptDrawState* fOptState;
         const GrProgramDesc* fDesc;
         const GrBatchTracker* fBatchTracker;
-        DrawType fDrawType;
     };
 
     void draw(const DrawArgs&, const GrDrawTarget::DrawInfo&);
@@ -405,23 +389,6 @@
                    int count,
                    const GrStencilSettings&);
 
-    static DrawType PrimTypeToDrawType(GrPrimitiveType type) {
-        switch (type) {
-            case kTriangles_GrPrimitiveType:
-            case kTriangleStrip_GrPrimitiveType:
-            case kTriangleFan_GrPrimitiveType:
-                return kDrawTriangles_DrawType;
-            case kPoints_GrPrimitiveType:
-                return kDrawPoints_DrawType;
-            case kLines_GrPrimitiveType:
-            case kLineStrip_GrPrimitiveType:
-                return kDrawLines_DrawType;
-            default:
-                SkFAIL("Unexpected primitive type");
-                return kDrawTriangles_DrawType;
-        }
-    }
-
 protected:
     // Functions used to map clip-respecting stencil tests into normal
     // stencil funcs supported by GPUs.
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 1c7cb25..5b1f008 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -245,9 +245,7 @@
                                  const GrDeviceCoordTexture* dstCopy) {
     SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
 
-    if (!this->recordStateAndShouldDraw(ds, gp,
-                                        GrGpu::PrimTypeToDrawType(info.primitiveType()),
-                                        scissorState, dstCopy)) {
+    if (!this->recordStateAndShouldDraw(ds, gp, scissorState, dstCopy)) {
         return;
     }
 
@@ -287,8 +285,7 @@
                                      const GrStencilSettings& stencilSettings,
                                      const GrDeviceCoordTexture* dstCopy) {
     // TODO: Only compare the subset of GrDrawState relevant to path covering?
-    if (!this->recordStateAndShouldDraw(ds, pathProc, GrGpu::kDrawPath_DrawType,
-                                        scissorState, dstCopy)) {
+    if (!this->recordStateAndShouldDraw(ds, pathProc, scissorState, dstCopy)) {
         return;
     }
     DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
@@ -311,8 +308,7 @@
     SkASSERT(indices);
     SkASSERT(transformValues);
 
-    if (!this->recordStateAndShouldDraw(ds, pathProc, GrGpu::kDrawPath_DrawType, scissorState,
-                                        dstCopy)) {
+    if (!this->recordStateAndShouldDraw(ds, pathProc, scissorState, dstCopy)) {
         return;
     }
 
@@ -435,8 +431,7 @@
             SetState* ss = reinterpret_cast<SetState*>(iter.get());
 
             this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, ss->fState,
-                                             ss->fState.descInfo(), ss->fDrawType,
-                                             ss->fBatchTracker);
+                                             ss->fState.descInfo(), ss->fBatchTracker);
             currentState = ss;
 
         } else {
@@ -455,7 +450,7 @@
 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
     SkASSERT(state);
     DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
-                  &state->fBatchTracker, state->fDrawType);
+                  &state->fBatchTracker);
     buf->getGpu()->draw(args, fInfo);
 }
 
@@ -473,14 +468,14 @@
 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
     SkASSERT(state);
     DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
-                  &state->fBatchTracker, state->fDrawType);
+                  &state->fBatchTracker);
     buf->getGpu()->drawPath(args, this->path(), fStencilSettings);
 }
 
 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
     SkASSERT(state);
     DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
-                  &state->fBatchTracker, state->fDrawType);
+                  &state->fBatchTracker);
     buf->getGpu()->drawPaths(args, this->pathRange(),
                             &buf->fPathIndexBuffer[fIndicesLocation], fIndexType,
                             &buf->fPathTransformBuffer[fTransformsLocation], fTransformType,
@@ -521,12 +516,11 @@
 
 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
                                                    const GrPrimitiveProcessor* primProc,
-                                                   GrGpu::DrawType drawType,
                                                    const GrScissorState& scissor,
                                                    const GrDeviceCoordTexture* dstCopy) {
     SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
                                             (ds, primProc, *this->getGpu()->caps(), scissor,
-                                             dstCopy, drawType));
+                                             dstCopy));
     if (ss->fState.mustSkip()) {
         fCmdBuffer.pop_back();
         return false;
@@ -536,7 +530,6 @@
                                               ss->fState.getInitBatchTracker());
 
     if (fPrevState &&
-        fPrevState->fDrawType == ss->fDrawType &&
         fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
                                                       *ss->fPrimitiveProcessor,
                                                       ss->fBatchTracker) &&
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index d94b311..ea1279b 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -181,12 +181,10 @@
     struct SetState : public Cmd {
         SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primProc,
                  const GrDrawTargetCaps& caps,
-                 const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy,
-                 GrGpu::DrawType drawType)
+                 const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy)
         : Cmd(kSetState_Cmd)
         , fPrimitiveProcessor(primProc)
-        , fState(drawState, primProc, caps, scissor, dstCopy)
-        , fDrawType(drawType) {}
+        , fState(drawState, primProc, caps, scissor, dstCopy) {}
 
         void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
 
@@ -195,7 +193,6 @@
         const GrOptDrawState        fState;
         GrProgramDesc               fDesc;
         GrBatchTracker              fBatchTracker;
-        GrGpu::DrawType             fDrawType;
     };
 
     typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
@@ -257,7 +254,6 @@
     // recorded.
     bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&,
                                                         const GrPrimitiveProcessor*,
-                                                        GrGpu::DrawType,
                                                         const GrScissorState&,
                                                         const GrDeviceCoordTexture*);
     // We lazily record clip changes in order to skip clips that have no effect.
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 3acf27e..5ec4dcf 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -66,7 +66,6 @@
     void buildProgramDesc(GrProgramDesc*,const GrPrimitiveProcessor&,
                           const GrOptDrawState&,
                           const GrProgramDesc::DescInfo&,
-                          GrGpu::DrawType,
                           const GrBatchTracker&) const SK_OVERRIDE {}
 
     void discard(GrRenderTarget*) SK_OVERRIDE {}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index f489d03..b28c32e 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1336,7 +1336,7 @@
     this->disableScissor();
 }
 
-bool GrGLGpu::flushGLState(const DrawArgs& args) {
+bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) {
     GrXferProcessor::BlendInfo blendInfo;
     const GrOptDrawState& optState = *args.fOptState;
     args.fOptState->getXferProcessor()->getBlendInfo(&blendInfo);
@@ -1368,8 +1368,7 @@
     GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget());
     this->flushStencil(optState.getStencil());
     this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin());
-    this->flushHWAAState(glRT, optState.isHWAntialiasState(),
-                         kDrawLines_DrawType == args.fDrawType);
+    this->flushHWAAState(glRT, optState.isHWAntialiasState(), isLineDraw);
 
     // This must come after textures are flushed because a texture may need
     // to be msaa-resolved (which will modify bound FBO state).
@@ -1435,9 +1434,8 @@
                                const GrPrimitiveProcessor& primProc,
                                const GrOptDrawState& optState,
                                const GrProgramDesc::DescInfo& descInfo,
-                               GrGpu::DrawType drawType,
                                const GrBatchTracker& batchTracker) const {
-    if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, drawType, this,
+    if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, this,
                                        batchTracker)) {
         SkDEBUGFAIL("Failed to generate GL program descriptor");
     }
@@ -1827,7 +1825,7 @@
 #endif
 
 void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) {
-    if (!this->flushGLState(args)) {
+    if (!this->flushGLState(args, GrIsPrimTypeLines(info.primitiveType()))) {
         return;
     }
 
@@ -1880,7 +1878,7 @@
 
 void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path,
                          const GrStencilSettings& stencil) {
-    if (!this->flushGLState(args)) {
+    if (!this->flushGLState(args, false)) {
         return;
     }
     fPathRendering->drawPath(path, stencil);
@@ -1894,7 +1892,7 @@
                           GrDrawTarget::PathTransformType transformType,
                            int count,
                            const GrStencilSettings& stencil) {
-    if (!this->flushGLState(args)) {
+    if (!this->flushGLState(args, false)) {
         return;
     }
     fPathRendering->drawPaths(pathRange, indices, indexType, transformValues,
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index d63c105..0173a23 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -108,7 +108,6 @@
                           const GrPrimitiveProcessor&,
                           const GrOptDrawState&,
                           const GrProgramDesc::DescInfo&,
-                          GrGpu::DrawType,
                           const GrBatchTracker&) const SK_OVERRIDE;
 
 private:
@@ -168,7 +167,9 @@
     void setTextureUnit(int unitIdx);
 
     // Flushes state from GrOptDrawState to GL. Returns false if the state couldn't be set.
-    bool flushGLState(const DrawArgs&);
+    // TODO we only have need to know if this is a line draw for flushing AA state on some buggy
+    // hardware.  Evaluate if this is really necessary anymore
+    bool flushGLState(const DrawArgs&, bool isLineDraw);
 
     // Sets up vertex attribute pointers and strides. On return indexOffsetInBytes gives the offset
     // an into the index buffer. It does not account for drawInfo.startIndex() but rather the start
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 243be01..a89941c 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -90,7 +90,6 @@
                                    const GrPrimitiveProcessor& primProc,
                                    const GrOptDrawState& optState,
                                    const GrProgramDesc::DescInfo& descInfo,
-                                   GrGpu::DrawType drawType,
                                    const GrGLGpu* gpu,
                                    const GrBatchTracker& batchTracker) {
     // The descriptor is used as a cache key. Thus when a field of the
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index 3b8093d..0584082 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -49,7 +49,6 @@
      *                        this optstate.
      * @param DescInfo  A descriptor info struct, generated by the optstate, which contains a number
      *                  of important facts about the program the built descriptor will represent
-     * @param DrawType
      * @param GrGLGpu  A GL Gpu, the caps and Gpu object are used to output processor specific
      *                 parts of the descriptor.
      * @param GrDeviceCoordTexture  A dstCopy texture, which may be null if frame buffer fetch is
@@ -60,7 +59,6 @@
                       const GrPrimitiveProcessor&,
                       const GrOptDrawState&,
                       const GrProgramDesc::DescInfo&,
-                      GrGpu::DrawType,
                       const GrGLGpu*,
                       const GrBatchTracker&);
 };
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index c26a72e..9fbb4c1 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -74,7 +74,7 @@
 
 GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const DrawArgs& args,
                                                              GrGLGpu* gpu) {
-    if (GrGpu::IsPathRenderingDrawType(args.fDrawType)) {
+    if (args.fPrimitiveProcessor->isPathRendering()) {
         SkASSERT(gpu->glCaps().pathRenderingSupport() &&
                  !args.fPrimitiveProcessor->willUseGeoShader() &&
                  args.fPrimitiveProcessor->numAttribs() == 0);
@@ -396,7 +396,7 @@
 
     // Legacy nvpr will not compile with a vertex shader, but newer nvpr requires a dummy vertex
     // shader
-    bool useNvpr = GrGpu::IsPathRenderingDrawType(this->drawType());
+    bool useNvpr = primitiveProcessor().isPathRendering();
     if (!(useNvpr && fGpu->glCaps().nvprSupport() == GrGLCaps::kLegacy_NvprSupport)) {
         if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) {
             this->cleanupProgram(programID, shadersToDelete);
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 37cd57f..612791e 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -287,7 +287,6 @@
     const GrProgramDesc& desc() const { return *fArgs.fDesc; }
     const GrBatchTracker& batchTracker() const { return *fArgs.fBatchTracker; }
     const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(); }
-    GrGpu::DrawType drawType() const { return fArgs.fDrawType; }
 
     // Generates a name for a variable. The generated string will be name prefixed by the prefix
     // char (unless the prefix is '\0'). It also mangles the name to be stage-specific if we're
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 3d1f5e2..638e229 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -272,9 +272,6 @@
         // if path rendering we have to setup a couple of things like the draw type
         bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.nextBool();
 
-        GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
-                                                      GrGpu::kDrawPoints_DrawType;
-
         // twiddle drawstate knobs randomly
         bool hasGeometryProcessor = !usePathRendering;
         SkAutoTUnref<const GrGeometryProcessor> gp;
@@ -320,9 +317,9 @@
         primProc->initBatchTracker(&bt, ods.getInitBatchTracker());
 
         GrProgramDesc desc;
-        gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), drawType, bt);
+        gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), bt);
 
-        GrGpu::DrawArgs args(primProc, &ods, &desc, &bt, drawType);
+        GrGpu::DrawArgs args(primProc, &ods, &desc, &bt);
         SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu));
 
         if (NULL == program.get()) {