summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/convolve.c120
-rw-r--r--src/mesa/main/image.c10
-rw-r--r--src/mesa/main/pixel.c4
-rw-r--r--src/mesa/main/pixel.h4
4 files changed, 49 insertions, 89 deletions
diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c
index afa550a481..1f4eaf439b 100644
--- a/src/mesa/main/convolve.c
+++ b/src/mesa/main/convolve.c
@@ -38,6 +38,7 @@
#include "context.h"
#include "image.h"
#include "mtypes.h"
+#include "pixel.h"
#include "state.h"
@@ -177,26 +178,16 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G
ctx->Unpack.BufferObj);
}
- /* apply scale and bias */
- {
- const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[0];
- const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[0];
- GLint i;
- for (i = 0; i < width; i++) {
- GLfloat r = ctx->Convolution1D.Filter[i * 4 + 0];
- GLfloat g = ctx->Convolution1D.Filter[i * 4 + 1];
- GLfloat b = ctx->Convolution1D.Filter[i * 4 + 2];
- GLfloat a = ctx->Convolution1D.Filter[i * 4 + 3];
- r = r * scale[0] + bias[0];
- g = g * scale[1] + bias[1];
- b = b * scale[2] + bias[2];
- a = a * scale[3] + bias[3];
- ctx->Convolution1D.Filter[i * 4 + 0] = r;
- ctx->Convolution1D.Filter[i * 4 + 1] = g;
- ctx->Convolution1D.Filter[i * 4 + 2] = b;
- ctx->Convolution1D.Filter[i * 4 + 3] = a;
- }
- }
+ _mesa_scale_and_bias_rgba(width,
+ (GLfloat (*)[4]) ctx->Convolution1D.Filter,
+ ctx->Pixel.ConvolutionFilterScale[0][0],
+ ctx->Pixel.ConvolutionFilterScale[0][1],
+ ctx->Pixel.ConvolutionFilterScale[0][2],
+ ctx->Pixel.ConvolutionFilterScale[0][3],
+ ctx->Pixel.ConvolutionFilterBias[0][0],
+ ctx->Pixel.ConvolutionFilterBias[0][1],
+ ctx->Pixel.ConvolutionFilterBias[0][2],
+ ctx->Pixel.ConvolutionFilterBias[0][3]);
ctx->NewState |= _NEW_PIXEL;
}
@@ -290,25 +281,16 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G
ctx->Unpack.BufferObj);
}
- /* apply scale and bias */
- {
- const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[1];
- const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[1];
- for (i = 0; i < width * height; i++) {
- GLfloat r = ctx->Convolution2D.Filter[i * 4 + 0];
- GLfloat g = ctx->Convolution2D.Filter[i * 4 + 1];
- GLfloat b = ctx->Convolution2D.Filter[i * 4 + 2];
- GLfloat a = ctx->Convolution2D.Filter[i * 4 + 3];
- r = r * scale[0] + bias[0];
- g = g * scale[1] + bias[1];
- b = b * scale[2] + bias[2];
- a = a * scale[3] + bias[3];
- ctx->Convolution2D.Filter[i * 4 + 0] = r;
- ctx->Convolution2D.Filter[i * 4 + 1] = g;
- ctx->Convolution2D.Filter[i * 4 + 2] = b;
- ctx->Convolution2D.Filter[i * 4 + 3] = a;
- }
- }
+ _mesa_scale_and_bias_rgba(width * height,
+ (GLfloat (*)[4]) ctx->Convolution2D.Filter,
+ ctx->Pixel.ConvolutionFilterScale[1][0],
+ ctx->Pixel.ConvolutionFilterScale[1][1],
+ ctx->Pixel.ConvolutionFilterScale[1][2],
+ ctx->Pixel.ConvolutionFilterScale[1][3],
+ ctx->Pixel.ConvolutionFilterBias[1][0],
+ ctx->Pixel.ConvolutionFilterBias[1][1],
+ ctx->Pixel.ConvolutionFilterBias[1][2],
+ ctx->Pixel.ConvolutionFilterBias[1][3]);
ctx->NewState |= _NEW_PIXEL;
}
@@ -958,26 +940,16 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs
format, type, row, &ctx->Unpack,
0); /* transferOps */
- /* apply scale and bias */
- {
- const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[2];
- const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[2];
- GLint i;
- for (i = 0; i < width; i++) {
- GLfloat r = ctx->Separable2D.Filter[i * 4 + 0];
- GLfloat g = ctx->Separable2D.Filter[i * 4 + 1];
- GLfloat b = ctx->Separable2D.Filter[i * 4 + 2];
- GLfloat a = ctx->Separable2D.Filter[i * 4 + 3];
- r = r * scale[0] + bias[0];
- g = g * scale[1] + bias[1];
- b = b * scale[2] + bias[2];
- a = a * scale[3] + bias[3];
- ctx->Separable2D.Filter[i * 4 + 0] = r;
- ctx->Separable2D.Filter[i * 4 + 1] = g;
- ctx->Separable2D.Filter[i * 4 + 2] = b;
- ctx->Separable2D.Filter[i * 4 + 3] = a;
- }
- }
+ _mesa_scale_and_bias_rgba(width,
+ (GLfloat (*)[4]) ctx->Separable2D.Filter,
+ ctx->Pixel.ConvolutionFilterScale[2][0],
+ ctx->Pixel.ConvolutionFilterScale[2][1],
+ ctx->Pixel.ConvolutionFilterScale[2][2],
+ ctx->Pixel.ConvolutionFilterScale[2][3],
+ ctx->Pixel.ConvolutionFilterBias[2][0],
+ ctx->Pixel.ConvolutionFilterBias[2][1],
+ ctx->Pixel.ConvolutionFilterBias[2][2],
+ ctx->Pixel.ConvolutionFilterBias[2][3]);
}
/* unpack column filter */
@@ -987,26 +959,16 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs
format, type, column, &ctx->Unpack,
0); /* transferOps */
- /* apply scale and bias */
- {
- const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[2];
- const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[2];
- GLint i;
- for (i = 0; i < height; i++) {
- GLfloat r = ctx->Separable2D.Filter[i * 4 + 0 + colStart];
- GLfloat g = ctx->Separable2D.Filter[i * 4 + 1 + colStart];
- GLfloat b = ctx->Separable2D.Filter[i * 4 + 2 + colStart];
- GLfloat a = ctx->Separable2D.Filter[i * 4 + 3 + colStart];
- r = r * scale[0] + bias[0];
- g = g * scale[1] + bias[1];
- b = b * scale[2] + bias[2];
- a = a * scale[3] + bias[3];
- ctx->Separable2D.Filter[i * 4 + 0 + colStart] = r;
- ctx->Separable2D.Filter[i * 4 + 1 + colStart] = g;
- ctx->Separable2D.Filter[i * 4 + 2 + colStart] = b;
- ctx->Separable2D.Filter[i * 4 + 3 + colStart] = a;
- }
- }
+ _mesa_scale_and_bias_rgba(height,
+ (GLfloat (*)[4]) (ctx->Separable2D.Filter + colStart),
+ ctx->Pixel.ConvolutionFilterScale[2][0],
+ ctx->Pixel.ConvolutionFilterScale[2][1],
+ ctx->Pixel.ConvolutionFilterScale[2][2],
+ ctx->Pixel.ConvolutionFilterScale[2][3],
+ ctx->Pixel.ConvolutionFilterBias[2][0],
+ ctx->Pixel.ConvolutionFilterBias[2][1],
+ ctx->Pixel.ConvolutionFilterBias[2][2],
+ ctx->Pixel.ConvolutionFilterBias[2][3]);
}
if (ctx->Unpack.BufferObj->Name) {
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 81cf985e6b..fcc5d4e3b4 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -503,7 +503,7 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing,
skippixels = packing->SkipPixels;
skipimages = packing->SkipImages;
- if (type==GL_BITMAP) {
+ if (type == GL_BITMAP) {
/* BITMAP data */
GLint comp_per_pixel; /* components per pixel */
GLint bytes_per_comp; /* bytes per component */
@@ -512,13 +512,13 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing,
/* Compute bytes per component */
bytes_per_comp = _mesa_sizeof_packed_type( type );
- if (bytes_per_comp<0) {
+ if (bytes_per_comp < 0) {
return NULL;
}
/* Compute number of components per pixel */
comp_per_pixel = _mesa_components_in_format( format );
- if (comp_per_pixel<0 && type != GL_BITMAP) {
+ if (comp_per_pixel < 0) {
return NULL;
}
@@ -922,7 +922,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps,
{
/* scale & bias */
if (transferOps & IMAGE_SCALE_BIAS_BIT) {
- _mesa_scale_and_bias_rgba(ctx, n, rgba,
+ _mesa_scale_and_bias_rgba(n, rgba,
ctx->Pixel.RedScale, ctx->Pixel.GreenScale,
ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale,
ctx->Pixel.RedBias, ctx->Pixel.GreenBias,
@@ -943,7 +943,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps,
}
/* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */
if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) {
- _mesa_scale_and_bias_rgba(ctx, n, rgba,
+ _mesa_scale_and_bias_rgba(n, rgba,
ctx->Pixel.PostConvolutionScale[RCOMP],
ctx->Pixel.PostConvolutionScale[GCOMP],
ctx->Pixel.PostConvolutionScale[BCOMP],
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 3d36c66e5b..2a0df1f347 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1074,14 +1074,12 @@ _mesa_PixelTransferi( GLenum pname, GLint param )
* Apply scale and bias factors to an array of RGBA pixels.
*/
void
-_mesa_scale_and_bias_rgba(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
+_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
GLfloat rScale, GLfloat gScale,
GLfloat bScale, GLfloat aScale,
GLfloat rBias, GLfloat gBias,
GLfloat bBias, GLfloat aBias)
{
- (void) ctx;
-
if (rScale != 1.0 || rBias != 0.0) {
GLuint i;
for (i = 0; i < n; i++) {
diff --git a/src/mesa/main/pixel.h b/src/mesa/main/pixel.h
index 13dee25510..9eef0cff5a 100644
--- a/src/mesa/main/pixel.h
+++ b/src/mesa/main/pixel.h
@@ -5,7 +5,7 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -79,7 +79,7 @@ _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(GLuint n, GLfloat rgba[][4],
GLfloat rScale, GLfloat gScale,
GLfloat bScale, GLfloat aScale,
GLfloat rBias, GLfloat gBias,