-/* $Id: convolve.c,v 1.20 2001/03/03 20:33:27 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*/
-#ifdef PC_HEADER
-#include "all.h"
-#else
#include "glheader.h"
#include "colormac.h"
#include "convolve.h"
#include "image.h"
#include "mtypes.h"
#include "state.h"
-#include "swrast/s_span.h" /* XXX SWRAST hack */
-#endif
/*
}
-void
+void GLAPIENTRY
_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image)
{
- GLenum baseFormat;
+ GLint baseFormat;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
}
-void
+void GLAPIENTRY
_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image)
{
- GLenum baseFormat;
- GLint i, components;
+ GLint baseFormat;
+ GLint i;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
return;
}
- components = _mesa_components_in_format(format);
- assert(components > 0); /* this should have been caught earlier */
+ /* this should have been caught earlier */
+ assert(_mesa_components_in_format(format));
ctx->Convolution2D.Format = format;
ctx->Convolution2D.InternalFormat = internalFormat;
{
const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[1];
const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[1];
- for (i = 0; i < width * height * 4; i++) {
+ 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];
}
-void
+void GLAPIENTRY
_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_convolution_attrib *conv;
GLuint c;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (target) {
case GL_CONVOLUTION_1D:
c = 0;
- conv = &ctx->Convolution1D;
break;
case GL_CONVOLUTION_2D:
c = 1;
- conv = &ctx->Convolution2D;
break;
case GL_SEPARABLE_2D:
c = 2;
- conv = &ctx->Separable2D;
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(target)");
}
-void
+void GLAPIENTRY
_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_convolution_attrib *conv;
GLuint c;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (target) {
case GL_CONVOLUTION_1D:
c = 0;
- conv = &ctx->Convolution1D;
break;
case GL_CONVOLUTION_2D:
c = 1;
- conv = &ctx->Convolution2D;
break;
case GL_SEPARABLE_2D:
c = 2;
- conv = &ctx->Separable2D;
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(target)");
}
break;
case GL_CONVOLUTION_FILTER_SCALE:
- COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params);
+ /* COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); */
+ /* need cast to prevent compiler warnings */
+ ctx->Pixel.ConvolutionFilterScale[c][0] = (GLfloat) params[0];
+ ctx->Pixel.ConvolutionFilterScale[c][1] = (GLfloat) params[1];
+ ctx->Pixel.ConvolutionFilterScale[c][2] = (GLfloat) params[2];
+ ctx->Pixel.ConvolutionFilterScale[c][3] = (GLfloat) params[3];
break;
case GL_CONVOLUTION_FILTER_BIAS:
- COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params);
+ /* COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); */
+ /* need cast to prevent compiler warnings */
+ ctx->Pixel.ConvolutionFilterBias[c][0] = (GLfloat) params[0];
+ ctx->Pixel.ConvolutionFilterBias[c][1] = (GLfloat) params[1];
+ ctx->Pixel.ConvolutionFilterBias[c][2] = (GLfloat) params[2];
+ ctx->Pixel.ConvolutionFilterBias[c][3] = (GLfloat) params[3];
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(pname)");
}
-void
+void GLAPIENTRY
_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width)
{
- GLenum baseFormat;
- GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
+ GLint baseFormat;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
return;
}
- /* read pixels from framebuffer */
- RENDER_START(ctx);
- _mesa_read_rgba_span(ctx, ctx->ReadBuffer, width, x, y, (GLchan (*)[4]) rgba);
- RENDER_FINISH(ctx);
-
- /* store as convolution filter */
- _mesa_ConvolutionFilter1D(target, internalFormat, width,
- GL_RGBA, CHAN_TYPE, rgba);
+ ctx->Driver.CopyConvolutionFilter1D( ctx, target,
+ internalFormat, x, y, width);
}
-void
+void GLAPIENTRY
_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height)
{
- GLenum baseFormat;
- GLint i;
- struct gl_pixelstore_attrib packSave;
- GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
+ GLint baseFormat;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
return;
}
- /* read pixels from framebuffer */
- RENDER_START(ctx);
- for (i = 0; i < height; i++) {
- _mesa_read_rgba_span(ctx, ctx->ReadBuffer, width, x, y + i,
- (GLchan (*)[4]) rgba[i]);
- }
- RENDER_FINISH(ctx);
-
- /*
- * store as convolution filter
- */
- packSave = ctx->Unpack; /* save pixel packing params */
-
- ctx->Unpack.Alignment = 1;
- ctx->Unpack.RowLength = MAX_CONVOLUTION_WIDTH;
- ctx->Unpack.SkipPixels = 0;
- ctx->Unpack.SkipRows = 0;
- ctx->Unpack.ImageHeight = 0;
- ctx->Unpack.SkipImages = 0;
- ctx->Unpack.SwapBytes = GL_FALSE;
- ctx->Unpack.LsbFirst = GL_FALSE;
- ctx->NewState |= _NEW_PACKUNPACK;
-
- _mesa_ConvolutionFilter2D(target, internalFormat, width, height,
- GL_RGBA, CHAN_TYPE, rgba);
-
- ctx->Unpack = packSave; /* restore pixel packing params */
- ctx->NewState |= _NEW_PACKUNPACK;
+ ctx->Driver.CopyConvolutionFilter2D( ctx, target, internalFormat, x, y,
+ width, height );
+
}
-void
+void GLAPIENTRY
_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image)
{
const struct gl_convolution_attrib *filter;
- GLint row;
+ GLuint row;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
}
-void
+void GLAPIENTRY
_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span)
{
const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
}
-void
+void GLAPIENTRY
_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column)
{
const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
- GLenum baseFormat;
+ GLint baseFormat;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
*height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1);
}
}
-