예제 #1
0
/**
 * Display/copy the image in the surface into the X window specified
 * by the XMesaBuffer.
 */
static void
xlib_softpipe_display_surface(struct xmesa_buffer *b,
                              struct pipe_surface *surf)
{
   XImage *ximage;
   struct softpipe_texture *spt = softpipe_texture(surf->texture);
   struct xm_buffer *xm_buf = xm_buffer(spt->buffer);
   static boolean no_swap = 0;
   static boolean firsttime = 1;

   if (firsttime) {
      no_swap = getenv("SP_NO_RAST") != NULL;
      firsttime = 0;
   }

   if (no_swap)
      return;

#ifdef USE_XSHM
   if (xm_buf->shm)
   {
      if (xm_buf->tempImage == NULL) 
      {
         assert(surf->texture->block.width == 1);
         assert(surf->texture->block.height == 1);
         alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
                          surf->texture->block.size, surf->height);
      }

      ximage = xm_buf->tempImage;
      ximage->data = xm_buf->data;

      /* _debug_printf("XSHM\n"); */
      XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
                   ximage, 0, 0, 0, 0, surf->width, surf->height, False);
   }
   else
#endif
   {
      /* display image in Window */
      ximage = b->tempImage;
      ximage->data = xm_buf->data;

      /* check that the XImage has been previously initialized */
      assert(ximage->format);
      assert(ximage->bitmap_unit);

      /* update XImage's fields */
      ximage->width = surf->width;
      ximage->height = surf->height;
      ximage->bytes_per_line = spt->stride[surf->level];

      /* _debug_printf("XPUT\n"); */
      XPutImage(b->xm_visual->display, b->drawable, b->gc,
                ximage, 0, 0, 0, 0, surf->width, surf->height);
   }
}
예제 #2
0
/**
 * Display/copy the image in the surface into the X window specified
 * by the XMesaBuffer.
 */
static void
xm_llvmpipe_display(struct xmesa_buffer *xm_buffer,
                    struct llvmpipe_displaytarget *dt)
{
   XImage *ximage;
   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
   static boolean no_swap = 0;
   static boolean firsttime = 1;

   if (firsttime) {
      no_swap = getenv("SP_NO_RAST") != NULL;
      firsttime = 0;
   }

   if (no_swap)
      return;

#ifdef USE_XSHM
   if (xm_dt->shm)
   {
      if (xm_dt->tempImage == NULL)
      {
         assert(xm_dt->block.width == 1);
         assert(xm_dt->block.height == 1);
         alloc_shm_ximage(xm_dt, xm_buffer,
                          xm_dt->stride / xm_dt->block.size,
                          xm_dt->height);
      }

      ximage = xm_dt->tempImage;
      ximage->data = xm_dt->data;

      /* _debug_printf("XSHM\n"); */
      XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc,
                   ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
   }
   else
#endif
   {
      /* display image in Window */
      ximage = xm_dt->tempImage;
      ximage->data = xm_dt->data;

      /* check that the XImage has been previously initialized */
      assert(ximage->format);
      assert(ximage->bitmap_unit);

      /* update XImage's fields */
      ximage->width = xm_dt->width;
      ximage->height = xm_dt->height;
      ximage->bytes_per_line = xm_dt->stride;

      /* _debug_printf("XPUT\n"); */
      XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc,
                ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height);
   }
}
예제 #3
0
static void
alloc_ximage(struct xlib_displaytarget *xlib_dt,
             struct xlib_drawable *xmb,
             unsigned width, unsigned height)
{
   /* try allocating a shared memory image first */
   if (xlib_dt->shm) {
      alloc_shm_ximage(xlib_dt, xmb, width, height);
      if (xlib_dt->tempImage)
         return; /* success */
   }

   /* try regular (non-shared memory) image */
   xlib_dt->tempImage = XCreateImage(xlib_dt->display,
                                   xmb->visual,
                                   xmb->depth,
                                   ZPixmap, 0,
                                   NULL, width, height,
                                   8, 0);
}