aboutsummaryrefslogtreecommitdiff
path: root/bufferinfo/BufferInfoMapperMetadata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bufferinfo/BufferInfoMapperMetadata.cpp')
-rw-r--r--bufferinfo/BufferInfoMapperMetadata.cpp60
1 files changed, 26 insertions, 34 deletions
diff --git a/bufferinfo/BufferInfoMapperMetadata.cpp b/bufferinfo/BufferInfoMapperMetadata.cpp
index 2f08a76..bdacb74 100644
--- a/bufferinfo/BufferInfoMapperMetadata.cpp
+++ b/bufferinfo/BufferInfoMapperMetadata.cpp
@@ -46,7 +46,7 @@ BufferInfoGetter *BufferInfoMapperMetadata::CreateInstance() {
* so that it can be overridden.
*/
int __attribute__((weak))
-BufferInfoMapperMetadata::GetFds(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+BufferInfoMapperMetadata::GetFds(buffer_handle_t handle, BufferInfo *bo) {
int fd_index = 0;
if (handle->numFds <= 0) {
@@ -54,7 +54,7 @@ BufferInfoMapperMetadata::GetFds(buffer_handle_t handle, hwc_drm_bo_t *bo) {
return android::BAD_VALUE;
}
- for (int i = 0; i < kHwcDrmBoMaxPlanes; i++) {
+ for (int i = 0; i < kBufferMaxPlanes; i++) {
/* If no size, we're out of usable planes */
if (bo->sizes[i] <= 0) {
if (i == 0) {
@@ -86,71 +86,63 @@ BufferInfoMapperMetadata::GetFds(buffer_handle_t handle, hwc_drm_bo_t *bo) {
return 0;
}
-int BufferInfoMapperMetadata::ConvertBoInfo(buffer_handle_t handle,
- hwc_drm_bo_t *bo) {
+auto BufferInfoMapperMetadata::GetBoInfo(buffer_handle_t handle)
+ -> std::optional<BufferInfo> {
GraphicBufferMapper &mapper = GraphicBufferMapper::getInstance();
if (handle == nullptr)
- return -EINVAL;
+ return {};
- uint64_t usage = 0;
- int err = mapper.getUsage(handle, &usage);
- if (err != 0) {
- ALOGE("Failed to get usage err=%d", err);
- return err;
- }
- bo->usage = static_cast<uint32_t>(usage);
-
- ui::PixelFormat hal_format;
- err = mapper.getPixelFormatRequested(handle, &hal_format);
- if (err != 0) {
- ALOGE("Failed to get HAL Pixel Format err=%d", err);
- return err;
- }
- bo->hal_format = static_cast<uint32_t>(hal_format);
+ BufferInfo bi{};
- err = mapper.getPixelFormatFourCC(handle, &bo->format);
+ int err = mapper.getPixelFormatFourCC(handle, &bi.format);
if (err != 0) {
ALOGE("Failed to get FourCC format err=%d", err);
- return err;
+ return {};
}
- err = mapper.getPixelFormatModifier(handle, &bo->modifiers[0]);
+ err = mapper.getPixelFormatModifier(handle, &bi.modifiers[0]);
if (err != 0) {
ALOGE("Failed to get DRM Modifier err=%d", err);
- return err;
+ return {};
}
uint64_t width = 0;
err = mapper.getWidth(handle, &width);
if (err != 0) {
ALOGE("Failed to get Width err=%d", err);
- return err;
+ return {};
}
- bo->width = static_cast<uint32_t>(width);
+ bi.width = static_cast<uint32_t>(width);
uint64_t height = 0;
err = mapper.getHeight(handle, &height);
if (err != 0) {
ALOGE("Failed to get Height err=%d", err);
- return err;
+ return {};
}
- bo->height = static_cast<uint32_t>(height);
+ bi.height = static_cast<uint32_t>(height);
std::vector<ui::PlaneLayout> layouts;
err = mapper.getPlaneLayouts(handle, &layouts);
if (err != 0) {
ALOGE("Failed to get Plane Layouts err=%d", err);
- return err;
+ return {};
}
for (uint32_t i = 0; i < layouts.size(); i++) {
- bo->modifiers[i] = bo->modifiers[0];
- bo->pitches[i] = layouts[i].strideInBytes;
- bo->offsets[i] = layouts[i].offsetInBytes;
- bo->sizes[i] = layouts[i].totalSizeInBytes;
+ bi.modifiers[i] = bi.modifiers[0];
+ bi.pitches[i] = layouts[i].strideInBytes;
+ bi.offsets[i] = layouts[i].offsetInBytes;
+ bi.sizes[i] = layouts[i].totalSizeInBytes;
+ }
+
+ err = GetFds(handle, &bi);
+ if (err != 0) {
+ ALOGE("Failed to get fds (err=%d)", err);
+ return {};
}
- return GetFds(handle, bo);
+ return bi;
}
} // namespace android