Merge branch 'origin' into i915-unification
[mesa.git] / src / mesa / swrast / s_copypix.c
index dbbfc58c6fdfa3a57ebdb2267d4524907914e880..2383015000aaf30b1b01797b2d3e9562fae71e30 100644 (file)
@@ -94,7 +94,6 @@ static void
 copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
                       GLint width, GLint height, GLint destx, GLint desty)
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLint row;
    const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
    const GLbitfield transferOps = ctx->_ImageTransferState;
@@ -104,13 +103,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
    SWspan span;
 
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
-
-   if (ctx->Depth.Test)
-      _swrast_span_default_z(ctx, &span);
-   if (swrast->_FogEnabled)
-      _swrast_span_default_fog(ctx, &span);
-   if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-      _swrast_span_default_secondary_color(ctx, &span);
+   _swrast_span_default_attribs(ctx, &span);
 
    /* allocate space for GLfloat image */
    tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
@@ -196,6 +189,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
                  GLint width, GLint height, GLint destx, GLint desty)
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
+   const GLbitfield prevActiveAttribs = swrast->_ActiveAttribMask;
    GLfloat *tmpImage, *p;
    GLint sy, dy, stepy, row;
    const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
@@ -205,12 +199,15 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
 
    if (!ctx->ReadBuffer->_ColorReadBuffer) {
       /* no readbuffer - OK */
-      return;
+      goto end;
    }
 
+   /* don't interpolate COL0 and overwrite the glDrawPixel colors! */
+   swrast->_ActiveAttribMask &= ~FRAG_BIT_COL0;
+
    if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
       copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
-      return;
+      goto end;
    }
    else if (ctx->Pixel.Convolution1DEnabled) {
       /* make sure we don't apply 1D convolution */
@@ -241,18 +238,13 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
    }
 
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
-   if (ctx->Depth.Test)
-      _swrast_span_default_z(ctx, &span);
-   if (swrast->_FogEnabled)
-      _swrast_span_default_fog(ctx, &span);
-   if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-      _swrast_span_default_secondary_color(ctx, &span);
+   _swrast_span_default_attribs(ctx, &span);
 
    if (overlapping) {
       tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4);
       if (!tmpImage) {
          _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
-         return;
+         goto end;
       }
       /* read the source image as RGBA/float */
       p = tmpImage;
@@ -307,6 +299,9 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
 
    if (overlapping)
       _mesa_free(tmpImage);
+
+end:
+   swrast->_ActiveAttribMask = prevActiveAttribs;
 }
 
 
@@ -315,7 +310,6 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
                 GLint width, GLint height,
                 GLint destx, GLint desty )
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLuint *tmpImage,*p;
    GLint sy, dy, stepy;
    GLint j;
@@ -329,6 +323,7 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
    }
 
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX);
+   _swrast_span_default_attribs(ctx, &span);
 
    if (ctx->DrawBuffer == ctx->ReadBuffer) {
       overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
@@ -352,11 +347,6 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
       stepy = 1;
    }
 
-   if (ctx->Depth.Test)
-      _swrast_span_default_z(ctx, &span);
-   if (swrast->_FogEnabled)
-      _swrast_span_default_fog(ctx, &span);
-
    if (overlapping) {
       GLint ssy = sy;
       tmpImage = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint));
@@ -452,7 +442,6 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
                    GLint width, GLint height,
                    GLint destx, GLint desty )
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    struct gl_framebuffer *fb = ctx->ReadBuffer;
    struct gl_renderbuffer *readRb = fb->_DepthBuffer;
    GLfloat *p, *tmpImage;
@@ -468,6 +457,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
    }
 
    INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
+   _swrast_span_default_attribs(ctx, &span);
 
    if (ctx->DrawBuffer == ctx->ReadBuffer) {
       overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
@@ -491,12 +481,6 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
       stepy = 1;
    }
 
-   _swrast_span_default_color(ctx, &span);
-   if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-      _swrast_span_default_secondary_color(ctx, &span);
-   if (swrast->_FogEnabled)
-      _swrast_span_default_fog(ctx, &span);
-
    if (overlapping) {
       GLint ssy = sy;
       tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat));