void *
egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name,
int32_t width, int32_t height,
- uint32_t stride,
- struct wl_visual *visual)
+ uint32_t stride, uint32_t format)
{
struct native_display *ndpy = user_data;
struct pipe_resource templ;
struct winsys_handle wsh;
- enum pipe_format format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ enum pipe_format pf;
+
+ switch (format) {
+ case WL_DRM_FORMAT_ARGB32:
+ case WL_DRM_FORMAT_PREMULTIPLIED_ARGB32:
+ pf = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+ case WL_DRM_FORMAT_XRGB32:
+ pf = PIPE_FORMAT_B8G8R8X8_UNORM;
+ break;
+ default:
+ pf = PIPE_FORMAT_NONE;
+ break;
+ }
+
+ if (pf == PIPE_FORMAT_NONE)
+ return NULL;
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
- templ.format = format;
+ templ.format = pf;
templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
templ.width0 = width;
templ.height0 = height;
void *
egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name,
int32_t width, int32_t height,
- uint32_t stride,
- struct wl_visual *visual);
+ uint32_t stride, uint32_t format);
void
egl_g3d_wl_drm_helper_unreference_buffer(void *user_data, void *buffer);
struct pipe_resource *resource;
struct winsys_handle wsh;
uint width, height;
- struct wl_visual *visual;
+ uint32_t format;
resource = resource_surface_get_single_resource(surface->rsurf, attachment);
resource_surface_get_size(surface->rsurf, &width, &height);
pipe_resource_reference(&resource, NULL);
- switch (surface->type) {
- case WL_WINDOW_SURFACE:
- visual = surface->win->visual;
+ switch (surface->color_format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ /* assume premultiplied */
+ format = WL_DRM_FORMAT_PREMULTIPLIED_ARGB32;
break;
- case WL_PIXMAP_SURFACE:
- visual = surface->pix->visual;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ format = WL_DRM_FORMAT_XRGB32;
break;
default:
return NULL;
+ break;
}
return wl_drm_create_buffer(drmdpy->wl_drm, wsh.handle,
- width, height, wsh.stride, visual);
+ width, height, wsh.stride, format);
}
static void
wl_drm_authenticate(drmdpy->wl_drm, magic);
}
+static void
+drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
+{
+ /* TODO */
+}
+
static void
drm_handle_authenticated(void *data, struct wl_drm *drm)
{
static const struct wl_drm_listener drm_listener = {
drm_handle_device,
+ drm_handle_format,
drm_handle_authenticated
};
struct pipe_resource *resource;
struct winsys_handle wsh;
uint width, height;
- struct wl_visual *visual;
+ uint32_t format;
resource = resource_surface_get_single_resource(surface->rsurf, attachment);
resource_surface_get_size(surface->rsurf, &width, &height);
pipe_resource_reference(&resource, NULL);
- switch (surface->type) {
- case WL_WINDOW_SURFACE:
- visual = surface->win->visual;
+ switch (surface->color_format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
break;
- case WL_PIXMAP_SURFACE:
- visual = surface->pix->visual;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ format = WL_SHM_FORMAT_XRGB32;
break;
default:
return NULL;
+ break;
}
return wl_shm_create_buffer(shmdpy->wl_shm, wsh.fd,
width, height,
- wsh.stride, visual);
+ wsh.stride, format);
}
static boolean