MCPcopy Create free account
hub / github.com/alibaba/MNN / copyDataFromAHardWareBuffer

Function copyDataFromAHardWareBuffer

tools/cpp/GpuInterTest.cpp:211–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209 return buffer;
210}
211static void copyDataFromAHardWareBuffer(AHardwareBuffer* buffer, int width, int height, void *data){
212 int result = 0;
213 if(nullptr != data){
214 void* map = nullptr;
215 ARect rect = { 0, 0, width, height }; // Define the region to lock
216 result = gFunction->Lock(buffer, AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN, -1, &rect, &map);
217 if (result != 0) {
218 MNN_PRINT("Handle lock failed\n");
219 }
220 if (map) {
221 memcpy(data, map, width * height * 4);
222 }
223
224 gFunction->Unlock(buffer, nullptr);
225 }
226}
227static void ReleaseAHardWareBuffer(AHardwareBuffer* buffer){
228 if(buffer != nullptr){
229 gFunction->Release(buffer);

Callers

nothing calls this directly

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected