diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-09-24 16:31:23 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-09-24 16:31:23 +0000 |
commit | f11508c29f4e2cbe50c5580e054342a4c3ddb4c0 (patch) | |
tree | 46b3c00f275679d242aeacb95582ac02b8882542 /src | |
parent | e184bd861c0b3023c5fd5596083e12aaedb2d5e2 (diff) |
use span.arrays for color/indexes instead of a local var when doing masked clears
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/swrast/s_buffers.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 1bc198c676..85ce0932de 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -48,6 +48,7 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; GLchan clearColor[4]; + struct sw_span span; GLint i; ASSERT(ctx->Visual.rgbMode); @@ -58,20 +59,22 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]); CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]); + /* Initialize color span with clear color */ + INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + for (i = 0; i < width; i++) { + COPY_CHAN4(span.array->rgba[i], clearColor); + } + + /* Note that masking will change the color values, but only the + * channels for which the write mask is GL_FALSE. The channels + * which which are write-enabled won't get modified. + */ for (i = 0; i < height; i++) { - struct sw_span span; - GLchan rgba[MAX_WIDTH][4]; - GLint j; - for (j = 0; j < width; j++) { - COPY_CHAN4(rgba[j], clearColor); - } - /* setup span struct for masking */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); span.x = x; span.y = y + i; - _swrast_mask_rgba_span(ctx, rb, &span, rgba); + _swrast_mask_rgba_span(ctx, rb, &span, span.array->rgba); /* write masked row */ - rb->PutRow(ctx, rb, width, x, y + i, rgba, NULL); + rb->PutRow(ctx, rb, width, x, y + i, span.array->rgba, NULL); } } @@ -86,26 +89,29 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) const GLint y = ctx->DrawBuffer->_Ymin; const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; + struct sw_span span; GLint i; ASSERT(!ctx->Visual.rgbMode); ASSERT(rb->PutRow); ASSERT(rb->DataType == GL_UNSIGNED_INT); + /* Initialize index span with clear index */ + INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + for (i = 0; i < width;i++) { + span.array->index[i] = ctx->Color.ClearIndex; + } + + /* Note that masking will change the color indexes, but only the + * bits for which the write mask is GL_FALSE. The bits + * which are write-enabled won't get modified. + */ for (i = 0; i < height;i++) { - struct sw_span span; - GLuint indexes[MAX_WIDTH]; - GLint j; - for (j = 0; j < width;j++) { - indexes[j] = ctx->Color.ClearIndex; - } - /* setup span struct for masking */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); span.x = x; span.y = y + i; - _swrast_mask_ci_span(ctx, rb, &span, indexes); + _swrast_mask_ci_span(ctx, rb, &span, span.array->index); /* write masked row */ - rb->PutRow(ctx, rb, width, x, y + i, indexes, NULL); + rb->PutRow(ctx, rb, width, x, y + i, span.array->index, NULL); } } |