XImage *ximage;
struct pipe_texture *texture;
- struct pipe_transfer *transfer;
XShmSegmentInfo *shm_info;
boolean xshm_attached;
};
{
struct ximage_surface *xsurf = ximage_surface(nsurf);
struct ximage_buffer *xbuf = &xsurf->buffers[which];
- struct pipe_screen *screen = xsurf->xdpy->base.screen;
- if (xbuf->transfer) {
- screen->tex_transfer_destroy(xbuf->transfer);
- xbuf->transfer = NULL;
- }
pipe_texture_reference(&xbuf->texture, NULL);
if (xbuf->shm_info) {
xbuf->texture = screen->texture_create(screen, &templ);
}
- if (xbuf->texture) {
- xbuf->transfer = screen->get_tex_transfer(screen, xbuf->texture,
- 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height);
- if (!xbuf->transfer)
- pipe_texture_reference(&xbuf->texture, NULL);
- }
-
/* clean up the buffer if allocation failed */
if (!xbuf->texture)
ximage_surface_free_buffer(&xsurf->base, which);
struct ximage_surface *xsurf = ximage_surface(nsurf);
struct ximage_buffer *xbuf = &xsurf->buffers[which];
struct pipe_screen *screen = xsurf->xdpy->base.screen;
+ struct pipe_transfer *transfer;
if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER)
return TRUE;
assert(xsurf->drawable && xbuf->ximage && xbuf->texture);
- xbuf->ximage->data = screen->transfer_map(screen, xbuf->transfer);
+ transfer = screen->get_tex_transfer(screen, xbuf->texture,
+ 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height);
+ if (!transfer)
+ return FALSE;
+
+ xbuf->ximage->bytes_per_line = transfer->stride;
+ xbuf->ximage->data = screen->transfer_map(screen, transfer);
+ if (!xbuf->ximage->data) {
+ screen->tex_transfer_destroy(transfer);
+ return FALSE;
+ }
+
if (xbuf->shm_info)
XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc,
xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height);
xbuf->ximage->data = NULL;
- screen->transfer_unmap(screen, xbuf->transfer);
+ screen->transfer_unmap(screen, transfer);
+
+ /*
+ * softpipe allows the pipe transfer to be re-used, but we don't want to
+ * rely on that behavior.
+ */
+ screen->tex_transfer_destroy(transfer);
XSync(xsurf->xdpy->dpy, FALSE);
if (ximage_surface_alloc_buffer(&xsurf->base, att)) {
/* update ximage */
if (xbuf->ximage) {
- xbuf->ximage->width = xbuf->transfer->width;
- xbuf->ximage->height = xbuf->transfer->height;
- xbuf->ximage->bytes_per_line = xbuf->transfer->stride;
+ xbuf->ximage->width = xsurf->width;
+ xbuf->ximage->height = xsurf->height;
}
}
}