Pass scale and bias values to _mesa_scale_and_bias_rgba().

Implemented post-convolution scale and bias operation.
This commit is contained in:
Brian Paul
2000-11-28 00:07:51 +00:00
parent 4304790e3e
commit 45015e4d79
6 changed files with 117 additions and 37 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: image.c,v 1.49 2000/11/22 07:32:17 joukj Exp $ */ /* $Id: image.c,v 1.50 2000/11/28 00:07:51 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -818,7 +818,11 @@ _mesa_pack_float_rgba_span( GLcontext *ctx,
/* scale & bias */ /* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) { if (transferOps & IMAGE_SCALE_BIAS_BIT) {
_mesa_scale_and_bias_rgba( ctx, n, rgba ); _mesa_scale_and_bias_rgba(ctx, n, 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 */ /* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) { if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -832,6 +836,18 @@ _mesa_pack_float_rgba_span( GLcontext *ctx,
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
/* this has to be done in the calling code */ /* this has to be done in the calling code */
} }
/* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */
if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) {
_mesa_scale_and_bias_rgba(ctx, n, rgba,
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 */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba); _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
@@ -2589,7 +2605,11 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
/* scale and bias colors */ /* scale and bias colors */
if (transferOps & IMAGE_SCALE_BIAS_BIT) { if (transferOps & IMAGE_SCALE_BIAS_BIT) {
_mesa_scale_and_bias_rgba(ctx, n, rgba); _mesa_scale_and_bias_rgba(ctx, n, 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 */ /* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) { if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -2606,6 +2626,18 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
/* this has to be done in the calling code */ /* this has to be done in the calling code */
} }
/* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */
if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) {
_mesa_scale_and_bias_rgba(ctx, n, rgba,
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 */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba); _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
@@ -2847,7 +2879,11 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
/* scale and bias colors */ /* scale and bias colors */
if (transferOps & IMAGE_SCALE_BIAS_BIT) { if (transferOps & IMAGE_SCALE_BIAS_BIT) {
_mesa_scale_and_bias_rgba(ctx, n, rgba); _mesa_scale_and_bias_rgba(ctx, n, 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 */ /* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) { if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -2864,6 +2900,18 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
/* XXX to do */ /* 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, n, rgba,
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 */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba); _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);

View File

@@ -1,4 +1,4 @@
/* $Id: mtypes.h,v 1.3 2000/11/27 18:22:13 brianp Exp $ */ /* $Id: mtypes.h,v 1.4 2000/11/28 00:07:51 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -1235,11 +1235,12 @@ struct gl_extensions {
#define IMAGE_MAP_COLOR_BIT 0x4 #define IMAGE_MAP_COLOR_BIT 0x4
#define IMAGE_COLOR_TABLE_BIT 0x8 #define IMAGE_COLOR_TABLE_BIT 0x8
#define IMAGE_CONVOLUTION_BIT 0x10 #define IMAGE_CONVOLUTION_BIT 0x10
#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x20 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
#define IMAGE_COLOR_MATRIX_BIT 0x40 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x80 #define IMAGE_COLOR_MATRIX_BIT 0x80
#define IMAGE_HISTOGRAM_BIT 0x100 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
#define IMAGE_MIN_MAX_BIT 0x200 #define IMAGE_HISTOGRAM_BIT 0x200
#define IMAGE_MIN_MAX_BIT 0x400
/* transfer ops up to convolution: */ /* transfer ops up to convolution: */
#define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \ #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
@@ -1248,7 +1249,8 @@ struct gl_extensions {
IMAGE_COLOR_TABLE_BIT) IMAGE_COLOR_TABLE_BIT)
/* transfer ops after convolution: */ /* transfer ops after convolution: */
#define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \ #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
IMAGE_COLOR_MATRIX_BIT | \ IMAGE_COLOR_MATRIX_BIT | \
IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\ IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
IMAGE_HISTOGRAM_BIT | \ IMAGE_HISTOGRAM_BIT | \

View File

@@ -1,4 +1,4 @@
/* $Id: pixel.c,v 1.19 2000/11/22 07:32:17 joukj Exp $ */ /* $Id: pixel.c,v 1.20 2000/11/28 00:07:51 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -653,38 +653,34 @@ _mesa_PixelTransferi( GLenum pname, GLint param )
* Apply scale and bias factors to an array of RGBA pixels. * Apply scale and bias factors to an array of RGBA pixels.
*/ */
void void
_mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]) _mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4],
GLfloat rScale, GLfloat gScale,
GLfloat bScale, GLfloat aScale,
GLfloat rBias, GLfloat gBias,
GLfloat bBias, GLfloat aBias)
{ {
if (ctx->Pixel.RedScale != 1.0 || ctx->Pixel.RedBias != 0.0) { if (rScale != 1.0 || rBias != 0.0) {
const GLfloat scale = ctx->Pixel.RedScale;
const GLfloat bias = ctx->Pixel.RedBias;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
rgba[i][RCOMP] = rgba[i][RCOMP] * scale + bias; rgba[i][RCOMP] = rgba[i][RCOMP] * rScale + rBias;
} }
} }
if (ctx->Pixel.GreenScale != 1.0 || ctx->Pixel.GreenBias != 0.0) { if (gScale != 1.0 || gBias != 0.0) {
const GLfloat scale = ctx->Pixel.GreenScale;
const GLfloat bias = ctx->Pixel.GreenBias;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
rgba[i][GCOMP] = rgba[i][GCOMP] * scale + bias; rgba[i][GCOMP] = rgba[i][GCOMP] * gScale + gBias;
} }
} }
if (ctx->Pixel.BlueScale != 1.0 || ctx->Pixel.BlueBias != 0.0) { if (bScale != 1.0 || bBias != 0.0) {
const GLfloat scale = ctx->Pixel.BlueScale;
const GLfloat bias = ctx->Pixel.BlueBias;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
rgba[i][BCOMP] = rgba[i][BCOMP] * scale + bias; rgba[i][BCOMP] = rgba[i][BCOMP] * bScale + bBias;
} }
} }
if (ctx->Pixel.AlphaScale != 1.0 || ctx->Pixel.AlphaBias != 0.0) { if (aScale != 1.0 || aBias != 0.0) {
const GLfloat scale = ctx->Pixel.AlphaScale;
const GLfloat bias = ctx->Pixel.AlphaBias;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
rgba[i][ACOMP] = rgba[i][ACOMP] * scale + bias; rgba[i][ACOMP] = rgba[i][ACOMP] * aScale + aBias;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
/* $Id: pixel.h,v 1.7 2000/11/22 07:32:17 joukj Exp $ */ /* $Id: pixel.h,v 1.8 2000/11/28 00:07:51 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -77,8 +77,11 @@ _mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor );
*/ */
extern void extern void
_mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); _mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4],
GLfloat rScale, GLfloat gScale,
GLfloat bScale, GLfloat aScale,
GLfloat rBias, GLfloat gBias,
GLfloat bBias, GLfloat aBias);
extern void extern void
_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); _mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);

View File

@@ -1,4 +1,4 @@
/* $Id: state.c,v 1.49 2000/11/27 18:22:13 brianp Exp $ */ /* $Id: state.c,v 1.50 2000/11/28 00:07:51 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -676,8 +676,19 @@ update_image_transfer_state(GLcontext *ctx)
if (ctx->Pixel.Convolution1DEnabled || if (ctx->Pixel.Convolution1DEnabled ||
ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Convolution2DEnabled ||
ctx->Pixel.Separable2DEnabled) ctx->Pixel.Separable2DEnabled) {
mask |= IMAGE_CONVOLUTION_BIT; mask |= IMAGE_CONVOLUTION_BIT;
if (ctx->Pixel.PostConvolutionScale[0] != 1.0F ||
ctx->Pixel.PostConvolutionScale[1] != 1.0F ||
ctx->Pixel.PostConvolutionScale[2] != 1.0F ||
ctx->Pixel.PostConvolutionScale[3] != 1.0F ||
ctx->Pixel.PostConvolutionBias[0] != 0.0F ||
ctx->Pixel.PostConvolutionBias[1] != 0.0F ||
ctx->Pixel.PostConvolutionBias[2] != 0.0F ||
ctx->Pixel.PostConvolutionBias[3] != 0.0F) {
mask |= IMAGE_POST_CONVOLUTION_SCALE_BIAS;
}
}
if (ctx->Pixel.PostConvolutionColorTableEnabled) if (ctx->Pixel.PostConvolutionColorTableEnabled)
mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT;

View File

@@ -1,4 +1,4 @@
/* $Id: s_copypix.c,v 1.4 2000/11/10 18:29:18 brianp Exp $ */ /* $Id: s_copypix.c,v 1.5 2000/11/28 00:07:52 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -167,7 +167,11 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* scale & bias */ /* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) { 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 */ /* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) { if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -415,7 +419,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
} }
/* scale & bias */ /* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) { 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 */ /* color map lookup */
if (transferOps & IMAGE_MAP_COLOR_BIT) { if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -429,6 +437,18 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
/* XXX to do */ /* 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, rgba,
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 */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgbaFloat); _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgbaFloat);