The TextBlobCache needs the ability to trigger a flush because otherwise its entire budget can be used up, but it will not be able to free up any space due to blobs being stuck in the GrInOrderDrawBuffer.  This was causing a segfault.  After this CL the cache will try to purge, and then flush if it cannot purge enough.  It will not purge the most recent addition to the cache.

TBR=bsalomon@google.com
BUG=skia:

Review URL: https://codereview.chromium.org/1071333002
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2d61f35..04e3f8f 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -137,7 +137,7 @@
     // GrBatchFontCache will eventually replace GrFontCache
     fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this));
 
-    fTextBlobCache.reset(SkNEW(GrTextBlobCache));
+    fTextBlobCache.reset(SkNEW_ARGS(GrTextBlobCache, (TextBlobCacheOverBudgetCB, this)));
 }
 
 GrContext::~GrContext() {
@@ -354,6 +354,17 @@
     context->fFlushToReduceCacheSize = true;
 }
 
+void GrContext::TextBlobCacheOverBudgetCB(void* data) {
+    SkASSERT(data);
+
+    // Unlike the GrResourceCache, TextBlobs are drawn at the SkGpuDevice level, therefore they
+    // cannot use fFlushTorReduceCacheSize because it uses AutoCheckFlush.  The solution is to move
+    // drawText calls to below the GrContext level, but this is not trivial because they call
+    // drawPath on SkGpuDevice
+    GrContext* context = reinterpret_cast<GrContext*>(data);
+    context->flush();
+}
+
 int GrContext::getMaxTextureSize() const {
     return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride);
 }