1 /* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
3 #include "spantmp_common.h"
9 #ifndef HAVE_HW_STENCIL_SPANS
10 #define HAVE_HW_STENCIL_SPANS 0
13 #ifndef HAVE_HW_STENCIL_PIXELS
14 #define HAVE_HW_STENCIL_PIXELS 0
17 static void TAG(WriteStencilSpan
)( GLcontext
*ctx
,
18 struct gl_renderbuffer
*rb
,
19 GLuint n
, GLint x
, GLint y
,
20 const void *values
, const GLubyte mask
[] )
24 const GLubyte
*stencil
= (const GLubyte
*) values
;
31 #if HAVE_HW_STENCIL_SPANS
34 if (DBG
) fprintf(stderr
, "WriteStencilSpan 0..%d (x1 %d)\n",
38 #else /* HAVE_HW_STENCIL_SPANS */
42 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
44 if (DBG
) fprintf(stderr
, "WriteStencilSpan %d..%d (x1 %d)\n",
45 (int)i
, (int)n1
, (int)x1
);
49 for (;n1
>0;i
++,x1
++,n1
--)
51 WRITE_STENCIL( x1
, y
, stencil
[i
] );
55 for (;n1
>0;i
++,x1
++,n1
--)
56 WRITE_STENCIL( x1
, y
, stencil
[i
] );
60 #endif /* !HAVE_HW_STENCIL_SPANS */
65 #if HAVE_HW_STENCIL_SPANS
66 /* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
68 TAG(WriteMonoStencilSpan
)( GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
69 GLuint n
, GLint x
, GLint y
,
70 const void *value
, const GLubyte mask
[] )
72 const GLuint stenVal
= *((GLuint
*) value
);
73 GLuint stens
[MAX_WIDTH
];
75 for (i
= 0; i
< n
; i
++)
77 TAG(WriteStencilSpan
)(ctx
, rb
, n
, x
, y
, stens
, mask
);
79 #else /* HAVE_HW_STENCIL_SPANS */
80 static void TAG(WriteMonoStencilSpan
)( GLcontext
*ctx
,
81 struct gl_renderbuffer
*rb
,
82 GLuint n
, GLint x
, GLint y
,
84 const GLubyte mask
[] )
88 const GLubyte stencil
= *((const GLubyte
*) value
);
98 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
100 if (DBG
) fprintf(stderr
, "WriteStencilSpan %d..%d (x1 %d)\n",
101 (int)i
, (int)n1
, (int)x1
);
105 for (;n1
>0;i
++,x1
++,n1
--)
107 WRITE_STENCIL( x1
, y
, stencil
);
111 for (;n1
>0;i
++,x1
++,n1
--)
112 WRITE_STENCIL( x1
, y
, stencil
);
119 #endif /* !HAVE_HW_STENCIL_SPANS */
122 static void TAG(WriteStencilPixels
)( GLcontext
*ctx
,
123 struct gl_renderbuffer
*rb
,
125 const GLint x
[], const GLint y
[],
126 const void *values
, const GLubyte mask
[] )
130 const GLubyte
*stencil
= (const GLubyte
*) values
;
134 if (DBG
) fprintf(stderr
, "WriteStencilPixels\n");
136 #if HAVE_HW_STENCIL_PIXELS
139 WRITE_STENCIL_PIXELS();
140 #else /* HAVE_HW_STENCIL_PIXELS */
146 const int fy
= Y_FLIP(y
[i
]);
147 if (CLIPPIXEL(x
[i
],fy
))
148 WRITE_STENCIL( x
[i
], fy
, stencil
[i
] );
153 #endif /* !HAVE_HW_STENCIL_PIXELS */
159 /* Read stencil spans and pixels
161 static void TAG(ReadStencilSpan
)( GLcontext
*ctx
,
162 struct gl_renderbuffer
*rb
,
163 GLuint n
, GLint x
, GLint y
,
168 GLubyte
*stencil
= (GLubyte
*) values
;
174 if (DBG
) fprintf(stderr
, "ReadStencilSpan\n");
176 #if HAVE_HW_STENCIL_SPANS
177 (void) x1
; (void) n1
;
180 #else /* HAVE_HW_STENCIL_SPANS */
184 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
186 READ_STENCIL( stencil
[i
], (x
+i
), y
);
189 #endif /* !HAVE_HW_STENCIL_SPANS */
194 static void TAG(ReadStencilPixels
)( GLcontext
*ctx
,
195 struct gl_renderbuffer
*rb
,
196 GLuint n
, const GLint x
[], const GLint y
[],
201 GLubyte
*stencil
= (GLubyte
*) values
;
205 if (DBG
) fprintf(stderr
, "ReadStencilPixels\n");
207 #if HAVE_HW_STENCIL_PIXELS
210 READ_STENCIL_PIXELS();
211 #else /* HAVE_HW_STENCIL_PIXELS */
215 int fy
= Y_FLIP( y
[i
] );
216 if (CLIPPIXEL( x
[i
], fy
))
217 READ_STENCIL( stencil
[i
], x
[i
], fy
);
221 #endif /* !HAVE_HW_STENCIL_PIXELS */
229 * Initialize the given renderbuffer's span routines to point to
230 * the stencil functions we generated above.
232 static void TAG(InitStencilPointers
)(struct gl_renderbuffer
*rb
)
234 rb
->GetRow
= TAG(ReadStencilSpan
);
235 rb
->GetValues
= TAG(ReadStencilPixels
);
236 rb
->PutRow
= TAG(WriteStencilSpan
);
237 rb
->PutRowRGB
= NULL
;
238 rb
->PutMonoRow
= TAG(WriteMonoStencilSpan
);
239 rb
->PutValues
= TAG(WriteStencilPixels
);
240 rb
->PutMonoValues
= NULL
;