summaryrefslogtreecommitdiff
path: root/libs/ui/GraphicBufferMapper.cpp
diff options
context:
space:
mode:
author Marissa Wall <marissaw@google.com> 2018-12-29 12:01:57 -0800
committer Marissa Wall <marissaw@google.com> 2019-01-02 11:42:16 -0800
commit1e77925bd46c700787aaf3c55d2857e73f91232d (patch)
tree5bc462029b494301330a96dd84fd8e312cf8ec39 /libs/ui/GraphicBufferMapper.cpp
parent49a99b9ff288a105de660cd43ce73e0ce2e7d2f2 (diff)
gralloc: move gralloc2 code inside gralloc2
Move Gralloc2 code and types from GraphicBufferAllocator and GraphicBufferMapper into Gralloc2.h/.cpp. Bug: 120493579 Test: manual Change-Id: I1268b0fd1a0645ce3dc4782a23d6d5fe83a4ba27
Diffstat (limited to 'libs/ui/GraphicBufferMapper.cpp')
-rw-r--r--libs/ui/GraphicBufferMapper.cpp50
1 files changed, 8 insertions, 42 deletions
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index 2d8e5824b0..8dd939668a 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -59,22 +59,15 @@ status_t GraphicBufferMapper::importBuffer(buffer_handle_t rawHandle,
ATRACE_CALL();
buffer_handle_t bufferHandle;
- Gralloc2::Error error = mMapper->importBuffer(
- hardware::hidl_handle(rawHandle), &bufferHandle);
- if (error != Gralloc2::Error::NONE) {
+ status_t error = mMapper->importBuffer(hardware::hidl_handle(rawHandle), &bufferHandle);
+ if (error != NO_ERROR) {
ALOGW("importBuffer(%p) failed: %d", rawHandle, error);
- return static_cast<status_t>(error);
+ return error;
}
- Gralloc2::IMapper::BufferDescriptorInfo info = {};
- info.width = width;
- info.height = height;
- info.layerCount = layerCount;
- info.format = static_cast<Gralloc2::PixelFormat>(format);
- info.usage = usage;
-
- error = mMapper->validateBufferSize(bufferHandle, info, stride);
- if (error != Gralloc2::Error::NONE) {
+ error = mMapper->validateBufferSize(bufferHandle, width, height, format, layerCount, usage,
+ stride);
+ if (error != NO_ERROR) {
ALOGE("validateBufferSize(%p) failed: %d", rawHandle, error);
freeBuffer(bufferHandle);
return static_cast<status_t>(error);
@@ -100,15 +93,6 @@ status_t GraphicBufferMapper::freeBuffer(buffer_handle_t handle)
return NO_ERROR;
}
-static inline Gralloc2::IMapper::Rect asGralloc2Rect(const Rect& rect) {
- Gralloc2::IMapper::Rect outRect{};
- outRect.left = rect.left;
- outRect.top = rect.top;
- outRect.width = rect.width();
- outRect.height = rect.height();
- return outRect;
-}
-
status_t GraphicBufferMapper::lock(buffer_handle_t handle, uint32_t usage,
const Rect& bounds, void** vaddr)
{
@@ -146,13 +130,7 @@ status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle,
const uint64_t usage = static_cast<uint64_t>(
android_convertGralloc1To0Usage(producerUsage, consumerUsage));
- Gralloc2::Error error = mMapper->lock(handle, usage,
- asGralloc2Rect(bounds), fenceFd, vaddr);
-
- ALOGW_IF(error != Gralloc2::Error::NONE, "lock(%p, ...) failed: %d",
- handle, error);
-
- return static_cast<status_t>(error);
+ return mMapper->lock(handle, usage, bounds, fenceFd, vaddr);
}
status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
@@ -160,19 +138,7 @@ status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
{
ATRACE_CALL();
- Gralloc2::YCbCrLayout layout;
- Gralloc2::Error error = mMapper->lock(handle, usage,
- asGralloc2Rect(bounds), fenceFd, &layout);
- if (error == Gralloc2::Error::NONE) {
- ycbcr->y = layout.y;
- ycbcr->cb = layout.cb;
- ycbcr->cr = layout.cr;
- ycbcr->ystride = static_cast<size_t>(layout.yStride);
- ycbcr->cstride = static_cast<size_t>(layout.cStride);
- ycbcr->chroma_step = static_cast<size_t>(layout.chromaStep);
- }
-
- return static_cast<status_t>(error);
+ return mMapper->lock(handle, usage, bounds, fenceFd, ycbcr);
}
status_t GraphicBufferMapper::unlockAsync(buffer_handle_t handle, int *fenceFd)