From a62efdf82c20747feb11dfd7756f0579aa914b57 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 9 Sep 2010 19:37:15 -0700 Subject: mesa: Remove EXT_convolution. More optional code. --- src/mesa/swrast/s_copypix.c | 103 -------------------------------------------- src/mesa/swrast/s_drawpix.c | 57 ------------------------ src/mesa/swrast/s_readpix.c | 59 +------------------------ 3 files changed, 2 insertions(+), 217 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index a9b4cb8081..c35494e385 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -27,7 +27,6 @@ #include "main/context.h" #include "main/colormac.h" #include "main/condrender.h" -#include "main/convolve.h" #include "main/image.h" #include "main/macros.h" #include "main/imports.h" @@ -93,98 +92,6 @@ regions_overlap(GLint srcx, GLint srcy, } -/** - * RGBA copypixels with convolution. - */ -static void -copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, - GLint width, GLint height, GLint destx, GLint desty) -{ - GLint row; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - const GLbitfield transferOps = ctx->_ImageTransferState; - GLfloat *dest, *tmpImage, *convImage; - SWspan span; - - INIT_SPAN(span, GL_BITMAP); - _swrast_span_default_attribs(ctx, &span); - span.arrayMask = SPAN_RGBA; - span.arrayAttribs = FRAG_BIT_COL0; - - /* allocate space for GLfloat image */ - tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return; - } - convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tmpImage); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return; - } - - /* read source image as float/RGBA */ - dest = tmpImage; - for (row = 0; row < height; row++) { - _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, srcy + row, GL_FLOAT, dest); - dest += 4 * width; - } - - /* do the image transfer ops which preceed convolution */ - for (row = 0; row < height; row++) { - GLfloat (*rgba)[4] = (GLfloat (*)[4]) (tmpImage + row * width * 4); - _mesa_apply_rgba_transfer_ops(ctx, - transferOps & IMAGE_PRE_CONVOLUTION_BITS, - width, rgba); - } - - /* do convolution */ - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); - } - free(tmpImage); - - /* do remaining post-convolution image transfer ops */ - for (row = 0; row < height; row++) { - GLfloat (*rgba)[4] = (GLfloat (*)[4]) (convImage + row * width * 4); - _mesa_apply_rgba_transfer_ops(ctx, - transferOps & IMAGE_POST_CONVOLUTION_BITS, - width, rgba); - } - - /* write the new image */ - for (row = 0; row < height; row++) { - const GLfloat *src = convImage + row * width * 4; - GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0]; - - /* copy convolved colors into span array */ - memcpy(rgba, src, width * 4 * sizeof(GLfloat)); - - /* write span */ - span.x = destx; - span.y = desty + row; - span.end = width; - span.array->ChanType = GL_FLOAT; - if (zoom) { - _swrast_write_zoomed_rgba_span(ctx, destx, desty, &span, rgba); - } - else { - _swrast_write_rgba_span(ctx, &span); - } - } - /* restore this */ - span.array->ChanType = CHAN_TYPE; - - free(convImage); -} - - /** * RGBA copypixels */ @@ -204,16 +111,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, return; } - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { - copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty); - return; - } - else if (ctx->Pixel.Convolution1DEnabled) { - /* make sure we don't apply 1D convolution */ - transferOps &= ~(IMAGE_CONVOLUTION_BIT | - IMAGE_POST_CONVOLUTION_SCALE_BIAS); - } - if (ctx->DrawBuffer == ctx->ReadBuffer) { overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 9bc0e9043b..7778820c5c 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -27,7 +27,6 @@ #include "main/bufferobj.h" #include "main/condrender.h" #include "main/context.h" -#include "main/convolve.h" #include "main/image.h" #include "main/macros.h" #include "main/imports.h" @@ -484,62 +483,6 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, span.arrayMask = SPAN_RGBA; span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */ - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { - /* Convolution has to be handled specially. We'll create an - * intermediate image, applying all pixel transfer operations - * up to convolution. Then we'll convolve the image. Then - * we'll proceed with the rest of the transfer operations and - * rasterize the image. - */ - GLint row; - GLfloat *dest, *tmpImage; - - tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tmpImage); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - - /* Unpack the image and apply transfer ops up to convolution */ - dest = tmpImage; - for (row = 0; row < height; row++) { - const GLvoid *source = _mesa_image_address2d(unpack, - pixels, width, height, format, type, row, 0); - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest, - format, type, source, unpack, - transferOps & IMAGE_PRE_CONVOLUTION_BITS); - dest += width * 4; - } - - /* do convolution */ - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); - } - free(tmpImage); - - /* continue transfer ops and draw the convolved image */ - unpack = &ctx->DefaultPacking; - pixels = convImage; - format = GL_RGBA; - type = GL_FLOAT; - transferOps &= IMAGE_POST_CONVOLUTION_BITS; - } - else if (ctx->Pixel.Convolution1DEnabled) { - /* we only want to apply 1D convolution to glTexImage1D */ - transferOps &= ~(IMAGE_CONVOLUTION_BIT | - IMAGE_POST_CONVOLUTION_SCALE_BIAS); - } - if (ctx->DrawBuffer->_NumColorDrawBuffers > 0 && ctx->DrawBuffer->_ColorDrawBuffers[0]->DataType != GL_FLOAT && ctx->Color.ClampFragmentColor != GL_FALSE) { diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 1de481248b..b0a3d36420 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -26,7 +26,6 @@ #include "main/glheader.h" #include "main/bufferobj.h" #include "main/colormac.h" -#include "main/convolve.h" #include "main/feedback.h" #include "main/formats.h" #include "main/image.h" @@ -326,57 +325,7 @@ read_rgba_pixels( GLcontext *ctx, /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { - GLfloat *dest, *src, *tmpImage, *convImage; - GLint row; - - tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tmpImage); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - - /* read full RGBA, FLOAT image */ - dest = tmpImage; - for (row = 0; row < height; row++, y++) { - _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest); - _mesa_apply_rgba_transfer_ops(ctx, - transferOps & IMAGE_PRE_CONVOLUTION_BITS, - width, (GLfloat (*)[4]) dest); - dest += width * 4; - } - - /* do convolution */ - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); - } - free(tmpImage); - - /* finish transfer ops and pack the resulting image */ - src = convImage; - for (row = 0; row < height; row++) { - GLvoid *dest; - dest = _mesa_image_address2d(packing, pixels, width, height, - format, type, row, 0); - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) src, - format, type, dest, packing, - transferOps & IMAGE_POST_CONVOLUTION_BITS); - src += width * 4; - } - free(convImage); - } - else { - /* no convolution */ + do { const GLint dstStride = _mesa_image_row_stride(packing, width, format, type); GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0]; @@ -385,10 +334,6 @@ read_rgba_pixels( GLcontext *ctx, = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); - /* make sure we don't apply 1D convolution */ - transferOps &= ~(IMAGE_CONVOLUTION_BIT | - IMAGE_POST_CONVOLUTION_SCALE_BIAS); - for (row = 0; row < height; row++, y++) { /* Get float rgba pixels */ @@ -407,7 +352,7 @@ read_rgba_pixels( GLcontext *ctx, dst += dstStride; } - } + } while (0); } -- cgit v1.2.3