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 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
36 #include "glxserver.h"
37 #include "singlesize.h"
38 #include "indirect_size_get.h"
39 #include "glapitable.h"
45 ** These routines compute the size of variable-size returned parameters.
46 ** Unlike the similar routines that do the same thing for variable-size
47 ** incoming parameters, the samplegl library itself doesn't use these routines.
48 ** Hence, they are located here, in the GLX extension library.
51 GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h)
53 return __glXImageSize( format, type, 0, w, h, 1, 0, 0, 0, 0, 4 );
56 GLint __glGetMap_size(GLenum target, GLenum query)
58 GLint k, order=0, majorMinor[2];
61 ** Assume target and query are both valid.
67 case GL_MAP1_TEXTURE_COORD_1:
68 case GL_MAP1_TEXTURE_COORD_2:
69 case GL_MAP1_TEXTURE_COORD_3:
70 case GL_MAP1_TEXTURE_COORD_4:
71 case GL_MAP1_VERTEX_3:
72 case GL_MAP1_VERTEX_4:
75 k = __glMap1d_size(target);
76 CALL_GetMapiv( GET_DISPATCH(), (target, GL_ORDER, &order) );
78 ** The query above might fail, but then order will be zero anyway.
90 case GL_MAP2_TEXTURE_COORD_1:
91 case GL_MAP2_TEXTURE_COORD_2:
92 case GL_MAP2_TEXTURE_COORD_3:
93 case GL_MAP2_TEXTURE_COORD_4:
94 case GL_MAP2_VERTEX_3:
95 case GL_MAP2_VERTEX_4:
98 k = __glMap2d_size(target);
99 majorMinor[0] = majorMinor[1] = 0;
100 CALL_GetMapiv( GET_DISPATCH(), (target, GL_ORDER, majorMinor) );
102 ** The query above might fail, but then majorMinor will be zeroes
104 return majorMinor[0] * majorMinor[1] * k;
115 GLint __glGetMapdv_size(GLenum target, GLenum query)
117 return __glGetMap_size(target, query);
120 GLint __glGetMapfv_size(GLenum target, GLenum query)
122 return __glGetMap_size(target, query);
125 GLint __glGetMapiv_size(GLenum target, GLenum query)
127 return __glGetMap_size(target, query);
130 GLint __glGetPixelMap_size(GLenum map)
136 case GL_PIXEL_MAP_I_TO_I:
137 query = GL_PIXEL_MAP_I_TO_I_SIZE;
139 case GL_PIXEL_MAP_S_TO_S:
140 query = GL_PIXEL_MAP_S_TO_S_SIZE;
142 case GL_PIXEL_MAP_I_TO_R:
143 query = GL_PIXEL_MAP_I_TO_R_SIZE;
145 case GL_PIXEL_MAP_I_TO_G:
146 query = GL_PIXEL_MAP_I_TO_G_SIZE;
148 case GL_PIXEL_MAP_I_TO_B:
149 query = GL_PIXEL_MAP_I_TO_B_SIZE;
151 case GL_PIXEL_MAP_I_TO_A:
152 query = GL_PIXEL_MAP_I_TO_A_SIZE;
154 case GL_PIXEL_MAP_R_TO_R:
155 query = GL_PIXEL_MAP_R_TO_R_SIZE;
157 case GL_PIXEL_MAP_G_TO_G:
158 query = GL_PIXEL_MAP_G_TO_G_SIZE;
160 case GL_PIXEL_MAP_B_TO_B:
161 query = GL_PIXEL_MAP_B_TO_B_SIZE;
163 case GL_PIXEL_MAP_A_TO_A:
164 query = GL_PIXEL_MAP_A_TO_A_SIZE;
169 CALL_GetIntegerv( GET_DISPATCH(), (query, &size) );
173 GLint __glGetPixelMapfv_size(GLenum map)
175 return __glGetPixelMap_size(map);
178 GLint __glGetPixelMapuiv_size(GLenum map)
180 return __glGetPixelMap_size(map);
183 GLint __glGetPixelMapusv_size(GLenum map)
185 return __glGetPixelMap_size(map);
188 GLint __glGetTexImage_size(GLenum target, GLint level, GLenum format,
189 GLenum type, GLint width, GLint height, GLint depth)
191 return __glXImageSize( format, type, target, width, height, depth,