Unify text flushing with other deferred drawing

Review URL: http://codereview.appspot.com/5936054/



git-svn-id: http://skia.googlecode.com/svn/trunk@3560 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrBatchedTextContext.cpp b/src/gpu/GrBatchedTextContext.cpp
index 3b3a4ba..9de2bad 100644
--- a/src/gpu/GrBatchedTextContext.cpp
+++ b/src/gpu/GrBatchedTextContext.cpp
@@ -70,7 +70,7 @@
                                                 NULL);
         if (flush) {
             this->flush();
-            fContext->flushText();
+            fContext->flush();
             fDrawTarget = fContext->getTextTarget(fGrPaint);
             fMaxVertices = kDefaultRequestedVerts;
             // ignore return, no point in flushing again.
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 4ef0f5b..4b3d942 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1539,18 +1539,10 @@
     }
 }
 
-void GrContext::flushText() {
-    if (kText_DrawCategory == fLastDrawCategory) {
-        flushDrawBuffer();
-    }
-}
-
 void GrContext::flushDrawBuffer() {
-#if BATCH_RECT_TO_RECT || DEFER_TEXT_RENDERING
     if (fDrawBuffer) {
         fDrawBuffer->flushTo(fGpu);
     }
-#endif
 }
 
 void GrContext::internalWriteTexturePixels(GrTexture* texture,
@@ -1955,21 +1947,16 @@
     this->setPaint(paint);
     GrDrawTarget* target = fGpu;
     switch (category) {
-    case kText_DrawCategory:
-#if DEFER_TEXT_RENDERING
-        target = fDrawBuffer;
-        fDrawBuffer->setClip(fGpu->getClip());
-#else
-        target = fGpu;
-#endif
-        break;
-    case kUnbuffered_DrawCategory:
-        target = fGpu;
-        break;
-    case kBuffered_DrawCategory:
-        target = fDrawBuffer;
-        fDrawBuffer->setClip(fGpu->getClip());
-        break;
+        case kUnbuffered_DrawCategory:
+            target = fGpu;
+            break;
+        case kBuffered_DrawCategory:
+            target = fDrawBuffer;
+            fDrawBuffer->setClip(fGpu->getClip());
+            break;
+        default:
+            GrCrash("Unexpected DrawCategory.");
+            break;
     }
     return target;
 }
@@ -2093,7 +2080,7 @@
 
 GrDrawTarget* GrContext::getTextTarget(const GrPaint& paint) {
 #if DEFER_TEXT_RENDERING
-    return prepareToDraw(paint, kText_DrawCategory);
+    return prepareToDraw(paint, kBuffered_DrawCategory);
 #else
     return prepareToDraw(paint, kUnbuffered_DrawCategory);
 #endif
diff --git a/src/gpu/GrDefaultTextContext.cpp b/src/gpu/GrDefaultTextContext.cpp
index d2c5d92..a606dd5 100644
--- a/src/gpu/GrDefaultTextContext.cpp
+++ b/src/gpu/GrDefaultTextContext.cpp
@@ -211,7 +211,7 @@
 
         // before we purge the cache, we must flush any accumulated draws
         this->flushGlyphs();
-        fContext->flushText();
+        fContext->flush();
 
         // try to purge
         fContext->getFontCache()->purgeExceptFor(fStrike);