867384b78dad096ea826bc4a1030fd69f42be241
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * 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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
27 * \brief Templates for vector conversions.
28 * \author Keith Whitwell.
32 static void DEST_4F( GLfloat (*t
)[4],
37 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
38 const GLubyte
*first
= f
;
43 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
46 if (SZ
>= 1) t
[i
][0] = TRX_4F(f
, 0);
47 if (SZ
>= 2) t
[i
][1] = TRX_4F(f
, 1);
48 if (SZ
>= 3) t
[i
][2] = TRX_4F(f
, 2);
49 if (SZ
== 4) t
[i
][3] = TRX_4F(f
, 3); else t
[i
][3] = 1.0;
58 static void DEST_4FN( GLfloat (*t
)[4],
63 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
64 const GLubyte
*first
= f
;
69 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
72 if (SZ
>= 1) t
[i
][0] = TRX_4FN(f
, 0);
73 if (SZ
>= 2) t
[i
][1] = TRX_4FN(f
, 1);
74 if (SZ
>= 3) t
[i
][2] = TRX_4FN(f
, 2);
75 if (SZ
== 4) t
[i
][3] = TRX_4FN(f
, 3); else t
[i
][3] = 1.0;
83 static void DEST_3FN( GLfloat (*t
)[3],
88 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
89 const GLubyte
*first
= f
;
93 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
96 t
[i
][0] = TRX_3FN(f
, 0);
97 t
[i
][1] = TRX_3FN(f
, 1);
98 t
[i
][2] = TRX_3FN(f
, 2);
105 static void DEST_1F( GLfloat
*t
,
110 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
111 const GLubyte
*first
= f
;
115 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
125 static void DEST_4UB( GLubyte (*t
)[4],
130 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
131 const GLubyte
*first
= f
;
135 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
138 if (SZ
>= 1) TRX_UB(t
[i
][0], f
, 0);
139 if (SZ
>= 2) TRX_UB(t
[i
][1], f
, 1);
140 if (SZ
>= 3) TRX_UB(t
[i
][2], f
, 2);
141 if (SZ
== 4) TRX_UB(t
[i
][3], f
, 3); else t
[i
][3] = 255;
149 static void DEST_4US( GLushort (*t
)[4],
154 const GLubyte
*f
= (GLubyte
*) ((GLubyte
*) ptr
+ SRC_START
* stride
);
155 const GLubyte
*first
= f
;
159 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
162 if (SZ
>= 1) TRX_US(t
[i
][0], f
, 0);
163 if (SZ
>= 2) TRX_US(t
[i
][1], f
, 1);
164 if (SZ
>= 3) TRX_US(t
[i
][2], f
, 2);
165 if (SZ
== 4) TRX_US(t
[i
][3], f
, 3); else t
[i
][3] = 65535;
173 static void DEST_1UB( GLubyte
*t
,
178 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
179 const GLubyte
*first
= f
;
183 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
194 static void DEST_1UI( GLuint
*t
,
199 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
200 const GLubyte
*first
= f
;
205 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
215 static void INIT(void)
219 TAB(_1ui
)[SRC_IDX
] = DEST_1UI
;
223 TAB(_1ub
)[SRC_IDX
] = DEST_1UB
;
227 TAB(_1f
)[SRC_IDX
] = DEST_1F
;
231 TAB(_3fn
)[SRC_IDX
] = DEST_3FN
;
234 TAB(_4ub
)[SZ
][SRC_IDX
] = DEST_4UB
;
237 TAB(_4us
)[SZ
][SRC_IDX
] = DEST_4US
;
240 TAB(_4f
)[SZ
][SRC_IDX
] = DEST_4F
;
243 TAB(_4fn
)[SZ
][SRC_IDX
] = DEST_4FN
;