diff options
| author | 2019-03-26 23:26:46 +0000 | |
|---|---|---|
| committer | 2019-03-26 23:26:46 +0000 | |
| commit | 3a18962e3a86d8ab08b36ffb4c71c48fd6d60641 (patch) | |
| tree | 567dbfe25a9afadfc26514144b61ca31d21d5543 | |
| parent | c257a0c9c627813721f175512f086117c60763d2 (diff) | |
| parent | 12d2d640765f54149dac22a570f2f687033ca4e5 (diff) | |
Merge "Setting bpp and bps to -1 whenever returning error"
| -rw-r--r-- | libs/nativewindow/AHardwareBuffer.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp index bf80481c44..9bd30955f3 100644 --- a/libs/nativewindow/AHardwareBuffer.cpp +++ b/libs/nativewindow/AHardwareBuffer.cpp @@ -96,7 +96,12 @@ void AHardwareBuffer_describe(const AHardwareBuffer* buffer, int AHardwareBuffer_lockAndGetInfo(AHardwareBuffer* buffer, uint64_t usage, int32_t fence, const ARect* rect, void** outVirtualAddress, int32_t* outBytesPerPixel, int32_t* outBytesPerStride) { - if (!buffer) return BAD_VALUE; + if (outBytesPerPixel) *outBytesPerPixel = -1; + if (outBytesPerStride) *outBytesPerStride = -1; + + if (!buffer) { + return BAD_VALUE; + } if (usage & ~(AHARDWAREBUFFER_USAGE_CPU_READ_MASK | AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK)) { @@ -127,15 +132,19 @@ int AHardwareBuffer_lockAndGetInfo(AHardwareBuffer* buffer, uint64_t usage, } else { bounds.set(Rect(rect->left, rect->top, rect->right, rect->bottom)); } - int result = gbuffer->lockAsync(usage, usage, bounds, outVirtualAddress, fence, outBytesPerPixel, outBytesPerStride); + int32_t bytesPerPixel; + int32_t bytesPerStride; + int result = gbuffer->lockAsync(usage, usage, bounds, outVirtualAddress, fence, &bytesPerPixel, &bytesPerStride); // if hardware returns -1 for bytes per pixel or bytes per stride, we fail // and unlock the buffer - if (*outBytesPerPixel == -1 || *outBytesPerStride == -1) { + if (bytesPerPixel == -1 || bytesPerStride == -1) { gbuffer->unlock(); return INVALID_OPERATION; } + if (outBytesPerPixel) *outBytesPerPixel = bytesPerPixel; + if (outBytesPerStride) *outBytesPerStride = bytesPerStride; return result; } |