From: Brian Paul Date: Sat, 24 Dec 2011 15:54:26 +0000 (-0700) Subject: swrast: stop using _swrast_get_values() in stencil code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e23e8cbf3965b721f475e489bcb381b1a5d91c0f;p=mesa.git swrast: stop using _swrast_get_values() in stencil code That function will go a way in the future. Reviewed-by: Eric Anholt --- diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index aa9ab162576..17b3b12edbf 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -879,6 +879,35 @@ stencil_test_pixels( struct gl_context *ctx, GLuint face, GLuint n, +static void +get_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + GLubyte stencil[]) +{ + const GLint w = rb->Width, h = rb->Height; + const GLubyte *map = (const GLubyte *) rb->Data; + GLuint i; + + if (rb->Format == MESA_FORMAT_S8) { + const GLuint rowStride = rb->RowStride; + for (i = 0; i < count; i++) { + if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { + stencil[i] = *(map + y[i] * rowStride + x[i]); + } + } + } + else { + const GLuint bpp = _mesa_get_format_bytes(rb->Format); + const GLuint rowStride = rb->RowStride * bpp; + for (i = 0; i < count; i++) { + if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { + const GLubyte *src = map + y[i] * rowStride + x[i] * bpp; + _mesa_unpack_ubyte_stencil_row(rb->Format, 1, src, &stencil[i]); + } + } + } +} + /** * Apply stencil and depth testing to an array of pixels. @@ -916,7 +945,7 @@ stencil_and_ztest_pixels( struct gl_context *ctx, SWspan *span, GLuint face ) GLubyte stencil[MAX_WIDTH]; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte)); + get_s8_values(ctx, rb, n, x, y, stencil); memcpy(origMask, mask, n * sizeof(GLubyte));