Consolidate texObj->Pos/Neg/X/Y/Z and texObj->Image into a single
[mesa.git] / src / mesa / swrast / s_imaging.c
index 1c63f5c3416d979f39e1f9cf9dafb84bd84462af..b9c413687b17197039d5e972372f147602f2adc3 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id: s_imaging.c,v 1.5 2002/04/04 16:53:00 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -37,22 +36,19 @@ _swrast_CopyColorTable( GLcontext *ctx,
                        GLenum target, GLenum internalformat,
                        GLint x, GLint y, GLsizei width)
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLchan data[MAX_WIDTH][4];
 
    /* Select buffer to read from */
-   (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
-                                 ctx->Pixel.DriverReadBuffer );
+   _swrast_use_read_buffer(ctx);
 
    if (width > MAX_WIDTH)
       width = MAX_WIDTH;
 
    /* read the data from framebuffer */
-   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
+   _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
 
    /* Restore reading from draw buffer (the default) */
-   (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
-                                 ctx->Color.DriverDrawBuffer );
+   _swrast_use_draw_buffer(ctx);
 
    glColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
 }
@@ -61,22 +57,19 @@ 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];
 
    /* Select buffer to read from */
-   (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
-                                 ctx->Pixel.DriverReadBuffer );
+   _swrast_use_read_buffer(ctx);
 
    if (width > MAX_WIDTH)
       width = MAX_WIDTH;
 
    /* read the data from framebuffer */
-   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
+   _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
 
    /* Restore reading from draw buffer (the default) */
-   (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
-                                 ctx->Color.DriverDrawBuffer );
+   _swrast_use_draw_buffer(ctx);
 
    glColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
 }
@@ -90,14 +83,20 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
 
+   /* Select buffer to read from */
+   _swrast_use_read_buffer(ctx);
+
    RENDER_START( swrast, ctx );
 
    /* read the data from framebuffer */
-   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y,
+   _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y,
                                (GLchan (*)[4]) rgba );
    
    RENDER_FINISH( swrast, ctx );
 
+   /* Restore reading from draw buffer (the default) */
+   _swrast_use_draw_buffer(ctx);
+
    /* store as convolution filter */
    glConvolutionFilter1D(target, internalFormat, width,
                         GL_RGBA, CHAN_TYPE, rgba);
@@ -114,16 +113,22 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
    GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
    GLint i;
 
+   /* Select buffer to read from */
+   _swrast_use_read_buffer(ctx);
+
    RENDER_START(swrast,ctx);
    
    /* read pixels from framebuffer */
    for (i = 0; i < height; i++) {
-      _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
+      _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
                                (GLchan (*)[4]) 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