remove drawType from optState

BUG=skia:

Review URL: https://codereview.chromium.org/864853002
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index cbae83f..53ac9c3 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -366,17 +366,20 @@
         DrawArgs(const GrPrimitiveProcessor* primProc,
                  const GrOptDrawState* optState,
                  const GrProgramDesc* desc,
-                 const GrBatchTracker* batchTracker)
+                 const GrBatchTracker* batchTracker,
+                 DrawType drawType)
             : fPrimitiveProcessor(primProc)
             , fOptState(optState)
             , fDesc(desc)
-            , fBatchTracker(batchTracker) {
+            , fBatchTracker(batchTracker)
+            , fDrawType(drawType) {
             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&);
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index f504f09..1c7cb25 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -435,7 +435,7 @@
             SetState* ss = reinterpret_cast<SetState*>(iter.get());
 
             this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, ss->fState,
-                                             ss->fState.descInfo(), ss->fState.drawType(),
+                                             ss->fState.descInfo(), ss->fDrawType,
                                              ss->fBatchTracker);
             currentState = ss;
 
@@ -455,7 +455,7 @@
 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
     SkASSERT(state);
     DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
-                  &state->fBatchTracker);
+                  &state->fBatchTracker, state->fDrawType);
     buf->getGpu()->draw(args, fInfo);
 }
 
@@ -473,14 +473,14 @@
 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
     SkASSERT(state);
     DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
-                  &state->fBatchTracker);
+                  &state->fBatchTracker, state->fDrawType);
     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->fBatchTracker, state->fDrawType);
     buf->getGpu()->drawPaths(args, this->pathRange(),
                             &buf->fPathIndexBuffer[fIndicesLocation], fIndexType,
                             &buf->fPathTransformBuffer[fTransformsLocation], fTransformType,
@@ -536,6 +536,7 @@
                                               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 6a6cd88..d94b311 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -185,7 +185,8 @@
                  GrGpu::DrawType drawType)
         : Cmd(kSetState_Cmd)
         , fPrimitiveProcessor(primProc)
-        , fState(drawState, primProc, caps, scissor, dstCopy, drawType) {}
+        , fState(drawState, primProc, caps, scissor, dstCopy)
+        , fDrawType(drawType) {}
 
         void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
 
@@ -194,6 +195,7 @@
         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.
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 8d28f44..a111007 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -17,10 +17,7 @@
                                const GrPrimitiveProcessor* primProc,
                                const GrDrawTargetCaps& caps,
                                const GrScissorState& scissorState,
-                               const GrDeviceCoordTexture* dstCopy,
-                               GrGpu::DrawType drawType) {
-    fDrawType = drawType;
-
+                               const GrDeviceCoordTexture* dstCopy) {
     const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc);
     const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc);
 
@@ -145,7 +142,6 @@
         this->fFragmentStages.count() != that.fFragmentStages.count() ||
         this->fNumColorStages != that.fNumColorStages ||
         this->fScissorState != that.fScissorState ||
-        this->fDrawType != that.fDrawType ||
         this->fFlags != that.fFlags ||
         this->fStencilSettings != that.fStencilSettings ||
         this->fDrawFace != that.fDrawFace ||
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 6beeea2..626e6d7 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -31,7 +31,7 @@
 
     GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*,
                    const GrDrawTargetCaps&, const GrScissorState&,
