diff options
author | Yichi Chen <yichichen@android.com> | 2018-03-29 21:21:54 +0800 |
---|---|---|
committer | Yichi Chen <yichichen@google.com> | 2018-09-04 04:04:58 +0000 |
commit | 9f959556201f59305cd80ad32a1c117d5b7c4113 (patch) | |
tree | 4e4b2db1dad5465b8721ac788566e1f7c86befeb /libs/hwui/renderthread/CacheManager.cpp | |
parent | 7b07e4aae6f55ef77f6c080f7a65f8b3b3e692e0 (diff) |
Add cache validation to ensure the validity
Create cache identity from GL_VERSION and store in ShaderCache.
In the next time ShaderCache is restored from disk, compare the
cache identity to ensure its validity. If GL_VERSION changes in
between, flush out entire FileBlobCache and start from an empty
one.
Bug: b/71800782
Test: Wrote a new unit test to save and restore ShaderCache
Test: hwui_unit_tests
Change-Id: Ie573dc4f18733eee090725be30445d879765231b
Diffstat (limited to 'libs/hwui/renderthread/CacheManager.cpp')
-rw-r--r-- | libs/hwui/renderthread/CacheManager.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index bec80b1e6011..82bfc4943526 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -50,7 +50,6 @@ CacheManager::CacheManager(const DisplayInfo& display) : mMaxSurfaceArea(display mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( mMaxSurfaceArea / 2, skiapipeline::VectorDrawableAtlas::StorageMode::disallowSharedSurface); - skiapipeline::ShaderCache::get().initShaderDiskCache(); } void CacheManager::reset(sk_sp<GrContext> context) { @@ -103,7 +102,7 @@ public: } }; -void CacheManager::configureContext(GrContextOptions* contextOptions) { +void CacheManager::configureContext(GrContextOptions* contextOptions, const void* identity, ssize_t size) { contextOptions->fAllowPathMaskCaching = true; float screenMP = mMaxSurfaceArea / 1024.0f / 1024.0f; @@ -133,7 +132,9 @@ void CacheManager::configureContext(GrContextOptions* contextOptions) { contextOptions->fExecutor = mTaskProcessor.get(); } - contextOptions->fPersistentCache = &skiapipeline::ShaderCache::get(); + auto& cache = skiapipeline::ShaderCache::get(); + cache.initShaderDiskCache(identity, size); + contextOptions->fPersistentCache = &cache; contextOptions->fGpuPathRenderers &= ~GpuPathRenderers::kCoverageCounting; } |