summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Foss <robert.foss@collabora.com>2017-03-02 15:45:20 -0500
committerRobert Foss <robert.foss@collabora.com>2017-03-02 15:45:54 -0500
commite0654674787657a86a45298d90136dd2d27cdaac (patch)
tree991adf894e11c4eb3f70ae05aab39c3bee0560c7
parent58bcf909b59b888987abef9ce569428d2426c89c (diff)
downloaddrm_hwcomposer-hwc2_fence_v2_yuv.tar.gz
drm_hwcomposer-hwc2_fence_v2_yuv.tar.xz
drm_hwcomposer: Add YUV420 support to DrmGenericImporter::ImportImagehwc2_fence_v2_yuv
Change-Id: I2c8f29f7636c291c1e1660f53ea4005d4d6a40a3 Signed-off-by: Robert Foss <robert.foss@collabora.com>
-rw-r--r--platformdrmgeneric.cpp54
1 files changed, 48 insertions, 6 deletions
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index b370c1b..d051c31 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -85,12 +85,49 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) {
}
EGLImageKHR DrmGenericImporter::ImportImage(EGLDisplay egl_display,
- DrmHwcBuffer * /*buffer*/,
+ DrmHwcBuffer * buffer,
buffer_handle_t handle) {
+ EGLImageKHR image = EGL_NO_IMAGE_KHR;
gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
+
if (!gr_handle)
- return NULL;
- EGLint attr[] = {
+ return image;
+
+ if (buffer->operator->()->format == DRM_FORMAT_YUV420) {
+ const EGLint attr_list_yv12[] = {
+ EGL_WIDTH,
+ static_cast<EGLint>(buffer->operator->()->width),
+ EGL_HEIGHT,
+ static_cast<EGLint>(buffer->operator->()->height),
+ EGL_LINUX_DRM_FOURCC_EXT,
+ DRM_FORMAT_YUV420,
+ EGL_DMA_BUF_PLANE0_FD_EXT,
+ gr_handle->prime_fd,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT,
+ static_cast<EGLint>(buffer->operator->()->pitches[0]),
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT,
+ static_cast<EGLint>(buffer->operator->()->offsets[0]),
+ EGL_DMA_BUF_PLANE1_FD_EXT,
+ gr_handle->prime_fd,
+ EGL_DMA_BUF_PLANE1_PITCH_EXT,
+ static_cast<EGLint>(buffer->operator->()->pitches[1]),
+ EGL_DMA_BUF_PLANE1_OFFSET_EXT,
+ static_cast<EGLint>(buffer->operator->()->offsets[1]),
+ EGL_DMA_BUF_PLANE2_FD_EXT,
+ gr_handle->prime_fd,
+ EGL_DMA_BUF_PLANE2_PITCH_EXT,
+ static_cast<EGLint>(buffer->operator->()->pitches[2]),
+ EGL_DMA_BUF_PLANE2_OFFSET_EXT,
+ static_cast<EGLint>(buffer->operator->()->offsets[2]),
+ EGL_NONE,
+ 0
+ };
+ image = eglCreateImageKHR(egl_display, EGL_NO_CONTEXT,
+ EGL_LINUX_DMA_BUF_EXT,
+ static_cast<EGLClientBuffer>(nullptr),
+ attr_list_yv12);
+ } else {
+ EGLint attr[] = {
EGL_WIDTH,
gr_handle->width,
EGL_HEIGHT,
@@ -104,9 +141,14 @@ EGLImageKHR DrmGenericImporter::ImportImage(EGLDisplay egl_display,
EGL_DMA_BUF_PLANE0_PITCH_EXT,
gr_handle->stride,
EGL_NONE,
- };
- return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT,
- NULL, attr);
+ };
+ image = eglCreateImageKHR(egl_display, EGL_NO_CONTEXT,
+ EGL_LINUX_DMA_BUF_EXT,
+ NULL,
+ attr);
+ }
+
+ return image;
}
int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {