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
)( struct gl_context
*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 */
65 static void TAG(WriteStencilPixels
)( struct gl_context
*ctx
,
66 struct gl_renderbuffer
*rb
,
68 const GLint x
[], const GLint y
[],
69 const void *values
, const GLubyte mask
[] )
73 const GLubyte
*stencil
= (const GLubyte
*) values
;
77 if (DBG
) fprintf(stderr
, "WriteStencilPixels\n");
79 #if HAVE_HW_STENCIL_PIXELS
82 WRITE_STENCIL_PIXELS();
83 #else /* HAVE_HW_STENCIL_PIXELS */
89 const int fy
= Y_FLIP(y
[i
]);
90 if (CLIPPIXEL(x
[i
],fy
))
91 WRITE_STENCIL( x
[i
], fy
, stencil
[i
] );
96 #endif /* !HAVE_HW_STENCIL_PIXELS */
102 /* Read stencil spans and pixels
104 static void TAG(ReadStencilSpan
)( struct gl_context
*ctx
,
105 struct gl_renderbuffer
*rb
,
106 GLuint n
, GLint x
, GLint y
,
111 GLubyte
*stencil
= (GLubyte
*) values
;
117 if (DBG
) fprintf(stderr
, "ReadStencilSpan\n");
119 #if HAVE_HW_STENCIL_SPANS
120 (void) x1
; (void) n1
;
123 #else /* HAVE_HW_STENCIL_SPANS */
127 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
129 READ_STENCIL( stencil
[i
], (x
+i
), y
);
132 #endif /* !HAVE_HW_STENCIL_SPANS */
137 static void TAG(ReadStencilPixels
)( struct gl_context
*ctx
,
138 struct gl_renderbuffer
*rb
,
139 GLuint n
, const GLint x
[], const GLint y
[],
144 GLubyte
*stencil
= (GLubyte
*) values
;
148 if (DBG
) fprintf(stderr
, "ReadStencilPixels\n");
150 #if HAVE_HW_STENCIL_PIXELS
153 READ_STENCIL_PIXELS();
154 #else /* HAVE_HW_STENCIL_PIXELS */
158 int fy
= Y_FLIP( y
[i
] );
159 if (CLIPPIXEL( x
[i
], fy
))
160 READ_STENCIL( stencil
[i
], x
[i
], fy
);
164 #endif /* !HAVE_HW_STENCIL_PIXELS */
172 * Initialize the given renderbuffer's span routines to point to
173 * the stencil functions we generated above.
175 static void TAG(InitStencilPointers
)(struct gl_renderbuffer
*rb
)
177 rb
->GetRow
= TAG(ReadStencilSpan
);
178 rb
->GetValues
= TAG(ReadStencilPixels
);
179 rb
->PutRow
= TAG(WriteStencilSpan
);
180 rb
->PutValues
= TAG(WriteStencilPixels
);