another fix for glDrawPixels + clipping
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 16 Jan 2003 18:57:44 +0000 (18:57 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 16 Jan 2003 18:57:44 +0000 (18:57 +0000)
src/mesa/swrast/s_drawpix.c

index 9a75aa48b95c3e9ef65ec0385a6807b5761912ec..a69f3cc3c95bd9e155fb11c626a5db91d0dc61ad 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.43 2003/01/15 23:46:34 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.44 2003/01/16 18:57:44 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -522,11 +522,11 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
     */
    skipPixels = 0;
    while (skipPixels < width) {
-      span.x = x + (zoom ? 0 : skipPixels);
-      span.y = y;
-      span.end = (width - skipPixels > MAX_WIDTH)
-               ? MAX_WIDTH : (width - skipPixels);
-      ASSERT(span.end <= MAX_WIDTH);
+      const GLint spanX = x + (zoom ? 0 : skipPixels);
+      GLint spanY = y;
+      const GLint spanEnd = (width - skipPixels > MAX_WIDTH)
+                          ? MAX_WIDTH : (width - skipPixels);
+      ASSERT(spanEnd <= MAX_WIDTH);
       for (row = 0; row < height; row++, span.y++) {
          const GLvoid *source = _mesa_image_address(&ctx->Unpack, pixels,
                                                     width, height,
@@ -535,12 +535,18 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
          _mesa_unpack_index_span(ctx, span.end, GL_UNSIGNED_INT,
                                  span.array->index, type, source, &ctx->Unpack,
                                  ctx->_ImageTransferState);
+
+         /* These may get changed during writing/clipping */
+         span.x = spanX;
+         span.y = spanY;
+         span.end = spanEnd;
+         
          if (zoom)
             _mesa_write_zoomed_index_span(ctx, &span, y, skipPixels);
          else
             _mesa_write_index_span(ctx, &span);
       }
-      skipPixels += span.end;
+      skipPixels += spanEnd;
    }
 }
 
@@ -733,7 +739,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
                   _mesa_write_index_span(ctx, &span);
             }
          }
-         skipPixels += span.end;
+         skipPixels += spanEnd;
       }
    }
 }
@@ -840,6 +846,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
     * General solution
     */
    {
+      const GLuint interpMask = span.interpMask;
+      const GLuint arrayMask = span.arrayMask;
       GLint row, skipPixels = 0;
 
       /* if the span is wider than MAX_WIDTH we have to do it in chunks */
@@ -860,6 +868,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
             span.x = spanX;
             span.y = spanY;
             span.end = spanEnd;
+            span.arrayMask = arrayMask;
+            span.interpMask = interpMask;
 
             _mesa_unpack_chan_color_span(ctx, span.end, GL_RGBA,
                                          (GLchan *) span.array->rgba,
@@ -874,6 +884,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
                _swrast_pixel_texture(ctx, &span);
             }
 
+            /* draw the span */
             if (quickDraw) {
                (*swrast->Driver.WriteRGBASpan)(ctx, span.end, span.x, span.y,
                                  (CONST GLchan (*)[4]) span.array->rgba, NULL);
@@ -886,7 +897,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
                _mesa_write_rgba_span(ctx, &span);
             }
          }
-         skipPixels += span.end;
+
+         skipPixels += spanEnd;
       }
    }