Fix for blinking/corrupted text in Canvas 2D.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Oct 2013 18:20:27 +0000 (18:20 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Oct 2013 18:20:27 +0000 (18:20 +0000)
Ensure that we update the drawToken for a glyph's plot every time it is
used, not just when the glyph is first added.

BUG=303803
R=junov@chromium.org, bsalomon@google.com

Author: jvanverth@google.com

Review URL: https://codereview.chromium.org/26253003

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

src/gpu/GrTextContext.cpp
src/gpu/GrTextStrike.cpp
src/gpu/GrTextStrike.h

index 5a61839..8178032 100644 (file)
@@ -153,15 +153,14 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
         }
     }
 
-    GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
     if (NULL == glyph->fPlot) {
-        if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) {
+        if (fStrike->getGlyphAtlas(glyph, scaler)) {
             goto HAS_ATLAS;
         }
 
         // try to clear out an unused plot before we flush
         fContext->getFontCache()->freePlotExceptFor(fStrike);
-        if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) {
+        if (fStrike->getGlyphAtlas(glyph, scaler)) {
             goto HAS_ATLAS;
         }
 
@@ -178,7 +177,7 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
         // try to purge
         fContext->getFontCache()->purgeExceptFor(fStrike);
         // need to use new flush count here
-        if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) {
+        if (fStrike->getGlyphAtlas(glyph, scaler)) {
             goto HAS_ATLAS;
         }
 
@@ -205,6 +204,8 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
 
 HAS_ATLAS:
     SkASSERT(glyph->fPlot);
+    GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
+    glyph->fPlot->setDrawToken(drawToken);
 
     // now promote them to fixed (TODO: Rethink using fixed pt).
     width = SkIntToFixed(width);
index 4a56051..ab7d8f0 100644 (file)
@@ -259,8 +259,7 @@ bool GrTextStrike::removeUnusedPlots() {
     return fAtlasMgr->removeUnusedPlots(&fAtlas);
 }
 
-bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler,
-                                 GrDrawTarget::DrawToken currentDrawToken) {
+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;
@@ -269,10 +268,7 @@ bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler,
     SkASSERT(glyph);
     SkASSERT(scaler);
     SkASSERT(fCache.contains(glyph));
-    if (glyph->fPlot) {
-        glyph->fPlot->setDrawToken(currentDrawToken);
-        return true;
-    }
+    SkASSERT(NULL == glyph->fPlot);
 
     SkAutoRef ar(scaler);
 
@@ -294,6 +290,5 @@ bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler,
     }
 
     glyph->fPlot = plot;
-    plot->setDrawToken(currentDrawToken);
     return true;
 }
index 35d5008..3d5bfdc 100644 (file)
@@ -38,7 +38,7 @@ public:
     GrMaskFormat getMaskFormat() const { return fMaskFormat; }
 
     inline GrGlyph* getGlyph(GrGlyph::PackedID, GrFontScaler*);
-    bool getGlyphAtlas(GrGlyph*, GrFontScaler*, GrDrawTarget::DrawToken currentDrawToken);
+    bool getGlyphAtlas(GrGlyph*, GrFontScaler*);
 
     // testing
     int countGlyphs() const { return fCache.getArray().count(); }