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
This commit is contained in:
commit-bot@chromium.org 2013-10-07 18:20:27 +00:00
parent 6c1ee2d4e7
commit 49e80830e9
3 changed files with 8 additions and 12 deletions

View 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);

View 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;
}

View 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(); }