aboutsummaryrefslogtreecommitdiff
path: root/bufferinfo/legacy/BufferInfoLibdrm.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-07 05:08:05 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-07 05:08:05 +0000
commitdc8559eade3cae25703b70f6e93417ff368b2c14 (patch)
tree0be8b55408ec891b7c275a1eb9e4f0310702b339 /bufferinfo/legacy/BufferInfoLibdrm.cpp
parent1d29a2e82fad8d0f4d00e62cbac070995ae40a43 (diff)
parent39e9dc65f3a608c85124d4014b07ede70680f18b (diff)
downloaddrm_hwcomposer-dc8559eade3cae25703b70f6e93417ff368b2c14.tar.gz
Change-Id: If430f272132aef6c1f7508bff477d243782cc7d2
Diffstat (limited to 'bufferinfo/legacy/BufferInfoLibdrm.cpp')
-rw-r--r--bufferinfo/legacy/BufferInfoLibdrm.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/bufferinfo/legacy/BufferInfoLibdrm.cpp b/bufferinfo/legacy/BufferInfoLibdrm.cpp
index 6baf6bb..ac71ec0 100644
--- a/bufferinfo/legacy/BufferInfoLibdrm.cpp
+++ b/bufferinfo/legacy/BufferInfoLibdrm.cpp
@@ -91,8 +91,8 @@ static bool is_yuv(uint32_t native) {
return false;
}
-bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle,
- hwc_drm_bo_t *bo) {
+bool BufferInfoLibdrm::GetYuvPlaneInfo(uint32_t hal_format, int num_fds,
+ buffer_handle_t handle, BufferInfo *bo) {
struct android_ycbcr ycbcr {};
enum chroma_order chroma_order {};
int ret = 0;
@@ -136,12 +136,12 @@ bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle,
/* .chroma_step is the byte distance between the same chroma channel
* values of subsequent pixels, assumed to be the same for Cb and Cr. */
- bo->format = get_fourcc_yuv(bo->hal_format, chroma_order, ycbcr.chroma_step);
+ bo->format = get_fourcc_yuv(hal_format, chroma_order, ycbcr.chroma_step);
if (bo->format == UINT32_MAX) {
ALOGW(
"unsupported YUV format, native = %x, chroma_order = %s, chroma_step = "
"%d",
- bo->hal_format, chroma_order == kYCbCr ? "YCbCr" : "YCrCb",
+ hal_format, chroma_order == kYCbCr ? "YCbCr" : "YCrCb",
(int)ycbcr.chroma_step);
return false;
}
@@ -162,14 +162,16 @@ bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle,
return true;
}
-int BufferInfoLibdrm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+auto BufferInfoLibdrm::GetBoInfo(buffer_handle_t handle)
+ -> std::optional<BufferInfo> {
gralloc_handle_t *gr_handle = gralloc_handle(handle);
if (!gr_handle)
- return -EINVAL;
+ return {};
+
+ BufferInfo bi{};
- bo->width = gr_handle->width;
- bo->height = gr_handle->height;
- bo->hal_format = gr_handle->format;
+ bi.width = gr_handle->width;
+ bi.height = gr_handle->height;
#if GRALLOC_HANDLE_VERSION < 4
static std::once_flag once;
@@ -179,35 +181,34 @@ int BufferInfoLibdrm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
});
#endif
#if GRALLOC_HANDLE_VERSION == 4
- bo->modifiers[0] = gr_handle->modifier;
+ bi.modifiers[0] = gr_handle->modifier;
#endif
- bo->usage = gr_handle->usage;
- bo->prime_fds[0] = gr_handle->prime_fd;
+ bi.prime_fds[0] = gr_handle->prime_fd;
if (is_yuv(gr_handle->format)) {
- if (!GetYuvPlaneInfo(handle->numFds, handle, bo))
- return -EINVAL;
+ if (!GetYuvPlaneInfo(gr_handle->format, handle->numFds, handle, &bi))
+ return {};
} else {
- bo->pitches[0] = gr_handle->stride;
- bo->offsets[0] = 0;
+ bi.pitches[0] = gr_handle->stride;
+ bi.offsets[0] = 0;
/* FOSS graphic components (gbm_gralloc, mesa3d) are translating
* HAL_PIXEL_FORMAT_RGB_565 to DRM_FORMAT_RGB565 without swapping
* the R and B components. Same must be done here. */
- switch (bo->hal_format) {
+ switch (gr_handle->format) {
case HAL_PIXEL_FORMAT_RGB_565:
- bo->format = DRM_FORMAT_RGB565;
+ bi.format = DRM_FORMAT_RGB565;
break;
default:
- bo->format = ConvertHalFormatToDrm(gr_handle->format);
+ bi.format = ConvertHalFormatToDrm(gr_handle->format);
}
- if (bo->format == DRM_FORMAT_INVALID)
- return -EINVAL;
+ if (bi.format == DRM_FORMAT_INVALID)
+ return {};
}
- return 0;
+ return bi;
}
constexpr char gbm_gralloc_module_name[] = "GBM Memory Allocator";