Android: remove headers from LOCAL_SRC_FILES
[mesa.git] / src / mesa / main / convolve.c
index ee7a8134213b223b1bdb0e975d55d3aa95afa602..83d590f4a48b43e91e23cd7a03a6e124ba3a3095 100644 (file)
@@ -1,10 +1,7 @@
-/* $Id: convolve.c,v 1.1 2000/07/12 13:00:09 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.3
  *
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  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"),
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 
  */
 
 
-#ifdef PC_HEADER
-#include "all.h"
-#else
 #include "glheader.h"
-#include "types.h"
-#endif
+#include "context.h"
+#include "convolve.h"
+#include "main/dispatch.h"
+
 
+void GLAPIENTRY
+_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter1D");
+}
 
-void
-_mesa_convolve_1d_reduce(GLint srcWidth, const GLfloat src[][4],
-                         GLint filterWidth, const GLfloat filter[][4],
-                         GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image)
 {
-   const GLint dstWidth = srcWidth - (filterWidth - 1);
-   GLint i, n;
-
-   if (dstWidth <= 0)
-      return;  /* null result */
-
-   for (i = 0; i < dstWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (n = 0; n < filterWidth; n++) {
-         sumR += src[i + n][RCOMP] * filter[n][RCOMP];
-         sumG += src[i + n][GCOMP] * filter[n][GCOMP];
-         sumB += src[i + n][BCOMP] * filter[n][BCOMP];
-         sumA += src[i + n][ACOMP] * filter[n][ACOMP];
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D");
 }
 
 
-void
-_mesa_convolve_1d_constant(GLint srcWidth, const GLfloat src[][4],
-                           GLint filterWidth, const GLfloat filter[][4],
-                           const GLfloat borderColor[4], GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
 {
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (n = 0; n < filterWidth; n++) {
-         if (i + n < halfFilterWidth || i + n - halfFilterWidth >= srcWidth) {
-            sumR += borderColor[RCOMP] * filter[n][RCOMP];
-            sumG += borderColor[GCOMP] * filter[n][GCOMP];
-            sumB += borderColor[BCOMP] * filter[n][BCOMP];
-            sumA += borderColor[ACOMP] * filter[n][ACOMP];
-         }
-         else {
-            sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP];
-            sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP];
-            sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP];
-            sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP];
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionParameterf");
 }
 
 
-void
-_mesa_convolve_1d_replicate(GLint srcWidth, const GLfloat src[][4],
-                            GLint filterWidth, const GLfloat filter[][4],
-                            GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 {
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (n = 0; n < filterWidth; n++) {
-         if (i + n < halfFilterWidth) {
-            sumR += src[0][RCOMP] * filter[n][RCOMP];
-            sumG += src[0][GCOMP] * filter[n][GCOMP];
-            sumB += src[0][BCOMP] * filter[n][BCOMP];
-            sumA += src[0][ACOMP] * filter[n][ACOMP];
-         }
-         else if (i + n - halfFilterWidth >= srcWidth) {
-            sumR += src[srcWidth - 1][RCOMP] * filter[n][RCOMP];
-            sumG += src[srcWidth - 1][GCOMP] * filter[n][GCOMP];
-            sumB += src[srcWidth - 1][BCOMP] * filter[n][BCOMP];
-            sumA += src[srcWidth - 1][ACOMP] * filter[n][ACOMP];
-         }
-         else {
-            sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP];
-            sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP];
-            sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP];
-            sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP];
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionParameterfv");
 }
 
 
