Init the DMA buffer in gralloc_lock
gralloc_unlock copies pixels into the DMA buffer
if it is enabled, but it was allocated without
a prior call to gralloc_register_buffer.
Bug: 128324105
Test: emugl_combined_unittests
Change-Id: I6105529b4938c8ab8c9bd9a66a1f837aabd3ac96
Signed-off-by: Roman Kiryanov <rkir@google.com>
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 725848e..ee83b15 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -1025,13 +1025,6 @@
int32_t* openCountPtr = getOpenCountPtr(cb);
if (!*openCountPtr) *openCountPtr = 1;
}
-
- hostCon->lock();
- if (rcEnc->getDmaVersion() > 0) {
- gralloc_dmaregion_register_ashmem(rcEnc, cb->ashmemSize);
- }
- hostCon->unlock();
-
}
if (cb->ashmemSize > 0) {
@@ -1226,6 +1219,10 @@
delete [] tmpBuf;
}
}
+
+ if (rcEnc->getDmaVersion() > 0) {
+ gralloc_dmaregion_register_ashmem(rcEnc, cb->ashmemSize);
+ }
hostCon->unlock();
}