diff options
author | Daniel Stone <[email protected]> | 2018-02-06 10:15:32 +0000 |
---|---|---|
committer | Daniel Stone <[email protected]> | 2018-02-09 16:17:16 +0000 |
commit | 3323ce72ff2d5de2fa7ad32d192c1a28ba8681e6 (patch) | |
tree | 367b6e35fbf30a16fe7c37c9ec8d84a6bfdd6c7e /src/egl | |
parent | a9cc4edb6077e9ccda5792c240358ba01df62aed (diff) |
egl/wayland: Use visual map for buffer_from_image
When creating a wl_buffer on an upstream Wayland display from an
existing EGLImage, use the dri2_wl_visual map rather than another
hardcoded list of formats.
Signed-off-by: Daniel Stone <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Tested-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 91434dbba0e..28eba980925 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -116,7 +116,7 @@ dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy, dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_BLUE_MASK, &blue); dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_ALPHA_MASK, &alpha); - for (int i = 0; i < ARRAY_SIZE(dri2_wl_visuals); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(dri2_wl_visuals); i++) { const struct dri2_wl_visual *wl_visual = &dri2_wl_visuals[i]; if (red == wl_visual->rgba_masks[0] && @@ -131,6 +131,17 @@ dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy, } static int +dri2_wl_visual_idx_from_dri_image_format(uint32_t dri_image_format) +{ + for (int i = 0; i < ARRAY_SIZE(dri2_wl_visuals); i++) { + if (dri2_wl_visuals[i].dri_image_format == dri_image_format) + return i; + } + + return -1; +} + +static int roundtrip(struct dri2_egl_display *dri2_dpy) { return wl_display_roundtrip_queue(dri2_dpy->wl_dpy, dri2_dpy->wl_queue); @@ -1042,29 +1053,16 @@ dri2_wl_create_wayland_buffer_from_image(_EGLDriver *drv, struct dri2_egl_image *dri2_img = dri2_egl_image(img); __DRIimage *image = dri2_img->dri_image; struct wl_buffer *buffer; - int format; + int format, visual_idx; + /* Check the upstream display supports this buffer's format. */ dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &format); - switch (format) { - case __DRI_IMAGE_FORMAT_ARGB2101010: - if (!(dri2_dpy->formats & HAS_ARGB2101010)) - goto bad_format; - break; - case __DRI_IMAGE_FORMAT_XRGB2101010: - if (!(dri2_dpy->formats & HAS_XRGB2101010)) - goto bad_format; - break; - case __DRI_IMAGE_FORMAT_ARGB8888: - if (!(dri2_dpy->formats & HAS_ARGB8888)) - goto bad_format; - break; - case __DRI_IMAGE_FORMAT_XRGB8888: - if (!(dri2_dpy->formats & HAS_XRGB8888)) - goto bad_format; - break; - default: + visual_idx = dri2_wl_visual_idx_from_dri_image_format(format); + if (visual_idx == -1) + goto bad_format; + + if (!(dri2_dpy->formats & dri2_wl_visuals[visual_idx].has_format)) goto bad_format; - } buffer = create_wl_buffer(dri2_dpy, NULL, image); |