glx: add a line of Emacs helping variables
[mesa.git] / src / glx / x11 / eval.c
1 /* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
2 /*
3 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
4 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice including the dates of first publication and
14 * either this permission notice or a reference to
15 * http://oss.sgi.com/projects/FreeB/
16 * shall be included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 *
26 * Except as contained in this notice, the name of Silicon Graphics, Inc.
27 * shall not be used in advertising or otherwise to promote the sale, use or
28 * other dealings in this Software without prior written authorization from
29 * Silicon Graphics, Inc.
30 */
31
32 #include "packrender.h"
33
34 /*
35 ** Routines to pack evaluator maps into the transport buffer. Maps are
36 ** allowed to have extra arbitrary data, so these routines extract just
37 ** the information that the GL needs.
38 */
39
40 void __glFillMap1f(GLint k, GLint order, GLint stride,
41 const GLfloat *points, GLubyte *pc)
42 {
43 if (stride == k) {
44 /* Just copy the data */
45 __GLX_PUT_FLOAT_ARRAY(0, points, order * k);
46 } else {
47 GLint i;
48
49 for (i = 0; i < order; i++) {
50 __GLX_PUT_FLOAT_ARRAY(0, points, k);
51 points += stride;
52 pc += k * __GLX_SIZE_FLOAT32;
53 }
54 }
55 }
56
57 void __glFillMap1d(GLint k, GLint order, GLint stride,
58 const GLdouble *points, GLubyte *pc)
59 {
60 if (stride == k) {
61 /* Just copy the data */
62 __GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
63 } else {
64 GLint i;
65 for (i = 0; i < order; i++) {
66 __GLX_PUT_DOUBLE_ARRAY(0, points, k);
67 points += stride;
68 pc += k * __GLX_SIZE_FLOAT64;
69 }
70 }
71 }
72
73 void __glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
74 GLint majorStride, GLint minorStride,
75 const GLfloat *points, GLfloat *data)
76 {
77 GLint i, j, x;
78
79 if ((minorStride == k) && (majorStride == minorOrder*k)) {
80 /* Just copy the data */
81 __GLX_MEM_COPY(data, points, majorOrder * majorStride *
82 __GLX_SIZE_FLOAT32);
83 return;
84 }
85 for (i = 0; i < majorOrder; i++) {
86 for (j = 0; j < minorOrder; j++) {
87 for (x = 0; x < k; x++) {
88 data[x] = points[x];
89 }
90 points += minorStride;
91 data += k;
92 }
93 points += majorStride - minorStride * minorOrder;
94 }
95 }
96
97 void __glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
98 GLint majorStride, GLint minorStride,
99 const GLdouble *points, GLdouble *data)
100 {
101 int i,j,x;
102
103 if ((minorStride == k) && (majorStride == minorOrder*k)) {
104 /* Just copy the data */
105 __GLX_MEM_COPY(data, points, majorOrder * majorStride *
106 __GLX_SIZE_FLOAT64);
107 return;
108 }
109
110 #ifdef __GLX_ALIGN64
111 x = k * __GLX_SIZE_FLOAT64;
112 #endif
113 for (i = 0; i<majorOrder; i++) {
114 for (j = 0; j<minorOrder; j++) {
115 #ifdef __GLX_ALIGN64
116 __GLX_MEM_COPY(data, points, x);
117 #else
118 for (x = 0; x<k; x++) {
119 data[x] = points[x];
120 }
121 #endif
122 points += minorStride;
123 data += k;
124 }
125 points += majorStride - minorStride * minorOrder;
126 }
127 }