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
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 7fe966d..6904743 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -732,6 +732,18 @@
thread.queue(task);
}
+CREATE_BRIDGE1(releaseVDAtlasEntries, RenderThread* thread) {
+ args->thread->cacheManager().acquireVectorDrawableAtlas()->delayedReleaseEntries();
+ return nullptr;
+}
+
+void RenderProxy::releaseVDAtlasEntries() {
+ RenderThread& thread = RenderThread::getInstance();
+ SETUP_TASK(releaseVDAtlasEntries);
+ args->thread = &thread;
+ thread.queue(task);
+}
+
void* RenderProxy::postAndWait(MethodInvokeRenderTask* task) {
void* retval;
task->setReturnPtr(&retval);
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 06eaebd..9440b15 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -143,6 +143,8 @@
static void repackVectorDrawableAtlas();
+ static void releaseVDAtlasEntries();
+
private:
RenderThread& mRenderThread;
CanvasContext* mContext;
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index 72a428f..51e9374 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -499,6 +499,10 @@
return nullptr;
}
+bool RenderThread::isCurrent() {
+ return gettid() == getInstance().getTid();
+}
+
} /* namespace renderthread */
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index bef47b3..30884b5 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -111,6 +111,14 @@
sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& skBitmap);
void dumpGraphicsMemory(int fd);
+ /**
+ * isCurrent provides a way to query, if the caller is running on
+ * the render thread.
+ *
+ * @return true only if isCurrent is invoked from the render thread.
+ */
+ static bool isCurrent();
+
protected:
virtual bool threadLoop() override;