include sched.h to get sched_yield() prototype
[mesa.git] / src / mesa / drivers / dri / common / spantmp.h
1 #ifndef DBG
2 #define DBG 0
3 #endif
4
5 #ifndef HW_WRITE_LOCK
6 #define HW_WRITE_LOCK() HW_LOCK()
7 #endif
8
9 #ifndef HW_WRITE_UNLOCK
10 #define HW_WRITE_UNLOCK() HW_UNLOCK()
11 #endif
12
13 #ifndef HW_READ_LOCK
14 #define HW_READ_LOCK() HW_LOCK()
15 #endif
16
17 #ifndef HW_READ_UNLOCK
18 #define HW_READ_UNLOCK() HW_UNLOCK()
19 #endif
20
21 #ifndef HW_READ_CLIPLOOP
22 #define HW_READ_CLIPLOOP() HW_CLIPLOOP()
23 #endif
24
25 #ifndef HW_WRITE_CLIPLOOP
26 #define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
27 #endif
28
29
30 static void TAG(WriteRGBASpan)( const GLcontext *ctx,
31 GLuint n, GLint x, GLint y,
32 const GLubyte rgba[][4],
33 const GLubyte mask[] )
34 {
35 HW_WRITE_LOCK()
36 {
37 GLint x1;
38 GLint n1;
39 LOCAL_VARS;
40
41 y = Y_FLIP(y);
42
43 HW_WRITE_CLIPLOOP()
44 {
45 GLint i = 0;
46 CLIPSPAN(x,y,n,x1,n1,i);
47
48 if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
49 (int)i, (int)n1, (int)x1);
50
51 if (mask)
52 {
53 for (;n1>0;i++,x1++,n1--)
54 if (mask[i])
55 WRITE_RGBA( x1, y,
56 rgba[i][0], rgba[i][1],
57 rgba[i][2], rgba[i][3] );
58 }
59 else
60 {
61 for (;n1>0;i++,x1++,n1--)
62 WRITE_RGBA( x1, y,
63 rgba[i][0], rgba[i][1],
64 rgba[i][2], rgba[i][3] );
65 }
66 }
67 HW_ENDCLIPLOOP();
68 }
69 HW_WRITE_UNLOCK();
70 }
71
72 static void TAG(WriteRGBSpan)( const GLcontext *ctx,
73 GLuint n, GLint x, GLint y,
74 const GLubyte rgb[][3],
75 const GLubyte mask[] )
76 {
77 HW_WRITE_LOCK()
78 {
79 GLint x1;
80 GLint n1;
81 LOCAL_VARS;
82
83 y = Y_FLIP(y);
84
85 HW_WRITE_CLIPLOOP()
86 {
87 GLint i = 0;
88 CLIPSPAN(x,y,n,x1,n1,i);
89
90 if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
91 (int)i, (int)n1, (int)x1);
92
93 if (mask)
94 {
95 for (;n1>0;i++,x1++,n1--)
96 if (mask[i])
97 WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
98 }
99 else
100 {
101 for (;n1>0;i++,x1++,n1--)
102 WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
103 }
104 }
105 HW_ENDCLIPLOOP();
106 }
107 HW_WRITE_UNLOCK();
108 }
109
110 static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
111 GLuint n,
112 const GLint x[],
113 const GLint y[],
114 const GLubyte rgba[][4],
115 const GLubyte mask[] )
116 {
117 HW_WRITE_LOCK()
118 {
119 GLint i;
120 LOCAL_VARS;
121
122 if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
123
124 HW_WRITE_CLIPLOOP()
125 {
126 for (i=0;i<n;i++)
127 {
128 if (mask[i]) {
129 const int fy = Y_FLIP(y[i]);
130 if (CLIPPIXEL(x[i],fy))
131 WRITE_RGBA( x[i], fy,
132 rgba[i][0], rgba[i][1],
133 rgba[i][2], rgba[i][3] );
134 }
135 }
136 }
137 HW_ENDCLIPLOOP();
138 }
139 HW_WRITE_UNLOCK();
140 }
141
142
143 static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
144 GLuint n, GLint x, GLint y,
145 const GLchan color[4],
146 const GLubyte mask[] )
147 {
148 HW_WRITE_LOCK()
149 {
150 GLint x1;
151 GLint n1;
152 LOCAL_VARS;
153 INIT_MONO_PIXEL(p, color);
154
155 y = Y_FLIP( y );
156
157 if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
158
159 HW_WRITE_CLIPLOOP()
160 {
161 GLint i = 0;
162 CLIPSPAN(x,y,n,x1,n1,i);
163 for (;n1>0;i++,x1++,n1--)
164 if (mask[i])
165 WRITE_PIXEL( x1, y, p );
166 }
167 HW_ENDCLIPLOOP();
168 }
169 HW_WRITE_UNLOCK();
170 }
171
172
173 static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
174 GLuint n,
175 const GLint x[], const GLint y[],
176 const GLchan color[],
177 const GLubyte mask[] )
178 {
179 HW_WRITE_LOCK()
180 {
181 GLint i;
182 LOCAL_VARS;
183 INIT_MONO_PIXEL(p, color);
184
185 if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
186
187 HW_WRITE_CLIPLOOP()
188 {
189 for (i=0;i<n;i++)
190 if (mask[i]) {
191 int fy = Y_FLIP(y[i]);
192 if (CLIPPIXEL( x[i], fy ))
193 WRITE_PIXEL( x[i], fy, p );
194 }
195 }
196 HW_ENDCLIPLOOP();
197 }
198 HW_WRITE_UNLOCK();
199 }
200
201
202 static void TAG(ReadRGBASpan)( const GLcontext *ctx,
203 GLuint n, GLint x, GLint y,
204 GLubyte rgba[][4])
205 {
206 HW_READ_LOCK()
207 {
208 GLint x1,n1;
209 LOCAL_VARS;
210
211 y = Y_FLIP(y);
212
213 if (DBG) fprintf(stderr, "ReadRGBASpan\n");
214
215 HW_READ_CLIPLOOP()
216 {
217 GLint i = 0;
218 CLIPSPAN(x,y,n,x1,n1,i);
219 for (;n1>0;i++,x1++,n1--)
220 READ_RGBA( rgba[i], x1, y );
221 }
222 HW_ENDCLIPLOOP();
223 }
224 HW_READ_UNLOCK();
225 }
226
227
228 static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
229 GLuint n, const GLint x[], const GLint y[],
230 GLubyte rgba[][4], const GLubyte mask[] )
231 {
232 HW_READ_LOCK()
233 {
234 GLint i;
235 LOCAL_VARS;
236
237 if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
238
239 HW_READ_CLIPLOOP()
240 {
241 for (i=0;i<n;i++)
242 if (mask[i]) {
243 int fy = Y_FLIP( y[i] );
244 if (CLIPPIXEL( x[i], fy ))
245 READ_RGBA( rgba[i], x[i], fy );
246 }
247 }
248 HW_ENDCLIPLOOP();
249 }
250 HW_READ_UNLOCK();
251 }
252
253
254
255
256 #undef WRITE_PIXEL
257 #undef WRITE_RGBA
258 #undef READ_RGBA
259 #undef TAG