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 * SPDX-License-Identifier: SGI-B-2.0
6 */
7
8 #include "packsingle.h"
9 #include "indirect.h"
10 #include "glapi.h"
11 #include <GL/glxproto.h>
12
13 void
__indirect_glGetSeparableFilter(GLenum target,GLenum format,GLenum type,GLvoid * row,GLvoid * column,GLvoid * span)14 __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
15 GLvoid * row, GLvoid * column, GLvoid * span)
16 {
17 __GLX_SINGLE_DECLARE_VARIABLES();
18 const __GLXattribute *state;
19 xGLXGetSeparableFilterReply reply;
20 GLubyte *rowBuf, *colBuf;
21
22 if (!dpy)
23 return;
24 __GLX_SINGLE_LOAD_VARIABLES();
25 state = gc->client_state_private;
26
27 /* Send request */
28 __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
29 __GLX_SINGLE_PUT_LONG(0, target);
30 __GLX_SINGLE_PUT_LONG(4, format);
31 __GLX_SINGLE_PUT_LONG(8, type);
32 __GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian);
33 __GLX_SINGLE_READ_XREPLY();
34 compsize = reply.length << 2;
35
36 if (compsize != 0) {
37 GLint width, height;
38 GLint widthsize, heightsize;
39
40 width = reply.width;
41 height = reply.height;
42
43 widthsize = __glImageSize(width, 1, 1, format, type, 0);
44 heightsize = __glImageSize(height, 1, 1, format, type, 0);
45
46 /* Allocate a holding buffer to transform the data from */
47 rowBuf = malloc(widthsize);
48 if (!rowBuf) {
49 /* Throw data away */
50 _XEatData(dpy, compsize);
51 __glXSetError(gc, GL_OUT_OF_MEMORY);
52 UnlockDisplay(dpy);
53 SyncHandle();
54 return;
55 }
56 else {
57 __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize);
58 __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
59 free((char *) rowBuf);
60 }
61 colBuf = malloc(heightsize);
62 if (!colBuf) {
63 /* Throw data away */
64 _XEatData(dpy, compsize - __GLX_PAD(widthsize));
65 __glXSetError(gc, GL_OUT_OF_MEMORY);
66 UnlockDisplay(dpy);
67 SyncHandle();
68 return;
69 }
70 else {
71 __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize);
72 __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
73 free((char *) colBuf);
74 }
75 }
76 else {
77 /*
78 ** don't modify user's buffer.
79 */
80 }
81 __GLX_SINGLE_END();
82
83 }
84