2 #include "spantmp_common.h"
8 #ifndef HAVE_HW_STENCIL_SPANS
9 #define HAVE_HW_STENCIL_SPANS 0
12 #ifndef HAVE_HW_STENCIL_PIXELS
13 #define HAVE_HW_STENCIL_PIXELS 0
16 static void TAG(WriteStencilSpan
)( GLcontext
*ctx
,
17 struct gl_renderbuffer
*rb
,
18 GLuint n
, GLint x
, GLint y
,
19 const void *values
, const GLubyte mask
[] )
23 const GLubyte
*stencil
= (const GLubyte
*) values
;
30 #if HAVE_HW_STENCIL_SPANS
33 if (DBG
) fprintf(stderr
, "WriteStencilSpan 0..%d (x1 %d)\n",
37 #else /* HAVE_HW_STENCIL_SPANS */
41 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
43 if (DBG
) fprintf(stderr
, "WriteStencilSpan %d..%d (x1 %d)\n",
44 (int)i
, (int)n1
, (int)x1
);
48 for (;n1
>0;i
++,x1
++,n1
--)
50 WRITE_STENCIL( x1
, y
, stencil
[i
] );
54 for (;n1
>0;i
++,x1
++,n1
--)
55 WRITE_STENCIL( x1
, y
, stencil
[i
] );
59 #endif /* !HAVE_HW_STENCIL_SPANS */
64 #if HAVE_HW_STENCIL_SPANS
65 /* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
67 TAG(WriteMonoStencilSpan
)( GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
68 GLuint n
, GLint x
, GLint y
,
69 const void *value
, const GLubyte mask
[] )
71 const GLuint stenVal
= *((GLuint
*) value
);
72 GLuint stens
[MAX_WIDTH
];
74 for (i
= 0; i
< n
; i
++)
76 TAG(WriteStencilSpan
)(ctx
, rb
, n
, x
, y
, stens
, mask
);
78 #else /* HAVE_HW_STENCIL_SPANS */
79 static void TAG(WriteMonoStencilSpan
)( GLcontext
*ctx
,
80 struct gl_renderbuffer
*rb
,
81 GLuint n
, GLint x
, GLint y
,
83 const GLubyte mask
[] )
87 const GLubyte stencil
= *((const GLubyte
*) value
);
97 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
99 if (DBG
) fprintf(stderr
, "WriteStencilSpan %d..%d (x1 %d)\n",
100 (int)i
, (int)n1
, (int)x1
);
104 for (;n1
>0;i
++,x1
++,n1
--)
106 WRITE_STENCIL( x1
, y
, stencil
);
110 for (;n1
>0;i
++,x1
++,n1
--)
111 WRITE_STENCIL( x1
, y
, stencil
);
118 #endif /* !HAVE_HW_STENCIL_SPANS */
121 static void TAG(WriteStencilPixels
)( GLcontext
*ctx
,
122 struct gl_renderbuffer
*rb
,
124 const GLint x
[], const GLint y
[],
125 const void *values
, const GLubyte mask
[] )
129 const GLubyte
*stencil
= (const GLubyte
*) values
;
133 if (DBG
) fprintf(stderr
, "WriteStencilPixels\n");
135 #if HAVE_HW_STENCIL_PIXELS
138 WRITE_STENCIL_PIXELS();
139 #else /* HAVE_HW_STENCIL_PIXELS */
145 const int fy
= Y_FLIP(y
[i
]);
146 if (CLIPPIXEL(x
[i
],fy
))
147 WRITE_STENCIL( x
[i
], fy
, stencil
[i
] );
152 #endif /* !HAVE_HW_STENCIL_PIXELS */
158 /* Read stencil spans and pixels
160 static void TAG(ReadStencilSpan
)( GLcontext
*ctx
,
161 struct gl_renderbuffer
*rb
,
162 GLuint n
, GLint x
, GLint y
,
167 GLubyte
*stencil
= (GLubyte
*) values
;
173 if (DBG
) fprintf(stderr
, "ReadStencilSpan\n");
175 #if HAVE_HW_STENCIL_SPANS
176 (void) x1
; (void) n1
;
179 #else /* HAVE_HW_STENCIL_SPANS */
183 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
185 READ_STENCIL( stencil
[i
], (x
+i
), y
);
188 #endif /* !HAVE_HW_STENCIL_SPANS */
193 static void TAG(ReadStencilPixels
)( GLcontext
*ctx
,
194 struct gl_renderbuffer
*rb
,
195 GLuint n
, const GLint x
[], const GLint y
[],
200 GLubyte
*stencil
= (GLubyte
*) values
;
204 if (DBG
) fprintf(stderr
, "ReadStencilPixels\n");
206 #if HAVE_HW_STENCIL_PIXELS
209 READ_STENCIL_PIXELS();
210 #else /* HAVE_HW_STENCIL_PIXELS */
214 int fy
= Y_FLIP( y
[i
] );
215 if (CLIPPIXEL( x
[i
], fy
))
216 READ_STENCIL( stencil
[i
], x
[i
], fy
);
220 #endif /* !HAVE_HW_STENCIL_PIXELS */
228 * Initialize the given renderbuffer's span routines to point to
229 * the stencil functions we generated above.
231 static void TAG(InitStencilPointers
)(struct gl_renderbuffer
*rb
)
233 rb
->GetRow
= TAG(ReadStencilSpan
);
234 rb
->GetValues
= TAG(ReadStencilPixels
);
235 rb
->PutRow
= TAG(WriteStencilSpan
);
236 rb
->PutRowRGB
= NULL
;
237 rb
->PutMonoRow
= TAG(WriteMonoStencilSpan
);
238 rb
->PutValues
= TAG(WriteStencilPixels
);
239 rb
->PutMonoValues
= NULL
;