Unify text flushing with other deferred drawing
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 30 Mar 2012 17:35:12 +0000 (17:35 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 30 Mar 2012 17:35:12 +0000 (17:35 +0000)
Review URL: http://codereview.appspot.com/5936054/

git-svn-id: http://skia.googlecode.com/svn/trunk@3560 2bbb7eff-a529-9590-31e7-b0007b416f81

include/gpu/GrContext.h
src/gpu/GrBatchedTextContext.cpp
src/gpu/GrContext.cpp
src/gpu/GrDefaultTextContext.cpp

index e0bbb4c..bed2d99 100644 (file)
@@ -645,7 +645,6 @@ public:
     const GrGpu* getGpu() const { return fGpu; }
     GrFontCache* getFontCache() { return fFontCache; }
     GrDrawTarget* getTextTarget(const GrPaint& paint);
-    void flushText();
     const GrIndexBuffer* getQuadIndexBuffer() const;
     void resetStats();
     const GrGpuStats& getStats() const;
@@ -667,7 +666,6 @@ private:
     enum DrawCategory {
         kBuffered_DrawCategory,      // last draw was inserted in draw buffer
         kUnbuffered_DrawCategory,    // last draw was not inserted in the draw buffer
-        kText_DrawCategory           // text context was last to draw
     };
     DrawCategory fLastDrawCategory;
 
index 3b3a4ba..9de2bad 100644 (file)
@@ -70,7 +70,7 @@ void GrBatchedTextContext::setupVertexBuff(void** vertexBuff,
                                                 NULL);
         if (flush) {
             this->flush();
-            fContext->flushText();
+            fContext->flush();
             fDrawTarget = fContext->getTextTarget(fGrPaint);
             fMaxVertices = kDefaultRequestedVerts;
             // ignore return, no point in flushing again.
index 4ef0f5b..4b3d942 100644 (file)
@@ -1539,18 +1539,10 @@ void GrContext::flush(int flagsBitfield) {
     }
 }
 
-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 @@ GrDrawTarget* GrContext::prepareToDraw(const GrPaint& paint,
     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 @@ void GrContext::setupDrawBuffer() {
 
 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
index d2c5d92..a606dd5 100644 (file)
@@ -211,7 +211,7 @@ void GrDefaultTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
 
         // before we purge the cache, we must flush any accumulated draws
         this->flushGlyphs();
-        fContext->flushText();
+        fContext->flush();
 
         // try to purge
         fContext->getFontCache()->purgeExceptFor(fStrike);