Fix for blinking/corrupted text in Canvas 2D.
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
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index 5a61839..8178032 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -153,15 +153,14 @@
}
}
- 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 @@
// 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 @@
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);
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index 4a56051..ab7d8f0 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -259,8 +259,7 @@
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 @@
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 @@
}
glyph->fPlot = plot;
- plot->setDrawToken(currentDrawToken);
return true;
}
diff --git a/src/gpu/GrTextStrike.h b/src/gpu/GrTextStrike.h
index 35d5008..3d5bfdc 100644
--- a/src/gpu/GrTextStrike.h
+++ b/src/gpu/GrTextStrike.h
@@ -38,7 +38,7 @@
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(); }