Rev 135 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
135 | giacomo | 1 | /* $Id: tmp_texformat.h,v 1.1 2003-04-24 14:24:01 giacomo Exp $ */ |
2 | |||
3 | /* |
||
4 | * Mesa 3-D graphics library |
||
5 | * Version: 4.1 |
||
6 | * |
||
7 | * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
||
8 | * |
||
9 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
10 | * copy of this software and associated documentation files (the "Software"), |
||
11 | * to deal in the Software without restriction, including without limitation |
||
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
13 | * and/or sell copies of the Software, and to permit persons to whom the |
||
14 | * Software is furnished to do so, subject to the following conditions: |
||
15 | * |
||
16 | * The above copyright notice and this permission notice shall be included |
||
17 | * in all copies or substantial portions of the Software. |
||
18 | * |
||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
25 | * |
||
26 | * Authors: |
||
27 | * Gareth Hughes |
||
28 | * Brian Paul |
||
29 | */ |
||
30 | |||
31 | |||
32 | /* |
||
33 | * This template file generates texel fetch functions for 1-D, 2-D and 3-D |
||
34 | * texture images. |
||
35 | */ |
||
36 | |||
37 | |||
38 | #if DIM == 1 |
||
39 | |||
40 | #define CHAN_SRC( t, i, j, k, sz ) \ |
||
41 | ((GLchan *)(t)->Data + (i) * (sz)) |
||
42 | #define UBYTE_SRC( t, i, j, k, sz ) \ |
||
43 | ((GLubyte *)(t)->Data + (i) * (sz)) |
||
44 | #define USHORT_SRC( t, i, j, k ) \ |
||
45 | ((GLushort *)(t)->Data + (i)) |
||
46 | #define FLOAT_SRC( t, i, j, k ) \ |
||
47 | ((GLfloat *)(t)->Data + (i)) |
||
48 | |||
49 | #define FETCH(x) fetch_1d_texel_##x |
||
50 | |||
51 | #elif DIM == 2 |
||
52 | |||
53 | #define CHAN_SRC( t, i, j, k, sz ) \ |
||
54 | ((GLchan *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)) |
||
55 | #define UBYTE_SRC( t, i, j, k, sz ) \ |
||
56 | ((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)) |
||
57 | #define USHORT_SRC( t, i, j, k ) \ |
||
58 | ((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i))) |
||
59 | #define FLOAT_SRC( t, i, j, k ) \ |
||
60 | ((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i))) |
||
61 | |||
62 | #define FETCH(x) fetch_2d_texel_##x |
||
63 | |||
64 | #elif DIM == 3 |
||
65 | |||
66 | #define CHAN_SRC( t, i, j, k, sz ) \ |
||
67 | (GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
||
68 | (t)->RowStride + (i)) * (sz) |
||
69 | #define UBYTE_SRC( t, i, j, k, sz ) \ |
||
70 | ((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
||
71 | (t)->RowStride + (i)) * (sz)) |
||
72 | #define USHORT_SRC( t, i, j, k ) \ |
||
73 | ((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
||
74 | (t)->RowStride + (i))) |
||
75 | #define FLOAT_SRC( t, i, j, k ) \ |
||
76 | ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
||
77 | (t)->RowStride + (i))) |
||
78 | |||
79 | #define FETCH(x) fetch_3d_texel_##x |
||
80 | |||
81 | #else |
||
82 | #error illegal number of texture dimensions |
||
83 | #endif |
||
84 | |||
85 | |||
86 | static void FETCH(rgba)( const struct gl_texture_image *texImage, |
||
87 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
88 | { |
||
89 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); |
||
90 | GLchan *rgba = (GLchan *) texel; |
||
91 | COPY_CHAN4( rgba, src ); |
||
92 | } |
||
93 | |||
94 | static void FETCH(rgb)( const struct gl_texture_image *texImage, |
||
95 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
96 | { |
||
97 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 ); |
||
98 | GLchan *rgba = (GLchan *) texel; |
||
99 | rgba[RCOMP] = src[0]; |
||
100 | rgba[GCOMP] = src[1]; |
||
101 | rgba[BCOMP] = src[2]; |
||
102 | rgba[ACOMP] = CHAN_MAX; |
||
103 | } |
||
104 | |||
105 | static void FETCH(alpha)( const struct gl_texture_image *texImage, |
||
106 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
107 | { |
||
108 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
||
109 | GLchan *rgba = (GLchan *) texel; |
||
110 | rgba[RCOMP] = 0; |
||
111 | rgba[GCOMP] = 0; |
||
112 | rgba[BCOMP] = 0; |
||
113 | rgba[ACOMP] = src[0]; |
||
114 | } |
||
115 | |||
116 | static void FETCH(luminance)( const struct gl_texture_image *texImage, |
||
117 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
118 | { |
||
119 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
||
120 | GLchan *rgba = (GLchan *) texel; |
||
121 | rgba[RCOMP] = src[0]; |
||
122 | rgba[GCOMP] = src[0]; |
||
123 | rgba[BCOMP] = src[0]; |
||
124 | rgba[ACOMP] = CHAN_MAX; |
||
125 | } |
||
126 | |||
127 | static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, |
||
128 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
129 | { |
||
130 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 ); |
||
131 | GLchan *rgba = (GLchan *) texel; |
||
132 | rgba[RCOMP] = src[0]; |
||
133 | rgba[GCOMP] = src[0]; |
||
134 | rgba[BCOMP] = src[0]; |
||
135 | rgba[ACOMP] = src[1]; |
||
136 | } |
||
137 | |||
138 | static void FETCH(intensity)( const struct gl_texture_image *texImage, |
||
139 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
140 | { |
||
141 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
||
142 | GLchan *rgba = (GLchan *) texel; |
||
143 | rgba[RCOMP] = src[0]; |
||
144 | rgba[GCOMP] = src[0]; |
||
145 | rgba[BCOMP] = src[0]; |
||
146 | rgba[ACOMP] = src[0]; |
||
147 | } |
||
148 | |||
149 | static void FETCH(color_index)( const struct gl_texture_image *texImage, |
||
150 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
151 | { |
||
152 | const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
||
153 | GLchan *index = (GLchan *) texel; |
||
154 | *index = *src; |
||
155 | } |
||
156 | |||
157 | static void FETCH(depth_component)( const struct gl_texture_image *texImage, |
||
158 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
159 | { |
||
160 | const GLfloat *src = FLOAT_SRC( texImage, i, j, k ); |
||
161 | GLfloat *depth = (GLfloat *) texel; |
||
162 | *depth = *src; |
||
163 | } |
||
164 | |||
165 | static void FETCH(rgba8888)( const struct gl_texture_image *texImage, |
||
166 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
167 | { |
||
168 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
||
169 | GLchan *rgba = (GLchan *) texel; |
||
170 | rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); |
||
171 | rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); |
||
172 | rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); |
||
173 | rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
||
174 | } |
||
175 | |||
176 | static void FETCH(argb8888)( const struct gl_texture_image *texImage, |
||
177 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
178 | { |
||
179 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
||
180 | GLchan *rgba = (GLchan *) texel; |
||
181 | rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
||
182 | rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
||
183 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
184 | rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); |
||
185 | } |
||
186 | |||
187 | static void FETCH(rgb888)( const struct gl_texture_image *texImage, |
||
188 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
189 | { |
||
190 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); |
||
191 | GLchan *rgba = (GLchan *) texel; |
||
192 | rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
||
193 | rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
||
194 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
195 | rgba[ACOMP] = CHAN_MAX; |
||
196 | } |
||
197 | |||
198 | static void FETCH(rgb565)( const struct gl_texture_image *texImage, |
||
199 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
200 | { |
||
201 | const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
||
202 | const GLushort s = *src; |
||
203 | GLchan *rgba = (GLchan *) texel; |
||
204 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); |
||
205 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); |
||
206 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); |
||
207 | rgba[ACOMP] = CHAN_MAX; |
||
208 | } |
||
209 | |||
210 | static void FETCH(argb4444)( const struct gl_texture_image *texImage, |
||
211 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
212 | { |
||
213 | const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
||
214 | const GLushort s = *src; |
||
215 | GLchan *rgba = (GLchan *) texel; |
||
216 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); |
||
217 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); |
||
218 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); |
||
219 | rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); |
||
220 | } |
||
221 | |||
222 | static void FETCH(argb1555)( const struct gl_texture_image *texImage, |
||
223 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
224 | { |
||
225 | const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
||
226 | const GLushort s = *src; |
||
227 | GLchan *rgba = (GLchan *) texel; |
||
228 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); |
||
229 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); |
||
230 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); |
||
231 | rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); |
||
232 | } |
||
233 | |||
234 | static void FETCH(al88)( const struct gl_texture_image *texImage, |
||
235 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
236 | { |
||
237 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); |
||
238 | GLchan *rgba = (GLchan *) texel; |
||
239 | rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
240 | rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
241 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
242 | rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); |
||
243 | } |
||
244 | |||
245 | static void FETCH(rgb332)( const struct gl_texture_image *texImage, |
||
246 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
247 | { |
||
248 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
||
249 | const GLubyte s = *src; |
||
250 | GLchan *rgba = (GLchan *) texel; |
||
251 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); |
||
252 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); |
||
253 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); |
||
254 | rgba[ACOMP] = CHAN_MAX; |
||
255 | } |
||
256 | |||
257 | static void FETCH(a8)( const struct gl_texture_image *texImage, |
||
258 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
259 | { |
||
260 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
||
261 | GLchan *rgba = (GLchan *) texel; |
||
262 | rgba[RCOMP] = 0; |
||
263 | rgba[GCOMP] = 0; |
||
264 | rgba[BCOMP] = 0; |
||
265 | rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
||
266 | } |
||
267 | |||
268 | static void FETCH(l8)( const struct gl_texture_image *texImage, |
||
269 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
270 | { |
||
271 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
||
272 | GLchan *rgba = (GLchan *) texel; |
||
273 | rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
274 | rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
275 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
276 | rgba[ACOMP] = CHAN_MAX; |
||
277 | } |
||
278 | |||
279 | static void FETCH(i8)( const struct gl_texture_image *texImage, |
||
280 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
281 | { |
||
282 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
||
283 | GLchan *rgba = (GLchan *) texel; |
||
284 | rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
285 | rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
286 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
287 | rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
||
288 | } |
||
289 | |||
290 | static void FETCH(ci8)( const struct gl_texture_image *texImage, |
||
291 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
292 | { |
||
293 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
||
294 | GLchan *index = (GLchan *) texel; |
||
295 | *index = UBYTE_TO_CHAN( *src ); |
||
296 | } |
||
297 | |||
298 | /* XXX this may break if GLchan != GLubyte */ |
||
299 | static void FETCH(ycbcr)( const struct gl_texture_image *texImage, |
||
300 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
301 | { |
||
302 | const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ |
||
303 | const GLushort *src1 = src0 + 1; /* odd */ |
||
304 | const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ |
||
305 | const GLubyte cb = *src0 & 0xff; /* chroma U */ |
||
306 | const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ |
||
307 | const GLubyte cr = *src1 & 0xff; /* chroma V */ |
||
308 | GLchan *rgba = (GLchan *) texel; |
||
309 | GLint r, g, b; |
||
310 | if (i & 1) { |
||
311 | /* odd pixel: use y1,cr,cb */ |
||
312 | r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128)); |
||
313 | g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
||
314 | b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128)); |
||
315 | } |
||
316 | else { |
||
317 | /* even pixel: use y0,cr,cb */ |
||
318 | r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128)); |
||
319 | g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
||
320 | b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); |
||
321 | } |
||
322 | rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX); |
||
323 | rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX); |
||
324 | rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX); |
||
325 | rgba[ACOMP] = CHAN_MAX; |
||
326 | } |
||
327 | |||
328 | /* XXX this may break if GLchan != GLubyte */ |
||
329 | static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, |
||
330 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
331 | { |
||
332 | const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ |
||
333 | const GLushort *src1 = src0 + 1; /* odd */ |
||
334 | const GLubyte y0 = *src0 & 0xff; /* luminance */ |
||
335 | const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma U */ |
||
336 | const GLubyte y1 = *src1 & 0xff; /* luminance */ |
||
337 | const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma V */ |
||
338 | GLchan *rgba = (GLchan *) texel; |
||
339 | GLint r, g, b; |
||
340 | if (i & 1) { |
||
341 | /* odd pixel: use y1,cr,cb */ |
||
342 | r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128)); |
||
343 | g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
||
344 | b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128)); |
||
345 | } |
||
346 | else { |
||
347 | /* even pixel: use y0,cr,cb */ |
||
348 | r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128)); |
||
349 | g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
||
350 | b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); |
||
351 | } |
||
352 | rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX); |
||
353 | rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX); |
||
354 | rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX); |
||
355 | rgba[ACOMP] = CHAN_MAX; |
||
356 | } |
||
357 | |||
358 | |||
359 | /* big-endian */ |
||
360 | |||
361 | #if 0 |
||
362 | static void FETCH(abgr8888)( const struct gl_texture_image *texImage, |
||
363 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
364 | { |
||
365 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
||
366 | GLchan *rgba = (GLchan *) texel; |
||
367 | rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); |
||
368 | rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); |
||
369 | rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); |
||
370 | rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
||
371 | } |
||
372 | |||
373 | static void FETCH(bgra8888)( const struct gl_texture_image *texImage, |
||
374 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
375 | { |
||
376 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
||
377 | GLchan *rgba = (GLchan *) texel; |
||
378 | rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
||
379 | rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
||
380 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
381 | rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); |
||
382 | } |
||
383 | |||
384 | static void FETCH(bgr888)( const struct gl_texture_image *texImage, |
||
385 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
386 | { |
||
387 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); |
||
388 | GLchan *rgba = (GLchan *) texel; |
||
389 | rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
||
390 | rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
||
391 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
392 | rgba[ACOMP] = CHAN_MAX; |
||
393 | } |
||
394 | |||
395 | static void FETCH(bgr565)( const struct gl_texture_image *texImage, |
||
396 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
397 | { |
||
398 | const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
||
399 | const GLushort s = *src; |
||
400 | GLchan *rgba = (GLchan *) texel; |
||
401 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); |
||
402 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); |
||
403 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); |
||
404 | rgba[ACOMP] = CHAN_MAX; |
||
405 | } |
||
406 | |||
407 | static void FETCH(bgra4444)( const struct gl_texture_image *texImage, |
||
408 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
409 | { |
||
410 | const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
||
411 | const GLushort s = *src; |
||
412 | GLchan *rgba = (GLchan *) texel; |
||
413 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); |
||
414 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); |
||
415 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); |
||
416 | rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); |
||
417 | } |
||
418 | |||
419 | static void FETCH(bgra5551)( const struct gl_texture_image *texImage, |
||
420 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
421 | { |
||
422 | const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
||
423 | const GLushort s = *src; |
||
424 | GLchan *rgba = (GLchan *) texel; |
||
425 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); |
||
426 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); |
||
427 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); |
||
428 | rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); |
||
429 | } |
||
430 | |||
431 | static void FETCH(la88)( const struct gl_texture_image *texImage, |
||
432 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
433 | { |
||
434 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); |
||
435 | GLchan *rgba = (GLchan *) texel; |
||
436 | rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
437 | rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
438 | rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
||
439 | rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); |
||
440 | } |
||
441 | |||
442 | static void FETCH(bgr233)( const struct gl_texture_image *texImage, |
||
443 | GLint i, GLint j, GLint k, GLvoid *texel ) |
||
444 | { |
||
445 | const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
||
446 | const GLubyte s = *src; |
||
447 | GLchan *rgba = (GLchan *) texel; |
||
448 | rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); |
||
449 | rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); |
||
450 | rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); |
||
451 | rgba[ACOMP] = CHAN_MAX; |
||
452 | } |
||
453 | #endif |
||
454 | |||
455 | |||
456 | #undef CHAN_SRC |
||
457 | #undef UBYTE_SRC |
||
458 | #undef USHORT_SRC |
||
459 | #undef FLOAT_SRC |
||
460 | #undef FETCH |
||
461 | #undef DIM |