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.
32 #include "packsingle.h"
37 #include "glapioffsets.h"
38 #include <GL/glxproto.h>
40 void __indirect_glGetSeparableFilter(GLenum target
, GLenum format
, GLenum type
,
41 GLvoid
*row
, GLvoid
*column
, GLvoid
*span
)
43 __GLX_SINGLE_DECLARE_VARIABLES();
44 const __GLXattribute
* state
;
45 xGLXGetSeparableFilterReply reply
;
46 GLubyte
*rowBuf
, *colBuf
;
49 __GLX_SINGLE_LOAD_VARIABLES();
50 state
= gc
->client_state_private
;
53 __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter
, __GLX_PAD(13));
54 __GLX_SINGLE_PUT_LONG(0,target
);
55 __GLX_SINGLE_PUT_LONG(4,format
);
56 __GLX_SINGLE_PUT_LONG(8,type
);
57 __GLX_SINGLE_PUT_CHAR(12,state
->storePack
.swapEndian
);
58 __GLX_SINGLE_READ_XREPLY();
59 compsize
= reply
.length
<< 2;
63 GLint widthsize
, heightsize
;
66 height
= reply
.height
;
68 widthsize
= __glImageSize(width
,1,1,format
, type
, 0);
69 heightsize
= __glImageSize(height
,1,1,format
, type
, 0);
71 /* Allocate a holding buffer to transform the data from */
72 rowBuf
= (GLubyte
*) Xmalloc(widthsize
);
75 _XEatData(dpy
, compsize
);
76 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
81 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf
),widthsize
);
82 __glEmptyImage(gc
, 1, width
, 1, 1, format
, type
, rowBuf
, row
);
83 Xfree((char*) rowBuf
);
85 colBuf
= (GLubyte
*) Xmalloc(heightsize
);
88 _XEatData(dpy
, compsize
- __GLX_PAD(widthsize
));
89 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
94 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf
),heightsize
);
95 __glEmptyImage(gc
, 1, height
, 1, 1, format
, type
, colBuf
, column
);
96 Xfree((char*) colBuf
);
100 ** don't modify user's buffer.
108 #define CONCAT(a,b) a ## b
109 #define NAME(o) CONCAT(gl_dispatch_stub_, o)
111 void NAME(_gloffset_GetSeparableFilter
)(GLenum target
, GLenum format
, GLenum type
,
112 GLvoid
*row
, GLvoid
*column
, GLvoid
*span
)
114 __GLXcontext
* const gc
= __glXGetCurrentContext();
116 #ifdef GLX_DIRECT_RENDERING
117 if (gc
->driContext
) {
118 CALL_GetSeparableFilter(GET_DISPATCH(),
119 (target
, format
, type
, row
, column
, span
));
124 Display
*const dpy
= gc
->currentDpy
;
125 const GLuint cmdlen
= __GLX_PAD(13);
128 const __GLXattribute
* const state
= gc
->client_state_private
;
129 xGLXGetSeparableFilterReply reply
;
131 __glXSetupVendorRequest(gc
, X_GLXVendorPrivateWithReply
,
132 X_GLvop_GetSeparableFilterEXT
, cmdlen
);
136 (void) memcpy((void *) (pc
+ 0), (void *) (&target
), 4);
137 (void) memcpy((void *) (pc
+ 4), (void *) (&format
), 4);
138 (void) memcpy((void *) (pc
+ 8), (void *) (&type
), 4);
139 *(int8_t *) (pc
+ 12) = state
->storePack
.swapEndian
;
141 (void) _XReply(dpy
, (xReply
*) & reply
, 0, False
);
143 compsize
= reply
.length
<< 2;
146 const GLint width
= reply
.width
;
147 const GLint height
= reply
.height
;
148 const GLint widthsize
=
149 __glImageSize(width
, 1, 1, format
, type
, 0);
150 const GLint heightsize
=
151 __glImageSize(height
, 1, 1, format
, type
, 0);
152 GLubyte
* const buf
=
153 (GLubyte
*) Xmalloc((widthsize
> heightsize
) ? widthsize
: heightsize
);
156 /* Throw data away */
157 _XEatData(dpy
, compsize
);
158 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
166 extra
= 4 - (widthsize
& 3);
167 _XRead(dpy
, (char *)buf
, widthsize
);
169 _XEatData(dpy
, extra
);
172 __glEmptyImage(gc
, 1, width
, 1, 1, format
, type
, buf
,
175 extra
= 4 - (heightsize
& 3);
176 _XRead(dpy
, (char *)buf
, heightsize
);
178 _XEatData(dpy
, extra
);
181 __glEmptyImage(gc
, 1, height
, 1, 1, format
, type
, buf
,