diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-04-19 11:12:18 +0200 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-05-18 18:36:12 +0200 |
commit | ac2b9b85a13885f289f879e1bcb3427e27e748b8 (patch) | |
tree | b5413dbb5ac032eab66bca18375ded1e39f06178 | |
parent | a0d08dd175627e1404b3f551a762935d6dc7da84 (diff) |
wayland-drm: handle YUV formats in wl_drm_create_buffer().{merged}/10.wayland-drm
Add support for YUV 4:2:0, 4:2:2 and 4:4:4 formats to wl_drm_create_buffer().
The layout will be derived from width, height and stride. In particular, the
luma plane has exact same size, i.e. without any padding like aligning the
height to 16-pixel boundaries, and the chroma planes immediately follow the
luma plane.
-rw-r--r-- | src/egl/wayland/wayland-drm/wayland-drm.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c index fdd0e1f79c..c22d308829 100644 --- a/src/egl/wayland/wayland-drm/wayland-drm.c +++ b/src/egl/wayland/wayland-drm/wayland-drm.c @@ -192,6 +192,10 @@ drm_create_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t stride, uint32_t format) { struct wl_buffer_layout layout; + uint32_t width2, height2; + + width2 = (width + 1) / 2; + height2 = (height + 1) / 2; switch (format) { case WL_DRM_FORMAT_ARGB8888: @@ -206,6 +210,44 @@ drm_create_buffer(struct wl_client *client, struct wl_resource *resource, layout.offsets[0] = 0; layout.pitches[0] = stride; break; + case WL_DRM_FORMAT_NV12: + layout.format = WL_BUFFER_FORMAT_NV12; + layout.num_planes = 2; + layout.offsets[0] = 0; + layout.pitches[0] = stride; + layout.offsets[1] = layout.offsets[0] + height * layout.pitches[0]; + layout.pitches[1] = stride; + break; + case WL_DRM_FORMAT_YUV420: + layout.format = WL_BUFFER_FORMAT_YUV420; + layout.num_planes = 3; + layout.offsets[0] = 0; + layout.pitches[0] = stride; + layout.offsets[1] = layout.offsets[0] + height * layout.pitches[0]; + layout.pitches[1] = width2; + layout.offsets[2] = layout.offsets[1] + height2 * layout.pitches[1]; + layout.pitches[2] = width2; + break; + case WL_DRM_FORMAT_YUV422: + layout.format = WL_BUFFER_FORMAT_YUV422; + layout.num_planes = 3; + layout.offsets[0] = 0; + layout.pitches[0] = stride; + layout.offsets[1] = layout.offsets[0] + height * layout.pitches[0]; + layout.pitches[1] = width2; + layout.offsets[2] = layout.offsets[1] + height * layout.pitches[1]; + layout.pitches[2] = width2; + break; + case WL_DRM_FORMAT_YUV444: + layout.format = WL_BUFFER_FORMAT_YUV444; + layout.num_planes = 3; + layout.offsets[0] = 0; + layout.pitches[0] = stride; + layout.offsets[1] = layout.offsets[0] + height * layout.pitches[0]; + layout.pitches[1] = width; + layout.offsets[2] = layout.offsets[1] + height * layout.pitches[1]; + layout.pitches[2] = width; + break; default: wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, |