r300: Further reduced the radeon_span.c diff.
[mesa.git] / src / mesa / swrast / s_drawpix.c
index 46dd79702396e9b758a13ac00d92e20c634ad991..cd5b7bc2935be6fe2f8f031a73aa3a230382ef30 100644 (file)
@@ -71,6 +71,7 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
    }
 
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
+   _swrast_span_default_secondary_color(ctx, &span);
    if (ctx->Depth.Test)
       _swrast_span_default_z(ctx, &span);
    if (swrast->_FogEnabled)
@@ -110,8 +111,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
     */
 
    if (format == GL_RGBA && type == rbType) {
-      const GLubyte *src = _mesa_image_address2d(&unpack, pixels, width,
-                                                 height, format, type, 0, 0);
+      const GLubyte *src
+         = (const GLubyte *) _mesa_image_address2d(&unpack, pixels, width,
+                                                   height, format, type, 0, 0);
       const GLint srcStride = _mesa_image_row_stride(&unpack, width,
                                                      format, type);
       if (simpleZoom) {
@@ -139,8 +141,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
    }
 
    if (format == GL_RGB && type == rbType) {
-      const GLubyte *src = _mesa_image_address2d(&unpack, pixels, width,
-                                                 height, format, type, 0, 0);
+      const GLubyte *src
+         = (const GLubyte *) _mesa_image_address2d(&unpack, pixels, width,
+                                                   height, format, type, 0, 0);
       const GLint srcStride = _mesa_image_row_stride(&unpack, width,
                                                      format, type);
       if (simpleZoom) {
@@ -261,33 +264,35 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
       return GL_TRUE;
    }
 
-   if (format==GL_COLOR_INDEX && type==GL_UNSIGNED_BYTE) {
+   if (format == GL_COLOR_INDEX && type == GL_UNSIGNED_BYTE) {
       const GLubyte *src = (const GLubyte *) pixels
          + unpack.SkipRows * unpack.RowLength + unpack.SkipPixels;
-      if (ctx->Visual.rgbMode && rbType == CHAN_TYPE) {
-         /* convert CI data to RGBA */
+      if (ctx->Visual.rgbMode && rbType == GL_UNSIGNED_BYTE) {
+         /* convert ubyte/CI data to ubyte/RGBA */
          if (simpleZoom) {
             GLint row;
             for (row = 0; row < drawHeight; row++) {
                ASSERT(drawWidth <= MAX_WIDTH);
-               _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
+               _mesa_map_ci8_to_rgba8(ctx, drawWidth, src,
+                                      span.array->color.sz1.rgba);
                rb->PutRow(ctx, rb, drawWidth, destX, destY,
-                          span.array->rgba, NULL);
+                          span.array->color.sz1.rgba, NULL);
                src += unpack.RowLength;
                destY += yStep;
             }
          }
          else {
-            /* with zooming */
+            /* ubyte/CI to ubyte/RGBA with zooming */
             GLint row;
             for (row = 0; row < drawHeight; row++) {
                ASSERT(drawWidth <= MAX_WIDTH);
-               _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
+               _mesa_map_ci8_to_rgba8(ctx, drawWidth, src,
+                                      span.array->color.sz1.rgba);
                span.x = destX;
                span.y = destY;
                span.end = drawWidth;
                _swrast_write_zoomed_rgba_span(ctx, imgX, imgY, &span,
-                                              span.array->rgba);
+                                              span.array->color.sz1.rgba);
                src += unpack.RowLength;
                destY++;
             }
@@ -404,13 +409,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
          _mesa_unpack_index_span(ctx, spanWidth, destType, values,
                                  type, source, unpack,
                                  ctx->_ImageTransferState);
-         if (ctx->_ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) {
-            _mesa_shift_and_offset_stencil(ctx, spanWidth, values);
-         }
-         if (ctx->Pixel.MapStencilFlag) {
-            _mesa_map_stencil(ctx, spanWidth, values);
-         }
-
+         _mesa_apply_stencil_transfer_ops(ctx, spanWidth, values);
          if (zoom) {
             _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth,
                                               spanX, spanY, values);
@@ -443,7 +442,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
 
    _swrast_span_default_color(ctx, &span);
-
+   _swrast_span_default_secondary_color(ctx, &span);
    if (swrast->_FogEnabled)
       _swrast_span_default_fog(ctx, &span);
    if (ctx->Texture._EnabledCoordUnits)
@@ -454,7 +453,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
        && !scaleOrBias
        && !zoom
        && ctx->Visual.rgbMode
-       && width <= MAX_WIDTH) {
+       && width <= MAX_WIDTH
+       && !unpack->SwapBytes) {
       /* Special case: directly write 16-bit depth values */
       GLint row;
       for (row = 0; row < height; row++) {
@@ -474,7 +474,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
             && !scaleOrBias
             && !zoom
             && ctx->Visual.rgbMode
-            && width <= MAX_WIDTH) {
+            && width <= MAX_WIDTH
+            && !unpack->SwapBytes) {
       /* Special case: shift 32-bit values down to Visual.depthBits */
       const GLint shift = 32 - ctx->DrawBuffer->Visual.depthBits;
       GLint row;
@@ -553,7 +554,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
    const GLint imgX = x, imgY = y;
    const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
    GLfloat *convImage = NULL;
-   GLuint transferOps = ctx->_ImageTransferState;
+   GLbitfield transferOps = ctx->_ImageTransferState;
    SWspan span;
 
    /* Try an optimized glDrawPixels first */
@@ -562,6 +563,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
       return;
 
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
+   _swrast_span_default_secondary_color(ctx, &span);
    if (ctx->Depth.Test)
       _swrast_span_default_z(ctx, &span);
    if (swrast->_FogEnabled)
@@ -619,6 +621,11 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
       type = GL_FLOAT;
       transferOps &= IMAGE_POST_CONVOLUTION_BITS;
    }
+   else if (ctx->Pixel.Convolution1DEnabled) {
+      /* we only want to apply 1D convolution to glTexImage1D */
+      transferOps &= ~(IMAGE_CONVOLUTION_BIT |
+                       IMAGE_POST_CONVOLUTION_SCALE_BIAS);
+   }
 
    if (ctx->DrawBuffer->_NumColorDrawBuffers[0] > 0 &&
        ctx->DrawBuffer->_ColorDrawBuffers[0][0]->DataType != GL_FLOAT &&
@@ -639,13 +646,15 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
          = _mesa_image_row_stride(unpack, width, format, type);
       GLint skipPixels = 0;
       /* use span array for temp color storage */
-      GLfloat *rgba = (GLfloat *) span.array->color.sz4.rgba;
+      GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0];
 
       /* if the span is wider than MAX_WIDTH we have to do it in chunks */
       while (skipPixels < width) {
          const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH);
-         const GLubyte *source = _mesa_image_address2d(unpack, pixels,
-                               width, height, format, type, 0, skipPixels);
+         const GLubyte *source
+            = (const GLubyte *) _mesa_image_address2d(unpack, pixels,
+                                                      width, height, format,
+                                                      type, 0, skipPixels);
          GLint row;
 
          for (row = 0; row < height; row++) {