diff options
author | 2016-08-22 15:13:01 -0700 | |
---|---|---|
committer | 2016-08-22 15:13:01 -0700 | |
commit | 4a3b0c7587dc995e00ed4e7d7ed61544f7715d2c (patch) | |
tree | 2b476e8f9b1e0a6b7d9461045468aa50cc89f1c0 | |
parent | 2a739b4fabc0b221c88764cc4263375e7d507512 (diff) | |
parent | 24e38ab322a0c396df1c6fe95f3f427d85cd5da1 (diff) |
resolve merge conflicts of 24e38ab to stage-aosp-master
Change-Id: I25844e17d2d6371ed786833c756051d19d0abec4
-rw-r--r-- | libs/hwui/PathCache.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/PathCache.h | 6 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 1c298b16154d..eb606cb037e9 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -182,7 +182,8 @@ static SkBitmap* drawPath(const SkPath* path, const SkPaint* paint, PathTexture* 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 @@ void PathCache::removeTexture(PathTexture* texture) { "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::purgeCache(uint32_t width, uint32_t height) { } void PathCache::trim() { - while (mSize > mMaxSize) { + while (mSize > mMaxSize || mTexNum > DEFAULT_PATH_TEXTURE_CAP) { mCache.removeOldest(); } } @@ -310,6 +312,7 @@ void PathCache::generateTexture(SkBitmap& bitmap, Texture* texture) { ATRACE_NAME("Upload Path Texture"); texture->upload(bitmap); texture->setFilter(GL_LINEAR); + mTexNum++; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h index 18bcc566296f..b45a2c5bf5f3 100644 --- a/libs/hwui/PathCache.h +++ b/libs/hwui/PathCache.h @@ -281,6 +281,12 @@ private: bool mDebugEnabled; + /** + * Driver allocated 4k/8k/16k memory for small path cache, + * limit the number of PathTexture in case occupy too much memory in hardware. + */ + uint32_t mTexNum; + sp<PathProcessor> mProcessor; std::vector<uint32_t> mGarbage; diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 133ae809ab2c..44d701057c04 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -224,6 +224,9 @@ enum DebugLevel { #define DEFAULT_TEXT_GAMMA 1.4f +// cap to 256 to limite paths in the path cache +#define DEFAULT_PATH_TEXTURE_CAP 256 + /////////////////////////////////////////////////////////////////////////////// // Misc /////////////////////////////////////////////////////////////////////////////// |