- const GLfloat scale = (1.0F / CHAN_MAXF);
- GLint k;
- DEFMARRAY(GLfloat, rgbaFloat, MAX_WIDTH, 4); /* mac 32k limitation */
- CHECKARRAY(rgbaFloat, return);
-
- /* convert chan to float */
- for (k = 0; k < width; k++) {
- rgbaFloat[k][RCOMP] = (GLfloat) rgba[k][RCOMP] * scale;
- rgbaFloat[k][GCOMP] = (GLfloat) rgba[k][GCOMP] * scale;
- rgbaFloat[k][BCOMP] = (GLfloat) rgba[k][BCOMP] * scale;
- rgbaFloat[k][ACOMP] = (GLfloat) rgba[k][ACOMP] * scale;
- }
- /* scale & bias */
- if (transferOps & IMAGE_SCALE_BIAS_BIT) {
- _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) {
- _mesa_map_rgba(ctx, width, rgbaFloat);
- }
- /* GL_COLOR_TABLE lookup */
- if (transferOps & IMAGE_COLOR_TABLE_BIT) {
- _mesa_lookup_rgba(&ctx->ColorTable, width, rgbaFloat);
- }
- /* convolution */
- 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);
- }
- /* color matrix */
- if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
- _mesa_transform_rgba(ctx, width, rgbaFloat);
- }
- /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
- if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
- _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, width, rgbaFloat);
- }
- /* update histogram count */
- if (transferOps & IMAGE_HISTOGRAM_BIT) {
- _mesa_update_histogram(ctx, width, (CONST GLfloat (*)[4]) rgbaFloat);
- }
- /* update min/max */
- if (transferOps & IMAGE_MIN_MAX_BIT) {
- _mesa_update_minmax(ctx, width, (CONST GLfloat (*)[4]) rgbaFloat);
- }
- /* clamp to [0,1] and convert float back to chan */
- for (k = 0; k < width; k++) {
- GLint r = (GLint) (rgbaFloat[k][RCOMP] * CHAN_MAXF);
- GLint g = (GLint) (rgbaFloat[k][GCOMP] * CHAN_MAXF);
- GLint b = (GLint) (rgbaFloat[k][BCOMP] * CHAN_MAXF);
- GLint a = (GLint) (rgbaFloat[k][ACOMP] * CHAN_MAXF);
- rgba[k][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
- rgba[k][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
- rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
- rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
- }
- UNDEFARRAY(rgbaFloat); /* mac 32k limitation */
- }
-
- if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
- GLuint unit;
- GLchan primary_rgba[MAX_WIDTH][4];
- GLfloat texcoord[MAX_WIDTH][3];
- DEFARRAY(GLfloat, s, MAX_WIDTH); /* mac 32k limitation */
- DEFARRAY(GLfloat, t, MAX_WIDTH); /* mac 32k limitation */
- DEFARRAY(GLfloat, r, MAX_WIDTH); /* mac 32k limitation */
- DEFARRAY(GLfloat, q, MAX_WIDTH); /* mac 32k limitation */
- CHECKARRAY(s, return); /* mac 32k limitation */
- CHECKARRAY(t, return);
- CHECKARRAY(r, return);
- CHECKARRAY(q, return);
-
- /* XXX not sure how multitexture is supposed to work here */
- MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
-
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
- s, t, r, q);
- /* this is an ugly work-around. s,t,r has to be copied to
- texcoords, because the functions need different
- input. */
- for (i=0; i<width; i++) {
- texcoord[i][0] = s[i],
- texcoord[i][1] = t[i],
- texcoord[i][2] = r[i];
- }
- _old_swrast_texture_fragments( ctx, unit, width, texcoord, NULL,
- (CONST GLchan (*)[4]) primary_rgba,
- rgba);
- }
-
- UNDEFARRAY(s); /* mac 32k limitation */
- UNDEFARRAY(t);
- UNDEFARRAY(r);
- UNDEFARRAY(q);