diff options
author | Stan Iliev <stani@google.com> | 2017-08-23 12:41:41 -0400 |
---|---|---|
committer | Stan Iliev <stani@google.com> | 2017-08-25 10:25:11 -0400 |
commit | 6b894d77462e96fb655a2959017d3aef2a32a90e (patch) | |
tree | b63e20145abdf0c0b6f25249ee93b0c5b29ee11e /libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp | |
parent | b18835d4533d054c7524d52062c5b52630574cf2 (diff) |
Release VectorDrawable cache surface on render thread
Release VectorDrawable cache surface on render thread.
This is fixing an assert in skia GrSingleOwner.h:33.
Test: Ran gmail before and after the change.
Bug: 64842607
Change-Id: I46e0c2557ac5b2fc3be2cc2d35abf96f6d6c9399
Diffstat (limited to 'libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp')
-rw-r--r-- | libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp b/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp index 437653a8dfa8..23969908ff4d 100644 --- a/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp +++ b/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp @@ -21,6 +21,7 @@ #include <cmath> #include "utils/TraceUtils.h" #include "renderthread/RenderProxy.h" +#include "renderthread/RenderThread.h" namespace android { namespace uirenderer { @@ -228,6 +229,15 @@ AtlasEntry VectorDrawableAtlas::getEntry(AtlasKey atlasKey) { void VectorDrawableAtlas::releaseEntry(AtlasKey atlasKey) { if (INVALID_ATLAS_KEY != atlasKey) { + if (!renderthread::RenderThread::isCurrent()) { + { + AutoMutex _lock(mReleaseKeyLock); + mKeysForRelease.push_back(atlasKey); + } + // invoke releaseEntry on the renderthread + renderthread::RenderProxy::releaseVDAtlasEntries(); + return; + } CacheEntry* entry = reinterpret_cast<CacheEntry*>(atlasKey); if (!entry->surface) { // Store freed atlas rectangles in "mFreeRects" and try to reuse them later, when atlas @@ -245,6 +255,14 @@ void VectorDrawableAtlas::releaseEntry(AtlasKey atlasKey) { } } +void VectorDrawableAtlas::delayedReleaseEntries() { + AutoMutex _lock(mReleaseKeyLock); + for (auto key : mKeysForRelease) { + releaseEntry(key); + } + mKeysForRelease.clear(); +} + sk_sp<SkSurface> VectorDrawableAtlas::createSurface(int width, int height, GrContext* context) { #ifndef ANDROID_ENABLE_LINEAR_BLENDING sk_sp<SkColorSpace> colorSpace = nullptr; |