summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_surface.c
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-06-27 19:37:56 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-06-27 19:37:56 +0900
commit4ddd65967915ca4846f2831bc676c878a29dae4a (patch)
treef2c66e355d5e9ea6f80531f995ccc25166d06fc3 /src/gallium/drivers/softpipe/sp_surface.c
parent05cfb4c4b84b4e3119112c381ceffc583a4ef5fe (diff)
gallium: Drop pipe_texture->cpp and pipe_surface->cpp.
The chars-per-pixel concept falls apart with compressed and yuv images, where more than one pixel are coded in a single data block.
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_surface.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_surface.c45
1 files changed, 11 insertions, 34 deletions
diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c
index 9fd48aeccc..7dc15c38d1 100644
--- a/src/gallium/drivers/softpipe/sp_surface.c
+++ b/src/gallium/drivers/softpipe/sp_surface.c
@@ -58,18 +58,20 @@ sp_surface_copy(struct pipe_context *pipe,
src,
PIPE_BUFFER_USAGE_CPU_READ );
- assert(dst->cpp == src->cpp);
+ assert(dst->block.size == src->block.size);
+ assert(dst->block.width == src->block.width);
+ assert(dst->block.height == src->block.height);
assert(src_map);
assert(dst_map);
/* If do_flip, invert src_y position and pass negative src stride */
pipe_copy_rect(dst_map,
- dst->cpp,
- dst->pitch,
+ &dst->block,
+ dst->stride,
dstx, dsty,
width, height,
src_map,
- do_flip ? -(int) src->pitch : src->pitch,
+ do_flip ? -(int) src->stride : src->stride,
srcx, do_flip ? src->height - 1 - srcy : srcy);
pipe->screen->surface_unmap(pipe->screen, src);
@@ -80,7 +82,7 @@ sp_surface_copy(struct pipe_context *pipe,
static void *
get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
{
- return (char *)dst_map + (y * dst->pitch + x) * dst->cpp;
+ return (char *)dst_map + y / dst->block.height * dst->stride + x / dst->block.width * dst->block.size;
}
@@ -102,39 +104,14 @@ sp_surface_fill(struct pipe_context *pipe,
dst,
PIPE_BUFFER_USAGE_CPU_WRITE );
- assert(dst->pitch > 0);
- assert(width <= dst->pitch);
+ assert(dst->stride > 0);
- switch (dst->cpp) {
+ switch (dst->block.size) {
case 1:
- {
- ubyte *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- memset(row, value, width);
- row += dst->pitch;
- }
- }
- break;
case 2:
- {
- ushort *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = (ushort) value;
- row += dst->pitch;
- }
- }
- break;
case 4:
- {
- unsigned *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = value;
- row += dst->pitch;
- }
- }
+ pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, width, height, value);
break;
case 8:
{
@@ -155,7 +132,7 @@ sp_surface_fill(struct pipe_context *pipe,
row[j*4+2] = val2;
row[j*4+3] = val3;
}
- row += dst->pitch * 4;
+ row += dst->stride/2;
}
}
break;