예제 #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;
}
예제 #2
0
static struct ximage_surface *
ximage_display_create_surface(struct native_display *ndpy,
                              enum ximage_surface_type type,
                              Drawable drawable,
                              const struct native_config *nconf)
{
   struct ximage_display *xdpy = ximage_display(ndpy);
   struct ximage_config *xconf = ximage_config(nconf);
   struct ximage_surface *xsurf;

   xsurf = CALLOC_STRUCT(ximage_surface);
   if (!xsurf)
      return NULL;

   xsurf->xdpy = xdpy;
   xsurf->type = type;
   xsurf->color_format = xconf->base.color_format;
   xsurf->drawable = drawable;

   xsurf->rsurf = resource_surface_create(xdpy->base.screen,
         xsurf->color_format,
         PIPE_BIND_RENDER_TARGET |
         PIPE_BIND_SAMPLER_VIEW |
         PIPE_BIND_DISPLAY_TARGET |
         PIPE_BIND_SCANOUT);
   if (!xsurf->rsurf) {
      FREE(xsurf);
      return NULL;
   }

   xsurf->drawable = drawable;
   xsurf->visual = *xconf->visual;
   /* initialize the geometry */
   ximage_surface_update_geometry(&xsurf->base);

   xsurf->xdraw.visual = xsurf->visual.visual;
   xsurf->xdraw.depth = xsurf->visual.depth;
   xsurf->xdraw.drawable = xsurf->drawable;

   xsurf->base.destroy = ximage_surface_destroy;
   xsurf->base.present = ximage_surface_present;
   xsurf->base.validate = ximage_surface_validate;
   xsurf->base.wait = ximage_surface_wait;

   return xsurf;
}
예제 #3
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;
}
예제 #4
0
파일: modeset.c 프로젝트: nikai3d/mesa
static struct drm_surface *
drm_display_create_surface(struct native_display *ndpy,
                           const struct native_config *nconf,
                           uint width, uint height)
{
   struct drm_display *drmdpy = drm_display(ndpy);
   struct drm_config *drmconf = drm_config(nconf);
   struct drm_surface *drmsurf;

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

   drmsurf->drmdpy = drmdpy;
   drmsurf->color_format = drmconf->base.color_format;
   drmsurf->width = width;
   drmsurf->height = height;
   drmsurf->have_pageflip = TRUE;

   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);
   if (!drmsurf->rsurf) {
      FREE(drmsurf);
      return NULL;
   }

   resource_surface_set_size(drmsurf->rsurf, drmsurf->width, drmsurf->height);

   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;
}
예제 #5
0
static struct native_surface *
gdi_display_create_window_surface(struct native_display *ndpy,
                                  EGLNativeWindowType win,
                                  const struct native_config *nconf)
{
   struct gdi_display *gdpy = gdi_display(ndpy);
   struct gdi_surface *gsurf;

   gsurf = CALLOC_STRUCT(gdi_surface);
   if (!gsurf)
      return NULL;

   gsurf->gdpy = gdpy;
   gsurf->color_format = nconf->color_format;
   gsurf->hWnd = (HWND) win;

   gsurf->rsurf = resource_surface_create(gdpy->base.screen,
         gsurf->color_format,
         PIPE_BIND_RENDER_TARGET |
         PIPE_BIND_SAMPLER_VIEW |
         PIPE_BIND_DISPLAY_TARGET |
         PIPE_BIND_SCANOUT);
   if (!gsurf->rsurf) {
      FREE(gsurf);
      return NULL;
   }

   /* initialize the geometry */
   gdi_surface_update_geometry(&gsurf->base);

   gsurf->base.destroy = gdi_surface_destroy;
   gsurf->base.present = gdi_surface_present;
   gsurf->base.validate = gdi_surface_validate;
   gsurf->base.wait = gdi_surface_wait;

   return &gsurf->base;
}
예제 #6
0
static struct native_surface *
psl1ght_display_create_scanout_surface(struct native_display *ndpy,
				       const struct native_config *nconf,
				       uint width, uint height)
{
   struct psl1ght_display *psdpy = psl1ght_display(ndpy);
   struct psl1ght_surface *pssurf;

   pssurf = CALLOC_STRUCT(psl1ght_surface);
   if (!pssurf)
      return NULL;

   pssurf->psdpy = psdpy;
   pssurf->width = width;
   pssurf->height = height;
   pssurf->format = nconf->native_visual_id;

   pssurf->rsurf = resource_surface_create(psdpy->base.screen,
         nconf->color_format,
         PIPE_BIND_RENDER_TARGET |
         PIPE_BIND_DISPLAY_TARGET |
         PIPE_BIND_SCANOUT);
   if (!pssurf->rsurf) {
      FREE(pssurf);
      return NULL;
   }

   resource_surface_set_size(pssurf->rsurf, pssurf->width, pssurf->height);

   pssurf->base.destroy = psl1ght_surface_destroy;
   pssurf->base.present = psl1ght_surface_present;
   pssurf->base.validate = psl1ght_surface_validate;
   pssurf->base.wait = psl1ght_surface_wait;

   return &pssurf->base;
}