diff options
author | José Fonseca <[email protected]> | 2012-12-05 20:15:40 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-12-06 17:12:31 +0000 |
commit | b79194401a944e952e3035c676d1d22df24aa2a8 (patch) | |
tree | 8aa18376a4d6b900cb4afdbfcaeb6b10e372afe5 /src/gallium/auxiliary/util/u_surface.c | |
parent | 4da4e8ee2ac337a765afd828880efe5a5a168088 (diff) |
util: Add util_copy_box helper.
Must users of util_copy_rect() need or should deal with volumes.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_surface.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_surface.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index b17dd74fd37..2c197c3df6a 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -168,6 +168,39 @@ util_copy_rect(ubyte * dst, } +/** + * Copy 3D box from one place to another. + * Position and sizes are in pixels. + */ +void +util_copy_box(ubyte * dst, + enum pipe_format format, + unsigned dst_stride, unsigned dst_slice_stride, + unsigned dst_x, unsigned dst_y, unsigned dst_z, + unsigned width, unsigned height, unsigned depth, + const ubyte * src, + int src_stride, unsigned src_slice_stride, + unsigned src_x, unsigned src_y, unsigned src_z) +{ + unsigned z; + dst += dst_z * dst_slice_stride; + src += src_z * src_slice_stride; + for (z = 0; z < depth; ++z) { + util_copy_rect(dst, + format, + dst_stride, + dst_x, dst_y, + width, height, + src, + src_stride, + src_x, src_y); + + dst += dst_slice_stride; + src += src_slice_stride; + } +} + + void util_fill_rect(ubyte * dst, enum pipe_format format, @@ -257,7 +290,6 @@ util_resource_copy_region(struct pipe_context *pipe, const uint8_t *src_map; enum pipe_format src_format, dst_format; struct pipe_box dst_box; - int z; assert(src && dst); if (!src || !dst) @@ -305,19 +337,14 @@ util_resource_copy_region(struct pipe_context *pipe, assert(src_box->depth == 1); memcpy(dst_map, src_map, src_box->width); } else { - for (z = 0; z < src_box->depth; ++z) { - util_copy_rect(dst_map, - dst_format, - dst_trans->stride, - 0, 0, - src_box->width, src_box->height, - src_map, - src_trans->stride, - 0, 0); - - dst_map += dst_trans->layer_stride; - src_map += src_trans->layer_stride; - } + util_copy_box(dst_map, + dst_format, + dst_trans->stride, dst_trans->layer_stride, + 0, 0, 0, + src_box->width, src_box->height, src_box->depth, + src_map, + src_trans->stride, src_trans->layer_stride, + 0, 0, 0); } pipe->transfer_unmap(pipe, dst_trans); |