xref: /OK3568_Linux_fs/external/xserver/glx/renderpixswap.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3*4882a593Smuzhiyun  * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
6*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
7*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
8*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
10*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * The above copyright notice including the dates of first publication and
13*4882a593Smuzhiyun  * either this permission notice or a reference to
14*4882a593Smuzhiyun  * http://oss.sgi.com/projects/FreeB/
15*4882a593Smuzhiyun  * shall be included in all copies or substantial portions of the Software.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18*4882a593Smuzhiyun  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20*4882a593Smuzhiyun  * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21*4882a593Smuzhiyun  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22*4882a593Smuzhiyun  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23*4882a593Smuzhiyun  * SOFTWARE.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * Except as contained in this notice, the name of Silicon Graphics, Inc.
26*4882a593Smuzhiyun  * shall not be used in advertising or otherwise to promote the sale, use or
27*4882a593Smuzhiyun  * other dealings in this Software without prior written authorization from
28*4882a593Smuzhiyun  * Silicon Graphics, Inc.
29*4882a593Smuzhiyun  */
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
32*4882a593Smuzhiyun #include <dix-config.h>
33*4882a593Smuzhiyun #endif
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include "glxserver.h"
36*4882a593Smuzhiyun #include "unpack.h"
37*4882a593Smuzhiyun #include "indirect_dispatch.h"
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun void
__glXDispSwap_SeparableFilter2D(GLbyte * pc)40*4882a593Smuzhiyun __glXDispSwap_SeparableFilter2D(GLbyte * pc)
41*4882a593Smuzhiyun {
42*4882a593Smuzhiyun     __GLXdispatchConvolutionFilterHeader *hdr =
43*4882a593Smuzhiyun         (__GLXdispatchConvolutionFilterHeader *) pc;
44*4882a593Smuzhiyun     GLint hdrlen, image1len;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun     __GLX_DECLARE_SWAP_VARIABLES;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun     hdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->rowLength);
51*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->skipRows);
52*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->skipPixels);
53*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->alignment);
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->target);
56*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->internalformat);
57*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->width);
58*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->height);
59*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->format);
60*4882a593Smuzhiyun     __GLX_SWAP_INT((GLbyte *) &hdr->type);
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun     /*
63*4882a593Smuzhiyun      ** Just invert swapBytes flag; the GL will figure out if it needs to swap
64*4882a593Smuzhiyun      ** the pixel data.
65*4882a593Smuzhiyun      */
66*4882a593Smuzhiyun     glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
67*4882a593Smuzhiyun     glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
68*4882a593Smuzhiyun     glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
69*4882a593Smuzhiyun     glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
70*4882a593Smuzhiyun     glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
71*4882a593Smuzhiyun     glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun     /* XXX check this usage - internal code called
74*4882a593Smuzhiyun      ** a version without the packing parameters
75*4882a593Smuzhiyun      */
76*4882a593Smuzhiyun     image1len = __glXImageSize(hdr->format, hdr->type, 0, hdr->width, 1, 1,
77*4882a593Smuzhiyun                                0, hdr->rowLength, 0, hdr->skipRows,
78*4882a593Smuzhiyun                                hdr->alignment);
79*4882a593Smuzhiyun     image1len = __GLX_PAD(image1len);
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun     glSeparableFilter2D(hdr->target, hdr->internalformat, hdr->width,
82*4882a593Smuzhiyun                         hdr->height, hdr->format, hdr->type,
83*4882a593Smuzhiyun                         ((GLubyte *) hdr + hdrlen),
84*4882a593Smuzhiyun                         ((GLubyte *) hdr + hdrlen + image1len));
85*4882a593Smuzhiyun }
86