/** * Copy image data from application memory in the surface's native format to * a VdpOutputSurface. */ VdpStatus vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface, void const *const *source_data, uint32_t const *source_pitches, VdpRect const *destination_rect) { vlVdpOutputSurface *vlsurface; struct pipe_box dst_box; struct pipe_context *pipe; vlsurface = vlGetDataHTAB(surface); if (!vlsurface) return VDP_STATUS_INVALID_HANDLE; pipe = vlsurface->device->context; if (!pipe) return VDP_STATUS_INVALID_HANDLE; pipe_mutex_lock(vlsurface->device->mutex); vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL); dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture); pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0, PIPE_TRANSFER_WRITE, &dst_box, *source_data, *source_pitches, 0); pipe_mutex_unlock(vlsurface->device->mutex); return VDP_STATUS_OK; }
/** * Copy image data from application memory in the surface's native format to * a VdpBitmapSurface. */ VdpStatus vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface, void const *const *source_data, uint32_t const *source_pitches, VdpRect const *destination_rect) { vlVdpBitmapSurface *vlsurface; struct pipe_box dst_box; struct pipe_context *pipe; vlsurface = vlGetDataHTAB(surface); if (!vlsurface) return VDP_STATUS_INVALID_HANDLE; if (!(source_data && source_pitches)) return VDP_STATUS_INVALID_POINTER; pipe = vlsurface->device->context; mtx_lock(&vlsurface->device->mutex); dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture); pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0, PIPE_TRANSFER_WRITE, &dst_box, *source_data, *source_pitches, 0); mtx_unlock(&vlsurface->device->mutex); return VDP_STATUS_OK; }
/** * Copy image data from a VdpOutputSurface to application memory in the * surface's native format. */ VdpStatus vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface, VdpRect const *source_rect, void *const *destination_data, uint32_t const *destination_pitches) { vlVdpOutputSurface *vlsurface; struct pipe_context *pipe; struct pipe_resource *res; struct pipe_box box; struct pipe_transfer *transfer; uint8_t *map; vlsurface = vlGetDataHTAB(surface); if (!vlsurface) return VDP_STATUS_INVALID_HANDLE; pipe = vlsurface->device->context; if (!pipe) return VDP_STATUS_INVALID_HANDLE; pipe_mutex_lock(vlsurface->device->mutex); vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL); res = vlsurface->sampler_view->texture; box = RectToPipeBox(source_rect, res); map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer); if (!map) { pipe_mutex_unlock(vlsurface->device->mutex); return VDP_STATUS_RESOURCES; } util_copy_rect(*destination_data, res->format, *destination_pitches, 0, 0, box.width, box.height, map, transfer->stride, 0, 0); pipe_transfer_unmap(pipe, transfer); pipe_mutex_unlock(vlsurface->device->mutex); return VDP_STATUS_OK; }