From 7359eae7c6fce8cb88ae28ca7048283b77535db4 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Tue, 21 Jun 2011 21:18:25 +0000 Subject: fix to free a plot when purging gr font cache Review URL: http://codereview.appspot.com/4645054/ git-svn-id: http://skia.googlecode.com/svn/trunk@1667 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gpu/src/GrTextStrike.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gpu/src/GrTextStrike.cpp b/gpu/src/GrTextStrike.cpp index 7aae7571a3..455f88a7bb 100644 --- a/gpu/src/GrTextStrike.cpp +++ b/gpu/src/GrTextStrike.cpp @@ -68,15 +68,19 @@ void GrFontCache::freeAll() { void GrFontCache::purgeExceptFor(GrTextStrike* preserveStrike) { GrTextStrike* strike = fTail; - if (strike == preserveStrike) { - strike = strike->fPrev; - } - if (strike) { - int index = fCache.slowFindIndex(strike); + while (strike) { + if (strike == preserveStrike) { + strike = strike->fPrev; + continue; + } + GrTextStrike* strikeToPurge = strike; + // keep going if we won't free up any atlases with this strike. + strike = (NULL == strikeToPurge->fAtlas) ? strikeToPurge->fPrev : NULL; + int index = fCache.slowFindIndex(strikeToPurge); GrAssert(index >= 0); - fCache.removeAt(index, strike->fFontScalerKey->getHash()); - this->detachStrikeFromList(strike); - delete strike; + fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash()); + this->detachStrikeFromList(strikeToPurge); + delete strikeToPurge; } } -- cgit v1.2.3