st/egl: track changes to drop wl_visual in wayland

Follow a subset of changes in 7b1d94e5d1.
There are known issues, but it works to a certain degree.  Non-working
demos also fail gracefully.  More importantly, it fixes the build.
This commit is contained in:
Chia-I Wu 2011-09-07 21:41:30 +08:00
parent b89bca6d8b
commit 6b52e82768
4 changed files with 44 additions and 20 deletions

View file

@ -15,17 +15,32 @@
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;

View file

@ -31,8 +31,7 @@
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);

View file

@ -97,7 +97,7 @@ wayland_create_drm_buffer(struct wayland_display *display,
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);
@ -107,19 +107,21 @@ wayland_create_drm_buffer(struct wayland_display *display,
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
@ -143,6 +145,12 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
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)
{
@ -153,6 +161,7 @@ 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
};

View file

@ -84,7 +84,7 @@ wayland_create_shm_buffer(struct wayland_display *display,
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);
@ -93,20 +93,21 @@ wayland_create_shm_buffer(struct wayland_display *display,
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