Esempio n. 1
0
static struct native_surface *
fbdev_display_create_window_surface(struct native_display *ndpy,
                                    EGLNativeWindowType win,
                                    const struct native_config *nconf)
{
   struct fbdev_display *fbdpy = fbdev_display(ndpy);
   struct fbdev_surface *fbsurf;
   struct fb_var_screeninfo vinfo;

   /* there is only one native window: NULL */
   if (win)
      return NULL;

   fbsurf = CALLOC_STRUCT(fbdev_surface);
   if (!fbsurf)
      return NULL;

   fbsurf->fbdpy = fbdpy;

   /* get current vinfo */
   if (fbdpy->assume_fixed_vinfo) {
      vinfo = fbdpy->config_vinfo;
   }
   else {
      memset(&vinfo, 0, sizeof(vinfo));
      if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &vinfo)) {
         FREE(fbsurf);
         return NULL;
      }
   }

   fbsurf->width = vinfo.xres;
   fbsurf->height = vinfo.yres;

   if (!fbdev_surface_update_drawable(&fbsurf->base, &vinfo)) {
      FREE(fbsurf);
      return NULL;
   }

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

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

   fbsurf->base.destroy = fbdev_surface_destroy;
   fbsurf->base.present = fbdev_surface_present;
   fbsurf->base.validate = fbdev_surface_validate;
   fbsurf->base.wait = fbdev_surface_wait;

   return &fbsurf->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;
}
Esempio n. 3
0
/**
 * Update the geometry of the surface.  This is a slow functions.
 */
static void
ximage_surface_update_geometry(struct native_surface *nsurf)
{
   struct ximage_surface *xsurf = ximage_surface(nsurf);
   Status ok;
   Window root;
   int x, y;
   unsigned int w, h, border, depth;

   ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable,
         &root, &x, &y, &w, &h, &border, &depth);
   if (ok && resource_surface_set_size(xsurf->rsurf, w, h))
      xsurf->server_stamp++;
}
Esempio n. 4
0
/**
 * Update the geometry of the surface.  This is a slow functions.
 */
static void
gdi_surface_update_geometry(struct native_surface *nsurf)
{
   struct gdi_surface *gsurf = gdi_surface(nsurf);
   RECT rect;
   uint w, h;

   GetClientRect(gsurf->hWnd, &rect);
   w = rect.right - rect.left;
   h = rect.bottom - rect.top;

   if (resource_surface_set_size(gsurf->rsurf, w, h))
      gsurf->server_stamp++;
}
Esempio n. 5
0
static boolean
fbdev_surface_present(struct native_surface *nsurf,
                      const struct native_present_control *ctrl)
{
   struct fbdev_surface *fbsurf = fbdev_surface(nsurf);
   struct fbdev_display *fbdpy = fbsurf->fbdpy;
   boolean ret = FALSE;

   if (ctrl->swap_interval)
      return FALSE;
   if (ctrl->natt != NATIVE_ATTACHMENT_BACK_LEFT)
      return FALSE;

   if (!fbdpy->assume_fixed_vinfo) {
      struct fb_var_screeninfo vinfo;

      memset(&vinfo, 0, sizeof(vinfo));
      if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &vinfo))
         return FALSE;

      /* present the surface */
      if (fbdev_surface_update_drawable(&fbsurf->base, &vinfo)) {
         ret = resource_surface_present(fbsurf->rsurf,
               ctrl->natt, (void *) &fbsurf->drawable);
      }

      fbsurf->width = vinfo.xres;
      fbsurf->height = vinfo.yres;

      if (resource_surface_set_size(fbsurf->rsurf,
               fbsurf->width, fbsurf->height)) {
         /* surface resized */
         fbsurf->sequence_number++;
         fbdpy->event_handler->invalid_surface(&fbdpy->base,
               &fbsurf->base, fbsurf->sequence_number);
      }
   }
   else {
      /* the drawable never changes */
      ret = resource_surface_present(fbsurf->rsurf,
            ctrl->natt, (void *) &fbsurf->drawable);
   }

   return ret;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
static void
wayland_window_surface_handle_resize(struct wayland_surface *surface)
{
   struct wayland_display *display = surface->display;
   struct pipe_resource *front_resource;
   const enum native_attachment front_natt = NATIVE_ATTACHMENT_FRONT_LEFT;
   int i;

   front_resource = resource_surface_get_single_resource(surface->rsurf,
                                                         front_natt);
   if (resource_surface_set_size(surface->rsurf,
                                 surface->win->width, surface->win->height)) {

      if (surface->pending_resource)
         wayland_roundtrip(display);

      if (front_resource) {
         struct wl_callback *callback;

         surface->pending_resource = front_resource;
         front_resource = NULL;

         callback = wl_display_sync(display->dpy);
         wl_callback_add_listener(callback, &release_buffer_listener, surface);
         wl_proxy_set_queue((struct wl_proxy *) callback, display->queue);
      }

      for (i = 0; i < WL_BUFFER_COUNT; ++i) {
         if (surface->buffer[i])
            wl_buffer_destroy(surface->buffer[i]);
         surface->buffer[i] = NULL;
      }

      surface->dx = surface->win->dx;
      surface->dy = surface->win->dy;
   }
   pipe_resource_reference(&front_resource, NULL);
}
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;
}