aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-12-24 08:54:26 -0700
committerBrian Paul <[email protected]>2011-12-24 08:54:26 -0700
commite23e8cbf3965b721f475e489bcb381b1a5d91c0f (patch)
tree6225343a5addda20a90bf738fd1bdefa11a78119
parent89fb81d521bdcd341a88d2bf54ae3d79ad232cca (diff)
swrast: stop using _swrast_get_values() in stencil code
That function will go a way in the future. Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/mesa/swrast/s_stencil.c31
1 files changed, 30 insertions, 1 deletions
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));