add explicit purgeAll() so we don't get foiled by the min cache-limit
call unref instead of delete on the GrFontScaler Review URL: https://codereview.appspot.com/6353045 git-svn-id: http://skia.googlecode.com/svn/trunk@4366 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
c0c1daa7f6
commit
26344cfaff
@ -356,25 +356,6 @@ void SkGlyphCache::setAuxProc(void (*proc)(void*), void* data) {
|
||||
fAuxProcList = rec;
|
||||
}
|
||||
|
||||
void SkGlyphCache::removeAuxProc(void (*proc)(void*)) {
|
||||
AuxProcRec* rec = fAuxProcList;
|
||||
AuxProcRec* prev = NULL;
|
||||
while (rec) {
|
||||
AuxProcRec* next = rec->fNext;
|
||||
if (rec->fProc == proc) {
|
||||
if (prev) {
|
||||
prev->fNext = next;
|
||||
} else {
|
||||
fAuxProcList = next;
|
||||
}
|
||||
SkDELETE(rec);
|
||||
return;
|
||||
}
|
||||
prev = rec;
|
||||
rec = next;
|
||||
}
|
||||
}
|
||||
|
||||
void SkGlyphCache::invokeAndRemoveAuxProcs() {
|
||||
AuxProcRec* rec = fAuxProcList;
|
||||
while (rec) {
|
||||
@ -457,6 +438,7 @@ public:
|
||||
|
||||
size_t getFontCacheLimit() const { return fFontCacheLimit; }
|
||||
size_t setFontCacheLimit(size_t limit);
|
||||
void purgeAll(); // does not change budget
|
||||
|
||||
// can return NULL
|
||||
static SkGlyphCache_Globals* FindTLS() {
|
||||
@ -486,7 +468,7 @@ size_t SkGlyphCache_Globals::setFontCacheLimit(size_t newLimit) {
|
||||
if (newLimit < minLimit) {
|
||||
newLimit = minLimit;
|
||||
}
|
||||
|
||||
|
||||
size_t prevLimit = fFontCacheLimit;
|
||||
fFontCacheLimit = newLimit;
|
||||
|
||||
@ -498,6 +480,11 @@ size_t SkGlyphCache_Globals::setFontCacheLimit(size_t newLimit) {
|
||||
return prevLimit;
|
||||
}
|
||||
|
||||
void SkGlyphCache_Globals::purgeAll() {
|
||||
SkAutoMutexAcquire ac(fMutex);
|
||||
SkGlyphCache::InternalFreeCache(this, fTotalMemoryUsed);
|
||||
}
|
||||
|
||||
// Returns the shared globals
|
||||
static SkGlyphCache_Globals& getSharedGlobals() {
|
||||
// we leak this, so we don't incur any shutdown cost of the destructor
|
||||
@ -731,7 +718,7 @@ size_t SkGraphics::SetFontCacheLimit(size_t bytes) {
|
||||
}
|
||||
|
||||
void SkGraphics::PurgeFontCache() {
|
||||
getSharedGlobals().setFontCacheLimit(0);
|
||||
getSharedGlobals().purgeAll();
|
||||
SkTypefaceCache::PurgeAll();
|
||||
}
|
||||
|
||||
|
@ -119,9 +119,6 @@ public:
|
||||
bool getAuxProcData(void (*auxProc)(void*), void** dataPtr) const;
|
||||
//! Add a proc/data pair to the glyphcache. proc should be non-null
|
||||
void setAuxProc(void (*auxProc)(void*), void* auxData);
|
||||
//! If found, remove the proc/data pair from the glyphcache (does not
|
||||
// call the proc)
|
||||
void removeAuxProc(void (*auxProc)(void*));
|
||||
|
||||
SkScalerContext* getScalerContext() const { return fScalerContext; }
|
||||
|
||||
|
@ -1673,7 +1673,8 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void GlyphCacheAuxProc(void* data) {
|
||||
delete (GrFontScaler*)data;
|
||||
GrFontScaler* scaler = (GrFontScaler*)data;
|
||||
SkSafeUnref(scaler);
|
||||
}
|
||||
|
||||
static GrFontScaler* get_gr_font_scaler(SkGlyphCache* cache) {
|
||||
|
Loading…
Reference in New Issue
Block a user