summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-10-13 17:41:23 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-10-13 17:41:23 +0000
commit5b0edff412f45fe64bd42fb481adeda7d34b0fa8 (patch)
tree141c7825eb0f289f69a4fc5fb206e6c7415d51c7 /src/mesa/swrast
parent461651357713b1408400669d6a809f2e367182fe (diff)
Consolidate, move, fix code related to color index and stencil image transfer
operations (shift, offset, table lookup, etc).
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_copypix.c30
-rw-r--r--src/mesa/swrast/s_drawpix.c8
-rw-r--r--src/mesa/swrast/s_readpix.c14
3 files changed, 13 insertions, 39 deletions
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index accf59f307..1a17b75c70 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -312,7 +312,6 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint sy, dy, stepy;
GLint j;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
- const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
GLint overlapping;
SWspan span;
@@ -382,13 +381,9 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
width, srcx, sy, span.array->index );
}
- /* Apply shift, offset, look-up table */
- if (shift_or_offset) {
- _mesa_shift_and_offset_ci( ctx, width, span.array->index );
- }
- if (ctx->Pixel.MapColorFlag) {
- _mesa_map_ci( ctx, width, span.array->index );
- }
+ if (ctx->_ImageTransferState)
+ _mesa_apply_ci_transfer_ops(ctx, ctx->_ImageTransferState,
+ width, span.array->index);
/* write color indexes */
span.x = destx;
@@ -561,7 +556,6 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint j;
GLstencil *p, *tmpImage;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
- const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
GLint overlapping;
if (!rb) {
@@ -622,13 +616,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
_swrast_read_stencil_span( ctx, rb, width, srcx, sy, stencil );
}
- /* Apply shift, offset, look-up table */
- if (shift_or_offset) {
- _mesa_shift_and_offset_stencil( ctx, width, stencil );
- }
- if (ctx->Pixel.MapStencilFlag) {
- _mesa_map_stencil( ctx, width, stencil );
- }
+ _mesa_apply_stencil_transfer_ops(ctx, width, stencil);
/* Write stencil values */
if (zoom) {
@@ -664,8 +652,6 @@ copy_depth_stencil_pixels(GLcontext *ctx,
const GLfloat depthScale = ctx->DrawBuffer->_DepthMaxF;
const GLuint stencilMask = ctx->Stencil.WriteMask[0];
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
- const GLboolean shiftOrOffset
- = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
const GLboolean scaleOrBias
= ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
GLint overlapping;
@@ -755,13 +741,7 @@ copy_depth_stencil_pixels(GLcontext *ctx,
width, srcX, sy, stencil);
}
- /* Apply shift, offset, look-up table */
- if (shiftOrOffset) {
- _mesa_shift_and_offset_stencil(ctx, width, stencil);
- }
- if (ctx->Pixel.MapStencilFlag) {
- _mesa_map_stencil(ctx, width, stencil);
- }
+ _mesa_apply_stencil_transfer_ops(ctx, width, stencil);
/* Write values */
if (zoom) {
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 4270d23f06..bdb2558351 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -406,13 +406,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
_mesa_unpack_index_span(ctx, spanWidth, destType, values,
type, source, unpack,
ctx->_ImageTransferState);
- if (ctx->_ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) {
- _mesa_shift_and_offset_stencil(ctx, spanWidth, values);
- }
- if (ctx->Pixel.MapStencilFlag) {
- _mesa_map_stencil(ctx, spanWidth, values);
- }
-
+ _mesa_apply_stencil_transfer_ops(ctx, spanWidth, values);
if (zoom) {
_swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth,
spanX, spanY, values);
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index fb39427b62..0189b0e797 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -309,6 +309,7 @@ read_rgba_pixels( GLcontext *ctx,
const struct gl_pixelstore_attrib *packing )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLbitfield transferOps = ctx->_ImageTransferState;
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
@@ -324,7 +325,6 @@ read_rgba_pixels( GLcontext *ctx,
ASSERT(width <= MAX_WIDTH);
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
- const GLbitfield transferOps = ctx->_ImageTransferState;
GLfloat *dest, *src, *tmpImage, *convImage;
GLint row;
@@ -350,9 +350,9 @@ read_rgba_pixels( GLcontext *ctx,
GLuint index[MAX_WIDTH];
ASSERT(rb->DataType == GL_UNSIGNED_INT);
rb->GetRow(ctx, rb, width, x, y, index);
- if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset !=0 ) {
- _mesa_map_ci(ctx, width, index);
- }
+ _mesa_apply_ci_transfer_ops(ctx,
+ transferOps & IMAGE_SHIFT_OFFSET_BIT,
+ width, index);
_mesa_map_ci_to_rgba(ctx, width, index, (GLfloat (*)[4]) dest);
}
_mesa_apply_rgba_transfer_ops(ctx,
@@ -404,9 +404,9 @@ read_rgba_pixels( GLcontext *ctx,
GLuint index[MAX_WIDTH];
ASSERT(rb->DataType == GL_UNSIGNED_INT);
rb->GetRow(ctx, rb, width, x, y, index);
- if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) {
- _mesa_map_ci(ctx, width, index);
- }
+ _mesa_apply_ci_transfer_ops(ctx,
+ transferOps & IMAGE_SHIFT_OFFSET_BIT,
+ width, index);
_mesa_map_ci_to_rgba(ctx, width, index, rgba);
}