2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
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:
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.
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
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.
32 * (C) Copyright IBM Corporation 2005
33 * All Rights Reserved.
35 * Permission is hereby granted, free of charge, to any person obtaining a
36 * copy of this software and associated documentation files (the "Software"),
37 * to deal in the Software without restriction, including without limitation
38 * the rights to use, copy, modify, merge, publish, distribute, sub license,
39 * and/or sell copies of the Software, and to permit persons to whom the
40 * Software is furnished to do so, subject to the following conditions:
42 * The above copyright notice and this permission notice (including the next
43 * paragraph) shall be included in all copies or substantial portions of the
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
50 * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
51 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
52 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56 #include "packrender.h"
60 * Send a large image to the server. If necessary, a buffer is allocated
61 * to hold the unpacked data that is copied from the clients memory.
63 * \param gc Current GLX context
64 * \param compsize Size, in bytes, of the image portion
65 * \param dim Number of dimensions of the image
66 * \param width Width of the image
67 * \param height Height of the image, must be 1 for 1D images
68 * \param depth Depth of the image, must be 1 for 1D or 2D images
69 * \param format Format of the image
70 * \param type Data type of the image
71 * \param src Pointer to the image data
72 * \param pc Pointer to end of the command header
73 * \param modes Pointer to the pixel unpack data
76 * Modify this function so that \c NULL images are sent using
77 * \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this
78 * will eliminate the need to allocate a buffer for that case.
81 * The \c fastImageUnpack path, which is thankfully never used, is completely
85 __glXSendLargeImage(__GLXcontext
*gc
, GLint compsize
, GLint dim
,
86 GLint width
, GLint height
, GLint depth
,
87 GLenum format
, GLenum type
, const GLvoid
*src
,
88 GLubyte
*pc
, GLubyte
*modes
)
90 if ( !gc
->fastImageUnpack
|| (src
== NULL
) ) {
91 /* Allocate a temporary holding buffer */
92 GLubyte
*buf
= (GLubyte
*) Xmalloc(compsize
);
94 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
98 /* Apply pixel store unpack modes to copy data into buf */
100 (*gc
->fillImage
)(gc
, dim
, width
, height
, depth
, format
, type
,
105 (void) memcpy( modes
, __glXDefaultPixelStore
+ 4, 20 );
108 (void) memcpy( modes
, __glXDefaultPixelStore
+ 0, 36 );
112 /* Send large command */
113 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, buf
, compsize
);
118 /* Just send the data straight as is */
119 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, pc
, compsize
);
123 /************************************************************************/
126 * Implement GLX protocol for \c glSeparableFilter2D.
129 * The \c fastImageUnpack path, which is thankfully never used, is completely
132 void __indirect_glSeparableFilter2D(GLenum target
, GLenum internalformat
,
133 GLsizei width
, GLsizei height
, GLenum format
,
134 GLenum type
, const GLvoid
*row
,
135 const GLvoid
*column
)
137 __GLX_DECLARE_VARIABLES();
138 GLuint compsize2
, hdrlen
, totalhdrlen
, image1len
, image2len
;
140 __GLX_LOAD_VARIABLES();
141 compsize
= __glImageSize(width
, 1, 1, format
, type
, 0);
142 compsize2
= __glImageSize(height
, 1, 1, format
, type
, 0);
143 totalhdrlen
= __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE
);
144 hdrlen
= __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE
);
145 image1len
= __GLX_PAD(compsize
);
146 image2len
= __GLX_PAD(compsize2
);
147 cmdlen
= totalhdrlen
+ image1len
+ image2len
;
148 if (!gc
->currentDpy
) return;
150 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
151 /* Use GLXRender protocol to send small command */
152 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D
, cmdlen
);
153 __GLX_PUT_LONG(0,target
);
154 __GLX_PUT_LONG(4,internalformat
);
155 __GLX_PUT_LONG(8,width
);
156 __GLX_PUT_LONG(12,height
);
157 __GLX_PUT_LONG(16,format
);
158 __GLX_PUT_LONG(20,type
);
161 (*gc
->fillImage
)(gc
, 1, width
, 1, 1, format
, type
,
162 row
, pc
, pixelHeaderPC
);
166 (*gc
->fillImage
)(gc
, 1, height
, 1, 1, format
, type
,
170 if ((compsize
== 0) && (compsize2
== 0)) {
171 /* Setup default store modes */
172 (void) memcpy( pixelHeaderPC
, __glXDefaultPixelStore
+ 4, 20 );
176 const GLint bufsize
= image1len
+ image2len
;
178 /* Use GLXRenderLarge protocol to send command */
179 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D
,cmdlen
+4);
180 __GLX_PUT_LONG(0,target
);
181 __GLX_PUT_LONG(4,internalformat
);
182 __GLX_PUT_LONG(8,width
);
183 __GLX_PUT_LONG(12,height
);
184 __GLX_PUT_LONG(16,format
);
185 __GLX_PUT_LONG(20,type
);
188 if (!gc
->fastImageUnpack
) {
189 /* Allocate a temporary holding buffer */
190 GLubyte
*buf
= (GLubyte
*) Xmalloc(bufsize
);
192 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
195 (*gc
->fillImage
)(gc
, 1, width
, 1, 1, format
, type
, row
, buf
, pixelHeaderPC
);
197 (*gc
->fillImage
)(gc
, 1, height
, 1, 1, format
, type
, column
,
198 buf
+ image1len
, pixelHeaderPC
);
200 /* Send large command */
201 __glXSendLargeCommand(gc
, gc
->pc
, (GLint
)(pc
- gc
->pc
), buf
, bufsize
);
205 /* Just send the data straight as is */
206 __glXSendLargeCommand(gc
, gc
->pc
, (GLint
)(pc
- gc
->pc
), pc
, bufsize
);