Improve picture capture debug path
* Fixes hardware bitmap capture
* Fixes mutable bitmap capture (no flickering)
* Adds basic single-frame LRU cache to avoid
repeated readbacks of GPU resources
* Does up-front readback of GPU resources
* Moves serialization off RenderThread again thanks
to up-front readback avoiding needing GPU access
off-thread
* Reduces RAM usage & improves performance by serializing
directly to output stream instead of first copying to
a byte[]
Bug: 174223722
Test: PictureCaptureDemo mirrors the content
Change-Id: If7ec208b61d5b917e82087cc312880fc5a38c943
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index ac19a15..6fd644b 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -390,6 +390,17 @@
}
}
+int RenderProxy::copyImageInto(const sk_sp<SkImage>& image, SkBitmap* bitmap) {
+ RenderThread& thread = RenderThread::getInstance();
+ if (gettid() == thread.getTid()) {
+ // TODO: fix everything that hits this. We should never be triggering a readback ourselves.
+ return (int)thread.readback().copyImageInto(image, bitmap);
+ } else {
+ return thread.queue().runSync(
+ [&]() -> int { return (int)thread.readback().copyImageInto(image, bitmap); });
+ }
+}
+
void RenderProxy::disableVsync() {
Properties::disableVsync = true;
}