resolve merge conflicts of 24e38ab to stage-aosp-master

Change-Id: I02db3eb317ccb182b563ec9350a116bd5de063b6
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index a8ace8c..972ff81 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -182,7 +182,8 @@
 PathCache::PathCache()
         : mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity)
         , mSize(0)
-        , mMaxSize(Properties::pathCacheSize) {
+        , mMaxSize(Properties::pathCacheSize)
+        , mTexNum(0) {
     mCache.setOnEntryRemovedListener(this);
 
     GLint maxTextureSize;
@@ -238,6 +239,7 @@
                         "the cache in an inconsistent state", size);
             }
             mSize -= size;
+            mTexNum--;
         }
 
         PATH_LOGD("PathCache::delete name, size, mSize = %d, %d, %d",
@@ -262,7 +264,7 @@
 }
 
 void PathCache::trim() {
-    while (mSize > mMaxSize) {
+    while (mSize > mMaxSize || mTexNum > DEFAULT_PATH_TEXTURE_CAP) {
         mCache.removeOldest();
     }
 }
@@ -316,6 +318,7 @@
     ATRACE_NAME("Upload Path Texture");
     texture->upload(bitmap);
     texture->setFilter(GL_LINEAR);
+    mTexNum++;
 }
 
 ///////////////////////////////////////////////////////////////////////////////