summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_copypix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast/s_copypix.c')
-rw-r--r--src/mesa/swrast/s_copypix.c161
1 files changed, 27 insertions, 134 deletions
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index e881d1be30..f4f0c8a330 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -114,14 +114,14 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
span.arrayAttribs = FRAG_BIT_COL0;
/* allocate space for GLfloat image */
- tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
if (!tmpImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
return;
}
- convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
if (!convImage) {
- _mesa_free(tmpImage);
+ free(tmpImage);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
return;
}
@@ -150,7 +150,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
ASSERT(ctx->Pixel.Separable2DEnabled);
_mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
}
- _mesa_free(tmpImage);
+ free(tmpImage);
/* do remaining post-convolution image transfer ops */
for (row = 0; row < height; row++) {
@@ -167,7 +167,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0];
/* copy convolved colors into span array */
- _mesa_memcpy(rgba, src, width * 4 * sizeof(GLfloat));
+ memcpy(rgba, src, width * 4 * sizeof(GLfloat));
/* write span */
span.x = destx;
@@ -185,7 +185,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
span.array->ChanType = CHAN_TYPE;
}
- _mesa_free(convImage);
+ free(convImage);
}
@@ -246,7 +246,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
span.arrayAttribs = FRAG_BIT_COL0; /* we'll fill in COL0 attrib values */
if (overlapping) {
- tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4);
+ tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat) * 4);
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
return;
@@ -273,7 +273,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* Get row/span of source pixels */
if (overlapping) {
/* get from buffered image */
- _mesa_memcpy(rgba, p, width * sizeof(GLfloat) * 4);
+ memcpy(rgba, p, width * sizeof(GLfloat) * 4);
p += width * 4;
}
else {
@@ -303,101 +303,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
span.array->ChanType = CHAN_TYPE; /* restore */
if (overlapping)
- _mesa_free(tmpImage);
-}
-
-
-static void
-copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
- GLint width, GLint height,
- GLint destx, GLint desty )
-{
- GLuint *tmpImage,*p;
- GLint sy, dy, stepy;
- GLint j;
- const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
- GLint overlapping;
- SWspan span;
-
- if (!ctx->ReadBuffer->_ColorReadBuffer) {
- /* no readbuffer - OK */
- return;
- }
-
- INIT_SPAN(span, GL_BITMAP);
- _swrast_span_default_attribs(ctx, &span);
- span.arrayMask = SPAN_INDEX;
-
- if (ctx->DrawBuffer == ctx->ReadBuffer) {
- overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
- ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
- }
- else {
- overlapping = GL_FALSE;
- }
-
- /* Determine if copy should be bottom-to-top or top-to-bottom */
- if (!overlapping && srcy < desty) {
- /* top-down max-to-min */
- sy = srcy + height - 1;
- dy = desty + height - 1;
- stepy = -1;
- }
- else {
- /* bottom-up min-to-max */
- sy = srcy;
- dy = desty;
- stepy = 1;
- }
-
- if (overlapping) {
- GLint ssy = sy;
- tmpImage = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint));
- if (!tmpImage) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
- return;
- }
- /* read the image */
- p = tmpImage;
- for (j = 0; j < height; j++, ssy += stepy) {
- _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, ssy, p );
- p += width;
- }
- p = tmpImage;
- }
- else {
- tmpImage = NULL; /* silence compiler warning */
- p = NULL;
- }
-
- for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
- /* Get color indexes */
- if (overlapping) {
- _mesa_memcpy(span.array->index, p, width * sizeof(GLuint));
- p += width;
- }
- else {
- _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, sy, span.array->index );
- }
-
- if (ctx->_ImageTransferState)
- _mesa_apply_ci_transfer_ops(ctx, ctx->_ImageTransferState,
- width, span.array->index);
-
- /* write color indexes */
- span.x = destx;
- span.y = dy;
- span.end = width;
- if (zoom)
- _swrast_write_zoomed_index_span(ctx, destx, desty, &span);
- else
- _swrast_write_index_span(ctx, &span);
- }
-
- if (overlapping)
- _mesa_free(tmpImage);
+ free(tmpImage);
}
@@ -487,7 +393,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
if (overlapping) {
GLint ssy = sy;
- tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat));
+ tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat));
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
return;
@@ -508,7 +414,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLfloat depth[MAX_WIDTH];
/* get depth values */
if (overlapping) {
- _mesa_memcpy(depth, p, width * sizeof(GLfloat));
+ memcpy(depth, p, width * sizeof(GLfloat));
p += width;
}
else {
@@ -522,22 +428,14 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
span.x = destx;
span.y = dy;
span.end = width;
- if (fb->Visual.rgbMode) {
- if (zoom)
- _swrast_write_zoomed_depth_span(ctx, destx, desty, &span);
- else
- _swrast_write_rgba_span(ctx, &span);
- }
- else {
- if (zoom)
- _swrast_write_zoomed_depth_span(ctx, destx, desty, &span);
- else
- _swrast_write_index_span(ctx, &span);
- }
+ if (zoom)
+ _swrast_write_zoomed_depth_span(ctx, destx, desty, &span);
+ else
+ _swrast_write_rgba_span(ctx, &span);
}
if (overlapping)
- _mesa_free(tmpImage);
+ free(tmpImage);
}
@@ -584,7 +482,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
if (overlapping) {
GLint ssy = sy;
- tmpImage = (GLstencil *) _mesa_malloc(width * height * sizeof(GLstencil));
+ tmpImage = (GLstencil *) malloc(width * height * sizeof(GLstencil));
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
return;
@@ -606,7 +504,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
/* Get stencil values */
if (overlapping) {
- _mesa_memcpy(stencil, p, width * sizeof(GLstencil));
+ memcpy(stencil, p, width * sizeof(GLstencil));
p += width;
}
else {
@@ -626,7 +524,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
}
if (overlapping)
- _mesa_free(tmpImage);
+ free(tmpImage);
}
@@ -688,7 +586,7 @@ copy_depth_stencil_pixels(GLcontext *ctx,
if (stencilMask != 0x0) {
tempStencilImage
- = (GLstencil *) _mesa_malloc(width * height * sizeof(GLstencil));
+ = (GLstencil *) malloc(width * height * sizeof(GLstencil));
if (!tempStencilImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
return;
@@ -706,10 +604,10 @@ copy_depth_stencil_pixels(GLcontext *ctx,
if (ctx->Depth.Mask) {
tempDepthImage
- = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat));
+ = (GLfloat *) malloc(width * height * sizeof(GLfloat));
if (!tempDepthImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
- _mesa_free(tempStencilImage);
+ free(tempStencilImage);
return;
}
@@ -730,7 +628,7 @@ copy_depth_stencil_pixels(GLcontext *ctx,
/* Get stencil values */
if (overlapping) {
- _mesa_memcpy(stencil, stencilPtr, width * sizeof(GLstencil));
+ memcpy(stencil, stencilPtr, width * sizeof(GLstencil));
stencilPtr += width;
}
else {
@@ -759,7 +657,7 @@ copy_depth_stencil_pixels(GLcontext *ctx,
/* get depth values */
if (overlapping) {
- _mesa_memcpy(depth, depthPtr, width * sizeof(GLfloat));
+ memcpy(depth, depthPtr, width * sizeof(GLfloat));
depthPtr += width;
}
else {
@@ -799,10 +697,10 @@ copy_depth_stencil_pixels(GLcontext *ctx,
}
if (tempStencilImage)
- _mesa_free(tempStencilImage);
+ free(tempStencilImage);
if (tempDepthImage)
- _mesa_free(tempDepthImage);
+ free(tempDepthImage);
}
@@ -909,12 +807,7 @@ _swrast_CopyPixels( GLcontext *ctx,
if (!fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty, type)) {
switch (type) {
case GL_COLOR:
- if (ctx->Visual.rgbMode) {
- copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
- }
- else {
- copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty );
- }
+ copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
break;
case GL_DEPTH:
copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty );