-/* $Id: s_copypix.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
+/* $Id: s_copypix.c,v 1.9 2001/01/05 21:28:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "mmath.h"
#include "pixel.h"
+#include "s_context.h"
#include "s_depth.h"
-#include "s_imaging.h"
+#include "s_histogram.h"
#include "s_pixeltex.h"
#include "s_span.h"
#include "s_stencil.h"
GLboolean changeBuffer;
GLchan *saveReadAlpha;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
- const GLuint transferOps = ctx->ImageTransferState;
+ const GLuint transferOps = ctx->_ImageTransferState;
GLfloat *dest, *tmpImage, *convImage;
if (ctx->Depth.Test || ctx->Fog.Enabled) {
}
}
- if (ctx->RasterMask == 0
+ if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
&& !zoom
&& destx >= 0
&& destx + width <= ctx->DrawBuffer->Width) {
/* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) {
- _mesa_scale_and_bias_rgba(ctx, width, rgba);
+ _mesa_scale_and_bias_rgba(ctx, width, rgba,
+ ctx->Pixel.RedScale, ctx->Pixel.GreenScale,
+ ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale,
+ ctx->Pixel.RedBias, ctx->Pixel.GreenBias,
+ ctx->Pixel.BlueBias, ctx->Pixel.AlphaBias);
}
/* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) {
rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
- if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
+ if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
- for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
_mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q);
- gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
- primary_rgba, rgba);
+ _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL,
+ primary_rgba, rgba);
}
}
GLchan *saveReadAlpha;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
- const GLuint transferOps = ctx->ImageTransferState;
+ const GLuint transferOps = ctx->_ImageTransferState;
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
}
}
- if (ctx->RasterMask == 0
+ if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
&& !zoom
&& destx >= 0
&& destx + width <= ctx->DrawBuffer->Width) {
/* If read and draw buffer are different we must do buffer switching */
saveReadAlpha = ctx->ReadBuffer->Alpha;
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
- || ctx->DrawBuffer != ctx->ReadBuffer;
+ || ctx->DrawBuffer != ctx->ReadBuffer;
+
+ (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ ctx->Pixel.DriverReadBuffer );
if (overlapping) {
GLint ssy = sy;
}
/* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) {
- _mesa_scale_and_bias_rgba(ctx, width, rgbaFloat);
+ _mesa_scale_and_bias_rgba(ctx, width, rgbaFloat,
+ ctx->Pixel.RedScale, ctx->Pixel.GreenScale,
+ ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale,
+ ctx->Pixel.RedBias, ctx->Pixel.GreenBias,
+ ctx->Pixel.BlueBias, ctx->Pixel.AlphaBias);
}
/* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) {
if (transferOps & IMAGE_CONVOLUTION_BIT) {
/* XXX to do */
}
+ /* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */
+ if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) {
+ _mesa_scale_and_bias_rgba(ctx, width, rgbaFloat,
+ ctx->Pixel.PostConvolutionScale[RCOMP],
+ ctx->Pixel.PostConvolutionScale[GCOMP],
+ ctx->Pixel.PostConvolutionScale[BCOMP],
+ ctx->Pixel.PostConvolutionScale[ACOMP],
+ ctx->Pixel.PostConvolutionBias[RCOMP],
+ ctx->Pixel.PostConvolutionBias[GCOMP],
+ ctx->Pixel.PostConvolutionBias[BCOMP],
+ ctx->Pixel.PostConvolutionBias[ACOMP]);
+ }
/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgbaFloat);
}
}
- if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
+ if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
- for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
_mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q);
- gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
- primary_rgba, rgba);
+ _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL,
+ primary_rgba, rgba);
}
}
}
}
+ /* Restore pixel source to be the draw buffer (for blending, etc) */
+ (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ ctx->Color.DriverDrawBuffer );
+
if (overlapping)
FREE(tmpImage);
}
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
|| ctx->DrawBuffer != ctx->ReadBuffer;
+ (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ ctx->Pixel.DriverReadBuffer );
+
if (overlapping) {
GLint ssy = sy;
tmpImage = (GLuint *) MALLOC(width * height * sizeof(GLuint));
}
}
+ /* Restore pixel source to be the draw buffer (for blending, etc) */
+ (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ ctx->Color.DriverDrawBuffer );
+
if (overlapping)
FREE(tmpImage);
}
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
- if (!ctx->ReadBuffer->DepthBuffer || !ctx->DrawBuffer->DepthBuffer) {
+ if (!ctx->Visual.DepthBits) {
gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
GLint overlapping;
- if (!ctx->DrawBuffer->Stencil || !ctx->ReadBuffer->Stencil) {
+ if (!ctx->Visual.StencilBits) {
gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
GLint destx, GLint desty,
GLenum type )
{
+ if (SWRAST_CONTEXT(ctx)->NewState)
+ _swrast_validate_derived( ctx );
+
if (type == GL_COLOR && ctx->Visual.RGBAflag) {
copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
}