Pass scale and bias values to _mesa_scale_and_bias_rgba().
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 28 Nov 2000 00:07:51 +0000 (00:07 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 28 Nov 2000 00:07:51 +0000 (00:07 +0000)
Implemented post-convolution scale and bias operation.

src/mesa/main/image.c
src/mesa/main/mtypes.h
src/mesa/main/pixel.c
src/mesa/main/pixel.h
src/mesa/main/state.c
src/mesa/swrast/s_copypix.c

index 1c3203f63fe704fac03323ac5ff0f9933184ccbf..f2003ccfbe0f5abc3de614e366a28fef2f5c80fe 100644 (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
@@ -818,7 +818,11 @@ _mesa_pack_float_rgba_span( GLcontext *ctx,
 
       /* scale & bias */
       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 */
       if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -832,6 +836,18 @@ _mesa_pack_float_rgba_span( GLcontext *ctx,
       if (transferOps & IMAGE_CONVOLUTION_BIT) {
          /* 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 */
       if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
          _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
@@ -2589,7 +2605,11 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
 
          /* scale and bias colors */
          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 */
          if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -2606,6 +2626,18 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
          if (transferOps & IMAGE_CONVOLUTION_BIT) {
             /* 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 */
          if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
             _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
@@ -2847,7 +2879,11 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
 
          /* scale and bias colors */
          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 */
          if (transferOps & IMAGE_MAP_COLOR_BIT) {
@@ -2864,6 +2900,18 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
          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, 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 */
          if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
             _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
index 41c1000c1d2913fcb59859065faa08782302e03e..ee1fecfb30e45c99e6862bdff09b20d503b99278 100644 (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
@@ -1235,11 +1235,12 @@ struct gl_extensions {
 #define IMAGE_MAP_COLOR_BIT                       0x4
 #define IMAGE_COLOR_TABLE_BIT                     0x8
 #define IMAGE_CONVOLUTION_BIT                     0x10
-#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT    0x20
-#define IMAGE_COLOR_MATRIX_BIT                    0x40
-#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT   0x80
-#define IMAGE_HISTOGRAM_BIT                       0x100
-#define IMAGE_MIN_MAX_BIT                         0x200
+#define IMAGE_POST_CONVOLUTION_SCALE_BIAS         0x20
+#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT    0x40
+#define IMAGE_COLOR_MATRIX_BIT                    0x80
+#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT   0x100
+#define IMAGE_HISTOGRAM_BIT                       0x200
+#define IMAGE_MIN_MAX_BIT                         0x400
 
 /* transfer ops up to convolution: */
 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT |     \
@@ -1248,7 +1249,8 @@ struct gl_extensions {
                                     IMAGE_COLOR_TABLE_BIT)
 
 /* 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_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
                                      IMAGE_HISTOGRAM_BIT |                    \
index 12097397fbc7a59d2ab46e01a4281bdbca8ac412..efd89cadd42dc90cced58788a81e673d7adf6233 100644 (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
@@ -653,38 +653,34 @@ _mesa_PixelTransferi( GLenum pname, GLint param )
  * Apply scale and bias factors to an array of RGBA pixels.
  */
 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) {
-      const GLfloat scale = ctx->Pixel.RedScale;
-      const GLfloat bias = ctx->Pixel.RedBias;
+   if (rScale != 1.0 || rBias != 0.0) {
       GLuint 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) {
-      const GLfloat scale = ctx->Pixel.GreenScale;
-      const GLfloat bias = ctx->Pixel.GreenBias;
+   if (gScale != 1.0 || gBias != 0.0) {
       GLuint 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) {
-      const GLfloat scale = ctx->Pixel.BlueScale;
-      const GLfloat bias = ctx->Pixel.BlueBias;
+   if (bScale != 1.0 || bBias != 0.0) {
       GLuint 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) {
-      const GLfloat scale = ctx->Pixel.AlphaScale;
-      const GLfloat bias = ctx->Pixel.AlphaBias;
+   if (aScale != 1.0 || aBias != 0.0) {
       GLuint i;
       for (i = 0; i < n; i++) {
-         rgba[i][ACOMP] = rgba[i][ACOMP] * scale + bias;
+         rgba[i][ACOMP] = rgba[i][ACOMP] * aScale + aBias;
       }
    }
 }
index 2ff5a4ac6b3f233857d33435276f877b021c07b4..db6dd78ffdb8436f5683117f5acdb960c3b740f6 100644 (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
@@ -77,8 +77,11 @@ _mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor );
  */
 
 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
 _mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
index 0dbf48163d9e0b595cc3fcbb80f1300af723b594..5c4dda99e8d97db0e8c131f087bf6424368c9608 100644 (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
@@ -676,8 +676,19 @@ update_image_transfer_state(GLcontext *ctx)
 
    if (ctx->Pixel.Convolution1DEnabled ||
        ctx->Pixel.Convolution2DEnabled ||
-       ctx->Pixel.Separable2DEnabled)
+       ctx->Pixel.Separable2DEnabled) {
       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)
       mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT;
index 03887a9e14ca582657e2b3fa36184f7a6b73970f..96172e027125fdd9f351708c1af2d6143873180d 100644 (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
@@ -167,7 +167,11 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
 
       /* 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) {
@@ -415,7 +419,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
          }
          /* 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) {
@@ -429,6 +437,18 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
          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, 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 */
          if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
             _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgbaFloat);