From: commit-bot@chromium.org Date: Mon, 7 Oct 2013 18:20:27 +0000 (+0000) Subject: Fix for blinking/corrupted text in Canvas 2D. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~10565 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49e80830e9c633dcb8e7596bda17ea004ae48bd4;p=platform%2Fupstream%2FlibSkiaSharp.git 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 @@ 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); 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 @@ 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; } 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 @@ 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(); }