Esempio n. 1
0
struct native_surface *
drm_display_create_surface_from_resource(struct native_display *ndpy,
                                         struct pipe_resource *resource)
{
   struct drm_display *drmdpy = drm_display(ndpy);
   struct drm_surface *drmsurf;
   enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT;

   drmsurf = CALLOC_STRUCT(drm_surface);
   if (!drmsurf)
      return NULL;

   drmsurf->drmdpy = drmdpy;
   drmsurf->color_format = resource->format;
   drmsurf->width = resource->width0;
   drmsurf->height = resource->height0;
   drmsurf->have_pageflip = FALSE;

   drmsurf->rsurf = resource_surface_create(drmdpy->base.screen,
         drmsurf->color_format,
         PIPE_BIND_RENDER_TARGET |
         PIPE_BIND_SAMPLER_VIEW |
         PIPE_BIND_DISPLAY_TARGET |
         PIPE_BIND_SCANOUT);
   
   resource_surface_import_resource(drmsurf->rsurf, natt, resource);

   drmsurf->base.destroy = drm_surface_destroy;
   drmsurf->base.present = drm_surface_present;
   drmsurf->base.validate = drm_surface_validate;
   drmsurf->base.wait = drm_surface_wait;

   return &drmsurf->base;
}
Esempio n. 2
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;
}