always flush accumulated draws before we purge the font cache



git-svn-id: http://skia.googlecode.com/svn/trunk@1051 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrInOrderDrawBuffer.cpp b/gpu/src/GrInOrderDrawBuffer.cpp
index 8225425..8191814 100644
--- a/gpu/src/GrInOrderDrawBuffer.cpp
+++ b/gpu/src/GrInOrderDrawBuffer.cpp
@@ -316,6 +316,7 @@
 }
 
 void GrInOrderDrawBuffer::playback(GrDrawTarget* target) {
+    GrAssert(!fReservedGeometry.fLocked);
     GrAssert(NULL != target);
     GrAssert(target != this); // not considered and why?
 
@@ -346,8 +347,6 @@
             ++currClip;
             target->setClip(fClips[currClip]);
         }
-        uint32_t vertexReserveCount = 0;
-        uint32_t indexReserveCount = 0;
 
         target->setVertexSourceToBuffer(draw.fVertexLayout, draw.fVertexBuffer);
 
@@ -366,9 +365,6 @@
                                    draw.fStartVertex,
                                    draw.fVertexCount);
         }
-        if (vertexReserveCount || indexReserveCount) {
-            target->releaseReservedGeometry();
-        }
     }
 }
 
diff --git a/gpu/src/GrTextContext.cpp b/gpu/src/GrTextContext.cpp
index 2230af2..e2c81c7 100644
--- a/gpu/src/GrTextContext.cpp
+++ b/gpu/src/GrTextContext.cpp
@@ -176,7 +176,9 @@
         if (fStrike->getGlyphAtlas(glyph, scaler)) {
             goto HAS_ATLAS;
         }
-        // must do this to flush inorder buffering before we purge
+
+        // before we purge the cache, we must flush any accumulated draws
+        this->flushGlyphs();
         fContext->flushText();
 
         // try to purge
@@ -185,11 +187,7 @@
             goto HAS_ATLAS;
         }
 
-        // Draw as a path, so we flush any accumulated glyphs first
-        this->flushGlyphs();
-
         if (NULL == glyph->fPath) {
-
             GrPath* path = new GrPath;
             if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
                 // flag the glyph as being dead?
diff --git a/gpu/src/GrTextStrike.cpp b/gpu/src/GrTextStrike.cpp
index a245997..7aae757 100644
--- a/gpu/src/GrTextStrike.cpp
+++ b/gpu/src/GrTextStrike.cpp
@@ -169,6 +169,11 @@
 }
 
 bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
+#if 0   // testing hack to force us to flush our cache often
+    static int gCounter;
+    if ((++gCounter % 10) == 0) return false;
+#endif
+
     GrAssert(glyph);
     GrAssert(scaler);
     GrAssert(fCache.contains(glyph));