summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorDaniel Stone <[email protected]>2018-02-06 10:29:13 +0000
committerDaniel Stone <[email protected]>2018-02-09 16:17:16 +0000
commit4732094cff302a10c167e0cb23851c19fccddbe0 (patch)
treec7a4013719a8f3079f2306290868c939d47d40b8 /src/egl
parent5bc49d4cbf8c7c5d465dc994d0a0d2111f742705 (diff)
egl/wayland: Use an array for modifiers
Each Wayland EGLDisplay currently contains a struct with one vector of modifiers per format, hardcoded in the header. To allow easier support for more formats, turn this into an array of u_vectors which is opaque outside of platform_wayland.c. 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/egl_dri2.h8
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c84
2 files changed, 20 insertions, 72 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index c49156fbb6e..0f4e7a8d1e8 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -212,13 +212,7 @@ struct dri2_egl_display
struct wl_shm *wl_shm;
struct wl_event_queue *wl_queue;
struct zwp_linux_dmabuf_v1 *wl_dmabuf;
- struct {
- struct u_vector xrgb2101010;
- struct u_vector argb2101010;
- struct u_vector xrgb8888;
- struct u_vector argb8888;
- struct u_vector rgb565;
- } wl_modifiers;
+ struct u_vector *wl_modifiers;
bool authenticated;
int formats;
uint32_t capabilities;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index d214a8515d6..f91baded877 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -436,37 +436,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
visual_idx = dri2_wl_visual_idx_from_fourcc(dri2_surf->format);
assert(visual_idx != -1);
dri_image_format = dri2_wl_visuals[visual_idx].dri_image_format;
-
- /* currently supports five WL DRM formats,
- * WL_DRM_FORMAT_ARGB2101010, WL_DRM_FORMAT_XRGB2101010,
- * WL_DRM_FORMAT_ARGB8888, WL_DRM_FORMAT_XRGB8888,
- * and WL_DRM_FORMAT_RGB565
- */
- switch (dri2_surf->format) {
- case WL_DRM_FORMAT_ARGB2101010:
- modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.argb2101010);
- num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.argb2101010);
- break;
- case WL_DRM_FORMAT_XRGB2101010:
- modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.xrgb2101010);
- num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.xrgb2101010);
- break;
- case WL_DRM_FORMAT_ARGB8888:
- modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.argb8888);
- num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.argb8888);
- break;
- case WL_DRM_FORMAT_XRGB8888:
- modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.xrgb8888);
- num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.xrgb8888);
- break;
- case WL_DRM_FORMAT_RGB565:
- modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.rgb565);
- num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.rgb565);
- break;
- default:
- /* format is not supported */
- return -1;
- }
+ modifiers = u_vector_tail(&dri2_dpy->wl_modifiers[visual_idx]);
+ num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers[visual_idx]);
/* There might be a buffer release already queued that wasn't processed */
wl_display_dispatch_queue_pending(dri2_dpy->wl_dpy, dri2_surf->wl_queue);
@@ -1187,36 +1158,18 @@ dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
{
struct dri2_egl_display *dri2_dpy = data;
int visual_idx = dri2_wl_visual_idx_from_fourcc(format);
- uint64_t *mod = NULL;
+ uint64_t *mod;
- if (modifier_hi == (DRM_FORMAT_MOD_INVALID >> 32) &&
- modifier_lo == (DRM_FORMAT_MOD_INVALID & 0xffffffff))
+ if (visual_idx == -1)
return;
- switch (format) {
- case WL_DRM_FORMAT_ARGB2101010:
- mod = u_vector_add(&dri2_dpy->wl_modifiers.argb2101010);
- break;
- case WL_DRM_FORMAT_XRGB2101010:
- mod = u_vector_add(&dri2_dpy->wl_modifiers.xrgb2101010);
- break;
- case WL_DRM_FORMAT_ARGB8888:
- mod = u_vector_add(&dri2_dpy->wl_modifiers.argb8888);
- break;
- case WL_DRM_FORMAT_XRGB8888:
- mod = u_vector_add(&dri2_dpy->wl_modifiers.xrgb8888);
- break;
- case WL_DRM_FORMAT_RGB565:
- mod = u_vector_add(&dri2_dpy->wl_modifiers.rgb565);
- break;
- default:
- break;
- }
-
- if (!mod)
+ if (modifier_hi == (DRM_FORMAT_MOD_INVALID >> 32) &&
+ modifier_lo == (DRM_FORMAT_MOD_INVALID & 0xffffffff))
return;
dri2_dpy->formats |= (1 << visual_idx);
+
+ mod = u_vector_add(&dri2_dpy->wl_modifiers[visual_idx]);
*mod = (uint64_t) modifier_hi << 32;
*mod |= (uint64_t) (modifier_lo & 0xffffffff);
}
@@ -1358,12 +1311,13 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
dri2_dpy->wl_dpy = disp->PlatformDisplay;
}
- if (!u_vector_init(&dri2_dpy->wl_modifiers.xrgb2101010, sizeof(uint64_t), 32) ||
- !u_vector_init(&dri2_dpy->wl_modifiers.argb2101010, sizeof(uint64_t), 32) ||
- !u_vector_init(&dri2_dpy->wl_modifiers.xrgb8888, sizeof(uint64_t), 32) ||
- !u_vector_init(&dri2_dpy->wl_modifiers.argb8888, sizeof(uint64_t), 32) ||
- !u_vector_init(&dri2_dpy->wl_modifiers.rgb565, sizeof(uint64_t), 32)) {
+ dri2_dpy->wl_modifiers =
+ calloc(ARRAY_SIZE(dri2_wl_visuals), sizeof(*dri2_dpy->wl_modifiers));
+ if (!dri2_dpy->wl_modifiers)
goto cleanup;
+ for (int i = 0; i < ARRAY_SIZE(dri2_wl_visuals); i++) {
+ if (!u_vector_init(&dri2_dpy->wl_modifiers[i], sizeof(uint64_t), 32))
+ goto cleanup;
}
dri2_dpy->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy);
@@ -2094,11 +2048,11 @@ dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy)
wl_event_queue_destroy(dri2_dpy->wl_queue);
if (dri2_dpy->wl_dpy_wrapper)
wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper);
- u_vector_finish(&dri2_dpy->wl_modifiers.argb2101010);
- u_vector_finish(&dri2_dpy->wl_modifiers.xrgb2101010);
- u_vector_finish(&dri2_dpy->wl_modifiers.argb8888);
- u_vector_finish(&dri2_dpy->wl_modifiers.xrgb8888);
- u_vector_finish(&dri2_dpy->wl_modifiers.rgb565);
+
+ for (int i = 0; dri2_dpy->wl_modifiers && i < ARRAY_SIZE(dri2_wl_visuals); i++)
+ u_vector_finish(&dri2_dpy->wl_modifiers[i]);
+ free(dri2_dpy->wl_modifiers);
+
if (dri2_dpy->own_device)
wl_display_disconnect(dri2_dpy->wl_dpy);
}