Esempio n. 1
0
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;
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
static union waffle_native_context*
wayland_context_get_native(struct wcore_context *wc_ctx)
{
    struct wayland_display *dpy = wayland_display(wc_ctx->display);
    struct wegl_context *ctx = wegl_context(wc_ctx);
    union waffle_native_context *n_ctx;

    WCORE_CREATE_NATIVE_UNION(n_ctx, wayland);
    if (!n_ctx)
        return NULL;

    wayland_display_fill_native(dpy, &n_ctx->wayland->display);
    n_ctx->wayland->egl_context = ctx->egl;

    return n_ctx;
}
Esempio n. 4
0
static union waffle_native_config*
wayland_config_get_native(struct wcore_config *wc_config)
{
    struct wegl_config *config = wegl_config(wc_config);
    struct wayland_display *dpy = wayland_display(wc_config->display);
    union waffle_native_config *n_config;

    WCORE_CREATE_NATIVE_UNION(n_config, wayland);
    if (!n_config)
        return NULL;

    wayland_display_fill_native(dpy, &n_config->wayland->display);
    n_config->wayland->egl_config = config->egl;

    return n_config;
}
Esempio n. 5
0
static struct native_surface *
wayland_create_window_surface(struct native_display *ndpy,
                              EGLNativeWindowType win,
                              const struct native_config *nconf)
{
   struct wayland_display *display = wayland_display(ndpy);
   struct wayland_config *config = wayland_config(nconf);
   struct wayland_surface *surface;
   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->color_format = config->base.color_format;

   surface->win = (struct wl_egl_window *) win;

   surface->pending_resource = NULL;
   surface->block_swap_buffers = FALSE;
   surface->type = WL_WINDOW_SURFACE;

   surface->buffer[WL_BUFFER_FRONT] = NULL;
   surface->buffer[WL_BUFFER_BACK] = NULL;
   surface->attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
      (1 << NATIVE_ATTACHMENT_BACK_LEFT);

   surface->rsurf = resource_surface_create(display->base.screen,
                                            surface->color_format, bind);

   if (!surface->rsurf) {
      FREE(surface);
      return NULL;
   }

   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;
}
Esempio n. 6
0
static int
wayland_display_get_param(struct native_display *ndpy,
                          enum native_param_type param)
{
   struct wayland_display *display = wayland_display(ndpy);
   int val;

   switch (param) {
   case NATIVE_PARAM_PREMULTIPLIED_ALPHA:
      val = ((display->formats & HAS_ARGB32) &&
             (display->formats & HAS_PREMUL_ARGB32));
      break;
   case NATIVE_PARAM_USE_NATIVE_BUFFER:
   case NATIVE_PARAM_PRESERVE_BUFFER:
   case NATIVE_PARAM_MAX_SWAP_INTERVAL:
   default:
      val = 0;
      break;
   }

   return val;
}