summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorSingh, Satyeshwar <satyeshwar.singh@intel.com>2013-10-16 01:10:12 +0000
committerKristian Høgsberg <krh@bitplanet.net>2013-10-15 21:26:56 -0700
commit2efc97d51300849636b4b64ef8dfb5645e3b4e5b (patch)
treea51d95b6111f75f3ce15e39fb0d7a73b2a340a54 /src/egl
parent94d05bf87a21bd364e84f699a0064e5fba58a6f9 (diff)
egl-wayland: Add support for RGB565 pixel format for Wayland clients
With this patch Wayland clients can now ask EGL for RGB 565 format buffers and attach them to a Wayland compositor. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c13
-rw-r--r--src/egl/wayland/wayland-drm/wayland-drm.c3
2 files changed, 14 insertions, 2 deletions
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 1d417bb27f2..fc21892813d 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -42,7 +42,8 @@
enum wl_drm_format_flags {
HAS_ARGB8888 = 1,
- HAS_XRGB8888 = 2
+ HAS_XRGB8888 = 2,
+ HAS_RGB565 = 4,
};
static void
@@ -132,7 +133,9 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list))
goto cleanup_surf;
- if (conf->AlphaSize == 0)
+ if (conf->RedSize == 5)
+ dri2_surf->format = WL_DRM_FORMAT_RGB565;
+ else if (conf->AlphaSize == 0)
dri2_surf->format = WL_DRM_FORMAT_XRGB8888;
else
dri2_surf->format = WL_DRM_FORMAT_ARGB8888;
@@ -674,6 +677,9 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
case WL_DRM_FORMAT_XRGB8888:
dri2_dpy->formats |= HAS_XRGB8888;
break;
+ case WL_DRM_FORMAT_RGB565:
+ dri2_dpy->formats |= HAS_RGB565;
+ break;
}
}
@@ -736,6 +742,7 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
static const unsigned int argb_masks[4] =
{ 0xff0000, 0xff00, 0xff, 0xff000000 };
static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0 };
+ static const unsigned int rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 };
drv->API.CreateWindowSurface = dri2_create_window_surface;
drv->API.DestroySurface = dri2_destroy_surface;
@@ -817,6 +824,8 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
dri2_add_config(disp, config, i + 1, 0, types, NULL, rgb_masks);
if (dri2_dpy->formats & HAS_ARGB8888)
dri2_add_config(disp, config, i + 1, 0, types, NULL, argb_masks);
+ if (dri2_dpy->formats & HAS_RGB565)
+ dri2_add_config(disp, config, i + 1, 0, types, NULL, rgb565_masks);
}
disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
index 7b614b71b5c..06bd18cf461 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -126,6 +126,7 @@ drm_create_buffer(struct wl_client *client, struct wl_resource *resource,
case WL_DRM_FORMAT_ARGB8888:
case WL_DRM_FORMAT_XRGB8888:
case WL_DRM_FORMAT_YUYV:
+ case WL_DRM_FORMAT_RGB565:
break;
default:
wl_resource_post_error(resource,
@@ -223,6 +224,8 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
WL_DRM_FORMAT_ARGB8888);
wl_resource_post_event(resource, WL_DRM_FORMAT,
WL_DRM_FORMAT_XRGB8888);
+ wl_resource_post_event(resource, WL_DRM_FORMAT,
+ WL_DRM_FORMAT_RGB565);
wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV410);
wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV411);
wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV420);