aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-27 18:23:01 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-27 18:23:01 +0000
commit26344cfaffa6a78c545c3e2253ec26cc277f82c9 (patch)
tree9bd4b29748ea3312be10f8038979f1eb9d10917f /src
parentc0c1daa7f60a88890a37bf31e5ce8ffa7d2d09a8 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGlyphCache.cpp29
-rw-r--r--src/core/SkGlyphCache.h3
-rw-r--r--src/gpu/SkGpuDevice.cpp3
3 files changed, 10 insertions, 25 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index 387b78bc41..8300d886f3 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -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();
}
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index f8a23a69fa..f393416238 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -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; }
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index c033f01e15..c6f377d230 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -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) {