summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-10-17 20:22:53 +0000
committerBrian Paul <[email protected]>2006-10-17 20:22:53 +0000
commitb88af5b4681d2085cd784b930dc259b66a55347e (patch)
treed006e107727d275730a843f87cf96f28d280fb90 /src/mesa/swrast
parent0c6c8d5f1c7bfbedc0acbf34a5a9701bdad29841 (diff)
apply_aa_coverage() for ubyte/ushort/float
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_span.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index a8cc268a950..2fc014ef68f 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1218,6 +1218,37 @@ add_specular(GLcontext *ctx, SWspan *span)
/**
+ * Apply antialiasing coverage value to alpha values.
+ */
+static void
+apply_aa_coverage(SWspan *span)
+{
+ const GLfloat *coverage = span->array->coverage;
+ GLuint i;
+ if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ GLubyte (*rgba)[4] = span->array->color.sz1.rgba;
+ for (i = 0; i < span->end; i++) {
+ ASSERT(coverage[i] >= 0.0);
+ ASSERT(coverage[i] <= 1.0);
+ UNCLAMPED_FLOAT_TO_UBYTE(rgba[i][ACOMP], rgba[i][ACOMP] * coverage[i]);
+ }
+ }
+ else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
+ GLushort (*rgba)[4] = span->array->color.sz2.rgba;
+ for (i = 0; i < span->end; i++) {
+ UNCLAMPED_FLOAT_TO_USHORT(rgba[i][ACOMP], rgba[i][ACOMP] * coverage[i]);
+ }
+ }
+ else {
+ GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ for (i = 0; i < span->end; i++) {
+ rgba[i][ACOMP] = rgba[i][ACOMP] * coverage[i];
+ }
+ }
+}
+
+
+/**
* Convert the span's color arrays to the given type.
* XXX this could be put into image.c and reused in several places.
*/
@@ -1476,12 +1507,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
/* Antialias coverage application */
if (span->arrayMask & SPAN_COVERAGE) {
- GLchan (*rgba)[4] = span->array->rgba;
- GLfloat *coverage = span->array->coverage;
- GLuint i;
- for (i = 0; i < span->end; i++) {
- rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * coverage[i]);
- }
+ apply_aa_coverage(span);
}
/* Clamp color/alpha values over the range [0.0, 1.0] before storage */