Changed escaping of double quotes.
[mesa.git] / src / mesa / drivers / dri / common / spantmp.h
1 /*
2 * Copyright 2000-2001 VA Linux Systems, Inc.
3 * (C) Copyright IBM Corporation 2002, 2003
4 * 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 * on the rights to use, copy, modify, merge, publish, distribute, sub
10 * license, and/or sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * Authors:
26 * Keith Whitwell <keithw@tungstengraphics.com>
27 * Gareth Hughes <gareth@nvidia.com>
28 */
29
30 #ifndef DBG
31 #define DBG 0
32 #endif
33
34 #ifndef HW_WRITE_LOCK
35 #define HW_WRITE_LOCK() HW_LOCK()
36 #endif
37
38 #ifndef HW_WRITE_UNLOCK
39 #define HW_WRITE_UNLOCK() HW_UNLOCK()
40 #endif
41
42 #ifndef HW_READ_LOCK
43 #define HW_READ_LOCK() HW_LOCK()
44 #endif
45
46 #ifndef HW_READ_UNLOCK
47 #define HW_READ_UNLOCK() HW_UNLOCK()
48 #endif
49
50 #ifndef HW_READ_CLIPLOOP
51 #define HW_READ_CLIPLOOP() HW_CLIPLOOP()
52 #endif
53
54 #ifndef HW_WRITE_CLIPLOOP
55 #define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
56 #endif
57
58
59 static void TAG(WriteRGBASpan)( const GLcontext *ctx,
60 GLuint n, GLint x, GLint y,
61 const GLubyte rgba[][4],
62 const GLubyte mask[] )
63 {
64 HW_WRITE_LOCK()
65 {
66 GLint x1;
67 GLint n1;
68 LOCAL_VARS;
69
70 y = Y_FLIP(y);
71
72 HW_WRITE_CLIPLOOP()
73 {
74 GLint i = 0;
75 CLIPSPAN(x,y,n,x1,n1,i);
76
77 if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
78 (int)i, (int)n1, (int)x1);
79
80 if (mask)
81 {
82 for (;n1>0;i++,x1++,n1--)
83 if (mask[i])
84 WRITE_RGBA( x1, y,
85 rgba[i][0], rgba[i][1],
86 rgba[i][2], rgba[i][3] );
87 }
88 else
89 {
90 for (;n1>0;i++,x1++,n1--)
91 WRITE_RGBA( x1, y,
92 rgba[i][0], rgba[i][1],
93 rgba[i][2], rgba[i][3] );
94 }
95 }
96 HW_ENDCLIPLOOP();
97 }
98 HW_WRITE_UNLOCK();
99 }
100
101 static void TAG(WriteRGBSpan)( const GLcontext *ctx,
102 GLuint n, GLint x, GLint y,
103 const GLubyte rgb[][3],
104 const GLubyte mask[] )
105 {
106 HW_WRITE_LOCK()
107 {
108 GLint x1;
109 GLint n1;
110 LOCAL_VARS;
111
112 y = Y_FLIP(y);
113
114 HW_WRITE_CLIPLOOP()
115 {
116 GLint i = 0;
117 CLIPSPAN(x,y,n,x1,n1,i);
118
119 if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
120 (int)i, (int)n1, (int)x1);
121
122 if (mask)
123 {
124 for (;n1>0;i++,x1++,n1--)
125 if (mask[i])
126 WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
127 }
128 else
129 {
130 for (;n1>0;i++,x1++,n1--)
131 WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
132 }
133 }
134 HW_ENDCLIPLOOP();
135 }
136 HW_WRITE_UNLOCK();
137 }
138
139 static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
140 GLuint n,
141 const GLint x[],
142 const GLint y[],
143 const GLubyte rgba[][4],
144 const GLubyte mask[] )
145 {
146 HW_WRITE_LOCK()
147 {
148 GLuint i;
149 LOCAL_VARS;
150
151 if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
152
153 HW_WRITE_CLIPLOOP()
154 {
155 if (mask)
156 {
157 for (i=0;i<n;i++)
158 {
159 if (mask[i]) {
160 const int fy = Y_FLIP(y[i]);
161 if (CLIPPIXEL(x[i],fy))
162 WRITE_RGBA( x[i], fy,
163 rgba[i][0], rgba[i][1],
164 rgba[i][2], rgba[i][3] );
165 }
166 }
167 }
168 else
169 {
170 for (i=0;i<n;i++)
171 {
172 const int fy = Y_FLIP(y[i]);
173 if (CLIPPIXEL(x[i],fy))
174 WRITE_RGBA( x[i], fy,
175 rgba[i][0], rgba[i][1],
176 rgba[i][2], rgba[i][3] );
177 }
178 }
179 }
180 HW_ENDCLIPLOOP();
181 }
182 HW_WRITE_UNLOCK();
183 }
184
185
186 static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
187 GLuint n, GLint x, GLint y,
188 const GLchan color[4],
189 const GLubyte mask[] )
190 {
191 HW_WRITE_LOCK()
192 {
193 GLint x1;
194 GLint n1;
195 LOCAL_VARS;
196 INIT_MONO_PIXEL(p, color);
197
198 y = Y_FLIP( y );
199
200 if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
201
202 HW_WRITE_CLIPLOOP()
203 {
204 GLint i = 0;
205 CLIPSPAN(x,y,n,x1,n1,i);
206 if (mask)
207 {
208 for (;n1>0;i++,x1++,n1--)
209 if (mask[i])
210 WRITE_PIXEL( x1, y, p );
211 }
212 else
213 {
214 for (;n1>0;i++,x1++,n1--)
215 WRITE_PIXEL( x1, y, p );
216 }
217 }
218 HW_ENDCLIPLOOP();
219 }
220 HW_WRITE_UNLOCK();
221 }
222
223
224 static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
225 GLuint n,
226 const GLint x[], const GLint y[],
227 const GLchan color[],
228 const GLubyte mask[] )
229 {
230 HW_WRITE_LOCK()
231 {
232 GLuint i;
233 LOCAL_VARS;
234 INIT_MONO_PIXEL(p, color);
235
236 if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
237
238 HW_WRITE_CLIPLOOP()
239 {
240 if (mask)
241 {
242 for (i=0;i<n;i++)
243 if (mask[i]) {
244 int fy = Y_FLIP(y[i]);
245 if (CLIPPIXEL( x[i], fy ))
246 WRITE_PIXEL( x[i], fy, p );
247 }
248 }
249 else
250 {
251 for (i=0;i<n;i++) {
252 int fy = Y_FLIP(y[i]);
253 if (CLIPPIXEL( x[i], fy ))
254 WRITE_PIXEL( x[i], fy, p );
255 }
256 }
257 }
258 HW_ENDCLIPLOOP();
259 }
260 HW_WRITE_UNLOCK();
261 }
262
263
264 static void TAG(ReadRGBASpan)( const GLcontext *ctx,
265 GLuint n, GLint x, GLint y,
266 GLubyte rgba[][4])
267 {
268 HW_READ_LOCK()
269 {
270 GLint x1,n1;
271 LOCAL_VARS;
272
273 y = Y_FLIP(y);
274
275 if (DBG) fprintf(stderr, "ReadRGBASpan\n");
276
277 HW_READ_CLIPLOOP()
278 {
279 GLint i = 0;
280 CLIPSPAN(x,y,n,x1,n1,i);
281 for (;n1>0;i++,x1++,n1--)
282 READ_RGBA( rgba[i], x1, y );
283 }
284 HW_ENDCLIPLOOP();
285 }
286 HW_READ_UNLOCK();
287 }
288
289
290 static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
291 GLuint n, const GLint x[], const GLint y[],
292 GLubyte rgba[][4], const GLubyte mask[] )
293 {
294 HW_READ_LOCK()
295 {
296 GLuint i;
297 LOCAL_VARS;
298
299 if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
300
301 HW_READ_CLIPLOOP()
302 {
303 if (mask)
304 {
305 for (i=0;i<n;i++)
306 if (mask[i]) {
307 int fy = Y_FLIP( y[i] );
308 if (CLIPPIXEL( x[i], fy ))
309 READ_RGBA( rgba[i], x[i], fy );
310 }
311 }
312 else
313 {
314 for (i=0;i<n;i++) {
315 int fy = Y_FLIP( y[i] );
316 if (CLIPPIXEL( x[i], fy ))
317 READ_RGBA( rgba[i], x[i], fy );
318 }
319 }
320 }
321 HW_ENDCLIPLOOP();
322 }
323 HW_READ_UNLOCK();
324 }
325
326
327
328
329 #undef WRITE_PIXEL
330 #undef WRITE_RGBA
331 #undef READ_RGBA
332 #undef TAG