},
};
+static_assert(ARRAY_SIZE(dri2_wl_visuals) <= EGL_DRI2_MAX_FORMATS,
+ "dri2_egl_display::formats is not large enough for "
+ "the formats in dri2_wl_visuals");
+
static int
dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy,
const __DRIconfig *config)
num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers[visual_idx]);
/* Substitute dri image format if server does not support original format */
- if (!(dri2_dpy->formats & (1 << visual_idx)))
+ if (!BITSET_TEST(dri2_dpy->formats, visual_idx))
linear_dri_image_format = dri2_wl_visuals[visual_idx].alt_dri_image_format;
/* These asserts hold, as long as dri2_wl_visuals[] is self-consistent and
* of bugs.
*/
assert(linear_dri_image_format != __DRI_IMAGE_FORMAT_NONE);
- assert(dri2_dpy->formats &
- (1 << dri2_wl_visual_idx_from_dri_image_format(linear_dri_image_format)));
+ assert(BITSET_TEST(dri2_dpy->formats,
+ dri2_wl_visual_idx_from_dri_image_format(linear_dri_image_format)));
/* 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);
if (visual_idx == -1)
goto bad_format;
- if (!(dri2_dpy->formats & (1u << visual_idx)))
+ if (!BITSET_TEST(dri2_dpy->formats, visual_idx))
goto bad_format;
buffer = create_wl_buffer(dri2_dpy, NULL, image);
if (visual_idx == -1)
return;
- dri2_dpy->formats |= (1u << visual_idx);
+ BITSET_SET(dri2_dpy->formats, visual_idx);
}
static void
modifier_lo == (DRM_FORMAT_MOD_INVALID & 0xffffffff))
return;
- dri2_dpy->formats |= (1u << visual_idx);
+ BITSET_SET(dri2_dpy->formats, visual_idx);
mod = u_vector_add(&dri2_dpy->wl_modifiers[visual_idx]);
*mod = combine_u32_into_u64(modifier_hi, modifier_lo);
for (unsigned j = 0; j < ARRAY_SIZE(dri2_wl_visuals); j++) {
struct dri2_egl_config *dri2_conf;
- if (!(dri2_dpy->formats & (1u << j)))
+ if (!BITSET_TEST(dri2_dpy->formats, j))
continue;
dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
alt_dri_image_format = dri2_wl_visuals[c].alt_dri_image_format;
s = dri2_wl_visual_idx_from_dri_image_format(alt_dri_image_format);
- if (s == -1 || !(dri2_dpy->formats & (1 << s)))
+ if (s == -1 || !BITSET_TEST(dri2_dpy->formats, s))
continue;
/* Visual s works for the Wayland server, and c can be converted into s
if (visual_idx == -1)
return;
- dri2_dpy->formats |= (1u << visual_idx);
+ BITSET_SET(dri2_dpy->formats, visual_idx);
}
static const struct wl_shm_listener shm_listener = {
if (roundtrip(dri2_dpy) < 0 || dri2_dpy->wl_shm == NULL)
goto cleanup;
- if (roundtrip(dri2_dpy) < 0 || dri2_dpy->formats == 0)
+ if (roundtrip(dri2_dpy) < 0 || !BITSET_TEST_RANGE(dri2_dpy->formats,
+ 0, EGL_DRI2_MAX_FORMATS))
goto cleanup;
dri2_dpy->driver_name = strdup("swrast");