diff options
| author | 2022-03-29 21:09:35 +0000 | |
|---|---|---|
| committer | 2022-03-29 21:09:35 +0000 | |
| commit | ac7b96d7771ae97f63ccc766d64b32063b7b13c1 (patch) | |
| tree | f84a22a8e3e459d7c679147d5e633e95b2b53da0 /libs/ui/Gralloc4.cpp | |
| parent | fd918caf415b3cc6991ed23f9a04db7eafda23fa (diff) | |
| parent | c8a7c7ab58df409e8995224b436e0e986c9371ff (diff) | |
Merge "Support AHardwareBuffer_lockPlanes() with P010" am: 24350bb0e7 am: 306ae2738a am: c8a7c7ab58
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1990470
Change-Id: Ieeeb3d5ffb659f1df5abc85cb70a6591d2d0c9c8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs/ui/Gralloc4.cpp')
| -rw-r--r-- | libs/ui/Gralloc4.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp index 1a42642838..c72ae1b138 100644 --- a/libs/ui/Gralloc4.cpp +++ b/libs/ui/Gralloc4.cpp @@ -358,20 +358,19 @@ status_t Gralloc4Mapper::lock(buffer_handle_t bufferHandle, uint64_t usage, cons if (!gralloc4::isStandardPlaneLayoutComponentType(planeLayoutComponent.type)) { continue; } - if (0 != planeLayoutComponent.offsetInBits % 8) { - unlock(bufferHandle); - return BAD_VALUE; - } - uint8_t* tmpData = static_cast<uint8_t*>(data) + planeLayout.offsetInBytes + - (planeLayoutComponent.offsetInBits / 8); + uint8_t* tmpData = static_cast<uint8_t*>(data) + planeLayout.offsetInBytes; + + // Note that `offsetInBits` may not be a multiple of 8 for packed formats (e.g. P010) + // but we still want to point to the start of the first byte. + tmpData += (planeLayoutComponent.offsetInBits / 8); + uint64_t sampleIncrementInBytes; auto type = static_cast<PlaneLayoutComponentType>(planeLayoutComponent.type.value); switch (type) { case PlaneLayoutComponentType::Y: - if ((ycbcr.y != nullptr) || (planeLayoutComponent.sizeInBits != 8) || - (planeLayout.sampleIncrementInBits != 8)) { + if ((ycbcr.y != nullptr) || (planeLayout.sampleIncrementInBits % 8 != 0)) { unlock(bufferHandle); return BAD_VALUE; } @@ -387,7 +386,8 @@ status_t Gralloc4Mapper::lock(buffer_handle_t bufferHandle, uint64_t usage, cons } sampleIncrementInBytes = planeLayout.sampleIncrementInBits / 8; - if ((sampleIncrementInBytes != 1) && (sampleIncrementInBytes != 2)) { + if ((sampleIncrementInBytes != 1) && (sampleIncrementInBytes != 2) && + (sampleIncrementInBytes != 4)) { unlock(bufferHandle); return BAD_VALUE; } |