Purge Skia objects from GL caches as needed.

Change-Id: I754c671cf790ad5ae8bf047ad328034217da4ecc
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index e558870..927070a 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -102,9 +102,10 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 Texture* TextureCache::get(SkBitmap* bitmap) {
-    Mutex::Autolock _l(mLock);
-
+    mLock.lock();
     Texture* texture = mCache.get(bitmap);
+    mLock.unlock();
+
     if (!texture) {
         if (bitmap->width() > mMaxTextureSize || bitmap->height() > mMaxTextureSize) {
             LOGW("Bitmap too large to be uploaded into a texture");
@@ -114,9 +115,11 @@
         const uint32_t size = bitmap->rowBytes() * bitmap->height();
         // Don't even try to cache a bitmap that's bigger than the cache
         if (size < mMaxSize) {
+            mLock.lock();
             while (mSize + size > mMaxSize) {
                 mCache.removeOldest();
             }
+            mLock.unlock();
         }
 
         texture = new Texture;
@@ -124,8 +127,10 @@
         generateTexture(bitmap, texture, false);
 
         if (size < mMaxSize) {
+            mLock.lock();
             mSize += size;
             mCache.put(bitmap, texture);
+            mLock.unlock();
         } else {
             texture->cleanup = true;
         }