1 /* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
3 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
4 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice including the dates of first publication and
14 * either this permission notice or a reference to
15 * http://oss.sgi.com/projects/FreeB/
16 * shall be included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Except as contained in this notice, the name of Silicon Graphics, Inc.
27 * shall not be used in advertising or otherwise to promote the sale, use or
28 * other dealings in this Software without prior written authorization from
29 * Silicon Graphics, Inc.
33 * (C) Copyright IBM Corporation 2005
34 * All Rights Reserved.
36 * Permission is hereby granted, free of charge, to any person obtaining a
37 * copy of this software and associated documentation files (the "Software"),
38 * to deal in the Software without restriction, including without limitation
39 * the rights to use, copy, modify, merge, publish, distribute, sub license,
40 * and/or sell copies of the Software, and to permit persons to whom the
41 * Software is furnished to do so, subject to the following conditions:
43 * The above copyright notice and this permission notice (including the next
44 * paragraph) shall be included in all copies or substantial portions of the
47 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
51 * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
52 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
53 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57 #include "packrender.h"
61 * Send a large image to the server. If necessary, a buffer is allocated
62 * to hold the unpacked data that is copied from the clients memory.
64 * \param gc Current GLX context
65 * \param compsize Size, in bytes, of the image portion
66 * \param dim Number of dimensions of the image
67 * \param width Width of the image
68 * \param height Height of the image, must be 1 for 1D images
69 * \param depth Depth of the image, must be 1 for 1D or 2D images
70 * \param format Format of the image
71 * \param type Data type of the image
72 * \param src Pointer to the image data
73 * \param pc Pointer to end of the command header
74 * \param modes Pointer to the pixel unpack data
77 * Modify this function so that \c NULL images are sent using
78 * \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this
79 * will eliminate the need to allocate a buffer for that case.
82 * The \c fastImageUnpack path, which is thankfully never used, is completely
86 __glXSendLargeImage(__GLXcontext
* gc
, GLint compsize
, GLint dim
,
87 GLint width
, GLint height
, GLint depth
,
88 GLenum format
, GLenum type
, const GLvoid
* src
,
89 GLubyte
* pc
, GLubyte
* modes
)
91 if (!gc
->fastImageUnpack
|| (src
== NULL
)) {
92 /* Allocate a temporary holding buffer */
93 GLubyte
*buf
= (GLubyte
*) Xmalloc(compsize
);
95 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
99 /* Apply pixel store unpack modes to copy data into buf */
101 (*gc
->fillImage
) (gc
, dim
, width
, height
, depth
, format
, type
,
106 (void) memcpy(modes
, __glXDefaultPixelStore
+ 4, 20);
109 (void) memcpy(modes
, __glXDefaultPixelStore
+ 0, 36);
113 /* Send large command */
114 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, buf
, compsize
);
120 /* Just send the data straight as is */
121 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, pc
, compsize
);
125 /************************************************************************/
128 * Implement GLX protocol for \c glSeparableFilter2D.
131 * The \c fastImageUnpack path, which is thankfully never used, is completely
135 __indirect_glSeparableFilter2D(GLenum target
, GLenum internalformat
,
136 GLsizei width
, GLsizei height
, GLenum format
,
137 GLenum type
, const GLvoid
* row
,
138 const GLvoid
* column
)
140 __GLX_DECLARE_VARIABLES();
141 GLuint compsize2
, hdrlen
, totalhdrlen
, image1len
, image2len
;
143 __GLX_LOAD_VARIABLES();
144 compsize
= __glImageSize(width
, 1, 1, format
, type
, 0);
145 compsize2
= __glImageSize(height
, 1, 1, format
, type
, 0);
146 totalhdrlen
= __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE
);
147 hdrlen
= __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE
);
148 image1len
= __GLX_PAD(compsize
);
149 image2len
= __GLX_PAD(compsize2
);
150 cmdlen
= totalhdrlen
+ image1len
+ image2len
;
154 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
155 /* Use GLXRender protocol to send small command */
156 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D
, cmdlen
);
157 __GLX_PUT_LONG(0, target
);
158 __GLX_PUT_LONG(4, internalformat
);
159 __GLX_PUT_LONG(8, width
);
160 __GLX_PUT_LONG(12, height
);
161 __GLX_PUT_LONG(16, format
);
162 __GLX_PUT_LONG(20, type
);
165 (*gc
->fillImage
) (gc
, 1, width
, 1, 1, format
, type
,
166 row
, pc
, pixelHeaderPC
);
170 (*gc
->fillImage
) (gc
, 1, height
, 1, 1, format
, type
,
174 if ((compsize
== 0) && (compsize2
== 0)) {
175 /* Setup default store modes */
176 (void) memcpy(pixelHeaderPC
, __glXDefaultPixelStore
+ 4, 20);
181 const GLint bufsize
= image1len
+ image2len
;
183 /* Use GLXRenderLarge protocol to send command */
184 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D
,
186 __GLX_PUT_LONG(0, target
);
187 __GLX_PUT_LONG(4, internalformat
);
188 __GLX_PUT_LONG(8, width
);
189 __GLX_PUT_LONG(12, height
);
190 __GLX_PUT_LONG(16, format
);
191 __GLX_PUT_LONG(20, type
);
194 if (!gc
->fastImageUnpack
) {
195 /* Allocate a temporary holding buffer */
196 GLubyte
*buf
= (GLubyte
*) Xmalloc(bufsize
);
198 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
201 (*gc
->fillImage
) (gc
, 1, width
, 1, 1, format
, type
, row
, buf
,
204 (*gc
->fillImage
) (gc
, 1, height
, 1, 1, format
, type
, column
,
205 buf
+ image1len
, pixelHeaderPC
);
207 /* Send large command */
208 __glXSendLargeCommand(gc
, gc
->pc
, (GLint
) (pc
- gc
->pc
), buf
,
214 /* Just send the data straight as is */
215 __glXSendLargeCommand(gc
, gc
->pc
, (GLint
) (pc
- gc
->pc
), pc
,