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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \brief Templates for vector conversions.
27 * \author Keith Whitwell.
31 static void DEST_4F( GLfloat (*t)[4],
36 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
37 const GLubyte *first = f;
42 for (i = DST_START ; i < n ; i++, NEXT_F) {
45 if (SZ >= 1) t[i][0] = TRX_4F(f, 0);
46 if (SZ >= 2) t[i][1] = TRX_4F(f, 1);
47 if (SZ >= 3) t[i][2] = TRX_4F(f, 2);
48 if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0;
57 static void DEST_4FN( GLfloat (*t)[4],
62 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
63 const GLubyte *first = f;
68 for (i = DST_START ; i < n ; i++, NEXT_F) {
71 if (SZ >= 1) t[i][0] = TRX_4FN(f, 0);
72 if (SZ >= 2) t[i][1] = TRX_4FN(f, 1);
73 if (SZ >= 3) t[i][2] = TRX_4FN(f, 2);
74 if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0;
82 static void DEST_3FN( GLfloat (*t)[3],
87 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
88 const GLubyte *first = f;
92 for (i = DST_START ; i < n ; i++, NEXT_F) {
95 t[i][0] = TRX_3FN(f, 0);
96 t[i][1] = TRX_3FN(f, 1);
97 t[i][2] = TRX_3FN(f, 2);
104 static void DEST_1F( GLfloat *t,
109 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
110 const GLubyte *first = f;
114 for (i = DST_START ; i < n ; i++, NEXT_F) {
124 static void DEST_4UB( GLubyte (*t)[4],
129 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
130 const GLubyte *first = f;
134 for (i = DST_START ; i < n ; i++, NEXT_F) {
137 if (SZ >= 1) TRX_UB(t[i][0], f, 0);
138 if (SZ >= 2) TRX_UB(t[i][1], f, 1);
139 if (SZ >= 3) TRX_UB(t[i][2], f, 2);
140 if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255;
148 static void DEST_4US( GLushort (*t)[4],
153 const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride);
154 const GLubyte *first = f;
158 for (i = DST_START ; i < n ; i++, NEXT_F) {
161 if (SZ >= 1) TRX_US(t[i][0], f, 0);
162 if (SZ >= 2) TRX_US(t[i][1], f, 1);
163 if (SZ >= 3) TRX_US(t[i][2], f, 2);
164 if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535;
172 static void DEST_1UB( GLubyte *t,
177 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
178 const GLubyte *first = f;
182 for (i = DST_START ; i < n ; i++, NEXT_F) {
193 static void DEST_1UI( GLuint *t,
198 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
199 const GLubyte *first = f;
204 for (i = DST_START ; i < n ; i++, NEXT_F) {
214 static void INIT(void)
218 TAB(_1ui)[SRC_IDX] = DEST_1UI;
222 TAB(_1ub)[SRC_IDX] = DEST_1UB;
226 TAB(_1f)[SRC_IDX] = DEST_1F;
230 TAB(_3fn)[SRC_IDX] = DEST_3FN;
233 TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB;
236 TAB(_4us)[SZ][SRC_IDX] = DEST_4US;
239 TAB(_4f)[SZ][SRC_IDX] = DEST_4F;
242 TAB(_4fn)[SZ][SRC_IDX] = DEST_4FN;