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