Add immediate mode option for gpu configs in dm

Review URL: https://codereview.chromium.org/1421853002
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index f42ee11..1dc26bc 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -32,13 +32,15 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
+GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
+                           const Options& options)
     : fGpu(SkRef(gpu))
     , fResourceProvider(resourceProvider)
     , fFlushState(fGpu, fResourceProvider, 0)
     , fFlushing(false)
     , fFirstUnpreparedBatch(0)
-    , fFlags(0) {
+    , fFlags(0)
+    , fOptions(options) {
     // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
     fContext = fGpu->getContext();
     fClipMaskManager.reset(new GrClipMaskManager(this));
@@ -472,6 +474,8 @@
 void GrDrawTarget::recordBatch(GrBatch* batch) {
     // A closed drawTarget should never receive new/more batches
     SkASSERT(!this->isClosed());
+    // Should never have batches queued up when in immediate mode.
+    SkASSERT(!fOptions.fImmediateMode || !fBatches.count());
 
     // Check if there is a Batch Draw we can batch with by linearly searching back until we either
     // 1) check every draw
@@ -524,6 +528,9 @@
         SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1);
         fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState);
     }
+    if (fOptions.fImmediateMode) {
+        this->flush();
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////