diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-09-26 18:34:43 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-09-26 18:34:43 -0600 |
commit | 78008dbcaaf74cac3b66dae103f631de94df6137 (patch) | |
tree | 1fa6169a92c71a18e56ac318f3402f78d715338a /src/mesa | |
parent | fcd4eeb743c717d48166e38a57fcd4a1752e32ab (diff) |
added a8r8g8b8_put_tile()
Diffstat (limited to 'src/mesa')
-rwxr-xr-x | src/mesa/pipe/softpipe/sp_surface.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 75e36e3e3f..b06f6813c0 100755 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -133,6 +133,46 @@ a8r8g8b8_get_tile(struct pipe_surface *ps, } +static void +a8r8g8b8_put_tile(struct pipe_surface *ps, + unsigned x, unsigned y, unsigned w, unsigned h, + const float *p) +{ + unsigned *dst + = ((unsigned *) (ps->region->map + ps->offset)) + + y * ps->region->pitch + x; + unsigned i, j; + unsigned w0 = w; + + assert(ps->format == PIPE_FORMAT_U_A8_R8_G8_B8); + +#if 0 + assert(x + w <= ps->width); + assert(y + h <= ps->height); +#else + /* temp clipping hack */ + if (x + w > ps->width) + w = ps->width - x; + if (y + h > ps->height) + h = ps->height -y; +#endif + for (i = 0; i < h; i++) { + const float *pRow = p; + for (j = 0; j < w; j++) { + unsigned r, g, b, a; + UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]); + UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]); + UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]); + UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]); + dst[j] = (a << 24) | (r << 16) | (g << 8) | b; + pRow += 4; + } + dst += ps->region->pitch; + p += w0 * 4; + } +} + + /*** PIPE_FORMAT_U_A1_R5_G5_B5 ***/ static void @@ -705,6 +745,7 @@ softpipe_init_surface_funcs(struct softpipe_surface *sps) sps->read_quad_f_swz = a8r8g8b8_read_quad_f_swz; sps->write_quad_f_swz = a8r8g8b8_write_quad_f_swz; sps->surface.get_tile = a8r8g8b8_get_tile; + sps->surface.put_tile = a8r8g8b8_put_tile; break; case PIPE_FORMAT_U_A1_R5_G5_B5: sps->surface.get_tile = a1r5g5b5_get_tile; |