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.
31
#include "glxclient.h"
33
#include "util/rounding.h"
35
#if !defined(__GNUC__)
36
# define __builtin_expect(x, y) x
40
* Send glPixelStore command to the server
42
* \param gc Current GLX context
43
* \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei
44
* \param pname Selector of which pixel parameter is to be set.
45
* \param param Value that \c pname is set to.
47
* \sa __indirect_glPixelStorei, __indirect_glPixelStoref
50
send_PixelStore(struct glx_context * gc, unsigned sop, GLenum pname,
53
Display *const dpy = gc->currentDpy;
54
const GLuint cmdlen = 8;
55
if (__builtin_expect(dpy != NULL, 1)) {
56
GLubyte const *pc = __glXSetupSingleRequest(gc, sop, cmdlen);
57
(void) memcpy((void *) (pc + 0), (void *) (&pname), 4);
58
(void) memcpy((void *) (pc + 4), param, 4);
66
** Specify parameters that control the storage format of pixel arrays.
69
__indirect_glPixelStoref(GLenum pname, GLfloat param)
71
struct glx_context *gc = __glXGetCurrentContext();
72
__GLXattribute *state = gc->client_state_private;
73
Display *dpy = gc->currentDpy;
80
case GL_PACK_ROW_LENGTH:
81
a = _mesa_lroundevenf(param);
82
if (((GLint) a) < 0) {
83
__glXSetError(gc, GL_INVALID_VALUE);
86
state->storePack.rowLength = a;
88
case GL_PACK_IMAGE_HEIGHT:
89
a = _mesa_lroundevenf(param);
90
if (((GLint) a) < 0) {
91
__glXSetError(gc, GL_INVALID_VALUE);
94
state->storePack.imageHeight = a;
96
case GL_PACK_SKIP_ROWS:
97
a = _mesa_lroundevenf(param);
98
if (((GLint) a) < 0) {
99
__glXSetError(gc, GL_INVALID_VALUE);
102
state->storePack.skipRows = a;
104
case GL_PACK_SKIP_PIXELS:
105
a = _mesa_lroundevenf(param);
106
if (((GLint) a) < 0) {
107
__glXSetError(gc, GL_INVALID_VALUE);
110
state->storePack.skipPixels = a;
112
case GL_PACK_SKIP_IMAGES:
113
a = _mesa_lroundevenf(param);
114
if (((GLint) a) < 0) {
115
__glXSetError(gc, GL_INVALID_VALUE);
118
state->storePack.skipImages = a;
120
case GL_PACK_ALIGNMENT:
121
a = _mesa_lroundevenf(param);
127
state->storePack.alignment = a;
130
__glXSetError(gc, GL_INVALID_VALUE);
134
case GL_PACK_SWAP_BYTES:
135
state->storePack.swapEndian = (param != 0);
137
case GL_PACK_LSB_FIRST:
138
state->storePack.lsbFirst = (param != 0);
141
case GL_UNPACK_ROW_LENGTH:
142
a = _mesa_lroundevenf(param);
143
if (((GLint) a) < 0) {
144
__glXSetError(gc, GL_INVALID_VALUE);
147
state->storeUnpack.rowLength = a;
149
case GL_UNPACK_IMAGE_HEIGHT:
150
a = _mesa_lroundevenf(param);
151
if (((GLint) a) < 0) {
152
__glXSetError(gc, GL_INVALID_VALUE);
155
state->storeUnpack.imageHeight = a;
157
case GL_UNPACK_SKIP_ROWS:
158
a = _mesa_lroundevenf(param);
159
if (((GLint) a) < 0) {
160
__glXSetError(gc, GL_INVALID_VALUE);
163
state->storeUnpack.skipRows = a;
165
case GL_UNPACK_SKIP_PIXELS:
166
a = _mesa_lroundevenf(param);
167
if (((GLint) a) < 0) {
168
__glXSetError(gc, GL_INVALID_VALUE);
171
state->storeUnpack.skipPixels = a;
173
case GL_UNPACK_SKIP_IMAGES:
174
a = _mesa_lroundevenf(param);
175
if (((GLint) a) < 0) {
176
__glXSetError(gc, GL_INVALID_VALUE);
179
state->storeUnpack.skipImages = a;
181
case GL_UNPACK_ALIGNMENT:
182
a = _mesa_lroundevenf(param);
188
state->storeUnpack.alignment = a;
191
__glXSetError(gc, GL_INVALID_VALUE);
195
case GL_UNPACK_SWAP_BYTES:
196
state->storeUnpack.swapEndian = (param != 0);
198
case GL_UNPACK_LSB_FIRST:
199
state->storeUnpack.lsbFirst = (param != 0);
202
/* Group all of the pixel store modes that need to be sent to the
203
* server here. Care must be used to only send modes to the server that
204
* won't affect the size of the data sent to or received from the
205
* server. GL_PACK_INVERT_MESA is safe in this respect, but other,
206
* future modes may not be.
208
case GL_PACK_INVERT_MESA:
209
send_PixelStore(gc, X_GLsop_PixelStoref, pname, ¶m);
213
__glXSetError(gc, GL_INVALID_ENUM);
219
__indirect_glPixelStorei(GLenum pname, GLint param)
221
struct glx_context *gc = __glXGetCurrentContext();
222
__GLXattribute *state = gc->client_state_private;
223
Display *dpy = gc->currentDpy;
229
case GL_PACK_ROW_LENGTH:
231
__glXSetError(gc, GL_INVALID_VALUE);
234
state->storePack.rowLength = param;
236
case GL_PACK_IMAGE_HEIGHT:
238
__glXSetError(gc, GL_INVALID_VALUE);
241
state->storePack.imageHeight = param;
243
case GL_PACK_SKIP_ROWS:
245
__glXSetError(gc, GL_INVALID_VALUE);
248
state->storePack.skipRows = param;
250
case GL_PACK_SKIP_PIXELS:
252
__glXSetError(gc, GL_INVALID_VALUE);
255
state->storePack.skipPixels = param;
257
case GL_PACK_SKIP_IMAGES:
259
__glXSetError(gc, GL_INVALID_VALUE);
262
state->storePack.skipImages = param;
264
case GL_PACK_ALIGNMENT:
270
state->storePack.alignment = param;
273
__glXSetError(gc, GL_INVALID_VALUE);
277
case GL_PACK_SWAP_BYTES:
278
state->storePack.swapEndian = (param != 0);
280
case GL_PACK_LSB_FIRST:
281
state->storePack.lsbFirst = (param != 0);
284
case GL_UNPACK_ROW_LENGTH:
286
__glXSetError(gc, GL_INVALID_VALUE);
289
state->storeUnpack.rowLength = param;
291
case GL_UNPACK_IMAGE_HEIGHT:
293
__glXSetError(gc, GL_INVALID_VALUE);
296
state->storeUnpack.imageHeight = param;
298
case GL_UNPACK_SKIP_ROWS:
300
__glXSetError(gc, GL_INVALID_VALUE);
303
state->storeUnpack.skipRows = param;
305
case GL_UNPACK_SKIP_PIXELS:
307
__glXSetError(gc, GL_INVALID_VALUE);
310
state->storeUnpack.skipPixels = param;
312
case GL_UNPACK_SKIP_IMAGES:
314
__glXSetError(gc, GL_INVALID_VALUE);
317
state->storeUnpack.skipImages = param;
319
case GL_UNPACK_ALIGNMENT:
325
state->storeUnpack.alignment = param;
328
__glXSetError(gc, GL_INVALID_VALUE);
332
case GL_UNPACK_SWAP_BYTES:
333
state->storeUnpack.swapEndian = (param != 0);
335
case GL_UNPACK_LSB_FIRST:
336
state->storeUnpack.lsbFirst = (param != 0);
339
/* Group all of the pixel store modes that need to be sent to the
340
* server here. Care must be used to only send modes to the server that
341
* won't affect the size of the data sent to or received from the
342
* server. GL_PACK_INVERT_MESA is safe in this respect, but other,
343
* future modes may not be.
345
case GL_PACK_INVERT_MESA:
346
send_PixelStore(gc, X_GLsop_PixelStorei, pname, ¶m);
350
__glXSetError(gc, GL_INVALID_ENUM);