Readd "immediate" mode

This isn't an exact replacement. The accumulated batches are now flushed at drawContext-entry-point granularity (via the AutoCheckFlush objects) rather than per batch.

TBR=bsalomon@google.com

Review URL: https://codereview.chromium.org/1439533003
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index 572b9ca..2ee7a37 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -206,7 +206,9 @@
         return fConfigTextureSupport[config];
     }
 
-    bool suppressPrints() const { return fSupressPrints; }
+    bool suppressPrints() const { return fSuppressPrints; }
+
+    bool immediateFlush() const { return fImmediateFlush; }
 
     bool drawPathMasksToCompressedTexturesSupport() const {
         return fDrawPathMasksToCompressedTextureSupport;
@@ -277,7 +279,8 @@
 private:
     virtual void onApplyOptionsOverrides(const GrContextOptions&) {};
 
-    bool fSupressPrints : 1;
+    bool fSuppressPrints : 1;
+    bool fImmediateFlush: 1;
     bool fDrawPathMasksToCompressedTextureSupport : 1;
 
     typedef SkRefCnt INHERITED;
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index c402416..098fdd2 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -8,6 +8,7 @@
 #ifndef GrContext_DEFINED
 #define GrContext_DEFINED
 
+#include "GrCaps.h"
 #include "GrClip.h"
 #include "GrColor.h"
 #include "GrPaint.h"
@@ -20,7 +21,6 @@
 
 struct GrBatchAtlasConfig;
 class GrBatchFontCache;
-class GrCaps;
 struct GrContextOptions;
 class GrDrawingManager;
 class GrDrawContext;
@@ -205,7 +205,7 @@
     void flush(int flagsBitfield = 0);
 
     void flushIfNecessary() {
-        if (fFlushToReduceCacheSize) {
+        if (fFlushToReduceCacheSize || this->caps()->immediateFlush()) {
             this->flush();
         }
     }
@@ -406,7 +406,7 @@
     bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
 
     void initMockContext();
-    void initCommon(const GrContextOptions& options);
+    void initCommon();
 
     /**
      * These functions create premul <-> unpremul effects if it is possible to generate a pair
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 3331db5..e4f81ab 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -111,7 +111,8 @@
     memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
     memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
 
-    fSupressPrints = options.fSuppressPrints;
+    fSuppressPrints = options.fSuppressPrints;
+    fImmediateFlush = options.fImmediateMode;
     fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedTexture;
     fGeometryBufferMapThreshold = options.fGeometryBufferMapThreshold;
     fUseDrawInsteadOfPartialRenderTargetWrite = options.fUseDrawInsteadOfPartialRenderTargetWrite;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index c2bcbd0..bd4ca40 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -72,11 +72,11 @@
     if (!fGpu) {
         return false;
     }
-    this->initCommon(options);
+    this->initCommon();
     return true;
 }
 
-void GrContext::initCommon(const GrContextOptions& options) {
+void GrContext::initCommon() {
     fCaps = SkRef(fGpu->caps());
     fResourceCache = new GrResourceCache(fCaps);
     fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 9c07211..bac3a16 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -88,7 +88,6 @@
     this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint);
 }
 
-
 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
                              const SkPaint& skPaint,
                              const SkMatrix& viewMatrix,
@@ -103,8 +102,8 @@
 
     fTextContext->drawText(this, fRenderTarget, clip, grPaint, skPaint, viewMatrix,
                            text, byteLength, x, y, clipBounds);
-
 }
+
 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
                                 const SkPaint& skPaint,
                                 const SkMatrix& viewMatrix,
@@ -122,6 +121,7 @@
                               pos, scalarsPerPosition, offset, clipBounds);
 
 }
+
 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
                                  const SkMatrix& viewMatrix, const SkTextBlob* blob,
                                  SkScalar x, SkScalar y,
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 975636d..6e9df21 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -300,7 +300,7 @@
     SkASSERT(nullptr == fGpu);
     fGpu = new MockGpu(this, options);
     SkASSERT(fGpu);
-    this->initCommon(options);
+    this->initCommon();
 
     // We delete these because we want to test the cache starting with zero resources. Also, none of
     // these objects are required for any of tests that use this context. TODO: make stop allocating
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index dedd009..d1798fc 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -301,8 +301,9 @@
     }
 }
 
-bool GrDrawingManager::ProgramUnitTest(GrContext* context, GrDrawTarget* drawTarget, int maxStages) {
-
+bool GrDrawingManager::ProgramUnitTest(GrContext* context,
+                                       GrDrawTarget* drawTarget,
+                                       int maxStages) {
     GrDrawingManager* drawingManager = context->drawingManager();
 
     // setup dummy textures