diff options
| author | 2023-12-19 17:04:07 -0500 | |
|---|---|---|
| committer | 2024-01-10 18:08:16 -0500 | |
| commit | 434bc98a0fec826dfdffc19658ba12b9a9da606c (patch) | |
| tree | 6a6f0292370de1e7665ef062cc1233b819e41783 /libs/ui/Gralloc4.cpp | |
| parent | 19db87d0b7c805825c8df79653bf3b58ef35aa4a (diff) | |
Move PlaneLayout lookup to GraphicBuffer
This keeps GraphicBufferMapper's lock closer to a raw
lock avoiding the PlaneLayout query if nobody is asking for it,
reduces code duplication between Gralloc 4 & 5, and enables
caching of the PlaneLayout to minimize queries
Partial step towards an extended lock buffer API
Also begin modernizing the API surface using a proper
Result<T> along with an error enum class
Test: make && atest
Bug: 288142323
Change-Id: Ib4590b7a3b839a993f6c747c5f09a6312f7ab329
Diffstat (limited to 'libs/ui/Gralloc4.cpp')
| -rw-r--r-- | libs/ui/Gralloc4.cpp | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp index d6970e0477..2a607308d1 100644 --- a/libs/ui/Gralloc4.cpp +++ b/libs/ui/Gralloc4.cpp @@ -262,37 +262,8 @@ void Gralloc4Mapper::getTransportSize(buffer_handle_t bufferHandle, uint32_t* ou status_t Gralloc4Mapper::lock(buffer_handle_t bufferHandle, uint64_t usage, const Rect& bounds, int acquireFence, void** outData, int32_t* outBytesPerPixel, int32_t* outBytesPerStride) const { - std::vector<ui::PlaneLayout> planeLayouts; - status_t err = getPlaneLayouts(bufferHandle, &planeLayouts); - - if (err == NO_ERROR && !planeLayouts.empty()) { - if (outBytesPerPixel) { - int32_t bitsPerPixel = planeLayouts.front().sampleIncrementInBits; - for (const auto& planeLayout : planeLayouts) { - if (bitsPerPixel != planeLayout.sampleIncrementInBits) { - bitsPerPixel = -1; - } - } - if (bitsPerPixel >= 0 && bitsPerPixel % 8 == 0) { - *outBytesPerPixel = bitsPerPixel / 8; - } else { - *outBytesPerPixel = -1; - } - } - if (outBytesPerStride) { - int32_t bytesPerStride = planeLayouts.front().strideInBytes; - for (const auto& planeLayout : planeLayouts) { - if (bytesPerStride != planeLayout.strideInBytes) { - bytesPerStride = -1; - } - } - if (bytesPerStride >= 0) { - *outBytesPerStride = bytesPerStride; - } else { - *outBytesPerStride = -1; - } - } - } + if (outBytesPerPixel) *outBytesPerPixel = -1; + if (outBytesPerStride) *outBytesPerStride = -1; auto buffer = const_cast<native_handle_t*>(bufferHandle); |