gallium: Fix memory leak.
[mesa.git] / src / mesa / swrast / s_imaging.c
index 5c79a7ba95e0b37969c8b7273e3c25e71dc374f4..73aaba1ec9fe4919f3f11814af3ead827c9bc975 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -38,6 +38,7 @@ _swrast_CopyColorTable( GLcontext *ctx,
                        GLenum target, GLenum internalformat,
                        GLint x, GLint y, GLsizei width)
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLchan data[MAX_WIDTH][4];
    struct gl_buffer_object *bufferSave;
 
@@ -46,18 +47,16 @@ _swrast_CopyColorTable( GLcontext *ctx,
       return;
    }
 
-   /* Select buffer to read from */
-   _swrast_use_read_buffer(ctx);
-
    if (width > MAX_WIDTH)
       width = MAX_WIDTH;
 
+   RENDER_START( swrast, ctx );
+
    /* read the data from framebuffer */
    _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
-                           width, x, y, data );
+                           width, x, y, CHAN_TYPE, data );
 
-   /* Restore reading from draw buffer (the default) */
-   _swrast_use_draw_buffer(ctx);
+   RENDER_FINISH(swrast,ctx);
 
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
@@ -74,6 +73,7 @@ void
 _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
                           GLint x, GLint y, GLsizei width)
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLchan data[MAX_WIDTH][4];
    struct gl_buffer_object *bufferSave;
 
@@ -82,18 +82,16 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
       return;
    }
 
-   /* Select buffer to read from */
-   _swrast_use_read_buffer(ctx);
-
    if (width > MAX_WIDTH)
       width = MAX_WIDTH;
 
+   RENDER_START( swrast, ctx );
+
    /* read the data from framebuffer */
    _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
-                           width, x, y, data );
+                           width, x, y, CHAN_TYPE, data );
 
-   /* Restore reading from draw buffer (the default) */
-   _swrast_use_draw_buffer(ctx);
+   RENDER_FINISH(swrast,ctx);
 
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
@@ -120,20 +118,14 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
       return;
    }
 
-   /* Select buffer to read from */
-   _swrast_use_read_buffer(ctx);
-
    RENDER_START( swrast, ctx );
 
    /* read the data from framebuffer */
    _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
-                           width, x, y, (GLchan (*)[4]) rgba );
+                           width, x, y, CHAN_TYPE, rgba );
    
    RENDER_FINISH( swrast, ctx );
 
-   /* Restore reading from draw buffer (the default) */
-   _swrast_use_draw_buffer(ctx);
-
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
    ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
@@ -163,22 +155,16 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
       return;
    }
 
-   /* Select buffer to read from */
-   _swrast_use_read_buffer(ctx);
-
    RENDER_START(swrast,ctx);
    
    /* read pixels from framebuffer */
    for (i = 0; i < height; i++) {
       _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
-                              width, x, y + i, (GLchan (*)[4]) rgba[i] );
+                              width, x, y + i, CHAN_TYPE, rgba[i] );
    }
 
    RENDER_FINISH(swrast,ctx);
 
-   /* Restore reading from draw buffer (the default) */
-   _swrast_use_draw_buffer(ctx);
-
    /*
     * HACK: save & restore context state so we can store this as a
     * convolution filter via the GL api.  Doesn't call any callbacks