Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / dmx / glxProxy / renderpixswap.c
CommitLineData
a09e091a
JB
1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included 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 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30
31#include "glxserver.h"
32#include "unpack.h"
33#include "g_disptab.h"
34
35void
36__glXDispSwap_PolygonStipple(GLbyte * pc)
37{
38 __GLXpixelHeader *hdr = (__GLXpixelHeader *) pc;
39
40 __GLX_DECLARE_SWAP_VARIABLES;
41
42 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
43 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
44 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
45 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
46
47 hdr->swapBytes = !hdr->swapBytes;
48}
49
50void
51__glXDispSwap_Bitmap(GLbyte * pc)
52{
53 __GLXdispatchBitmapHeader *hdr = (__GLXdispatchBitmapHeader *) pc;
54
55 __GLX_DECLARE_SWAP_VARIABLES;
56
57 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
58 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
59 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
60 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
61
62 __GLX_SWAP_INT((GLbyte *) &hdr->width);
63 __GLX_SWAP_INT((GLbyte *) &hdr->height);
64 __GLX_SWAP_FLOAT((GLbyte *) &hdr->xorig);
65 __GLX_SWAP_FLOAT((GLbyte *) &hdr->yorig);
66 __GLX_SWAP_FLOAT((GLbyte *) &hdr->xmove);
67 __GLX_SWAP_FLOAT((GLbyte *) &hdr->ymove);
68
69 hdr->swapBytes = !hdr->swapBytes;
70
71}
72
73void
74__glXDispSwap_TexImage1D(GLbyte * pc)
75{
76 __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
77
78 __GLX_DECLARE_SWAP_VARIABLES;
79
80 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
81 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
82 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
83 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
84
85 __GLX_SWAP_INT((GLbyte *) &hdr->target);
86 __GLX_SWAP_INT((GLbyte *) &hdr->level);
87 __GLX_SWAP_INT((GLbyte *) &hdr->components);
88 __GLX_SWAP_INT((GLbyte *) &hdr->width);
89 __GLX_SWAP_INT((GLbyte *) &hdr->height);
90 __GLX_SWAP_INT((GLbyte *) &hdr->border);
91 __GLX_SWAP_INT((GLbyte *) &hdr->format);
92 __GLX_SWAP_INT((GLbyte *) &hdr->type);
93
94 /*
95 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
96 ** the pixel data.
97 */
98 hdr->swapBytes = !hdr->swapBytes;
99}
100
101void
102__glXDispSwap_TexImage2D(GLbyte * pc)
103{
104 __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
105
106 __GLX_DECLARE_SWAP_VARIABLES;
107
108 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
109 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
110 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
111 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
112
113 __GLX_SWAP_INT((GLbyte *) &hdr->target);
114 __GLX_SWAP_INT((GLbyte *) &hdr->level);
115 __GLX_SWAP_INT((GLbyte *) &hdr->components);
116 __GLX_SWAP_INT((GLbyte *) &hdr->width);
117 __GLX_SWAP_INT((GLbyte *) &hdr->height);
118 __GLX_SWAP_INT((GLbyte *) &hdr->border);
119 __GLX_SWAP_INT((GLbyte *) &hdr->format);
120 __GLX_SWAP_INT((GLbyte *) &hdr->type);
121
122 /*
123 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
124 ** the pixel data.
125 */
126 hdr->swapBytes = !hdr->swapBytes;
127}
128
129void
130__glXDispSwap_TexImage3D(GLbyte * pc)
131{
132 __GLXdispatchTexImage3DHeader *hdr = (__GLXdispatchTexImage3DHeader *) pc;
133
134 __GLX_DECLARE_SWAP_VARIABLES;
135
136 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
137 __GLX_SWAP_INT((GLbyte *) &hdr->imageHeight);
138 __GLX_SWAP_INT((GLbyte *) &hdr->imageDepth);
139 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
140 __GLX_SWAP_INT((GLbyte *) &hdr->skipImages);
141 __GLX_SWAP_INT((GLbyte *) &hdr->skipVolumes);
142 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
143 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
144
145 __GLX_SWAP_INT((GLbyte *) &hdr->target);
146 __GLX_SWAP_INT((GLbyte *) &hdr->level);
147 __GLX_SWAP_INT((GLbyte *) &hdr->internalformat);
148 __GLX_SWAP_INT((GLbyte *) &hdr->width);
149 __GLX_SWAP_INT((GLbyte *) &hdr->height);
150 __GLX_SWAP_INT((GLbyte *) &hdr->depth);
151 __GLX_SWAP_INT((GLbyte *) &hdr->size4d);
152 __GLX_SWAP_INT((GLbyte *) &hdr->border);
153 __GLX_SWAP_INT((GLbyte *) &hdr->format);
154 __GLX_SWAP_INT((GLbyte *) &hdr->type);
155
156 /*
157 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
158 ** the pixel data.
159 */
160 hdr->swapBytes = !hdr->swapBytes;
161}
162
163void
164__glXDispSwap_DrawPixels(GLbyte * pc)
165{
166 __GLXdispatchDrawPixelsHeader *hdr = (__GLXdispatchDrawPixelsHeader *) pc;
167
168 __GLX_DECLARE_SWAP_VARIABLES;
169
170 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
171 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
172 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
173 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
174
175 __GLX_SWAP_INT((GLbyte *) &hdr->width);
176 __GLX_SWAP_INT((GLbyte *) &hdr->height);
177 __GLX_SWAP_INT((GLbyte *) &hdr->format);
178 __GLX_SWAP_INT((GLbyte *) &hdr->type);
179
180 /*
181 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
182 ** the pixel data.
183 */
184 hdr->swapBytes = !hdr->swapBytes;
185}
186
187void
188__glXDispSwap_TexSubImage1D(GLbyte * pc)
189{
190 __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
191
192 __GLX_DECLARE_SWAP_VARIABLES;
193
194 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
195 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
196 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
197 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
198
199 __GLX_SWAP_INT((GLbyte *) &hdr->target);
200 __GLX_SWAP_INT((GLbyte *) &hdr->level);
201 __GLX_SWAP_INT((GLbyte *) &hdr->xoffset);
202 __GLX_SWAP_INT((GLbyte *) &hdr->width);
203 __GLX_SWAP_INT((GLbyte *) &hdr->format);
204 __GLX_SWAP_INT((GLbyte *) &hdr->type);
205
206 /*
207 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
208 ** the pixel data.
209 */
210 hdr->swapBytes = !hdr->swapBytes;
211}
212
213void
214__glXDispSwap_TexSubImage2D(GLbyte * pc)
215{
216 __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
217
218 __GLX_DECLARE_SWAP_VARIABLES;
219
220 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
221 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
222 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
223 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
224
225 __GLX_SWAP_INT((GLbyte *) &hdr->target);
226 __GLX_SWAP_INT((GLbyte *) &hdr->level);
227 __GLX_SWAP_INT((GLbyte *) &hdr->xoffset);
228 __GLX_SWAP_INT((GLbyte *) &hdr->yoffset);
229 __GLX_SWAP_INT((GLbyte *) &hdr->width);
230 __GLX_SWAP_INT((GLbyte *) &hdr->height);
231 __GLX_SWAP_INT((GLbyte *) &hdr->format);
232 __GLX_SWAP_INT((GLbyte *) &hdr->type);
233
234 /*
235 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
236 ** the pixel data.
237 */
238 hdr->swapBytes = !hdr->swapBytes;
239}
240
241void
242__glXDispSwap_TexSubImage3D(GLbyte * pc)
243{
244 __GLXdispatchTexSubImage3DHeader *hdr =
245 (__GLXdispatchTexSubImage3DHeader *) pc;
246
247 __GLX_DECLARE_SWAP_VARIABLES;
248
249 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
250 __GLX_SWAP_INT((GLbyte *) &hdr->imageHeight);
251 __GLX_SWAP_INT((GLbyte *) &hdr->imageDepth);
252 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
253 __GLX_SWAP_INT((GLbyte *) &hdr->skipImages);
254 __GLX_SWAP_INT((GLbyte *) &hdr->skipVolumes);
255 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
256 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
257
258 __GLX_SWAP_INT((GLbyte *) &hdr->target);
259 __GLX_SWAP_INT((GLbyte *) &hdr->level);
260 __GLX_SWAP_INT((GLbyte *) &hdr->xoffset);
261 __GLX_SWAP_INT((GLbyte *) &hdr->yoffset);
262 __GLX_SWAP_INT((GLbyte *) &hdr->zoffset);
263 __GLX_SWAP_INT((GLbyte *) &hdr->width);
264 __GLX_SWAP_INT((GLbyte *) &hdr->height);
265 __GLX_SWAP_INT((GLbyte *) &hdr->depth);
266 __GLX_SWAP_INT((GLbyte *) &hdr->size4d);
267 __GLX_SWAP_INT((GLbyte *) &hdr->format);
268 __GLX_SWAP_INT((GLbyte *) &hdr->type);
269
270 /*
271 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
272 ** the pixel data.
273 */
274 hdr->swapBytes = !hdr->swapBytes;
275}
276
277void
278__glXDispSwap_ColorTable(GLbyte * pc)
279{
280 __GLXdispatchColorTableHeader *hdr = (__GLXdispatchColorTableHeader *) pc;
281
282 __GLX_DECLARE_SWAP_VARIABLES;
283
284 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
285 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
286 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
287 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
288
289 __GLX_SWAP_INT((GLbyte *) &hdr->target);
290 __GLX_SWAP_INT((GLbyte *) &hdr->internalformat);
291 __GLX_SWAP_INT((GLbyte *) &hdr->width);
292 __GLX_SWAP_INT((GLbyte *) &hdr->format);
293 __GLX_SWAP_INT((GLbyte *) &hdr->type);
294
295 /*
296 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
297 ** the pixel data.
298 */
299 hdr->swapBytes = !hdr->swapBytes;
300}
301
302void
303__glXDispSwap_ColorSubTable(GLbyte * pc)
304{
305 __GLXdispatchColorSubTableHeader *hdr =
306 (__GLXdispatchColorSubTableHeader *) pc;
307 __GLX_DECLARE_SWAP_VARIABLES;
308
309 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
310 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
311 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
312 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
313
314 __GLX_SWAP_INT((GLbyte *) &hdr->target);
315 __GLX_SWAP_INT((GLbyte *) &hdr->start);
316 __GLX_SWAP_INT((GLbyte *) &hdr->count);
317 __GLX_SWAP_INT((GLbyte *) &hdr->format);
318 __GLX_SWAP_INT((GLbyte *) &hdr->type);
319
320 /*
321 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
322 ** the pixel data.
323 */
324 hdr->swapBytes = !hdr->swapBytes;
325}
326
327void
328__glXDispSwap_ConvolutionFilter1D(GLbyte * pc)
329{
330 __GLXdispatchConvolutionFilterHeader *hdr =
331 (__GLXdispatchConvolutionFilterHeader *) pc;
332 __GLX_DECLARE_SWAP_VARIABLES;
333
334 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
335 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
336 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
337 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
338
339 __GLX_SWAP_INT((GLbyte *) &hdr->target);
340 __GLX_SWAP_INT((GLbyte *) &hdr->internalformat);
341 __GLX_SWAP_INT((GLbyte *) &hdr->width);
342 __GLX_SWAP_INT((GLbyte *) &hdr->format);
343 __GLX_SWAP_INT((GLbyte *) &hdr->type);
344
345 /*
346 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
347 ** the pixel data.
348 */
349 hdr->swapBytes = !hdr->swapBytes;
350}
351
352void
353__glXDispSwap_ConvolutionFilter2D(GLbyte * pc)
354{
355 __GLXdispatchConvolutionFilterHeader *hdr =
356 (__GLXdispatchConvolutionFilterHeader *) pc;
357 __GLX_DECLARE_SWAP_VARIABLES;
358
359 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
360 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
361 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
362 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
363
364 __GLX_SWAP_INT((GLbyte *) &hdr->target);
365 __GLX_SWAP_INT((GLbyte *) &hdr->internalformat);
366 __GLX_SWAP_INT((GLbyte *) &hdr->width);
367 __GLX_SWAP_INT((GLbyte *) &hdr->height);
368 __GLX_SWAP_INT((GLbyte *) &hdr->format);
369 __GLX_SWAP_INT((GLbyte *) &hdr->type);
370
371 /*
372 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
373 ** the pixel data.
374 */
375 hdr->swapBytes = !hdr->swapBytes;
376}
377
378void
379__glXDispSwap_SeparableFilter2D(GLbyte * pc)
380{
381 __GLXdispatchConvolutionFilterHeader *hdr =
382 (__GLXdispatchConvolutionFilterHeader *) pc;
383 GLint hdrlen;
384
385 __GLX_DECLARE_SWAP_VARIABLES;
386
387 hdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
388
389 __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
390 __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
391 __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
392 __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
393
394 __GLX_SWAP_INT((GLbyte *) &hdr->target);
395 __GLX_SWAP_INT((GLbyte *) &hdr->internalformat);
396 __GLX_SWAP_INT((GLbyte *) &hdr->width);
397 __GLX_SWAP_INT((GLbyte *) &hdr->height);
398 __GLX_SWAP_INT((GLbyte *) &hdr->format);
399 __GLX_SWAP_INT((GLbyte *) &hdr->type);
400
401 /*
402 ** Just invert swapBytes flag; the GL will figure out if it needs to swap
403 ** the pixel data.
404 */
405 hdr->swapBytes = !hdr->swapBytes;
406}