remove common macros used in the span functions of most drivers from the individual...
[mesa.git] / src / mesa / drivers / dri / common / stenciltmp.h
1 /* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
2
3 #include "spantmp_common.h"
4
5 #ifndef DBG
6 #define DBG 0
7 #endif
8
9 static void TAG(WriteStencilSpan)( GLcontext *ctx,
10 struct gl_renderbuffer *rb,
11 GLuint n, GLint x, GLint y,
12 const void *values, const GLubyte mask[] )
13 {
14 HW_WRITE_LOCK()
15 {
16 const GLubyte *stencil = (const GLubyte *) values;
17 GLint x1;
18 GLint n1;
19 LOCAL_STENCIL_VARS;
20
21 y = Y_FLIP(y);
22
23 HW_CLIPLOOP()
24 {
25 GLint i = 0;
26 CLIPSPAN(x,y,n,x1,n1,i);
27
28 if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
29 (int)i, (int)n1, (int)x1);
30
31 if (mask)
32 {
33 for (;n1>0;i++,x1++,n1--)
34 if (mask[i])
35 WRITE_STENCIL( x1, y, stencil[i] );
36 }
37 else
38 {
39 for (;n1>0;i++,x1++,n1--)
40 WRITE_STENCIL( x1, y, stencil[i] );
41 }
42 }
43 HW_ENDCLIPLOOP();
44 }
45 HW_WRITE_UNLOCK();
46 }
47
48
49 static void TAG(WriteMonoStencilSpan)( GLcontext *ctx,
50 struct gl_renderbuffer *rb,
51 GLuint n, GLint x, GLint y,
52 const void *value,
53 const GLubyte mask[] )
54 {
55 HW_WRITE_LOCK()
56 {
57 const GLubyte stencil = *((const GLubyte *) value);
58 GLint x1;
59 GLint n1;
60 LOCAL_STENCIL_VARS;
61
62 y = Y_FLIP(y);
63
64 HW_CLIPLOOP()
65 {
66 GLint i = 0;
67 CLIPSPAN(x,y,n,x1,n1,i);
68
69 if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
70 (int)i, (int)n1, (int)x1);
71
72 if (mask)
73 {
74 for (;n1>0;i++,x1++,n1--)
75 if (mask[i])
76 WRITE_STENCIL( x1, y, stencil );
77 }
78 else
79 {
80 for (;n1>0;i++,x1++,n1--)
81 WRITE_STENCIL( x1, y, stencil );
82 }
83 }
84 HW_ENDCLIPLOOP();
85 }
86 HW_WRITE_UNLOCK();
87 }
88
89
90
91 static void TAG(WriteStencilPixels)( GLcontext *ctx,
92 struct gl_renderbuffer *rb,
93 GLuint n,
94 const GLint x[], const GLint y[],
95 const void *values, const GLubyte mask[] )
96 {
97 HW_WRITE_LOCK()
98 {
99 const GLubyte *stencil = (const GLubyte *) values;
100 GLuint i;
101 LOCAL_STENCIL_VARS;
102
103 if (DBG) fprintf(stderr, "WriteStencilPixels\n");
104
105 HW_CLIPLOOP()
106 {
107 for (i=0;i<n;i++)
108 {
109 if (mask[i]) {
110 const int fy = Y_FLIP(y[i]);
111 if (CLIPPIXEL(x[i],fy))
112 WRITE_STENCIL( x[i], fy, stencil[i] );
113 }
114 }
115 }
116 HW_ENDCLIPLOOP();
117 }
118 HW_WRITE_UNLOCK();
119 }
120
121
122 /* Read stencil spans and pixels
123 */
124 static void TAG(ReadStencilSpan)( GLcontext *ctx,
125 struct gl_renderbuffer *rb,
126 GLuint n, GLint x, GLint y,
127 void *values)
128 {
129 HW_READ_LOCK()
130 {
131 GLubyte *stencil = (GLubyte *) values;
132 GLint x1,n1;
133 LOCAL_STENCIL_VARS;
134
135 y = Y_FLIP(y);
136
137 if (DBG) fprintf(stderr, "ReadStencilSpan\n");
138
139 HW_CLIPLOOP()
140 {
141 GLint i = 0;
142 CLIPSPAN(x,y,n,x1,n1,i);
143 for (;n1>0;i++,n1--)
144 READ_STENCIL( stencil[i], (x+i), y );
145 }
146 HW_ENDCLIPLOOP();
147 }
148 HW_READ_UNLOCK();
149 }
150
151 static void TAG(ReadStencilPixels)( GLcontext *ctx,
152 struct gl_renderbuffer *rb,
153 GLuint n, const GLint x[], const GLint y[],
154 void *values )
155 {
156 HW_READ_LOCK()
157 {
158 GLubyte *stencil = (GLubyte *) values;
159 GLuint i;
160 LOCAL_STENCIL_VARS;
161
162 if (DBG) fprintf(stderr, "ReadStencilPixels\n");
163
164 HW_CLIPLOOP()
165 {
166 for (i=0;i<n;i++) {
167 int fy = Y_FLIP( y[i] );
168 if (CLIPPIXEL( x[i], fy ))
169 READ_STENCIL( stencil[i], x[i], fy );
170 }
171 }
172 HW_ENDCLIPLOOP();
173 }
174 HW_READ_UNLOCK();
175 }
176
177
178
179
180 #undef WRITE_STENCIL
181 #undef READ_STENCIL
182 #undef TAG