swrast: remove prototypes for obsolete functions
[mesa.git] / src / mesa / swrast / s_imaging.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /* KW: Moved these here to remove knowledge of swrast from core mesa.
26 * Should probably pull the entire software implementation of these
27 * extensions into either swrast or a sister module.
28 */
29
30 #include "main/glheader.h"
31 #include "main/colortab.h"
32 #include "main/convolve.h"
33 #include "s_context.h"
34 #include "s_span.h"
35
36
37 void
38 _swrast_CopyColorTable( GLcontext *ctx,
39 GLenum target, GLenum internalformat,
40 GLint x, GLint y, GLsizei width)
41 {
42 GLchan data[MAX_WIDTH][4];
43 struct gl_buffer_object *bufferSave;
44
45 if (width > MAX_WIDTH)
46 width = MAX_WIDTH;
47
48 swrast_render_start(ctx);
49
50 /* read the data from framebuffer */
51 _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
52 width, x, y, CHAN_TYPE, data );
53
54 swrast_render_finish(ctx);
55
56 /* save PBO binding */
57 bufferSave = ctx->Unpack.BufferObj;
58 ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
59
60 _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
61
62 /* restore PBO binding */
63 ctx->Unpack.BufferObj = bufferSave;
64 }
65
66
67 void
68 _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
69 GLint x, GLint y, GLsizei width)
70 {
71 GLchan data[MAX_WIDTH][4];
72 struct gl_buffer_object *bufferSave;
73
74 if (width > MAX_WIDTH)
75 width = MAX_WIDTH;
76
77 swrast_render_start(ctx);
78
79 /* read the data from framebuffer */
80 _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
81 width, x, y, CHAN_TYPE, data );
82
83 swrast_render_finish(ctx);
84
85 /* save PBO binding */
86 bufferSave = ctx->Unpack.BufferObj;
87 ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
88
89 _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
90
91 /* restore PBO binding */
92 ctx->Unpack.BufferObj = bufferSave;
93 }
94
95
96 void
97 _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
98 GLenum internalFormat,
99 GLint x, GLint y, GLsizei width)
100 {
101 GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
102 struct gl_buffer_object *bufferSave;
103
104 swrast_render_start(ctx);
105
106 /* read the data from framebuffer */
107 _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
108 width, x, y, CHAN_TYPE, rgba );
109
110 swrast_render_finish(ctx);
111
112 /* save PBO binding */
113 bufferSave = ctx->Unpack.BufferObj;
114 ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
115
116 /* store as convolution filter */
117 _mesa_ConvolutionFilter1D(target, internalFormat, width,
118 GL_RGBA, CHAN_TYPE, rgba);
119
120 /* restore PBO binding */
121 ctx->Unpack.BufferObj = bufferSave;
122 }
123
124
125 void
126 _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
127 GLenum internalFormat,
128 GLint x, GLint y, GLsizei width, GLsizei height)
129 {
130 struct gl_pixelstore_attrib packSave;
131 GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
132 GLint i;
133 struct gl_buffer_object *bufferSave;
134
135 swrast_render_start(ctx);
136
137 /* read pixels from framebuffer */
138 for (i = 0; i < height; i++) {
139 _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
140 width, x, y + i, CHAN_TYPE, rgba[i] );
141 }
142
143 swrast_render_finish(ctx);
144
145 /*
146 * HACK: save & restore context state so we can store this as a
147 * convolution filter via the GL api. Doesn't call any callbacks
148 * hanging off ctx->Unpack statechanges.
149 */
150
151 packSave = ctx->Unpack; /* save pixel packing params */
152
153 ctx->Unpack.Alignment = 1;
154 ctx->Unpack.RowLength = MAX_CONVOLUTION_WIDTH;
155 ctx->Unpack.SkipPixels = 0;
156 ctx->Unpack.SkipRows = 0;
157 ctx->Unpack.ImageHeight = 0;
158 ctx->Unpack.SkipImages = 0;
159 ctx->Unpack.SwapBytes = GL_FALSE;
160 ctx->Unpack.LsbFirst = GL_FALSE;
161 ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
162 ctx->NewState |= _NEW_PACKUNPACK;
163
164 /* save PBO binding */
165 bufferSave = ctx->Unpack.BufferObj;
166 ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
167
168 _mesa_ConvolutionFilter2D(target, internalFormat, width, height,
169 GL_RGBA, CHAN_TYPE, rgba);
170
171 /* restore PBO binding */
172 ctx->Unpack.BufferObj = bufferSave;
173
174 ctx->Unpack = packSave; /* restore pixel packing params */
175 ctx->NewState |= _NEW_PACKUNPACK;
176 }