-/*
- * <src> is the source image width width = srcWidth, height = filterHeight.
- * <filter> has width <filterWidth> and height <filterHeight>.
- * <dst> is a 1-D image span of width <srcWidth> - (<filterWidth> - 1).
- */
-void
-_mesa_convolve_2d_reduce(GLint srcWidth, GLint srcHeight,
-                         const GLfloat src[][4],
-                         GLint filterWidth, GLint filterHeight,
-                         const GLfloat filter[][4],
-                         GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
 {
-   const GLint dstWidth = srcWidth - (filterWidth - 1);
-   GLint i, n, m;
-
-   if (dstWidth <= 0)
-      return;  /* null result */
-
-   /* XXX todo */
-   for (i = 0; i < dstWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (n = 0; n < filterHeight; n++) {
-         for (m = 0; m < filterWidth; m++) {
-            const GLint k = n * srcWidth + i + m;
-            sumR += src[k][RCOMP] * filter[n][RCOMP];
-            sumG += src[k][GCOMP] * filter[n][GCOMP];
-            sumB += src[k][BCOMP] * filter[n][BCOMP];
-            sumA += src[k][ACOMP] * filter[n][ACOMP];
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionParameteri");
+}
+
+
+void GLAPIENTRY
+_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionParameteriv");
 }
 
 
-void
-_mesa_convolve_2d_constant(GLint srcWidth, GLint srcHeight,
-                           const GLfloat src[][4],
-                           GLint filterWidth, GLint filterHeight,
-                           const GLfloat filter[][4],
-                           GLfloat dest[][4],
-                           const GLfloat borderColor[4])
+void GLAPIENTRY
+_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width)
 {
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n, m;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (m = 0; m < filterHeight; m++) {
-         const GLfloat (*filterRow)[4] = filter + m * filterWidth;
-         for (n = 0; n < filterWidth; n++) {
-            if (i + n < halfFilterWidth ||
-                i + n - halfFilterWidth >= srcWidth) {
-               sumR += borderColor[RCOMP] * filterRow[n][RCOMP];
-               sumG += borderColor[GCOMP] * filterRow[n][GCOMP];
-               sumB += borderColor[BCOMP] * filterRow[n][BCOMP];
-               sumA += borderColor[ACOMP] * filterRow[n][ACOMP];
-            }
-            else {
-               const GLint k = m * srcWidth + i + n - halfFilterWidth;
-               sumR += src[k][RCOMP] * filterRow[n][RCOMP];
-               sumG += src[k][GCOMP] * filterRow[n][GCOMP];
-               sumB += src[k][BCOMP] * filterRow[n][BCOMP];
-               sumA += src[k][ACOMP] * filterRow[n][ACOMP];
-            }
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyConvolutionFilter1D");
 }
 
 
-void
-_mesa_convolve_2d_replicate(GLint srcWidth, GLint srcHeight,
-                            const GLfloat src[][4],
-                            GLint filterWidth, GLint filterHeight,
-                            const GLfloat filter[][4],
-                            GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n, m;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (m = 0; m < filterHeight; m++) {
-         const GLfloat (*filterRow)[4] = filter + m * filterWidth;
-         for (n = 0; n < filterWidth; n++) {
-            if (i + n < halfFilterWidth) {
-               const GLint k = m * srcWidth + 0;
-               sumR += src[k][RCOMP] * filterRow[n][RCOMP];
-               sumG += src[k][GCOMP] * filterRow[n][GCOMP];
-               sumB += src[k][BCOMP] * filterRow[n][BCOMP];
-               sumA += src[k][ACOMP] * filterRow[n][ACOMP];
-            }
-            else if (i + n - halfFilterWidth >= srcWidth) {
-               const GLint k = m * srcWidth + srcWidth - 1;
-               sumR += src[k][RCOMP] * filterRow[n][RCOMP];
-               sumG += src[k][GCOMP] * filterRow[n][GCOMP];
-               sumB += src[k][BCOMP] * filterRow[n][BCOMP];
-               sumA += src[k][ACOMP] * filterRow[n][ACOMP];
-            }
-            else {
-               const GLint k = m * srcWidth + i + n - halfFilterWidth;
-               sumR += src[k][RCOMP] * filterRow[n][RCOMP];
-               sumG += src[k][GCOMP] * filterRow[n][GCOMP];
-               sumB += src[k][BCOMP] * filterRow[n][BCOMP];
-               sumA += src[k][ACOMP] * filterRow[n][ACOMP];
-            }
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyConvolutionFilter2D");
 }
 
 
-void
-_mesa_convolve_sep_constant(GLint srcWidth, GLint srcHeight,
-                            const GLfloat src[][4],
-                            GLint filterWidth, GLint filterHeight,
-                            const GLfloat rowFilt[][4],
-                            const GLfloat colFilt[][4],
-                            GLfloat dest[][4],
-                            const GLfloat borderColor[4])
+void GLAPIENTRY
+_mesa_GetnConvolutionFilterARB(GLenum target, GLenum format, GLenum type,
+                               GLsizei bufSize, GLvoid *image)
 {
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n, m;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (m = 0; m < filterHeight; m++) {
-         for (n = 0; n < filterWidth; n++) {
-            if (i + n < halfFilterWidth ||
-                i + n - halfFilterWidth >= srcWidth) {
-               sumR += borderColor[RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += borderColor[GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += borderColor[BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += borderColor[ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-            else {
-               const GLint k = m * srcWidth + i + n - halfFilterWidth;
-               sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter");
 }
 
 
-void
-_mesa_convolve_sep_reduce(GLint srcWidth, GLint srcHeight,
-                          const GLfloat src[][4],
-                          GLint filterWidth, GLint filterHeight,
-                          const GLfloat rowFilt[][4],
-                          const GLfloat colFilt[][4],
-                          GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
+                           GLvoid *image)
 {
-#if 00
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n, m;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (m = 0; m < filterHeight; m++) {
-         for (n = 0; n < filterWidth; n++) {
-            if (i + n < halfFilterWidth ||
-                i + n - halfFilterWidth >= srcWidth) {
-               sumR += borderColor[RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += borderColor[GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += borderColor[BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += borderColor[ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-            else {
-               const GLint k = m * srcWidth + i + n - halfFilterWidth;
-               sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
-#endif
+   _mesa_GetnConvolutionFilterARB(target, format, type, INT_MAX, image);
 }
 
 
-void
-_mesa_convolve_sep_replicate(GLint srcWidth, GLint srcHeight,
-                             const GLfloat src[][4],
-                             GLint filterWidth, GLint filterHeight,
-                             const GLfloat rowFilt[][4],
-                             const GLfloat colFilt[][4],
-                             GLfloat dest[][4])
+void GLAPIENTRY
+_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
 {
-   const GLint halfFilterWidth = filterWidth / 2;
-   GLint i, n, m;
-
-   for (i = 0; i < srcWidth; i++) {
-      GLfloat sumR = 0.0;
-      GLfloat sumG = 0.0;
-      GLfloat sumB = 0.0;
-      GLfloat sumA = 0.0;
-      for (m = 0; m < filterHeight; m++) {
-         for (n = 0; n < filterWidth; n++) {
-            if (i + n < halfFilterWidth) {
-               const GLint k = m * srcWidth + 0;
-               sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-            else if (i + n - halfFilterWidth >= srcWidth) {
-               const GLint k = m * srcWidth + srcWidth - 1;
-               sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-            else {
-               const GLint k = m * srcWidth + i + n - halfFilterWidth;
-               sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
-               sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
-               sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
-               sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
-            }
-         }
-      }
-      dest[i][RCOMP] = sumR;
-      dest[i][GCOMP] = sumG;
-      dest[i][BCOMP] = sumB;
-      dest[i][ACOMP] = sumA;
-   }
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionParameterfv");
+}
+
+
+void GLAPIENTRY
+_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionParameteriv");
+}
+
+
+void GLAPIENTRY
+_mesa_GetnSeparableFilterARB(GLenum target, GLenum format, GLenum type,
+                             GLsizei rowBufSize, GLvoid *row,
+                             GLsizei columnBufSize,  GLvoid *column,
+                             GLvoid *span)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSeparableFilter");
+}
+
+
+void GLAPIENTRY
+_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
+                         GLvoid *row, GLvoid *column, GLvoid *span)
+{
+   _mesa_GetnSeparableFilterARB(target, format, type, INT_MAX, row,
+                                INT_MAX, column, span);
+}
+
+
+void GLAPIENTRY
+_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_error(ctx, GL_INVALID_OPERATION, "glSeparableFilter2D");
 }