added missing \'s
[mesa.git] / src / mesa / swrast / s_readpix.c
index 4ca5af4c8f29f790fba8f1888fc3a636ab97a815..5fc03da27d72759457c939af3aeba9d7d6d84d6f 100644 (file)
@@ -1,21 +1,21 @@
-/* $Id: s_readpix.c,v 1.8 2001/03/03 20:33:30 brianp Exp $ */
+/* $Id: s_readpix.c,v 1.12 2001/05/16 20:27:12 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
  * Version:  3.5
- * 
+ *
  * Copyright (C) 1999-2001  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"),
  * to deal in the Software without restriction, including without limitation
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -53,6 +53,7 @@ read_index_pixels( GLcontext *ctx,
                    GLenum type, GLvoid *pixels,
                    const struct gl_pixelstore_attrib *packing )
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLint i, readWidth;
 
    /* error checking */
@@ -61,8 +62,8 @@ read_index_pixels( GLcontext *ctx,
       return;
    }
 
-   ASSERT(ctx->Driver.SetReadBuffer);
-   (*ctx->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer,
+   ASSERT(swrast->Driver.SetReadBuffer);
+   (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer,
                                 ctx->Pixel.DriverReadBuffer);
 
    readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
@@ -72,7 +73,7 @@ read_index_pixels( GLcontext *ctx,
       GLuint index[MAX_WIDTH];
       GLvoid *dest;
 
-      (*ctx->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
+      (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
 
       dest = _mesa_image_address(packing, pixels, width, height,
                                  GL_COLOR_INDEX, type, 0, i, 0);
@@ -81,7 +82,7 @@ read_index_pixels( GLcontext *ctx,
                             &ctx->Pack, ctx->_ImageTransferState);
    }
 
-   (*ctx->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer,
+   (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer,
                                 ctx->Color.DriverDrawBuffer);
 }
 
@@ -155,7 +156,8 @@ read_depth_pixels( GLcontext *ctx,
          dest = _mesa_image_address(packing, pixels, width, height,
                                     GL_DEPTH_COMPONENT, type, 0, j, 0);
 
-         _mesa_pack_depth_span(ctx, readWidth, dest, type, depth, &ctx->Pack);
+         _mesa_pack_depth_span(ctx, readWidth, (GLdepth *) dest, type,
+                               depth, &ctx->Pack);
       }
    }
 }
@@ -220,6 +222,7 @@ read_fast_rgba_pixels( GLcontext *ctx,
                        GLvoid *pixels,
                        const struct gl_pixelstore_attrib *packing )
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    /* can't do scale, bias, mapping, etc */
    if (ctx->_ImageTransferState)
        return GL_FALSE;
@@ -282,7 +285,7 @@ read_fast_rgba_pixels( GLcontext *ctx,
                          + (skipRows * rowLength + skipPixels) * 4;
          GLint row;
          for (row=0; row<readHeight; row++) {
-            (*ctx->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY,
+            (*swrast->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY,
                                         (GLchan (*)[4]) dest);
             if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
                _mesa_read_alpha_span(ctx, readWidth, srcX, srcY,
@@ -312,15 +315,16 @@ read_rgba_pixels( GLcontext *ctx,
                   GLenum format, GLenum type, GLvoid *pixels,
                   const struct gl_pixelstore_attrib *packing )
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLint readWidth;
 
-   (*ctx->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer);
+   (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer);
 
    /* Try optimized path first */
    if (read_fast_rgba_pixels( ctx, x, y, width, height,
                               format, type, pixels, packing )) {
 
-      (*ctx->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
+      (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
       return; /* done! */
    }
 
@@ -386,7 +390,7 @@ read_rgba_pixels( GLcontext *ctx,
          }
          else {
             GLuint index[MAX_WIDTH];
-            (*ctx->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
+            (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
             if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset !=0 ) {
                _mesa_map_ci(ctx, readWidth, index);
             }
@@ -432,7 +436,7 @@ read_rgba_pixels( GLcontext *ctx,
          }
          else {
             GLuint index[MAX_WIDTH];
-            (*ctx->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
+            (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
             if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) {
                _mesa_map_ci(ctx, readWidth, index);
             }
@@ -447,13 +451,15 @@ read_rgba_pixels( GLcontext *ctx,
              * there.  This fixes conformance failures with 16-bit color
              * buffers, for example.
              */
-            GLfloat rgbaf[MAX_WIDTH][4];
+            DEFMARRAY(GLfloat, rgbaf, MAX_WIDTH, 4);  /* mac 32k limitation */
+            CHECKARRAY(rgbaf, return);  /* mac 32k limitation */
             _mesa_chan_to_float_span(ctx, readWidth,
                                      (CONST GLchan (*)[4]) rgba, rgbaf);
             _mesa_pack_float_rgba_span(ctx, readWidth,
                                        (CONST GLfloat (*)[4]) rgbaf,
                                        format, type, dst, packing,
                                        ctx->_ImageTransferState);
+            UNDEFARRAY(rgbaf);  /* mac 32k limitation */
          }
          else {
             /* GLubytes are fine */
@@ -464,7 +470,7 @@ read_rgba_pixels( GLcontext *ctx,
       }
    }
 
-   (*ctx->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
+   (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
 }
 
 
@@ -472,15 +478,18 @@ read_rgba_pixels( GLcontext *ctx,
 void
 _swrast_ReadPixels( GLcontext *ctx,
                    GLint x, GLint y, GLsizei width, GLsizei height,
-                   GLenum format, GLenum type, 
+                   GLenum format, GLenum type,
                    const struct gl_pixelstore_attrib *pack,
                    GLvoid *pixels )
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    (void) pack;
 
-   if (SWRAST_CONTEXT(ctx)->NewState)
+   if (swrast->NewState)
       _swrast_validate_derived( ctx );
 
+   RENDER_START(swrast,ctx);
+
    switch (format) {
       case GL_COLOR_INDEX:
          read_index_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack);
@@ -508,4 +517,6 @@ _swrast_ReadPixels( GLcontext *ctx,
       default:
         _mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(format)" );
    }
+
+   RENDER_FINISH(swrast,ctx);
 }