summaryrefslogtreecommitdiffstats
path: root/skia/gl/SkGLCanvas.cpp
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 21:01:41 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 21:01:41 +0000
commit52e935d04c59135739c3a68fb6e19d313dc6d5ad (patch)
tree95f7ab178b045bef4456cbf92c6aa7e476becd99 /skia/gl/SkGLCanvas.cpp
parent30fab79877b4bb067944b74d98346ac9bb6bfc7e (diff)
downloadchromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.zip
chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.gz
chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.bz2
New drop of Skia. This is up to CL 121320.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/gl/SkGLCanvas.cpp')
-rw-r--r--skia/gl/SkGLCanvas.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/skia/gl/SkGLCanvas.cpp b/skia/gl/SkGLCanvas.cpp
index d9f2201..2e93209 100644
--- a/skia/gl/SkGLCanvas.cpp
+++ b/skia/gl/SkGLCanvas.cpp
@@ -90,18 +90,11 @@ SkDevice* SkGLCanvas::createDevice(SkBitmap::Config, int width, int height,
static SkMutex gTextureCacheMutex;
static SkTextureCache gTextureCache(kTexCountMax_Default, kTexSizeMax_Default);
-static void* gTextureGLContext;
SkGLDevice::TexCache* SkGLDevice::LockTexCache(const SkBitmap& bitmap,
GLuint* name, SkPoint* size) {
SkAutoMutexAcquire amc(gTextureCacheMutex);
- void* ctx = SkGetGLContext();
- if (gTextureGLContext != ctx) {
- gTextureGLContext = ctx;
- gTextureCache.zapAllTextures();
- }
-
SkTextureCache::Entry* entry = gTextureCache.lock(bitmap);
if (NULL != entry) {
if (name) {
@@ -141,3 +134,46 @@ void SkGLCanvas::SetTextureCacheMaxSize(size_t size) {
gTextureCache.setMaxSize(size);
}
+///////////////////////////////////////////////////////////////////////////////
+
+#include "SkGLTextCache.h"
+
+static bool deleteCachesProc(SkGlyphCache* cache, void* texturesAreValid) {
+ void* auxData;
+ if (cache->getAuxProcData(SkGLDevice::GlyphCacheAuxProc, &auxData)) {
+ bool valid = texturesAreValid != NULL;
+ SkGLTextCache* textCache = static_cast<SkGLTextCache*>(auxData);
+ // call this before delete, in case valid is false
+ textCache->deleteAllStrikes(valid);
+ // now free the memory for the cache itself
+ SkDELETE(textCache);
+ // now remove the entry in the glyphcache (does not call the proc)
+ cache->removeAuxProc(SkGLDevice::GlyphCacheAuxProc);
+ }
+ return false; // keep going
+}
+
+void SkGLCanvas::DeleteAllTextures() {
+ // free the textures in our cache
+
+ gTextureCacheMutex.acquire();
+ gTextureCache.deleteAllCaches(true);
+ gTextureCacheMutex.release();
+
+ // now free the textures in the font cache
+
+ SkGlyphCache::VisitAllCaches(deleteCachesProc, reinterpret_cast<void*>(true));
+}
+
+void SkGLCanvas::AbandonAllTextures() {
+ // abandon the textures in our cache
+
+ gTextureCacheMutex.acquire();
+ gTextureCache.deleteAllCaches(false);
+ gTextureCacheMutex.release();
+
+ // abandon the textures in the font cache
+
+ SkGlyphCache::VisitAllCaches(deleteCachesProc, reinterpret_cast<void*>(false));
+}
+