struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
struct dri2_egl_surface *dri2_surf;
- struct dri2_egl_buffer *dri2_buf;
int i;
(void) drv;
dri2_surf->base.Width = -1;
dri2_surf->base.Height = -1;
break;
- case EGL_PIXMAP_BIT:
- dri2_surf->wl_pix = (struct wl_egl_pixmap *) window;
-
- dri2_surf->base.Width = dri2_surf->wl_pix->width;
- dri2_surf->base.Height = dri2_surf->wl_pix->height;
-
- if (dri2_surf->wl_pix->driver_private) {
- dri2_buf = dri2_surf->wl_pix->driver_private;
- dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] = dri2_buf->dri_buffer;
- }
- break;
default:
goto cleanup_surf;
}
window, attrib_list);
}
-static _EGLSurface *
-dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLConfig *conf, EGLNativePixmapType pixmap,
- const EGLint *attrib_list)
-{
- return dri2_create_surface(drv, disp, EGL_PIXMAP_BIT, conf,
- pixmap, attrib_list);
-}
-
/**
* Called via eglDestroySurface(), drv->API.DestroySurface().
*/
wl_buffer_destroy(dri2_surf->wl_drm_buffer[i]);
for (i = 0; i < __DRI_BUFFER_COUNT; ++i)
- if (dri2_surf->dri_buffers[i] && !(i == __DRI_BUFFER_FRONT_LEFT &&
- dri2_surf->base.Type == EGL_PIXMAP_BIT))
+ if (dri2_surf->dri_buffers[i])
dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
dri2_surf->dri_buffers[i]);
return EGL_TRUE;
}
-static void
-dri2_wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap)
-{
- struct dri2_egl_buffer *dri2_buf = egl_pixmap->driver_private;
-
- assert(dri2_buf);
-
- dri2_buf->dri2_dpy->dri2->releaseBuffer(dri2_buf->dri2_dpy->dri_screen,
- dri2_buf->dri_buffer);
-
- free(dri2_buf);
-
- egl_pixmap->driver_private = NULL;
- egl_pixmap->destroy = NULL;
-}
-
static struct wl_buffer *
wayland_create_buffer(struct dri2_egl_surface *dri2_surf,
__DRIbuffer *buffer)
}
}
-static void
-dri2_process_front_buffer(struct dri2_egl_surface *dri2_surf, unsigned format)
-{
- struct dri2_egl_display *dri2_dpy =
- dri2_egl_display(dri2_surf->base.Resource.Display);
- struct dri2_egl_buffer *dri2_buf;
-
- switch (dri2_surf->base.Type) {
- case EGL_PIXMAP_BIT:
- dri2_buf = malloc(sizeof *dri2_buf);
- if (!dri2_buf)
- return;
-
- dri2_buf->dri_buffer = dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT];
- dri2_buf->dri2_dpy = dri2_dpy;
-
- dri2_surf->wl_pix->driver_private = dri2_buf;
- dri2_surf->wl_pix->destroy = dri2_wl_egl_pixmap_destroy;
- break;
- default:
- break;
- }
-}
-
static void
dri2_release_pending_buffer(void *data,
struct wl_callback *callback, uint32_t time)
if (!dri2_surf->dri_buffers[attachments[i]])
continue;
- if (attachments[i] == __DRI_BUFFER_FRONT_LEFT)
- dri2_process_front_buffer(dri2_surf, attachments[i+1]);
- else if (attachments[i] == __DRI_BUFFER_BACK_LEFT)
+ if (attachments[i] == __DRI_BUFFER_BACK_LEFT)
dri2_process_back_buffer(dri2_surf, attachments[i+1]);
}
dri2_surf->buffer_count++;
}
- assert(dri2_surf->base.Type == EGL_PIXMAP_BIT ||
- dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]);
-
- if (dri2_surf->base.Type == EGL_PIXMAP_BIT && !dri2_surf->wl_pix->buffer)
- dri2_surf->wl_pix->buffer =
- wayland_create_buffer(dri2_surf,
- dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT]);
+ assert(dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]);
*out_count = dri2_surf->buffer_count;
if (dri2_surf->buffer_count == 0)
return EGL_TRUE;
}
-/**
- * Called via eglCreateImageKHR(), drv->API.CreateImageKHR().
- */
-static _EGLImage *
-dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
- EGLClientBuffer buffer, const EGLint *attr_list)
-{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- struct wl_egl_pixmap *wl_egl_pixmap = (struct wl_egl_pixmap *) buffer;
- struct dri2_egl_buffer *dri2_buf;
- EGLint wl_attr_list[] = {
- EGL_WIDTH, 0,
- EGL_HEIGHT, 0,
- EGL_DRM_BUFFER_STRIDE_MESA, 0,
- EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
- EGL_NONE
- };
-
- dri2_buf = malloc(sizeof *dri2_buf);
- if (!dri2_buf)
- return NULL;
-
- dri2_buf->dri2_dpy = dri2_dpy;
- dri2_buf->dri_buffer =
- dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen,
- __DRI_BUFFER_FRONT_LEFT, 32,
- wl_egl_pixmap->width,
- wl_egl_pixmap->height);
-
- wl_egl_pixmap->destroy = dri2_wl_egl_pixmap_destroy;
- wl_egl_pixmap->driver_private = dri2_buf;
-
- /* FIXME: Get buffer format from attr_list somehow... or from the
- wl_egl_piaxmap. */
- wl_egl_pixmap->buffer =
- wl_drm_create_buffer(dri2_dpy->wl_drm,
- dri2_buf->dri_buffer->name,
- wl_egl_pixmap->width,
- wl_egl_pixmap->height,
- dri2_buf->dri_buffer->pitch,
- WL_DRM_FORMAT_ARGB8888);
-
- wl_attr_list[1] = wl_egl_pixmap->width;
- wl_attr_list[3] = wl_egl_pixmap->height;
- wl_attr_list[5] = dri2_buf->dri_buffer->pitch / 4;
-
- return dri2_create_image_khr(disp->Driver, disp, ctx, EGL_DRM_BUFFER_MESA,
- (EGLClientBuffer)(intptr_t) dri2_buf->dri_buffer->name, wl_attr_list);
-}
-
-static _EGLImage *
-dri2_wayland_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLContext *ctx, EGLenum target,
- EGLClientBuffer buffer, const EGLint *attr_list)
-{
- (void) drv;
-
- switch (target) {
- case EGL_NATIVE_PIXMAP_KHR:
- return dri2_create_image_khr_pixmap(disp, ctx, buffer, attr_list);
- default:
- return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list);
- }
-}
-
static int
dri2_wayland_authenticate(_EGLDisplay *disp, uint32_t id)
{
static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0 };
drv->API.CreateWindowSurface = dri2_create_window_surface;
- drv->API.CreatePixmapSurface = dri2_create_pixmap_surface;
drv->API.DestroySurface = dri2_destroy_surface;
drv->API.SwapBuffers = dri2_swap_buffers;
- drv->API.CreateImageKHR = dri2_wayland_create_image_khr;
drv->API.Terminate = dri2_terminate;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_create_screen(disp))
goto cleanup_driver;
- types = EGL_WINDOW_BIT | EGL_PIXMAP_BIT;
+ types = EGL_WINDOW_BIT;
for (i = 0; dri2_dpy->driver_configs[i]; i++) {
config = dri2_dpy->driver_configs[i];
if (dri2_dpy->formats & HAS_XRGB8888)
dri2_add_config(disp, config, i + 1, 0, types, NULL, argb_masks);
}
- disp->Extensions.KHR_image_pixmap = EGL_TRUE;
-
disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
dri2_dpy->authenticate = dri2_wayland_authenticate;
(1 << NATIVE_ATTACHMENT_BACK_LEFT);
nconf->window_bit = TRUE;
- nconf->pixmap_bit = TRUE;
nconf->color_format = wayland_formats[i].format;
display->num_configs++;
return val;
}
-static boolean
-wayland_display_get_pixmap_format(struct native_display *ndpy,
- EGLNativePixmapType pix,
- enum pipe_format *format)
-{
- /* all wl_egl_pixmaps are supported */
- *format = PIPE_FORMAT_NONE;
-
- return TRUE;
-}
-
-static void
-wayland_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap)
-{
- struct pipe_resource *resource = egl_pixmap->driver_private;
-
- assert(resource);
-
- pipe_resource_reference(&resource, NULL);
- if (egl_pixmap->buffer) {
- wl_buffer_destroy(egl_pixmap->buffer);
- egl_pixmap->buffer = NULL;
- }
-
- egl_pixmap->driver_private = NULL;
- egl_pixmap->destroy = NULL;
-}
-
-static void
-wayland_pixmap_surface_initialize(struct wayland_surface *surface)
-{
- struct wayland_display *display = wayland_display(&surface->display->base);
- const enum native_attachment front_natt = NATIVE_ATTACHMENT_FRONT_LEFT;
-
- if (surface->pix->buffer != NULL)
- return;
-
- surface->pix->buffer = display->create_buffer(display, surface, front_natt);
- surface->pix->destroy = wayland_pixmap_destroy;
- surface->pix->driver_private =
- resource_surface_get_single_resource(surface->rsurf, front_natt);
-}
-
static void
wayland_release_pending_resource(void *data,
struct wl_callback *callback,
resource_surface_get_size(surface->rsurf, (uint *) width, (uint *) height);
- if (surface->type == WL_PIXMAP_SURFACE)
- wayland_pixmap_surface_initialize(surface);
-
return TRUE;
}
}
-
-static struct native_surface *
-wayland_create_pixmap_surface(struct native_display *ndpy,
- EGLNativePixmapType pix,
- const struct native_config *nconf)
-{
- struct wayland_display *display = wayland_display(ndpy);
- struct wayland_surface *surface;
- struct wl_egl_pixmap *egl_pixmap = (struct wl_egl_pixmap *) pix;
- enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT;
- uint bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
- PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT;
-
- surface = CALLOC_STRUCT(wayland_surface);
- if (!surface)
- return NULL;
-
- surface->display = display;
-
- surface->pending_resource = NULL;
- surface->type = WL_PIXMAP_SURFACE;
- surface->pix = egl_pixmap;
-
- if (nconf)
- surface->color_format = nconf->color_format;
- else /* FIXME: derive format from wl_visual */
- surface->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
-
- surface->attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT);
-
- surface->rsurf = resource_surface_create(display->base.screen,
- surface->color_format, bind);
-
- if (!surface->rsurf) {
- FREE(surface);
- return NULL;
- }
-
- resource_surface_set_size(surface->rsurf,
- egl_pixmap->width, egl_pixmap->height);
-
- /* the pixmap is already allocated, so import it */
- if (surface->pix->buffer != NULL)
- resource_surface_import_resource(surface->rsurf, natt,
- surface->pix->driver_private);
-
- surface->base.destroy = wayland_surface_destroy;
- surface->base.present = wayland_surface_present;
- surface->base.validate = wayland_surface_validate;
- surface->base.wait = wayland_surface_wait;
-
- return &surface->base;
-}
-
-
static struct native_surface *
wayland_create_window_surface(struct native_display *ndpy,
EGLNativeWindowType win,
display->base.get_param = wayland_display_get_param;
display->base.get_configs = wayland_display_get_configs;
- display->base.get_pixmap_format = wayland_display_get_pixmap_format;
- display->base.copy_to_pixmap = native_display_copy_to_pixmap;
display->base.create_window_surface = wayland_create_window_surface;
- display->base.create_pixmap_surface = wayland_create_pixmap_surface;
display->own_dpy = own_dpy;