Support readback from hardware bitmaps
Test: hwuimacro readbackFromHBitmap --onscreen.
bug:30999911
Change-Id: I369c069c40cb0f9adae5a94501815f29c2d7df0f
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 2c48242..022e871 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -27,6 +27,8 @@
#include "utils/Macros.h"
#include "utils/TimeUtils.h"
+#include <ui/GraphicBuffer.h>
+
namespace android {
namespace uirenderer {
namespace renderthread {
@@ -663,6 +665,18 @@
return hardwareBitmap;
}
+CREATE_BRIDGE3(copyGraphicBufferInto, RenderThread* thread, GraphicBuffer* buffer, SkBitmap* bitmap) {
+ return (void*) args->thread->readback().copyGraphicBufferInto(args->buffer, args->bitmap);
+}
+
+int RenderProxy::copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap) {
+ SETUP_TASK(copyGraphicBufferInto);
+ args->thread = &RenderThread::getInstance();
+ args->bitmap = bitmap;
+ args->buffer = buffer;
+ return static_cast<int>(reinterpret_cast<intptr_t>(staticPostAndWait(task)));
+}
+
void RenderProxy::post(RenderTask* task) {
mRenderThread.queue(task);
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index e559142..44a5a14 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -35,6 +35,8 @@
#include "DrawFrameTask.h"
namespace android {
+class GraphicBuffer;
+
namespace uirenderer {
class DeferredLayerUpdater;
@@ -131,6 +133,8 @@
ANDROID_API static void prepareToDraw(Bitmap& bitmap);
static sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& bitmap);
+
+ static int copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap);
private:
RenderThread& mRenderThread;
CanvasContext* mContext;