-                   const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType);
+                   const GrDeviceCoordTexture* dstCopy);
 
     /*
      * Returns true if it is possible to combine the two GrOptDrawStates and it will update 'this'
@@ -128,8 +128,6 @@
 
     ///////////////////////////////////////////////////////////////////////////
 
-    GrGpu::DrawType drawType() const { return fDrawType; }
-
     const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ? &fDstCopy : NULL; }
 
     const GrProgramDesc::DescInfo& descInfo() const { return fDescInfo; }
@@ -171,7 +169,6 @@
     uint32_t                            fFlags;
     ProgramXferProcessor                fXferProcessor;
     FragmentStageArray                  fFragmentStages;
-    GrGpu::DrawType                     fDrawType;
     GrProgramDesc::DescInfo             fDescInfo;
     GrGeometryProcessor::InitBT         fInitBT;
 
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index aa9a3e6..f489d03 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1369,7 +1369,7 @@
     this->flushStencil(optState.getStencil());
     this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin());
     this->flushHWAAState(glRT, optState.isHWAntialiasState(),
-                         kDrawLines_DrawType == optState.drawType());
+                         kDrawLines_DrawType == args.fDrawType);
 
     // This must come after textures are flushed because a texture may need
     // to be msaa-resolved (which will modify bound FBO state).
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index bd36e59..c018cfe 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -142,7 +142,7 @@
     this->setFragmentData(primProc, optState);
 
     // Some of GrGLProgram subclasses need to update state here
-    this->didSetData(optState.drawType());
+    this->didSetData();
 }
 
 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
@@ -169,10 +169,6 @@
                          processor.processor()->coordTransforms());
 }
 
-void GrGLProgram::didSetData(GrGpu::DrawType drawType) {
-    SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
-}
-
 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
                                        const GrOptDrawState& optState) {
     // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
@@ -215,8 +211,7 @@
     : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc,
                 xferProcessor, fragmentProcessors) {
 }
-void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) {
-    SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
+void GrGLNvprProgram::didSetData() {
     GrGLPathProcessor* pathProc =
             static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.get());
     pathProc->didSetData(fGpu->glPathRendering());
@@ -234,8 +229,7 @@
 
 void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
                                              const GrOptDrawState& optState) {
-    SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType()) &&
-             !primProc.willUseGeoShader() && primProc.numAttribs() == 0);
+    SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0);
     const GrRenderTarget* rt = optState.getRenderTarget();
     SkISize size;
     size.set(rt->width(), rt->height());
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index bd4d6a3..cce6c2a 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -128,7 +128,7 @@
      * Legacy NVPR needs a hook here to flush path tex gen settings.
      * TODO when legacy nvpr is removed, remove this call.
      */
-    virtual void didSetData(GrGpu::DrawType);
+    virtual void didSetData() {}
 
     // Helper for setData() that sets the view matrix and loads the render target height uniform
     void setRenderTargetState(const GrPrimitiveProcessor&, const GrOptDrawState&);
@@ -175,7 +175,7 @@
                     GrGLInstalledFragProcs* fragmentProcessors);
 
 private:
-    void didSetData(GrGpu::DrawType) SK_OVERRIDE;
+    void didSetData() SK_OVERRIDE;
     virtual void setTransformData(const GrPrimitiveProcessor&,
                                   const GrPendingFragmentStage&,
                                   int index,
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index e81c079..c26a72e 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.fOptState->drawType())) {
+    if (GrGpu::IsPathRenderingDrawType(args.fDrawType)) {
         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->optState().drawType());
+    bool useNvpr = GrGpu::IsPathRenderingDrawType(this->drawType());
     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 612791e..37cd57f 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -287,6 +287,7 @@
     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 4dcba37..3d1f5e2 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -312,7 +312,7 @@
 
         // create optimized draw state, setup readDst texture if required, and build a descriptor
         // and program.  ODS creation can fail, so we have to check
-        GrOptDrawState ods(ds, primProc, *gpu->caps(), scissor, &dstCopy, drawType);
+        GrOptDrawState ods(ds, primProc, *gpu->caps(), scissor, &dstCopy);
         if (ods.mustSkip()) {
             continue;
         }
@@ -320,9 +320,9 @@
         primProc->initBatchTracker(&bt, ods.getInitBatchTracker());
 
         GrProgramDesc desc;
-        gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), ods.drawType(), bt);
+        gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), drawType, bt);
 
-        GrGpu::DrawArgs args(primProc, &ods, &desc, &bt);
+        GrGpu::DrawArgs args(primProc, &ods, &desc, &bt, drawType);
         SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu));
 
         if (NULL == program.get()) {