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"
41 ** These routines compute the size of variable-size returned parameters.
42 ** Unlike the similar routines that do the same thing for variable-size
43 ** incoming parameters, the samplegl library itself doesn't use these routines.
44 ** Hence, they are located here, in the GLX extension library.
48 __glReadPixels_size(GLenum format
, GLenum type
, GLint w
, GLint h
)
50 return __glXImageSize(format
, type
, 0, w
, h
, 1, 0, 0, 0, 0, 4);
54 __glGetMap_size(GLenum target
, GLenum query
)
56 GLint k
, order
= 0, majorMinor
[2];
59 ** Assume target and query are both valid.
65 case GL_MAP1_TEXTURE_COORD_1
:
66 case GL_MAP1_TEXTURE_COORD_2
:
67 case GL_MAP1_TEXTURE_COORD_3
:
68 case GL_MAP1_TEXTURE_COORD_4
:
69 case GL_MAP1_VERTEX_3
:
70 case GL_MAP1_VERTEX_4
:
73 k
= __glMap1d_size(target
);
74 glGetMapiv(target
, GL_ORDER
, &order
);
76 ** The query above might fail, but then order will be zero anyway.
88 case GL_MAP2_TEXTURE_COORD_1
:
89 case GL_MAP2_TEXTURE_COORD_2
:
90 case GL_MAP2_TEXTURE_COORD_3
:
91 case GL_MAP2_TEXTURE_COORD_4
:
92 case GL_MAP2_VERTEX_3
:
93 case GL_MAP2_VERTEX_4
:
96 k
= __glMap2d_size(target
);
97 majorMinor
[0] = majorMinor
[1] = 0;
98 glGetMapiv(target
, GL_ORDER
, majorMinor
);
100 ** The query above might fail, but then majorMinor will be zeroes
102 return majorMinor
[0] * majorMinor
[1] * k
;
114 __glGetMapdv_size(GLenum target
, GLenum query
)
116 return __glGetMap_size(target
, query
);
120 __glGetMapfv_size(GLenum target
, GLenum query
)
122 return __glGetMap_size(target
, query
);
126 __glGetMapiv_size(GLenum target
, GLenum query
)
128 return __glGetMap_size(target
, query
);
132 __glGetPixelMap_size(GLenum map
)
138 case GL_PIXEL_MAP_I_TO_I
:
139 query
= GL_PIXEL_MAP_I_TO_I_SIZE
;
141 case GL_PIXEL_MAP_S_TO_S
:
142 query
= GL_PIXEL_MAP_S_TO_S_SIZE
;
144 case GL_PIXEL_MAP_I_TO_R
:
145 query
= GL_PIXEL_MAP_I_TO_R_SIZE
;
147 case GL_PIXEL_MAP_I_TO_G
:
148 query
= GL_PIXEL_MAP_I_TO_G_SIZE
;
150 case GL_PIXEL_MAP_I_TO_B
:
151 query
= GL_PIXEL_MAP_I_TO_B_SIZE
;
153 case GL_PIXEL_MAP_I_TO_A
:
154 query
= GL_PIXEL_MAP_I_TO_A_SIZE
;
156 case GL_PIXEL_MAP_R_TO_R
:
157 query
= GL_PIXEL_MAP_R_TO_R_SIZE
;
159 case GL_PIXEL_MAP_G_TO_G
:
160 query
= GL_PIXEL_MAP_G_TO_G_SIZE
;
162 case GL_PIXEL_MAP_B_TO_B
:
163 query
= GL_PIXEL_MAP_B_TO_B_SIZE
;
165 case GL_PIXEL_MAP_A_TO_A
:
166 query
= GL_PIXEL_MAP_A_TO_A_SIZE
;
171 glGetIntegerv(query
, &size
);
176 __glGetPixelMapfv_size(GLenum map
)
178 return __glGetPixelMap_size(map
);
182 __glGetPixelMapuiv_size(GLenum map
)
184 return __glGetPixelMap_size(map
);
188 __glGetPixelMapusv_size(GLenum map
)
190 return __glGetPixelMap_size(map
);
194 __glGetTexImage_size(GLenum target
, GLint level
, GLenum format
,
195 GLenum type
, GLint width
, GLint height
, GLint depth
)
197 return __glXImageSize(format
, type
, target
, width
, height
, depth
,