| 209 | return buffer; |
| 210 | } |
| 211 | static 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 | } |
| 227 | static void ReleaseAHardWareBuffer(AHardwareBuffer* buffer){ |
| 228 | if(buffer != nullptr){ |
| 229 | gFunction->Release(buffer); |