glx: indent -br -i3 -npcs --no-tabs indirect_window_pos.c
[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
41 __glFillMap1f(GLint k, GLint order, GLint stride,
42 const GLfloat * points, GLubyte * pc)
43 {
44 if (stride == k) {
45 /* Just copy the data */
46 __GLX_PUT_FLOAT_ARRAY(0, points, order * k);
47 }
48 else {
49 GLint i;
50
51 for (i = 0; i < order; i++) {
52 __GLX_PUT_FLOAT_ARRAY(0, points, k);
53 points += stride;
54 pc += k * __GLX_SIZE_FLOAT32;
55 }
56 }
57 }
58
59 void
60 __glFillMap1d(GLint k, GLint order, GLint stride,
61 const GLdouble * points, GLubyte * pc)
62 {
63 if (stride == k) {
64 /* Just copy the data */
65 __GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
66 }
67 else {
68 GLint i;
69 for (i = 0; i < order; i++) {
70 __GLX_PUT_DOUBLE_ARRAY(0, points, k);
71 points += stride;
72 pc += k * __GLX_SIZE_FLOAT64;
73 }
74 }
75 }
76
77 void
78 __glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
79 GLint majorStride, GLint minorStride,
80 const GLfloat * points, GLfloat * data)
81 {
82 GLint i, j, x;
83
84 if ((minorStride == k) && (majorStride == minorOrder * k)) {
85 /* Just copy the data */
86 __GLX_MEM_COPY(data, points, majorOrder * majorStride *
87 __GLX_SIZE_FLOAT32);
88 return;
89 }
90 for (i = 0; i < majorOrder; i++) {
91 for (j = 0; j < minorOrder; j++) {
92 for (x = 0; x < k; x++) {
93 data[x] = points[x];
94 }
95 points += minorStride;
96 data += k;
97 }
98 points += majorStride - minorStride * minorOrder;
99 }
100 }
101
102 void
103 __glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
104 GLint majorStride, GLint minorStride,
105 const GLdouble * points, GLdouble * data)
106 {
107 int i, j, x;
108
109 if ((minorStride == k) && (majorStride == minorOrder * k)) {
110 /* Just copy the data */
111 __GLX_MEM_COPY(data, points, majorOrder * majorStride *
112 __GLX_SIZE_FLOAT64);
113 return;
114 }
115
116 #ifdef __GLX_ALIGN64
117 x = k * __GLX_SIZE_FLOAT64;
118 #endif
119 for (i = 0; i < majorOrder; i++) {
120 for (j = 0; j < minorOrder; j++) {
121 #ifdef __GLX_ALIGN64
122 __GLX_MEM_COPY(data, points, x);
123 #else
124 for (x = 0; x < k; x++) {
125 data[x] = points[x];
126 }
127 #endif
128 points += minorStride;
129 data += k;
130 }
131 points += majorStride - minorStride * minorOrder;
132 }
133 }